idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
40,600
public static Intent getIntent ( Context context , LynxConfig lynxConfig ) { if ( lynxConfig == null ) { lynxConfig = new LynxConfig ( ) ; } Intent intent = new Intent ( context , LynxActivity . class ) ; intent . putExtra ( LYNX_CONFIG_EXTRA , lynxConfig ) ; return intent ; }
Generates an Intent to start LynxActivity with a LynxConfig configuration passed as parameter .
78
19
40,601
public void startReading ( ) { logcat . setListener ( new Logcat . Listener ( ) { @ Override public void onTraceRead ( String logcatTrace ) { try { addTraceToTheBuffer ( logcatTrace ) ; } catch ( IllegalTraceException e ) { return ; } notifyNewTraces ( ) ; } } ) ; boolean logcatWasNotStarted = Thread . State . NEW . eq...
Configures a Logcat . Listener and initialize Logcat dependency to read traces from the OS log .
122
21
40,602
public synchronized void restart ( ) { Logcat . Listener previousListener = logcat . getListener ( ) ; logcat . stopReading ( ) ; logcat . interrupt ( ) ; logcat = ( Logcat ) logcat . clone ( ) ; logcat . setListener ( previousListener ) ; lastNotificationTime = 0 ; tracesToNotify . clear ( ) ; logcat . start ( ) ; }
Stops the configured Logcat dependency and creates a clone to restart using Logcat and LogcatListener configured previously .
86
23
40,603
public void init ( final LynxConfig lynxConfig ) { ShakeDetector shakeDetector = new ShakeDetector ( new ShakeDetector . Listener ( ) { @ Override public void hearShake ( ) { if ( isEnabled ) { openLynxActivity ( lynxConfig ) ; } } } ) ; SensorManager sensorManager = ( SensorManager ) context . getSystemService ( Conte...
Starts listening shakes to open LynxActivity if a shake is detected and if the ShakeDetector is enabled .
102
23
40,604
public List < String > list ( URL url , String path ) throws IOException { InputStream is = null ; try { List < String > resources = new ArrayList < String > ( ) ; // First, try to find the URL of a JAR file containing the requested resource. If a JAR // file is found, then we'll list child resources by reading the JAR...
Recursively list the full resource path of all the resources that are children of the resource identified by a URL .
295
23
40,605
public void doBackgroundOp ( final Runnable run , final boolean showWaitCursor ) { final Component [ ] key = new Component [ 1 ] ; ExecutorService jobRunner = getJobRunner ( ) ; if ( jobRunner != null ) { jobRunner . submit ( ( ) -> performBackgroundOp ( run , key , showWaitCursor ) ) ; } else { run . run ( ) ; } }
Runs a job in a background thread using the ExecutorService and optionally sets the cursor to the wait cursor and blocks input .
86
26
40,606
public static int getArrayLength ( Object obj ) { if ( obj == null ) { return 0 ; } IType type = TypeLoaderAccess . instance ( ) . getIntrinsicTypeFromObject ( obj ) ; if ( type . isArray ( ) ) { return type . getArrayLength ( obj ) ; } if ( obj instanceof CharSequence ) { return ( ( CharSequence ) obj ) . length ( ) ;...
Return the length of the specified Array or Collection .
162
10
40,607
private boolean canAccessPrivateMembers ( IType ownersClass , IType whosAskin ) { return getOwnersType ( ) == whosAskin || getTopLevelTypeName ( whosAskin ) . equals ( getTopLevelTypeName ( ownersClass ) ) ; }
A private feature is accessible from its declaring class and any inner class defined in its declaring class .
59
19
40,608
public static < T > T findAncestor ( Component start , Class < T > aClass ) { if ( start == null ) { return null ; } return findAtOrAbove ( start . getParent ( ) , aClass ) ; }
Finds the first widget above the passed in widget of the given class
51
14
40,609
public static < T > T findAtOrAbove ( Component start , Class < T > aClass ) { Component comp = start ; while ( comp != null ) { if ( aClass . isInstance ( comp ) ) { return ( T ) comp ; } else { comp = comp . getParent ( ) ; } } return null ; }
Finds the first widget at or above the passed in widget of the given class
70
16
40,610
public SimpleXmlNode shallowCopy ( ) { SimpleXmlNode copy = new SimpleXmlNode ( _name ) ; copy . setText ( _text ) ; copy . getAttributes ( ) . putAll ( _attributes ) ; return copy ; }
Makes a shallow copy of this node including its name text and attributes . The returned node will have no children and no parent .
54
26
40,611
public SimpleXmlNode deepCopy ( ) { SimpleXmlNode rootCopy = shallowCopy ( ) ; for ( SimpleXmlNode child : _children ) { rootCopy . getChildren ( ) . add ( child . deepCopy ( ) ) ; } return rootCopy ; }
Makes a deep copy of this node including copies of all contained children . The returned node will have the same name text and attributes as this node and its list of children will contain deep copies of each child of this node .
58
45
40,612
private void removeUseless ( ) { Set < Map . Entry < String , PropertyNode > > entries = _children . entrySet ( ) ; for ( Iterator < Map . Entry < String , PropertyNode > > it = entries . iterator ( ) ; it . hasNext ( ) ; ) { Map . Entry < String , PropertyNode > entry = it . next ( ) ; PropertyNode child = entry . get...
removes all useless nodes in the tree represented by this node as a root
118
15
40,613
public void setReadMethod ( Method getter ) throws IntrospectionException { super . setReadMethod ( getter ) ; if ( _propertyClass == null ) { _propertyClass = super . getPropertyType ( ) ; } }
this class maintains its own copy of propertyType .
48
10
40,614
private void compileJavaInteropBridgeConstructor ( DynamicFunctionSymbol dfs ) { DynamicFunctionSymbol copy = new DynamicFunctionSymbol ( dfs ) ; copy . setValue ( null ) ; copy . setInitializer ( null ) ; ConstructorStatement fs = new ConstructorStatement ( true ) ; fs . setDynamicFunctionSymbol ( copy ) ; fs . setSyn...
Add constructor so Java can use the Gosu generic class without explicitly passing in type arguments .
647
18
40,615
public Object evaluate ( ) { if ( ! isCompileTimeConstant ( ) ) { return super . evaluate ( ) ; } Object value = getLHS ( ) . evaluate ( ) ; IType argType = getType ( ) ; if ( value instanceof IType && argType instanceof IJavaType && JavaTypes . CLASS ( ) == TypeLord . getPureGenericType ( argType ) ) { // Don't force ...
Perform a type cast .
332
6
40,616
public static ProgressFeedback runWithProgress ( final String strNotice , final IRunnableWithProgress task ) { return runWithProgress ( strNotice , task , false , false ) ; }
A helper method that executes a task in a worker thread and displays feedback in a progress windows .
40
19
40,617
public Object parse ( ) { Object val = null ; if ( T . isValueType ( ) ) { val = parseValue ( ) ; } else { addError ( ) ; } return val ; }
jsonText = value .
42
5
40,618
public Object parseValue ( ) { Object val ; switch ( T . getType ( ) ) { case LCURLY : val = parseObject ( ) ; break ; case LSQUARE : val = parseArray ( ) ; break ; case INTEGER : if ( useBig ) { val = new BigInteger ( T . getString ( ) ) ; } else { try { val = Integer . parseInt ( T . getString ( ) ) ; } catch ( Numbe...
value = object | array | number | string | true | false | null .
282
16
40,619
private TypeVarToTypeMap mapTypes ( TypeVarToTypeMap actualParamByVarName , IType ... types ) { for ( int i = 0 ; i < types . length ; i ++ ) { IType type = types [ i ] ; if ( type instanceof ITypeVariableType ) { actualParamByVarName . put ( ( ITypeVariableType ) types [ i ] , types [ i ] ) ; } if ( type instanceof IT...
Move Intrinsic type helper up here
252
9
40,620
public ProcessRunner withEnvironmentVariable ( String name , String value ) { _env . put ( name , value ) ; return this ; }
Adds a name - value pair into this process environment . This can be called multiple times in a chain to set multiple environment variables .
28
26
40,621
public V put ( K key , V value ) { return _cacheImpl . put ( key , value ) ; }
This will put a specific entry in the cache
24
9
40,622
public V get ( K key ) { V value = _cacheImpl . get ( key ) ; _requests . incrementAndGet ( ) ; if ( value == null ) { value = _missHandler . load ( key ) ; _cacheImpl . put ( key , value ) ; _misses . incrementAndGet ( ) ; } else { _hits . incrementAndGet ( ) ; } return value ; }
This will get a specific entry it will call the missHandler if it is not found .
87
18
40,623
public synchronized Cache < K , V > logEveryNSeconds ( int seconds , final ILogger logger ) { if ( _loggingTask == null ) { ScheduledExecutorService service = Executors . newScheduledThreadPool ( 1 ) ; _loggingTask = service . scheduleAtFixedRate ( new Runnable ( ) { public void run ( ) { logger . info ( Cache . this )...
Sets up a recurring task every n seconds to report on the status of this cache . This can be useful if you are doing exploratory caching and wish to monitor the performance of this cache with minimal fuss . Consider
133
43
40,624
@ Override public void setUndoableEditListener ( UndoableEditListener uel ) { if ( _uel != null ) { getEditor ( ) . getDocument ( ) . removeUndoableEditListener ( _uel ) ; } _uel = uel ; if ( _uel != null ) { getEditor ( ) . getDocument ( ) . addUndoableEditListener ( _uel ) ; } }
Sets the one and only undoable edit listener for this editor section . The primary use case for this method is to establish an undo manager connection .
88
30
40,625
private IType getCompilingClass ( ) { if ( isIncludeAll ( ) ) { return _gsClass ; } IType type = GosuClassCompilingStack . getCurrentCompilingType ( ) ; if ( type != null ) { return type ; } ISymbolTable symTableCtx = CompiledGosuClassSymbolTable . getSymTableCtx ( ) ; ISymbol thisSymbol = symTableCtx . getThisSymbolFr...
We expose type info in a context sensitive manner . For instance we only expose private features from within the containing class . We can determine the context class from the current compiling class . The compiling class is obtained from either 1 ) the actual CompiledGosuClass stack the Gosu Class TypeLoader manages o...
175
91
40,626
public Object evaluate ( ) { if ( ! isCompileTimeConstant ( ) ) { return super . evaluate ( ) ; } return ( Boolean ) getLHS ( ) . evaluate ( ) || ( Boolean ) getRHS ( ) . evaluate ( ) ; }
Performs a logical OR operation . Note this operation is naturally short - circuited by using || in conjunction with postponing RHS evaluation .
55
29
40,627
public static int getModifiersFrom ( IAttributedFeatureInfo afi ) { int iModifiers = 0 ; iModifiers = Modifier . setBit ( iModifiers , afi . isPublic ( ) , PUBLIC ) ; iModifiers = Modifier . setBit ( iModifiers , afi . isPrivate ( ) , PRIVATE ) ; iModifiers = Modifier . setBit ( iModifiers , afi . isProtected ( ) , PRO...
Match the Java value for the annotation modifier
215
8
40,628
public static boolean isAM ( Date date ) { return dateToCalendar ( date ) . get ( Calendar . AM_PM ) == Calendar . AM ; }
Is the time AM?
33
5
40,629
public static boolean isPM ( Date date ) { return dateToCalendar ( date ) . get ( Calendar . AM_PM ) == Calendar . PM ; }
Is the time PM?
33
5
40,630
public Color getForeground ( int code ) { Style s = _tokenStyles . get ( new Integer ( code ) ) ; if ( s == null ) { s = getStyle ( DEFAULT_STYLE ) ; } return getForeground ( s ) ; }
Fetch the foreground color to use for a lexical token with the given value .
57
17
40,631
public Font getFont ( int code ) { Style s = _tokenStyles . get ( new Integer ( code ) ) ; if ( s == null ) { s = getStyle ( DEFAULT_STYLE ) ; } return getFont ( s ) ; }
Fetch the font to use for a lexical token with the given scan value .
55
17
40,632
public Style getStyleForScanValue ( int code ) { Style s = _tokenStyles . get ( new Integer ( code ) ) ; if ( s == null ) { s = getStyle ( DEFAULT_STYLE ) ; } return s ; }
Fetches the attribute set to use for the given scan code . The set is stored in a table to facilitate relatively fast access to use in conjunction with the scanner .
54
34
40,633
@ Override public Font getFont ( AttributeSet attr ) { boolean bUnderline = StyleConstants . isUnderline ( attr ) ; boolean bStrikethrough = StyleConstants . isStrikeThrough ( attr ) ; if ( ! bUnderline && ! bStrikethrough ) { // StyleContext ignores the Underline and Strikethrough attribute return getFont ( attr , get...
Fetch the font to use for a given attribute set .
408
12
40,634
public static GosuPathEntry createPathEntryForModuleFile ( IFile moduleFile ) { try { InputStream is = moduleFile . openInputStream ( ) ; try { SimpleXmlNode moduleNode = SimpleXmlNode . parse ( is ) ; IDirectory rootDir = moduleFile . getParent ( ) ; List < IDirectory > sourceDirs = new ArrayList < IDirectory > ( ) ; ...
Reads a pom . xml file into a GosuPathEntry object
186
15
40,635
private static int minLen ( String ... patterns ) { int minLen = patterns [ 0 ] . length ( ) ; for ( String str : patterns ) { if ( str . length ( ) < minLen ) { minLen = str . length ( ) ; } } return minLen ; }
Find the shortest of all patterns .
60
7
40,636
private int rollHash ( int hashvalue , String str , int i ) { // 'roll' hash char outchar = str . charAt ( str . length ( ) - 1 - i ) ; char inchar = str . charAt ( str . length ( ) - _block - 1 - i ) ; hashvalue = A * hashvalue + CHAR_HASHES [ inchar ] - _Apowblock * CHAR_HASHES [ outchar ] ; return hashvalue ; }
Update rolling hash values .
102
5
40,637
private int reverseHash ( String str ) { int hash = 0 ; int len = str . length ( ) ; for ( int i = 0 ; i < _block ; i ++ ) { char c = str . charAt ( len - i - 1 ) ; hash = A * hash + CHAR_HASHES [ c ] ; } return hash ; }
Take rolling hash of last block characters . Start from the end of the string .
74
16
40,638
@ Override public void insertString ( int offset , String str , AttributeSet a ) throws BadLocationException { switch ( str ) { case "(" : str = addParenthesis ( ) ; break ; case "\n" : str = addWhiteSpace ( offset ) ; break ; case "\"" : str = addMatchingQuotationMark ( ) ; break ; case "{" : str = addMatchingBrace ( ...
Override to apply syntax highlighting after the document has been updated
122
11
40,639
public void stopWatching ( ) { try { _watchService . close ( ) ; _watchService = null ; _watchedDirectories = null ; } catch ( IOException e ) { throw new RuntimeException ( "Could not stop watching directories!" , e ) ; } }
Close the watch service . Releases resources . After calling this instance becomes invalid and can t be used any more .
58
22
40,640
public void watchDirectoryTree ( Path dir ) { if ( _watchedDirectories == null ) { throw new IllegalStateException ( "DirectoryWatcher.close() was called. Please make a new instance." ) ; } try { if ( Files . exists ( dir ) ) { Files . walkFileTree ( dir , new SimpleFileVisitor < Path > ( ) { @ Override public FileVisi...
Walk the directories under given path and register a watcher for every directory .
138
15
40,641
public List getModelUpdatedOrFilteredByPredicate ( ) { List model = getModel ( ) ; if ( _filter != null ) { model = new ArrayList ( model ) ; //duplicate because, insanely, ColUtil.filter is destructive for ( Iterator it = model . iterator ( ) ; it . hasNext ( ) ; ) { Object o = it . next ( ) ; if ( ! _filter . evaluat...
Returns the underlying list filtered by the predicate if it exists
109
11
40,642
private Class getMapType ( ) { Class mapType = Map . class ; IParsedElement parent = getParsedElement ( ) . getParent ( ) ; if ( parent instanceof NewExpression ) { IType newType = ( ( NewExpression ) parent ) . getType ( ) ; IJavaClassInfo classInfo = IRTypeResolver . getJavaBackedClass ( newType ) ; Class javaBackedC...
Try to get a more specific class instead of using the Map interface i . e . invokevirtual is significantly faster then invokeinterface .
176
26
40,643
private Class getCollectionType ( ) { Class collectionType = Collection . class ; IParsedElement parent = getParsedElement ( ) . getParent ( ) ; if ( parent instanceof NewExpression ) { IType newType = ( ( NewExpression ) parent ) . getType ( ) ; IJavaClassInfo classInfo = IRTypeResolver . getJavaBackedClass ( newType ...
Try to get a more specific class instead of using the Collection interface i . e . invokevirtual is significantly faster then invokeinterface .
176
26
40,644
public static IRStatement compileInitializerAssignment ( TopLevelTransformationContext context , InitializerAssignment stmt , IRExpression root ) { return InitializerAssignmentTransformer . compile ( context , stmt , root ) ; }
This is in its own method because it requires additional context
50
11
40,645
public void setParent ( IParseTree l ) { if ( l != null && ! l . contains ( this ) && getLength ( ) > 0 ) { throw new IllegalArgumentException ( "Attempted set the parent location, but the parent location's area is not a superset of this location's area." ) ; } if ( _pe != null ) { ParsedElement parentElement = ( Parse...
Sets the parent location . Note the parent location must cover a superset of the specified location s area .
165
22
40,646
public boolean areOffsetAndExtentEqual ( IParseTree location ) { return location != null && location . getOffset ( ) == getOffset ( ) && location . getExtent ( ) == getExtent ( ) ; }
Is just the physical location equal?
48
7
40,647
public IType getFeatureType ( ) { if ( _delegate . getFeatureType ( ) . isArray ( ) ) { return _delegate . getFeatureType ( ) ; } return _delegate . getFeatureType ( ) . getArrayType ( ) ; }
Make an array type from the delegate s type if it s not already an array . The idea with array expansion is to allow access to properties of X from an array of X . We call the accessor For each X in the array we call the
57
50
40,648
public static < E > StringBuffer join ( String glue , Collection < E > charSequences ) { StringBuffer buf = new StringBuffer ( ) ; int i = 0 ; for ( Object charSequence : charSequences ) { if ( i > 0 ) { buf . append ( glue ) ; } buf . append ( charSequence ) ; i ++ ; } return buf ; }
Takes a string glue and collection of CharSequences and returns a StringBuffer containing the CharSequences joined with the glue between each of them . They are joined in the order returned by the iterator of the colection
80
44
40,649
public static String escapeForJava ( String string ) { String result ; StringBuffer resultBuffer = null ; for ( int i = 0 , length = string . length ( ) ; i < length ; i ++ ) { char ch = string . charAt ( i ) ; String escape = escapeForJava ( ch ) ; if ( escape != null ) { if ( resultBuffer == null ) { resultBuffer = n...
Escape any special characters in the string using the Java escape syntax . For example any tabs become \ t newlines become \ n etc .
151
28
40,650
public static < Q > LockingLazyVar < Q > make ( final LazyVarInit < Q > init ) { return new LockingLazyVar < Q > ( ) { protected Q init ( ) { return init . init ( ) ; } } ; }
Creates a new LockingLazyVar based on the type of the LazyVarInit passed in . This method is intended to be called with blocks from Gosu .
56
35
40,651
private List < List < IType > > extractContextTypes ( List < ? extends IInvocableType > funcTypes ) { if ( funcTypes != null ) { ArrayList < List < IType >> returnList = new ArrayList <> ( ) ; for ( IInvocableType funcType : funcTypes ) { for ( int i = 0 ; i < funcType . getParameterTypes ( ) . length ; i ++ ) { IType ...
returns a list of lists of unique types at each argument position
197
13
40,652
private List < IFunctionSymbol > maybeAddPrivateFunctionsIfSuperInSamePackage ( String name , List < IFunctionSymbol > functions ) { ICompilableTypeInternal gsClass = getGosuClass ( ) ; if ( gsClass == null ) { return functions ; } IType supertype = gsClass . getSupertype ( ) ; if ( gsClass instanceof IGosuClass && sup...
the super class is in the same package as the subclass .
195
12
40,653
public IConstructorType getConstructorType ( IType classBean , Expression [ ] eArgs , List < IConstructorType > listAllMatchingMethods , ParserBase parserState ) throws ParseException { if ( classBean == null ) { throw new ParseException ( parserState == null ? null : parserState . makeFullParserState ( ) , Res . MSG_B...
Get the type of the method specified in the member path .
633
12
40,654
public Value evaluate ( Debugger debugger ) throws InvocationException { RuntimeState runtimeState = getRuntimeState ( debugger ) ; Location suspendedLoc = debugger . getSuspendedLocation ( ) ; VirtualMachine vm = suspendedLoc . virtualMachine ( ) ; ClassType classType = runtimeState . getCodeRunnerClass ( vm ) ; Value...
EvaluationContextImpl should be at the same stackFrame as it was in the call to EvaluatorBuilderImpl . build
267
26
40,655
public static List < String > getJreJars ( ) { String javaHome = System . getProperty ( "java.home" ) ; Path libsDir = FileSystems . getDefault ( ) . getPath ( javaHome , "/lib" ) ; List < String > retval = GosucUtil . getIbmClasspath ( ) ; try { retval . addAll ( Files . walk ( libsDir ) . filter ( path -> path . toFi...
Get all JARs from the lib directory of the System s java . home property
183
17
40,656
protected static List < String > getIbmClasspath ( ) { List < String > retval = new ArrayList <> ( ) ; if ( System . getProperty ( "java.vendor" ) . equals ( "IBM Corporation" ) ) { String fileSeparator = System . getProperty ( "file.separator" ) ; String classpathSeparator = System . getProperty ( "path.separator" ) ;...
Special handling for the unusual structure of the IBM JDK .
173
12
40,657
public void refresh ( Path file ) { EditorHost editor = findTab ( file ) ; if ( editor != null ) { // The file is open in an editor, refresh it with the contents of the file try ( Reader reader = PathUtil . createReader ( file ) ) { editor . refresh ( StreamUtil . getContent ( reader ) ) ; setDirty ( editor , false ) ;...
This should only be called when either the file s contents change externally or when the file saves to disk .
167
21
40,658
public static Expression getUnwrappedExpression ( Expression expression ) { while ( expression instanceof ImplicitTypeAsExpression ) { expression = ( ( ImplicitTypeAsExpression ) expression ) . getLHS ( ) ; } return expression ; }
If the expression is wrapped in ImplicitTypeAsExpressions this will will unwrap them back down to the original expression .
52
25
40,659
private boolean isReadObjectOrWriteObjectMethod ( Symbol symbol ) { if ( symbol instanceof DynamicFunctionSymbol ) { DynamicFunctionSymbol dfs = ( DynamicFunctionSymbol ) symbol ; if ( dfs . getDisplayName ( ) . equals ( "readObject" ) ) { IType [ ] argTypes = dfs . getArgTypes ( ) ; return argTypes != null && argTypes...
Returns true if that is the case false otherwise
253
9
40,660
private boolean areTypeNamesEqual ( String name1 , String name2 ) { return name1 . replace ( ' ' , ' ' ) . equals ( name2 . replace ( ' ' , ' ' ) ) ; }
rather we just didn t care about the difference
46
9
40,661
public IType getType ( ) { IType type = getTypeImpl ( ) ; if ( TypeSystem . isDeleted ( type ) ) { type = TypeSystem . getErrorType ( ) ; } return type ; }
Returns this Expression s IType .
47
7
40,662
private static String xmlEncode ( String input , boolean attribute ) { if ( input == null || input . length ( ) == 0 ) { return attribute ? "\"\"" : input ; } StringBuilder output = new StringBuilder ( ) ; if ( attribute ) { output . append ( 0 ) ; // reserve space for leading quote } char quoteChar = 0 ; for ( int i =...
Properly encodes user input for inclusion in an XML document .
434
14
40,663
public void reassignClassLoader ( ) { ClassLoader loader = _module . getModuleClassLoader ( ) ; if ( loader . getParent ( ) instanceof IInjectableClassLoader ) { // Dispose the GosuPluginContainer "singleton" and create a new one ( ( IInjectableClassLoader ) loader . getParent ( ) ) . dispose ( ) ; // Dispose the Modul...
Called in Single module mode . If the parent loader of the ModuleClassLoader is the GosuPluginContainer we drop the ModuleClassLoader and its parent the GosuPluginContainer . New ones are created and assigned here . Note this is a giant hack among many gianter hacks that keep the old test framework floating .
140
65
40,664
public Object invoke ( Object [ ] args ) { Object value = getValue ( ) ; if ( value instanceof ISymbol ) { return ( ( Symbol ) value ) . invoke ( args ) ; } if ( value instanceof IBlock ) { return ( ( IBlock ) value ) . invokeWithArgs ( args ) ; } Method method = ( Method ) value ; Object ret ; try { ret = method . inv...
Invokes function .
117
4
40,665
public static ObjectSize deepSizeOf ( Object obj , IObjectSizeFilter filter , int maxObjects ) { Map < Object , Object > visited = new IdentityHashMap < Object , Object > ( ) ; Stack < ObjectEntry > stack = new Stack < ObjectEntry > ( ) ; InvocationCounter sizeHistogram = new InvocationCounter ( false ) ; long result =...
Calculates full size of object iterating over its hierarchy graph .
281
14
40,666
public Object evaluate ( ) { if ( ! isCompileTimeConstant ( ) ) { return super . evaluate ( ) ; } return ( Boolean ) getCondition ( ) . evaluate ( ) ? getFirst ( ) . evaluate ( ) : getSecond ( ) . evaluate ( ) ; }
Evaluates this Expression and returns the result .
59
10
40,667
public static int arrayHashCode ( Object array ) { if ( array == null ) { return 0 ; } IType arrayType = TypeSystem . getFromObject ( array ) ; int iLen = arrayType . getArrayLength ( array ) ; int hashCode = 0 ; for ( int i = 0 ; i < iLen ; i ++ ) { Object value = arrayType . getArrayComponent ( array , i ) ; if ( val...
Return the hash code for an array
166
7
40,668
public Integer getStyleCodeAtPosition ( int iPosition ) { if ( _locations == null || _locations . isEmpty ( ) ) { return null ; } IParseTree l ; try { l = IParseTree . Search . getDeepestLocation ( _locations , iPosition - _locationsOffset , true ) ; } catch ( Throwable t ) { // Ok, what we are guarding against here is...
Returns a style code for the absolute position in the document or null if no code is mapped .
335
19
40,669
public int getScannerStart ( int p ) { Element elem = getDefaultRootElement ( ) ; int lineNum = elem . getElementIndex ( p ) ; Element line = elem . getElement ( lineNum ) ; AttributeSet a = line . getAttributes ( ) ; while ( a . isDefined ( CommentAttribute ) && lineNum > 0 ) { lineNum -= 1 ; line = elem . getElement ...
Fetch a reasonable location to start scanning given the desired start location . This allows for adjustments needed to accomodate multiline comments .
116
29
40,670
@ Override protected void insertUpdate ( DefaultDocumentEvent chng , AttributeSet attr ) { super . insertUpdate ( chng , attr ) ; // Update comment marks Element root = getDefaultRootElement ( ) ; DocumentEvent . ElementChange ec = chng . getChange ( root ) ; if ( ec != null ) { Element [ ] added = ec . getChildrenAdde...
Updates document structure as a result of text insertion . This will happen within a write lock . The superclass behavior of updating the line map is executed followed by marking any comment areas that should backtracked before scanning .
310
44
40,671
public static < Q > LocklessLazyVar < Q > make ( final LazyVarInit < Q > closure ) { return new LocklessLazyVar < Q > ( ) { protected Q init ( ) { return closure . init ( ) ; } } ; }
Creates a new LockingLazyVar based on the type of the LazyVarInit passed in . This method is intended to be called with a lambda or block from Gosu .
56
38
40,672
public static IParsedElement boundingParent ( List < IParseTree > locations , int position , Class < ? extends IParsedElement > ... possibleTypes ) { IParseTree location = IParseTree . Search . getDeepestLocation ( locations , position , true ) ; IParsedElement pe = null ; if ( location != null ) { pe = location . getP...
Finds a bounding parent of any of the possible types passed in from the list of locations starting at the position given .
119
25
40,673
public static IParseTree [ ] findSpanningLogicalRange ( IParseTree start , IParseTree end ) { while ( end != null ) { IParseTree deepestAtStart = start ; while ( deepestAtStart != null ) { if ( deepestAtStart . isSiblingOf ( end ) ) { IParseTree [ ] returnVal = new IParseTree [ 2 ] ; if ( deepestAtStart . getOffset ( )...
Given two parse tree positions find the bounding pair that captures the start and end in one logical unit
199
20
40,674
public static List < GosuPathEntry > convertClasspathToGosuPathEntries ( List < File > classpath ) { // this is a hack to prevent loading of gosu directly from jar files in Diamond, // which prevents people from just embedding it in src and thus possibly having ND problems // it can be removed once "modules" are figure...
Converts a set of Files into a list of GosuPathEntries . The algorithm is as follows . For each File in the list if that file is a directory or a jar file see if there s a module . xml file in the root . If so parse that file and add in a GosuPathEntry based on the module definition . If not if the file is a directory ...
256
173
40,675
@ Override protected ITerminalStatement getLeastSignificantTerminalStatement_internal ( boolean [ ] bAbsolute ) { ITerminalStatement termRet = null ; bAbsolute [ 0 ] = true ; boolean bBreak = false ; ITerminalStatement lastCaseTerm = null ; if ( _cases != null ) { for ( int i = 0 ; i < _cases . length ; i ++ ) { List c...
bAbsolute is true iff there are no break terminals anywhere in any cases and the default clause s terminator is non - break and absolute
794
29
40,676
public static < T extends Annotation > Builder < T > builder ( Class < T > annotationType ) { return new Builder < T > ( annotationType ) ; }
Returns a builder that can be used to construct an annotation instance .
34
13
40,677
public static < T extends Annotation > T create ( Class < T > annotationType , Object value ) { return new Builder < T > ( annotationType ) . withValue ( value ) . create ( ) ; }
Convenience method that constructs an annotation instance with a single value element .
44
15
40,678
public static < T extends Annotation > T create ( Class < T > annotationType ) { return new Builder < T > ( annotationType ) . create ( ) ; }
Convenience method that constructs an annotation instance with no elements .
35
13
40,679
public Object evaluate ( ) { if ( ! isCompileTimeConstant ( ) ) { return super . evaluate ( ) ; } Object lhsValue = getLHS ( ) . evaluate ( ) ; Object rhsValue = getRHS ( ) . evaluate ( ) ; IType lhsType = getLHS ( ) . getType ( ) ; IType rhsType = getRHS ( ) . getType ( ) ; if ( _strOperator . equals ( ">" ) ) { if ( ...
Perform a relational comparison .
796
6
40,680
public static byte [ ] toBytes ( CharSequence seq ) { try { return seq . toString ( ) . getBytes ( "UTF-8" ) ; } catch ( UnsupportedEncodingException ex ) { throw new RuntimeException ( ex ) ; // shouldn't happen since UTF-8 is supported by all JVMs per spec } }
Converts the specified character sequence to bytes using UTF - 8 .
72
13
40,681
public static Properties toProperties ( String propFileText ) throws CharacterCodingException { CharsetEncoder encoder = Charset . forName ( "ISO-8859-1" ) . newEncoder ( ) . onUnmappableCharacter ( CodingErrorAction . REPORT ) ; byte [ ] bytes = encoder . encode ( CharBuffer . wrap ( propFileText ) ) . array ( ) ; Pro...
Converts the specified property file text to a Properties object .
141
12
40,682
public static Reader getInputStreamReader ( InputStream in , String charset ) { try { return new InputStreamReader ( in , charset ) ; } catch ( UnsupportedEncodingException ex ) { throw new RuntimeException ( ex ) ; // shouldn't happen since UTF-8 is supported by all JVMs per spec } }
Returns a reader for the specified input stream using specified encoding .
69
12
40,683
public static Writer getOutputStreamWriter ( OutputStream out ) { try { return new OutputStreamWriter ( out , "UTF-8" ) ; } catch ( UnsupportedEncodingException ex ) { throw new RuntimeException ( ex ) ; // shouldn't happen since UTF-8 is supported by all JVMs per spec } }
Returns a writer for the specified output stream using UTF - 8 encoding .
68
14
40,684
public static byte [ ] getContent ( InputStream in ) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; copy ( in , baos ) ; return baos . toByteArray ( ) ; } finally { in . close ( ) ; } }
Returns the content of the specified input stream . The stream will be closed after calling this method .
62
19
40,685
public static String getContent ( Reader in ) throws IOException { try { StringWriter sw = new StringWriter ( ) ; copy ( in , sw ) ; return sw . toString ( ) ; } finally { in . close ( ) ; } }
Returns the content of the specified reader . The reader will be closed after calling this method .
51
18
40,686
public static void copy ( InputStream in , Writer writer ) throws IOException { copy ( getInputStreamReader ( in ) , writer ) ; writer . flush ( ) ; }
Copies the content of an input stream to a writer .
36
12
40,687
public static void copy ( Reader reader , OutputStream out ) throws IOException { copy ( reader , getOutputStreamWriter ( out ) ) ; out . flush ( ) ; }
Copies the content of a reader to an output stream .
36
12
40,688
public static void copy ( Reader in , Writer out ) throws IOException { char [ ] buf = new char [ 1024 ] ; while ( true ) { int count = in . read ( buf ) ; if ( count < 0 ) { break ; } out . write ( buf , 0 , count ) ; } out . flush ( ) ; }
Copies the content of a reader to a writer .
70
11
40,689
private void forward ( MouseWheelEvent e ) { e = new MouseWheelEvent ( e . getComponent ( ) . getParent ( ) , e . getID ( ) , e . getWhen ( ) , e . getModifiers ( ) , e . getX ( ) , e . getY ( ) , e . getClickCount ( ) , e . isPopupTrigger ( ) , e . getScrollType ( ) , e . getScrollAmount ( ) , e . getWheelRotation ( )...
For some reason the parent does not get mouse wheel
132
10
40,690
public static IType parseTypeLiteral ( String typeName ) { try { IType type = GosuParserFactory . createParser ( typeName ) . parseTypeLiteral ( null ) . getType ( ) . getType ( ) ; if ( type instanceof IErrorType ) { throw new RuntimeException ( "Type not found: " + typeName ) ; } return type ; } catch ( ParseResultsE...
Parses a type name such as Iterable&lt ; Claim&gt ; .
112
18
40,691
public static TaskQueue getInstance ( ILogger logger , String strQueueName ) { if ( strQueueName == null ) { return null ; } TaskQueue taskQueue = QUEUE_MAP . get ( strQueueName ) ; if ( taskQueue == null ) { taskQueue = new TaskQueue ( logger , strQueueName ) ; QUEUE_MAP . put ( strQueueName , taskQueue ) ; } return t...
Fetch a TaskQueue by name . If the TaskQueue doesn t already exist creates the TaskQueue .
93
21
40,692
public static void emptyAndRemoveQueue ( String strQueueName ) { TaskQueue taskQueue = QUEUE_MAP . get ( strQueueName ) ; if ( taskQueue != null ) { taskQueue . emptyQueue ( ) ; synchronized ( taskQueue . _queue ) { taskQueue . _shutdown = true ; taskQueue . _queue . notifyAll ( ) ; } QUEUE_MAP . remove ( strQueueName ...
Clears all the inactive tasks in the specified queue .
93
11
40,693
@ Override public void run ( ) { while ( ! _shutdown ) { try { Runnable task ; synchronized ( _queue ) { while ( _queue . isEmpty ( ) ) { if ( _shutdown ) { return ; } _queue . wait ( ) ; } // The double sync get/remove thing is done to support peekTask above. task = _queue . get ( 0 ) ; _queue . notifyAll ( ) ; } try ...
Do NOT ever call this! Public only by contract .
210
11
40,694
protected void log ( Throwable t ) { if ( _logger == null ) { t . printStackTrace ( ) ; } else { _logger . warn ( "Error running job." , t ) ; } }
Log an exception or error .
47
6
40,695
public String toDebugString ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "GosuPathEntry:\n" ) ; sb . append ( " root: " ) . append ( _root . toJavaFile ( ) . getAbsolutePath ( ) ) . append ( "\n" ) ; for ( IDirectory src : _srcs ) { sb . append ( " src: " ) . append ( src . toJavaFile ( ) . getAbsolut...
Returns a String representation of this path entry suitable for use in debugging .
131
14
40,696
public static MethodDescriptor buildScriptableMethodDescriptorNoArgs ( Class actionClass , String methodName ) { MethodDescriptor md = _buildMethodDescriptor ( actionClass , methodName , EMPTY_STRING_ARRAY , EMPTY_CLASS_ARRAY , EMPTY_CLASS_ARRAY ) ; makeScriptable ( md ) ; return md ; }
Builds a no - arg method descriptor that is exposed for scripting everywhere .
81
15
40,697
public static MethodDescriptor buildScriptableMethodDescriptor ( Class actionClass , String methodName , String [ ] parameterNames , Class [ ] parameterTypes ) { MethodDescriptor md = _buildMethodDescriptor ( actionClass , methodName , parameterNames , parameterTypes , parameterTypes ) ; makeScriptable ( md ) ; return ...
Builds a method descriptor that is exposed for scripting everywhere .
75
12
40,698
public static MethodDescriptor buildScriptableDeprecatedMethodDescriptor ( Class actionClass , String methodName , String [ ] parameterNames , Class [ ] parameterTypes ) { MethodDescriptor md = _buildMethodDescriptor ( actionClass , methodName , parameterNames , parameterTypes , parameterTypes ) ; makeScriptableDepreca...
Builds a deprecated method descriptor that is exposed for scripting everywhere .
79
13
40,699
public static MethodDescriptor buildHiddenMethodDescriptor ( Class actionClass , String methodName , String [ ] parameterNames , Class [ ] parameterTypes ) { MethodDescriptor md = _buildMethodDescriptor ( actionClass , methodName , parameterNames , parameterTypes , parameterTypes ) ; md . setHidden ( true ) ; return md...
Completely hides a method from scripting .
75
8