idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
31,900
public void addElement ( ObjectProperty element ) { assertNotNull ( element ) ; if ( elements == null ) { elements = new ArrayList < ObjectProperty > ( ) ; } elements . add ( element ) ; element . setParent ( this ) ; }
Adds an element to the list and sets its parent to this node .
31,901
public static Object getStopIterationObject ( Scriptable scope ) { Scriptable top = ScriptableObject . getTopLevelScope ( scope ) ; return ScriptableObject . getTopScopeValue ( top , ITERATOR_TAG ) ; }
Get the value of the StopIteration object . Note that this value is stored in the top - level scope using associateValue so the value can still be found even if a script overwrites or deletes the global StopIteration property .
31,902
public void visit ( NodeVisitor v ) { if ( v . visit ( this ) ) { if ( namespace != null ) { namespace . visit ( v ) ; } propName . visit ( v ) ; } }
Visits this node then the namespace if present then the property name .
31,903
protected void checkMapSize ( ) { if ( ( map instanceof EmbeddedSlotMap ) && map . size ( ) >= LARGE_HASH_SIZE ) { SlotMap newMap = new HashSlotMap ( ) ; for ( Slot s : map ) { newMap . addSlot ( s ) ; } map = newMap ; } }
Before inserting a new item in the map check and see if we need to expand from the embedded map to a HashMap that is more robust against large numbers of hash collisions .
31,904
public boolean containsKey ( Object key ) { if ( key instanceof String ) { return has ( ( String ) key , this ) ; } else if ( key instanceof Number ) { return has ( ( ( Number ) key ) . intValue ( ) , this ) ; } return false ; }
methods implementing java . util . Map
31,905
public void setVisible ( boolean b ) { super . setVisible ( b ) ; if ( b ) { console . consoleTextArea . requestFocus ( ) ; context . split . setDividerLocation ( 0.5 ) ; try { console . setMaximum ( true ) ; console . setSelected ( true ) ; console . show ( ) ; console . consoleTextArea . requestFocus ( ) ; } catch ( ...
Sets the visibility of the debugger GUI .
31,906
void addTopLevel ( String key , JFrame frame ) { if ( frame != this ) { toplevels . put ( key , frame ) ; } }
Records a new internal frame .
31,907
static String getShortName ( String url ) { int lastSlash = url . lastIndexOf ( '/' ) ; if ( lastSlash < 0 ) { lastSlash = url . lastIndexOf ( '\\' ) ; } String shortName = url ; if ( lastSlash >= 0 && lastSlash + 1 < url . length ( ) ) { shortName = url . substring ( lastSlash + 1 ) ; } return shortName ; }
Returns a short version of the given URL .
31,908
void showStopLine ( Dim . StackFrame frame ) { String sourceName = frame . getUrl ( ) ; if ( sourceName == null || sourceName . equals ( "<stdin>" ) ) { if ( console . isVisible ( ) ) { console . show ( ) ; } } else { showFileWindow ( sourceName , - 1 ) ; int lineNumber = frame . getLineNumber ( ) ; FileWindow w = getF...
Shows the line at which execution in the given stack frame just stopped .
31,909
void enterInterruptImpl ( Dim . StackFrame lastFrame , String threadTitle , String alertMessage ) { statusBar . setText ( "Thread: " + threadTitle ) ; showStopLine ( lastFrame ) ; if ( alertMessage != null ) { MessageDialogWrapper . showMessageDialog ( this , alertMessage , "Exception in Script" , JOptionPane . ERROR_M...
Handles script interruption .
31,910
private JInternalFrame getSelectedFrame ( ) { JInternalFrame [ ] frames = desk . getAllFrames ( ) ; for ( int i = 0 ; i < frames . length ; i ++ ) { if ( frames [ i ] . isShowing ( ) ) { return frames [ i ] ; } } return frames [ frames . length - 1 ] ; }
Returns the current selected internal frame .
31,911
private void updateEnabled ( boolean interrupted ) { ( ( Menubar ) getJMenuBar ( ) ) . updateEnabled ( interrupted ) ; for ( int ci = 0 , cc = toolBar . getComponentCount ( ) ; ci < cc ; ci ++ ) { boolean enableButton ; if ( ci == 0 ) { enableButton = ! interrupted ; } else { enableButton = interrupted ; } toolBar . ge...
Enables or disables the menu and tool bars with respect to the state of script execution .
31,912
private String readFile ( String fileName ) { String text ; try { try ( Reader r = new FileReader ( fileName ) ) { text = Kit . readReader ( r ) ; } } catch ( IOException ex ) { MessageDialogWrapper . showMessageDialog ( this , ex . getMessage ( ) , "Error reading " + fileName , JOptionPane . ERROR_MESSAGE ) ; text = n...
Reads the file with the given name and returns its contents as a String .
31,913
public void updateSourceText ( Dim . SourceInfo sourceInfo ) { RunProxy proxy = new RunProxy ( this , RunProxy . UPDATE_SOURCE_TEXT ) ; proxy . sourceInfo = sourceInfo ; SwingUtilities . invokeLater ( proxy ) ; }
Called when the source text for a script has been updated .
31,914
public void enterInterrupt ( Dim . StackFrame lastFrame , String threadTitle , String alertMessage ) { if ( SwingUtilities . isEventDispatchThread ( ) ) { enterInterruptImpl ( lastFrame , threadTitle , alertMessage ) ; } else { RunProxy proxy = new RunProxy ( this , RunProxy . ENTER_INTERRUPT ) ; proxy . lastFrame = la...
Called when the interrupt loop has been entered .
31,915
public void dispatchNextGuiEvent ( ) throws InterruptedException { EventQueue queue = awtEventQueue ; if ( queue == null ) { queue = Toolkit . getDefaultToolkit ( ) . getSystemEventQueue ( ) ; awtEventQueue = queue ; } AWTEvent event = queue . getNextEvent ( ) ; if ( event instanceof ActiveEvent ) { ( ( ActiveEvent ) e...
Processes the next GUI event .
31,916
private synchronized void returnPressed ( ) { Document doc = getDocument ( ) ; int len = doc . getLength ( ) ; Segment segment = new Segment ( ) ; try { doc . getText ( outputMark , len - outputMark , segment ) ; } catch ( javax . swing . text . BadLocationException ignored ) { ignored . printStackTrace ( ) ; } String ...
Called when Enter is pressed .
31,917
public synchronized void insertUpdate ( DocumentEvent e ) { int len = e . getLength ( ) ; int off = e . getOffset ( ) ; if ( outputMark > off ) { outputMark += len ; } }
Called when text was inserted into the text area .
31,918
public synchronized void removeUpdate ( DocumentEvent e ) { int len = e . getLength ( ) ; int off = e . getOffset ( ) ; if ( outputMark > off ) { if ( outputMark >= off + len ) { outputMark -= len ; } else { outputMark = off ; } } }
Called when text was removed from the text area .
31,919
public void actionPerformed ( ActionEvent e ) { String cmd = e . getActionCommand ( ) ; if ( cmd . equals ( "Cut" ) ) { consoleTextArea . cut ( ) ; } else if ( cmd . equals ( "Copy" ) ) { consoleTextArea . copy ( ) ; } else if ( cmd . equals ( "Paste" ) ) { consoleTextArea . paste ( ) ; } }
Performs an action on the text area .
31,920
public void show ( JComponent comp , int x , int y ) { this . x = x ; this . y = y ; super . show ( comp , x , y ) ; }
Displays the menu at the given coordinates .
31,921
public void select ( int pos ) { if ( pos >= 0 ) { try { int line = getLineOfOffset ( pos ) ; Rectangle rect = modelToView ( pos ) ; if ( rect == null ) { select ( pos , pos ) ; } else { try { Rectangle nrect = modelToView ( getLineStartOffset ( line + 1 ) ) ; if ( nrect != null ) { rect = nrect ; } } catch ( Exception...
Moves the selection to the given offset .
31,922
private void checkPopup ( MouseEvent e ) { if ( e . isPopupTrigger ( ) ) { popup . show ( this , e . getX ( ) , e . getY ( ) ) ; } }
Checks if the popup menu should be shown .
31,923
public void mouseClicked ( MouseEvent e ) { checkPopup ( e ) ; requestFocus ( ) ; getCaret ( ) . setVisible ( true ) ; }
Called when the mouse is clicked .
31,924
public void keyPressed ( KeyEvent e ) { switch ( e . getKeyCode ( ) ) { case KeyEvent . VK_BACK_SPACE : case KeyEvent . VK_ENTER : case KeyEvent . VK_DELETE : case KeyEvent . VK_TAB : e . consume ( ) ; break ; } }
Called when a key is pressed .
31,925
public String showDialog ( Component comp ) { value = null ; setLocationRelativeTo ( comp ) ; setVisible ( true ) ; return value ; }
Shows the dialog .
31,926
public void update ( ) { FileTextArea textArea = fileWindow . textArea ; Font font = textArea . getFont ( ) ; setFont ( font ) ; FontMetrics metrics = getFontMetrics ( font ) ; int h = metrics . getHeight ( ) ; int lineCount = textArea . getLineCount ( ) + 1 ; String dummy = Integer . toString ( lineCount ) ; if ( dumm...
Updates the gutter .
31,927
public void mousePressed ( MouseEvent e ) { Font font = fileWindow . textArea . getFont ( ) ; FontMetrics metrics = getFontMetrics ( font ) ; int h = metrics . getHeight ( ) ; pressLine = e . getY ( ) / h ; }
Called when a mouse button is pressed .
31,928
void load ( ) { String url = getUrl ( ) ; if ( url != null ) { RunProxy proxy = new RunProxy ( debugGui , RunProxy . LOAD_FILE ) ; proxy . fileName = url ; proxy . text = sourceInfo . source ( ) ; new Thread ( proxy ) . start ( ) ; } }
Loads the file .
31,929
public int getPosition ( int line ) { int result = - 1 ; try { result = textArea . getLineStartOffset ( line ) ; } catch ( javax . swing . text . BadLocationException exc ) { } return result ; }
Returns the offset position for the given line .
31,930
public void setBreakPoint ( int line ) { if ( sourceInfo . breakableLine ( line ) ) { boolean changed = sourceInfo . breakpoint ( line , true ) ; if ( changed ) { fileHeader . repaint ( ) ; } } }
Sets a breakpoint on the given line .
31,931
public void clearBreakPoint ( int line ) { if ( sourceInfo . breakableLine ( line ) ) { boolean changed = sourceInfo . breakpoint ( line , false ) ; if ( changed ) { fileHeader . repaint ( ) ; } } }
Clears a breakpoint from the given line .
31,932
private void updateToolTip ( ) { int n = getComponentCount ( ) - 1 ; if ( n > 1 ) { n = 1 ; } else if ( n < 0 ) { return ; } Component c = getComponent ( n ) ; if ( c != null && c instanceof JComponent ) { ( ( JComponent ) c ) . setToolTipText ( getUrl ( ) ) ; } }
Updates the tool tip contents .
31,933
public void updateText ( Dim . SourceInfo sourceInfo ) { this . sourceInfo = sourceInfo ; String newText = sourceInfo . source ( ) ; if ( ! textArea . getText ( ) . equals ( newText ) ) { textArea . setText ( newText ) ; int pos = 0 ; if ( currentPos != - 1 ) { pos = currentPos ; } textArea . select ( pos ) ; } fileHea...
Called when the text of the script has changed .
31,934
public void select ( int start , int end ) { int docEnd = textArea . getDocument ( ) . getLength ( ) ; textArea . select ( docEnd , docEnd ) ; textArea . select ( start , end ) ; }
Selects a range of characters .
31,935
public Object getValueAt ( int row , int column ) { switch ( column ) { case 0 : return expressions . get ( row ) ; case 1 : return values . get ( row ) ; } return "" ; }
Returns the value in the given cell .
31,936
public void setValueAt ( Object value , int row , int column ) { switch ( column ) { case 0 : String expr = value . toString ( ) ; expressions . set ( row , expr ) ; String result = "" ; if ( expr . length ( ) > 0 ) { result = debugGui . dim . eval ( expr ) ; if ( result == null ) result = "" ; } values . set ( row , r...
Sets the value in the given cell .
31,937
void updateModel ( ) { for ( int i = 0 ; i < expressions . size ( ) ; ++ i ) { String expr = expressions . get ( i ) ; String result = "" ; if ( expr . length ( ) > 0 ) { result = debugGui . dim . eval ( expr ) ; if ( result == null ) result = "" ; } else { result = "" ; } result = result . replace ( '\n' , ' ' ) ; val...
Re - evaluates the expressions in the table .
31,938
public int getChildCount ( Object nodeObj ) { if ( debugger == null ) { return 0 ; } VariableNode node = ( VariableNode ) nodeObj ; return children ( node ) . length ; }
Returns the number of children of the given node .
31,939
public Object getChild ( Object nodeObj , int i ) { if ( debugger == null ) { return null ; } VariableNode node = ( VariableNode ) nodeObj ; return children ( node ) [ i ] ; }
Returns a child of the given node .
31,940
public boolean isLeaf ( Object nodeObj ) { if ( debugger == null ) { return true ; } VariableNode node = ( VariableNode ) nodeObj ; return children ( node ) . length == 0 ; }
Returns whether the given node is a leaf node .
31,941
public int getIndexOfChild ( Object parentObj , Object childObj ) { if ( debugger == null ) { return - 1 ; } VariableNode parent = ( VariableNode ) parentObj ; VariableNode child = ( VariableNode ) childObj ; VariableNode [ ] children = children ( parent ) ; for ( int i = 0 ; i != children . length ; i ++ ) { if ( chil...
Returns the index of a node under its parent .
31,942
public Object getValueAt ( Object nodeObj , int column ) { if ( debugger == null ) { return null ; } VariableNode node = ( VariableNode ) nodeObj ; switch ( column ) { case 0 : return node . toString ( ) ; case 1 : String result ; try { result = debugger . objectToString ( getValue ( node ) ) ; } catch ( RuntimeExcepti...
Returns the value at the given cell .
31,943
private VariableNode [ ] children ( VariableNode node ) { if ( node . children != null ) { return node . children ; } VariableNode [ ] children ; Object value = getValue ( node ) ; Object [ ] ids = debugger . getObjectIds ( value ) ; if ( ids == null || ids . length == 0 ) { children = CHILDLESS ; } else { Arrays . sor...
Returns an array of the children of the given node .
31,944
public Object getValue ( VariableNode node ) { try { return debugger . getObjectProperty ( node . object , node . id ) ; } catch ( Exception exc ) { return "undefined" ; } }
Returns the value of the given node .
31,945
public JTree resetTree ( TreeTableModel treeTableModel ) { tree = new TreeTableCellRenderer ( treeTableModel ) ; super . setModel ( new TreeTableModelAdapter ( treeTableModel , tree ) ) ; ListToTreeSelectionModelWrapper selectionWrapper = new ListToTreeSelectionModelWrapper ( ) ; tree . setSelectionModel ( selectionWra...
Initializes a tree for this tree table .
31,946
public void setEnabled ( boolean enabled ) { context . setEnabled ( enabled ) ; thisTable . setEnabled ( enabled ) ; localsTable . setEnabled ( enabled ) ; evaluator . setEnabled ( enabled ) ; cmdLine . setEnabled ( enabled ) ; }
Enables or disables the component .
31,947
public void addFile ( String url ) { int count = windowMenu . getItemCount ( ) ; JMenuItem item ; if ( count == 4 ) { windowMenu . addSeparator ( ) ; count ++ ; } JMenuItem lastItem = windowMenu . getItem ( count - 1 ) ; boolean hasMoreWin = false ; int maxWin = 5 ; if ( lastItem != null && lastItem . getText ( ) . equ...
Adds a file to the window menu .
31,948
public void updateEnabled ( boolean interrupted ) { for ( int i = 0 ; i != interruptOnlyItems . size ( ) ; ++ i ) { JMenuItem item = interruptOnlyItems . get ( i ) ; item . setEnabled ( interrupted ) ; } for ( int i = 0 ; i != runOnlyItems . size ( ) ; ++ i ) { JMenuItem item = runOnlyItems . get ( i ) ; item . setEnab...
Updates the enabledness of menu items .
31,949
public void run ( ) { switch ( type ) { case OPEN_FILE : try { debugGui . dim . compileScript ( fileName , text ) ; } catch ( RuntimeException ex ) { MessageDialogWrapper . showMessageDialog ( debugGui , ex . getMessage ( ) , "Error Compiling " + fileName , JOptionPane . ERROR_MESSAGE ) ; } break ; case LOAD_FILE : try...
Runs this Runnable .
31,950
private static long toArrayIndex ( String id ) { long index = toArrayIndex ( ScriptRuntime . toNumber ( id ) ) ; if ( Long . toString ( index ) . equals ( id ) ) { return index ; } return - 1 ; }
otherwise return - 1L
31,951
private static Object jsConstructor ( Context cx , Scriptable scope , Object [ ] args ) { if ( args . length == 0 ) return new NativeArray ( 0 ) ; if ( cx . getLanguageVersion ( ) == Context . VERSION_1_2 ) { return new NativeArray ( args ) ; } Object arg0 = args [ 0 ] ; if ( args . length > 1 || ! ( arg0 instanceof Nu...
See ECMA 15 . 4 . 1 2
31,952
private static Object getRawElem ( Scriptable target , long index ) { if ( index > Integer . MAX_VALUE ) { return ScriptableObject . getProperty ( target , Long . toString ( index ) ) ; } return ScriptableObject . getProperty ( target , ( int ) index ) ; }
same as getElem but without converting NOT_FOUND to undefined
31,953
private static String js_join ( Context cx , Scriptable thisObj , Object [ ] args ) { long llength = getLengthProperty ( cx , thisObj , false ) ; int length = ( int ) llength ; if ( llength != length ) { throw Context . reportRuntimeError1 ( "msg.arraylength.too.big" , String . valueOf ( llength ) ) ; } String separato...
See ECMA 15 . 4 . 4 . 3
31,954
private static Scriptable js_reverse ( Context cx , Scriptable thisObj , Object [ ] args ) { if ( thisObj instanceof NativeArray ) { NativeArray na = ( NativeArray ) thisObj ; if ( na . denseOnly ) { for ( int i = 0 , j = ( ( int ) na . length ) - 1 ; i < j ; i ++ , j -- ) { Object temp = na . dense [ i ] ; na . dense ...
See ECMA 15 . 4 . 4 . 4
31,955
private static Scriptable js_sort ( final Context cx , final Scriptable scope , final Scriptable thisObj , final Object [ ] args ) { final Comparator < Object > comparator ; if ( args . length > 0 && Undefined . instance != args [ 0 ] ) { final Callable jsCompareFunction = ScriptRuntime . getValueFunctionAndThis ( args...
See ECMA 15 . 4 . 4 . 5
31,956
private static Object reduceMethod ( Context cx , int id , Scriptable scope , Scriptable thisObj , Object [ ] args ) { Scriptable o = ScriptRuntime . toObject ( cx , scope , thisObj ) ; long length = getLengthProperty ( cx , o , false ) ; Object callbackArg = args . length > 0 ? args [ 0 ] : Undefined . instance ; if (...
Implements the methods reduce and reduceRight .
31,957
static Object js_parseInt ( Object [ ] args ) { String s = ScriptRuntime . toString ( args , 0 ) ; int radix = ScriptRuntime . toInt32 ( args , 1 ) ; int len = s . length ( ) ; if ( len == 0 ) return ScriptRuntime . NaNobj ; boolean negative = false ; int start = 0 ; char c ; do { c = s . charAt ( start ) ; if ( ! Scri...
The global method parseInt as per ECMA - 262 15 . 1 . 2 . 2 .
31,958
static Object js_parseFloat ( Object [ ] args ) { if ( args . length < 1 ) return ScriptRuntime . NaNobj ; String s = ScriptRuntime . toString ( args [ 0 ] ) ; int len = s . length ( ) ; int start = 0 ; char c ; for ( ; ; ) { if ( start == len ) { return ScriptRuntime . NaNobj ; } c = s . charAt ( start ) ; if ( ! Scri...
The global method parseFloat as per ECMA - 262 15 . 1 . 2 . 3 .
31,959
private Object js_escape ( Object [ ] args ) { final int URL_XALPHAS = 1 , URL_XPALPHAS = 2 , URL_PATH = 4 ; String s = ScriptRuntime . toString ( args , 0 ) ; int mask = URL_XALPHAS | URL_XPALPHAS | URL_PATH ; if ( args . length > 1 ) { double d = ScriptRuntime . toNumber ( args [ 1 ] ) ; if ( d != d || ( ( mask = ( i...
The global method escape as per ECMA - 262 15 . 1 . 2 . 4 .
31,960
private Object js_unescape ( Object [ ] args ) { String s = ScriptRuntime . toString ( args , 0 ) ; int firstEscapePos = s . indexOf ( '%' ) ; if ( firstEscapePos >= 0 ) { int L = s . length ( ) ; char [ ] buf = s . toCharArray ( ) ; int destination = firstEscapePos ; for ( int k = firstEscapePos ; k != L ; ) { char c ...
The global unescape method as per ECMA - 262 15 . 1 . 2 . 5 .
31,961
public void addCatchClause ( CatchClause clause ) { assertNotNull ( clause ) ; if ( catchClauses == null ) { catchClauses = new ArrayList < CatchClause > ( ) ; } catchClauses . add ( clause ) ; clause . setParent ( this ) ; }
Add a catch - clause to the end of the list and sets its parent to this node .
31,962
public void visit ( NodeVisitor v ) { if ( v . visit ( this ) ) { tryBlock . visit ( v ) ; for ( CatchClause cc : getCatchClauses ( ) ) { cc . visit ( v ) ; } if ( finallyBlock != null ) { finallyBlock . visit ( v ) ; } } }
Visits this node then the try - block then any catch clauses and then any finally block .
31,963
public void setIdentifier ( String identifier ) { assertNotNull ( identifier ) ; this . identifier = identifier ; setLength ( identifier . length ( ) ) ; }
Sets the node s identifier
31,964
private static Set < Kind > validateOperators ( Set < Kind > kinds ) { for ( Kind kind : kinds ) { if ( ! COMPOUND_ASSIGNMENT_OPERATORS . contains ( kind ) ) { throw new IllegalArgumentException ( kind . name ( ) + " is not a compound-assignment operator." ) ; } } return kinds ; }
Returns the provided set of operators if they are all compound - assignment operators . Otherwise throws an IllegalArgumentException .
31,965
private boolean wellKnownTypeArgument ( NewClassTree tree , VisitorState state ) { Type type = getType ( tree ) ; if ( type == null ) { return false ; } type = state . getTypes ( ) . asSuper ( type , state . getSymbolFromString ( "java.lang.ThreadLocal" ) ) ; if ( type == null ) { return false ; } if ( type . getTypeAr...
Ignore some common ThreadLocal type arguments that are fine to have per - instance copies of .
31,966
private Description findShadowedTypes ( Tree tree , List < ? extends TypeParameterTree > typeParameters , VisitorState state ) { Env < AttrContext > env = Enter . instance ( state . context ) . getEnv ( ASTHelpers . getSymbol ( state . findEnclosing ( ClassTree . class ) ) ) ; Symtab symtab = state . getSymtab ( ) ; Pa...
Iterate through a list of type parameters looking for type names shadowed by any of them .
31,967
public static String getTextFromComment ( Comment comment ) { switch ( comment . getStyle ( ) ) { case BLOCK : return comment . getText ( ) . replaceAll ( "^\\s*/\\*\\s*(.*?)\\s*\\*/\\s*" , "$1" ) ; case LINE : return comment . getText ( ) . replaceAll ( "^\\s*//\\s*" , "" ) ; default : return comment . getText ( ) ; }...
Extract the text body from a comment .
31,968
static Optional < Integer > computeEndPosition ( Tree methodInvocationTree , CharSequence sourceCode , VisitorState state ) { int invocationEnd = state . getEndPosition ( methodInvocationTree ) ; if ( invocationEnd == - 1 ) { return Optional . empty ( ) ; } int nextNewLine = CharMatcher . is ( '\n' ) . indexIn ( source...
Finds the end position of this MethodInvocationTree . This is complicated by the fact that sometimes a comment will fall outside of the bounds of the tree .
31,969
private static < T > T after ( T target , Iterable < ? extends T > iterable , T defaultValue ) { Iterator < ? extends T > iterator = iterable . iterator ( ) ; while ( iterator . hasNext ( ) ) { if ( iterator . next ( ) . equals ( target ) ) { break ; } } if ( iterator . hasNext ( ) ) { return iterator . next ( ) ; } re...
Find the element in the iterable following the target
31,970
public Void visitParameterizedType ( ParameterizedTypeTree tree , VisitorState visitorState ) { VisitorState state = processMatchers ( parameterizedTypeMatchers , tree , ParameterizedTypeTreeMatcher :: matchParameterizedType , visitorState ) ; return super . visitParameterizedType ( tree , state ) ; }
generated by javac to implement autoboxing . We are only interested in source - level constructs .
31,971
public boolean isAcceptableChange ( Changes changes , Tree node , MethodSymbol symbol , VisitorState state ) { return changes . changedPairs ( ) . stream ( ) . allMatch ( p -> findMatch ( p . formal ( ) ) == null ) ; }
Return true if this parameter does not match any of the regular expressions in the list of overloaded words .
31,972
protected String findMatch ( Parameter parameter ) { for ( String regex : overloadedNamesRegexs ) { if ( parameter . name ( ) . matches ( regex ) ) { return regex ; } } return null ; }
Return the first regular expression from the list of overloaded words which matches the parameter name .
31,973
public static ImmutableList < String > splitToLowercaseTerms ( String identifierName ) { if ( ONLY_UNDERSCORES . matcher ( identifierName ) . matches ( ) ) { return ImmutableList . of ( identifierName ) ; } return Arrays . stream ( TERM_SPLITTER . split ( identifierName ) ) . map ( String :: toLowerCase ) . collect ( t...
Split a Java name into terms based on either Camel Case or Underscores . We also split digits at the end of the name into a separate term so as to treat PERSON1 and PERSON_1 as the same thing .
31,974
public static Symbol findIdent ( String name , VisitorState state ) { return findIdent ( name , state , KindSelector . VAR ) ; }
Finds a variable declaration with the given name that is in scope at the current location .
31,975
public static Symbol findIdent ( String name , VisitorState state , KindSelector kind ) { ClassType enclosingClass = ASTHelpers . getType ( state . findEnclosing ( ClassTree . class ) ) ; if ( enclosingClass == null || enclosingClass . tsym == null ) { return null ; } Env < AttrContext > env = Enter . instance ( state ...
Finds a declaration with the given name and type that is in scope at the current location .
31,976
public static ImmutableSet < Symbol > findReferencedIdentifiers ( Tree tree ) { ImmutableSet . Builder < Symbol > builder = ImmutableSet . builder ( ) ; createFindIdentifiersScanner ( builder , null ) . scan ( tree , null ) ; return builder . build ( ) ; }
Find the set of all identifiers referenced within this Tree
31,977
public static List < VarSymbol > findAllFields ( Type classType , VisitorState state ) { return state . getTypes ( ) . closure ( classType ) . stream ( ) . flatMap ( type -> { TypeSymbol tsym = type . tsym ; if ( tsym == null ) { return ImmutableList . < VarSymbol > of ( ) . stream ( ) ; } WriteableScope scope = tsym ....
Finds all the visible fields declared or inherited in the target class
31,978
public Iterable < ExpressionTemplateMatch > match ( JCTree target , Context context ) { if ( target instanceof JCExpression ) { JCExpression targetExpr = ( JCExpression ) target ; Optional < Unifier > unifier = unify ( targetExpr , new Unifier ( context ) ) . first ( ) ; if ( unifier . isPresent ( ) ) { return Immutabl...
Returns the matches of this template against the specified target AST .
31,979
private static int getPrecedence ( JCTree leaf , Context context ) { JCCompilationUnit comp = context . get ( JCCompilationUnit . class ) ; JCTree parent = TreeInfo . pathFor ( leaf , comp ) . get ( 1 ) ; if ( parent instanceof JCConditional ) { JCConditional conditional = ( JCConditional ) parent ; return TreeInfo . c...
Returns the precedence level appropriate for unambiguously printing leaf as a subexpression of its parent .
31,980
public static MethodSymbol getSymbol ( NewClassTree tree ) { Symbol sym = ( ( JCNewClass ) tree ) . constructor ; return sym instanceof MethodSymbol ? ( MethodSymbol ) sym : null ; }
Gets the method symbol for a new class .
31,981
public static MethodSymbol getSymbol ( MethodInvocationTree tree ) { Symbol sym = ASTHelpers . getSymbol ( tree . getMethodSelect ( ) ) ; if ( ! ( sym instanceof MethodSymbol ) ) { return null ; } return ( MethodSymbol ) sym ; }
Gets the symbol for a method invocation .
31,982
public static MethodSymbol getSymbol ( MemberReferenceTree tree ) { Symbol sym = ( ( JCMemberReference ) tree ) . sym ; return sym instanceof MethodSymbol ? ( MethodSymbol ) sym : null ; }
Gets the symbol for a member reference .
31,983
public static Tree stripParentheses ( Tree tree ) { while ( tree instanceof ParenthesizedTree ) { tree = ( ( ParenthesizedTree ) tree ) . getExpression ( ) ; } return tree ; }
Removes any enclosing parentheses from the tree .
31,984
public static ExpressionTree stripParentheses ( ExpressionTree tree ) { while ( tree instanceof ParenthesizedTree ) { tree = ( ( ParenthesizedTree ) tree ) . getExpression ( ) ; } return tree ; }
Given an ExpressionTree removes any enclosing parentheses .
31,985
public static < T > T findEnclosingNode ( TreePath path , Class < T > klass ) { path = findPathFromEnclosingNodeToTopLevel ( path , klass ) ; return ( path == null ) ? null : klass . cast ( path . getLeaf ( ) ) ; }
Given a TreePath walks up the tree until it finds a node of the given type . Returns null if no such node is found .
31,986
public static Type getReturnType ( ExpressionTree expressionTree ) { if ( expressionTree instanceof JCFieldAccess ) { JCFieldAccess methodCall = ( JCFieldAccess ) expressionTree ; return methodCall . type . getReturnType ( ) ; } else if ( expressionTree instanceof JCIdent ) { JCIdent methodCall = ( JCIdent ) expression...
Gives the return type of an ExpressionTree that represents a method select .
31,987
public static ExpressionTree getReceiver ( ExpressionTree expressionTree ) { if ( expressionTree instanceof MethodInvocationTree ) { ExpressionTree methodSelect = ( ( MethodInvocationTree ) expressionTree ) . getMethodSelect ( ) ; if ( methodSelect instanceof IdentifierTree ) { return null ; } return getReceiver ( meth...
Returns the receiver of an expression .
31,988
public static List < ExpressionTree > matchBinaryTree ( BinaryTree tree , List < Matcher < ExpressionTree > > matchers , VisitorState state ) { ExpressionTree leftOperand = tree . getLeftOperand ( ) ; ExpressionTree rightOperand = tree . getRightOperand ( ) ; if ( matchers . get ( 0 ) . matches ( leftOperand , state ) ...
Given a BinaryTree to match against and a list of two matchers applies the matchers to the operands in both orders . If both matchers match returns a list with the operand that matched each matcher in the corresponding position .
31,989
public static MethodTree findMethod ( MethodSymbol symbol , VisitorState state ) { return JavacTrees . instance ( state . context ) . getTree ( symbol ) ; }
Returns the method tree that matches the given symbol within the compilation unit or null if none was found .
31,990
public static ClassTree findClass ( ClassSymbol symbol , VisitorState state ) { return JavacTrees . instance ( state . context ) . getTree ( symbol ) ; }
Returns the class tree that matches the given symbol within the compilation unit or null if none was found .
31,991
public static boolean methodCanBeOverridden ( MethodSymbol methodSymbol ) { if ( methodSymbol . getModifiers ( ) . contains ( Modifier . ABSTRACT ) ) { return true ; } if ( methodSymbol . isStatic ( ) || methodSymbol . isPrivate ( ) || isFinal ( methodSymbol ) || methodSymbol . isConstructor ( ) ) { return false ; } Cl...
Determines whether a method can be overridden .
31,992
public static boolean inSamePackage ( Symbol targetSymbol , VisitorState state ) { JCCompilationUnit compilationUnit = ( JCCompilationUnit ) state . getPath ( ) . getCompilationUnit ( ) ; PackageSymbol usePackage = compilationUnit . packge ; PackageSymbol targetPackage = targetSymbol . packge ( ) ; return targetPackage...
Return true if the given symbol is defined in the current package .
31,993
public static boolean isVoidType ( Type type , VisitorState state ) { if ( type == null ) { return false ; } return type . getKind ( ) == TypeKind . VOID || state . getTypes ( ) . isSameType ( Suppliers . JAVA_LANG_VOID_TYPE . get ( state ) , type ) ; }
Return true if the given type is void or Void .
31,994
public static ModifiersTree getModifiers ( Tree tree ) { if ( tree instanceof ClassTree ) { return ( ( ClassTree ) tree ) . getModifiers ( ) ; } else if ( tree instanceof MethodTree ) { return ( ( MethodTree ) tree ) . getModifiers ( ) ; } else if ( tree instanceof VariableTree ) { return ( ( VariableTree ) tree ) . ge...
Returns the modifiers tree of the given class method or variable declaration .
31,995
public static Type getUpperBound ( Type type , Types types ) { if ( type . hasTag ( TypeTag . WILDCARD ) ) { return types . wildUpperBound ( type ) ; } if ( type . hasTag ( TypeTag . TYPEVAR ) && ( ( TypeVar ) type ) . isCaptured ( ) ) { return types . cvarUpperBound ( type ) ; } if ( type . getUpperBound ( ) != null )...
Returns the upper bound of a type if it has one or the type itself if not . Correctly handles wildcards and capture variables .
31,996
private static Type unaryNumericPromotion ( Type type , VisitorState state ) { Type unboxed = unboxAndEnsureNumeric ( type , state ) ; switch ( unboxed . getTag ( ) ) { case BYTE : case SHORT : case CHAR : return state . getSymtab ( ) . intType ; case INT : case LONG : case FLOAT : case DOUBLE : return unboxed ; defaul...
Implementation of unary numeric promotion rules .
31,997
private static Type binaryNumericPromotion ( Type leftType , Type rightType , VisitorState state ) { Type unboxedLeft = unboxAndEnsureNumeric ( leftType , state ) ; Type unboxedRight = unboxAndEnsureNumeric ( rightType , state ) ; Set < TypeTag > tags = EnumSet . of ( unboxedLeft . getTag ( ) , unboxedRight . getTag ( ...
Implementation of binary numeric promotion rules .
31,998
public static int getWorstCaseEditDistance ( int sourceLength , int targetLength , int changeCost , int openGapCost , int continueGapCost ) { int maxLen = Math . max ( sourceLength , targetLength ) ; int minLen = Math . min ( sourceLength , targetLength ) ; int totChangeCost = scriptCost ( openGapCost , continueGapCost...
Return the worst case edit distance between strings of this length
31,999
public Description matchMethod ( MethodTree tree , VisitorState state ) { MethodSymbol methodSym = ASTHelpers . getSymbol ( tree ) ; if ( ! methodSym . getModifiers ( ) . contains ( Modifier . PRIVATE ) ) { return Description . NO_MATCH ; } ImmutableList < Tree > params = tree . getParameters ( ) . stream ( ) . filter ...
Identifies methods with parameters that have a generic argument with Int Long or Double . If pre - conditions are met it refactors them to the primitive specializations .