idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
33,800
public void addSarlRequiredCapacity ( String ... name ) { if ( name != null && name . length > 0 ) { SarlRequiredCapacity member = SarlFactory . eINSTANCE . createSarlRequiredCapacity ( ) ; this . sarlBehavior . getMembers ( ) . add ( member ) ; member . setAnnotationInfo ( XtendFactory . eINSTANCE . createXtendMember ( ) ) ; Collection < JvmParameterizedTypeReference > thecollection = member . getCapacities ( ) ; for ( final String aname : name ) { if ( ! Strings . isEmpty ( aname ) ) { thecollection . add ( newTypeRef ( this . sarlBehavior , aname ) ) ; } } } }
Create a SarlRequiredCapacity .
163
8
33,801
@ SuppressWarnings ( "static-method" ) @ Provides @ Singleton public SarlConfig getSarlcConfig ( ConfigurationFactory configFactory , Injector injector ) { final SarlConfig config = SarlConfig . getConfiguration ( configFactory ) ; injector . injectMembers ( config ) ; return config ; }
Replies the instance of the sarl configuration .
70
10
33,802
public static RefactoringStatus validatePackageName ( String newName ) { if ( ! PACKAGE_NAME_PATTERN . matcher ( newName ) . find ( ) ) { RefactoringStatus . createErrorStatus ( MessageFormat . format ( Messages . SARLJdtPackageRenameParticipant_0 , newName ) ) ; } return new RefactoringStatus ( ) ; }
Validate the package name .
83
6
33,803
protected void setPackageName ( String newName , ResourceSet resourceSet ) { final EObject object = resourceSet . getEObject ( this . uriProvider . apply ( resourceSet ) , true ) ; if ( object instanceof SarlScript ) { ( ( SarlScript ) object ) . setPackage ( newName ) ; } else { throw new RefactoringException ( "SARL script not loaded." ) ; //$NON-NLS-1$ } }
Change the package name .
102
5
33,804
protected TextEdit getDeclarationTextEdit ( String newName , ResourceSet resourceSet ) { final EObject object = resourceSet . getEObject ( this . uriProvider . apply ( resourceSet ) , true ) ; if ( object instanceof SarlScript ) { final ITextRegion region = getOriginalPackageRegion ( ( SarlScript ) object ) ; if ( region != null ) { return new ReplaceEdit ( region . getOffset ( ) , region . getLength ( ) , newName ) ; } } throw new RefactoringException ( "SARL script not loaded." ) ; //$NON-NLS-1$ }
Replies the text update for the rename .
136
9
33,805
protected ITextRegion getOriginalPackageRegion ( final SarlScript script ) { return this . locationInFileProvider . getFullTextRegion ( script , XtendPackage . Literals . XTEND_FILE__PACKAGE , 0 ) ; }
Replies the text region that is corresponding to the package name .
52
13
33,806
@ Inject public void setOutputLanguage ( @ Named ( Constants . LANGUAGE_NAME ) String outputLanguage ) { if ( ! Strings . isNullOrEmpty ( outputLanguage ) ) { final String [ ] parts = outputLanguage . split ( "\\.+" ) ; //$NON-NLS-1$ if ( parts . length > 0 ) { final String simpleName = parts [ parts . length - 1 ] ; if ( ! Strings . isNullOrEmpty ( simpleName ) ) { this . languageName = simpleName ; return ; } } } this . languageName = null ; }
Change the name of the language .
131
7
33,807
public static Function2 < String , String , String > getFencedCodeBlockFormatter ( ) { return ( languageName , content ) -> { /*final StringBuilder result = new StringBuilder(); result.append("<div class=\\\"highlight"); //$NON-NLS-1$ if (!Strings.isNullOrEmpty(languageName)) { result.append(" highlight-").append(languageName); //$NON-NLS-1$ } result.append("\"><pre>\n").append(content).append("</pre></div>\n"); //$NON-NLS-1$ //$NON-NLS-2$ return result.toString();*/ return "```" + Strings . nullToEmpty ( languageName ) . toLowerCase ( ) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ + content + "```\n" ; //$NON-NLS-1$ } ; }
Replies the fenced code block formatter .
221
10
33,808
public static Function2 < String , String , String > getBasicCodeBlockFormatter ( ) { return ( languageName , content ) -> { return Pattern . compile ( "^" , Pattern . MULTILINE ) . matcher ( content ) . replaceAll ( "\t" ) ; //$NON-NLS-1$ //$NON-NLS-2$ } ; }
Replies the basic code block formatter .
83
9
33,809
public void reset ( ) { this . rawPatterns . clear ( ) ; this . compiledPatterns . clear ( ) ; this . inlineFormat = DEFAULT_INLINE_FORMAT ; this . blockFormat = null ; this . outlineOutputTag = DEFAULT_OUTLINE_OUTPUT_TAG ; this . dynamicNameExtractionPattern = DEFAULT_TAG_NAME_PATTERN ; this . lineContinuation = DEFAULT_LINE_CONTINUATION ; }
Reset to the default settings .
101
7
33,810
public void setPattern ( Tag tag , String regex ) { if ( Strings . isNullOrEmpty ( regex ) ) { this . rawPatterns . remove ( tag ) ; this . compiledPatterns . remove ( tag ) ; } else { this . rawPatterns . put ( tag , regex ) ; this . compiledPatterns . put ( tag , Pattern . compile ( "^\\s*" + regex , PATTERN_COMPILE_OPTIONS ) ) ; //$NON-NLS-1$ } }
Change the pattern of the tag .
112
7
33,811
public String getPattern ( Tag tag ) { final String pattern = this . rawPatterns . get ( tag ) ; if ( pattern == null ) { return tag . getDefaultPattern ( ) ; } return pattern ; }
Replies the pattern of the tag .
45
8
33,812
public Tag getTagForPattern ( CharSequence text ) { for ( final Tag tag : Tag . values ( ) ) { Pattern pattern = this . compiledPatterns . get ( tag ) ; if ( pattern == null ) { pattern = Pattern . compile ( "^\\s*" + getPattern ( tag ) , Pattern . DOTALL ) ; //$NON-NLS-1$ this . compiledPatterns . put ( tag , pattern ) ; } final Matcher matcher = pattern . matcher ( text ) ; if ( matcher . find ( ) ) { return tag ; } } return null ; }
Replies the tag that is matching the given text .
129
11
33,813
public String getLineSeparator ( ) { if ( Strings . isNullOrEmpty ( this . lineSeparator ) ) { final String nl = System . getProperty ( "line.separator" ) ; //$NON-NLS-1$ if ( Strings . isNullOrEmpty ( nl ) ) { return "\n" ; //$NON-NLS-1$ } return nl ; } return this . lineSeparator ; }
Replies the OS - dependent line separator .
102
10
33,814
protected void extractDynamicName ( Tag tag , CharSequence name , OutParameter < String > dynamicName ) { if ( tag . hasDynamicName ( ) ) { final Pattern pattern = Pattern . compile ( getDynamicNameExtractionPattern ( ) ) ; final Matcher matcher = pattern . matcher ( name ) ; if ( matcher . matches ( ) ) { dynamicName . set ( Strings . nullToEmpty ( matcher . group ( 1 ) ) ) ; return ; } } dynamicName . set ( name . toString ( ) ) ; }
Extract the dynamic name of that from the raw text .
116
12
33,815
public String transform ( File inputFile ) { final String content ; try ( FileReader reader = new FileReader ( inputFile ) ) { content = read ( reader ) ; } catch ( IOException exception ) { reportError ( Messages . SarlDocumentationParser_0 , exception ) ; return null ; } return transform ( content , inputFile ) ; }
Read the given file and transform its content in order to have a raw text .
73
16
33,816
protected String postProcessing ( CharSequence text ) { final String lineContinuation = getLineContinuation ( ) ; if ( lineContinuation != null ) { final Pattern pattern = Pattern . compile ( "\\s*\\\\[\\n\\r]+\\s*" , //$NON-NLS-1$ Pattern . DOTALL ) ; final Matcher matcher = pattern . matcher ( text . toString ( ) . trim ( ) ) ; return matcher . replaceAll ( lineContinuation ) ; } return text . toString ( ) . trim ( ) ; }
Do a post processing of the text .
123
8
33,817
protected static String formatBlockText ( String content , String languageName , Function2 < String , String , String > blockFormat ) { String replacement = Strings . nullToEmpty ( content ) ; final String [ ] lines = replacement . trim ( ) . split ( "[\n\r]+" ) ; //$NON-NLS-1$ int minIndent = Integer . MAX_VALUE ; final Pattern wpPattern = Pattern . compile ( "^(\\s*)[^\\s]" ) ; //$NON-NLS-1$ for ( int i = lines . length > 1 ? 1 : 0 ; i < lines . length ; ++ i ) { final String line = lines [ i ] ; final Matcher matcher = wpPattern . matcher ( line ) ; if ( matcher . find ( ) ) { final int n = matcher . group ( 1 ) . length ( ) ; if ( n < minIndent ) { minIndent = n ; if ( minIndent <= 0 ) { break ; } } } } final StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( lines [ 0 ] ) ; buffer . append ( "\n" ) ; //$NON-NLS-1$ for ( int i = 1 ; i < lines . length ; ++ i ) { final String line = lines [ i ] ; buffer . append ( line . replaceFirst ( "^\\s{0," + minIndent + "}" , "" ) ) ; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ buffer . append ( "\n" ) ; //$NON-NLS-1$ } replacement = buffer . toString ( ) . replaceFirst ( "[\n\r]+$" , "\n" ) ; //$NON-NLS-1$ //$NON-NLS-2$ if ( ! Strings . isNullOrEmpty ( replacement ) && ! "\n" . equals ( replacement ) ) { //$NON-NLS-1$ if ( blockFormat != null ) { return blockFormat . apply ( languageName , replacement ) ; } return replacement ; } return "" ; //$NON-NLS-1$ }
Format the given text in order to be suitable for being output as a block .
487
16
33,818
protected void generateInnerDocumentationAdapter ( ) { final TypeReference adapter = getCodeElementExtractor ( ) . getInnerBlockDocumentationAdapter ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "public class " ) ; //$NON-NLS-1$ it . append ( adapter . getSimpleName ( ) ) ; it . append ( " extends " ) ; //$NON-NLS-1$ it . append ( AdapterImpl . class ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\tprivate String documentation;" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t@" ) ; //$NON-NLS-1$ it . append ( Pure . class ) ; it . newLine ( ) ; it . append ( "\tpublic String getDocumentation() {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\t\treturn this.documentation;" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\tpublic void setDocumentation(String documentation) {" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t\tthis.documentation = documentation;" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\t@" ) ; //$NON-NLS-1$ it . append ( Pure . class ) ; it . newLine ( ) ; it . append ( "\tpublic boolean isAdapterForType(Object type) {" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t\treturn type == " ) ; //$NON-NLS-1$ it . append ( adapter . getSimpleName ( ) ) ; it . append ( ".class;" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; } } ; final JavaFileAccess createJavaFile = getFileAccessFactory ( ) . createJavaFile ( adapter , content ) ; createJavaFile . writeTo ( getSrcGen ( ) ) ; }
Generate the adapter that supports the inner documentation .
690
10
33,819
public void setAutoFormattingEnabled ( Boolean enable ) { final IPreferenceStore store = getWritablePreferenceStore ( null ) ; if ( enable == null ) { store . setToDefault ( AUTOFORMATTING_PROPERTY ) ; } else { store . setValue ( AUTOFORMATTING_PROPERTY , enable . booleanValue ( ) ) ; } }
Enable or disable the auto - formatting feature into the SARL editor .
80
14
33,820
public void setReturnType ( String type ) { if ( ! Strings . isEmpty ( type ) && ! Objects . equals ( "void" , type ) && ! Objects . equals ( Void . class . getName ( ) , type ) ) { this . sarlAction . setReturnType ( newTypeRef ( container , type ) ) ; } else { this . sarlAction . setReturnType ( null ) ; } }
Change the return type .
90
5
33,821
public void addAnnotation ( String type ) { if ( ! Strings . isEmpty ( type ) ) { XAnnotation annotation = XAnnotationsFactory . eINSTANCE . createXAnnotation ( ) ; annotation . setAnnotationType ( newTypeRef ( getSarlAction ( ) , type ) . getType ( ) ) ; getSarlAction ( ) . getAnnotations ( ) . add ( annotation ) ; } }
Add an annotation .
91
4
33,822
public static void useJanusMessageFormat ( ) { final String format = System . getProperty ( FORMAT_PROPERTY_KEY , null ) ; if ( format == null || format . isEmpty ( ) ) { System . setProperty ( FORMAT_PROPERTY_KEY , JANUS_FORMAT ) ; } }
Change the configuration of the root logger for using the Janus format for the messages .
70
17
33,823
public static Logger createPlatformLogger ( ) { final Logger logger = Logger . getAnonymousLogger ( ) ; for ( final Handler handler : logger . getHandlers ( ) ) { logger . removeHandler ( handler ) ; } final Handler stderr = new StandardErrorOutputConsoleHandler ( ) ; stderr . setLevel ( Level . ALL ) ; final Handler stdout = new StandardOutputConsoleHandler ( ) ; stdout . setLevel ( Level . ALL ) ; logger . addHandler ( stderr ) ; logger . addHandler ( stdout ) ; logger . setUseParentHandlers ( false ) ; logger . setLevel ( Level . ALL ) ; return logger ; }
Create a logger with the given name for the platform .
145
11
33,824
public static Level getLoggingLevelFromProperties ( ) { if ( levelFromProperties == null ) { final String verboseLevel = JanusConfig . getSystemProperty ( JanusConfig . VERBOSE_LEVEL_NAME , JanusConfig . VERBOSE_LEVEL_VALUE ) ; levelFromProperties = parseLoggingLevel ( verboseLevel ) ; } return levelFromProperties ; }
Extract the logging level from the system properties .
87
10
33,825
@ SuppressWarnings ( { "checkstyle:returncount" , "checkstyle:cyclomaticcomplexity" } ) public static Level parseLoggingLevel ( String level ) { if ( level == null ) { return Level . INFO ; } switch ( level . toLowerCase ( ) ) { case "none" : //$NON-NLS-1$ case "false" : //$NON-NLS-1$ case "0" : //$NON-NLS-1$ return Level . OFF ; case "severe" : //$NON-NLS-1$ case "error" : //$NON-NLS-1$ case "1" : //$NON-NLS-1$ return Level . SEVERE ; case "warn" : //$NON-NLS-1$ case "warning" : //$NON-NLS-1$ case "2" : //$NON-NLS-1$ return Level . WARNING ; case "info" : //$NON-NLS-1$ case "true" : //$NON-NLS-1$ case "3" : //$NON-NLS-1$ return Level . INFO ; case "fine" : //$NON-NLS-1$ case "config" : //$NON-NLS-1$ case "4" : //$NON-NLS-1$ return Level . FINE ; case "finer" : //$NON-NLS-1$ case "5" : //$NON-NLS-1$ return Level . FINER ; case "finest" : //$NON-NLS-1$ case "debug" : //$NON-NLS-1$ case "6" : //$NON-NLS-1$ return Level . FINEST ; case "all" : //$NON-NLS-1$ case "7" : //$NON-NLS-1$ return Level . ALL ; default : try { return fromInt ( Integer . parseInt ( level ) ) ; } catch ( Throwable exception ) { // } return Level . INFO ; } }
Extract the logging level from the given string .
474
10
33,826
@ SuppressWarnings ( { "checkstyle:magicnumber" , "checkstyle:returncount" } ) public static Level fromInt ( int num ) { switch ( num ) { case 0 : return Level . OFF ; case 1 : return Level . SEVERE ; case 2 : return Level . WARNING ; case 3 : return Level . INFO ; case 4 : return Level . FINE ; case 5 : return Level . FINER ; case 6 : return Level . FINEST ; case 7 : return Level . ALL ; default : if ( num < 0 ) { return Level . OFF ; } return Level . ALL ; } }
Convert a numerical representation of logging level to the logging level .
131
13
33,827
@ SuppressWarnings ( { "checkstyle:magicnumber" , "checkstyle:returncount" , "checkstyle:npathcomplexity" } ) public static int toInt ( Level level ) { if ( level == Level . OFF ) { return 0 ; } if ( level == Level . SEVERE ) { return 1 ; } if ( level == Level . WARNING ) { return 2 ; } if ( level == Level . INFO ) { return 3 ; } if ( level == Level . CONFIG ) { return 4 ; } if ( level == Level . FINE ) { return 4 ; } if ( level == Level . FINER ) { return 5 ; } if ( level == Level . FINEST ) { return 6 ; } if ( level == Level . ALL ) { return 7 ; } return 3 ; }
Convert a logging level to its numerical equivalent .
171
10
33,828
public static void startServices ( IServiceManager manager ) { final List < Service > otherServices = new ArrayList <> ( ) ; final List < Service > infraServices = new ArrayList <> ( ) ; final LinkedList < DependencyNode > serviceQueue = new LinkedList <> ( ) ; final Accessors accessors = new StartingPhaseAccessors ( ) ; // Build the dependency graph buildDependencyGraph ( manager , serviceQueue , infraServices , otherServices , accessors ) ; // Launch the services runDependencyGraph ( serviceQueue , infraServices , otherServices , accessors ) ; manager . awaitHealthy ( ) ; }
Start the services associated to the given service manager .
141
10
33,829
public static void stopServices ( IServiceManager manager ) { final List < Service > otherServices = new ArrayList <> ( ) ; final List < Service > infraServices = new ArrayList <> ( ) ; final LinkedList < DependencyNode > serviceQueue = new LinkedList <> ( ) ; final Accessors accessors = new StoppingPhaseAccessors ( ) ; // Build the dependency graph buildInvertedDependencyGraph ( manager , serviceQueue , infraServices , otherServices , accessors ) ; // Launch the services runDependencyGraph ( serviceQueue , infraServices , otherServices , accessors ) ; manager . awaitStopped ( ) ; }
Stop the services associated to the given service manager .
144
10
33,830
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) private static void runDependencyGraph ( Queue < DependencyNode > roots , List < Service > infraServices , List < Service > freeServices , Accessors accessors ) { final boolean async = accessors . isAsyncStateWaitingEnabled ( ) ; final Set < Class < ? extends Service > > executed = new TreeSet <> ( Comparators . CLASS_COMPARATOR ) ; accessors . runInfrastructureServicesBefore ( infraServices ) ; accessors . runFreeServicesBefore ( freeServices ) ; while ( ! roots . isEmpty ( ) ) { final DependencyNode node = roots . remove ( ) ; assert node != null && node . getType ( ) != null ; if ( ! executed . contains ( node . getType ( ) ) ) { executed . add ( node . getType ( ) ) ; roots . addAll ( node . getNextServices ( ) ) ; roots . addAll ( node . getNextWeakServices ( ) ) ; assert node . getService ( ) != null ; if ( async ) { for ( final WeakReference < DependencyNode > asyncService : node . getAsyncStateServices ( ) ) { final AsyncStateService as = ( AsyncStateService ) ( asyncService . get ( ) . getService ( ) ) ; assert as != null ; while ( ! as . isReadyForOtherServices ( ) ) { Thread . yield ( ) ; } } } accessors . run ( node . getService ( ) ) ; } } accessors . runFreeServicesAfter ( freeServices ) ; accessors . runInfrastructureServicesAfter ( infraServices ) ; }
Run the dependency graph for the services .
355
8
33,831
public static SynchronizedIterable < AgentContext > getContextsOf ( Agent agent ) throws Exception { final ExternalContextAccess skill = SREutils . getInternalSkill ( agent , ExternalContextAccess . class ) ; assert skill != null ; return skill . getAllContexts ( ) ; }
Replies the contexts in which the agent is located .
61
11
33,832
public static AgentContext getContextIn ( Agent agent ) throws Exception { final InnerContextAccess skill = SREutils . getInternalSkill ( agent , InnerContextAccess . class ) ; if ( skill instanceof InnerContextSkill ) { final InnerContextSkill janusSkill = ( InnerContextSkill ) skill ; if ( janusSkill . hasInnerContext ( ) ) { return janusSkill . getInnerContext ( ) ; } return null ; } if ( skill == null ) { return null ; } return skill . getInnerContext ( ) ; }
Replies the inner context of the agent if it was created .
115
13
33,833
@ SuppressWarnings ( "static-method" ) protected void _toJavaStatement ( SarlBreakExpression breakExpression , ITreeAppendable appendable , boolean isReferenced ) { appendable . newLine ( ) . append ( "break;" ) ; //$NON-NLS-1$ }
Generate the Java code related to the preparation statements for the break keyword .
70
15
33,834
@ SuppressWarnings ( "static-method" ) protected Map < XVariableDeclaration , XFeatureCall > getReferencedLocalVariable ( XExpression expression , boolean onlyWritable ) { final Map < XVariableDeclaration , XFeatureCall > localVariables = new TreeMap <> ( ( k1 , k2 ) -> { return k1 . getIdentifier ( ) . compareTo ( k2 . getIdentifier ( ) ) ; } ) ; for ( final XFeatureCall featureCall : EcoreUtil2 . getAllContentsOfType ( expression , XFeatureCall . class ) ) { if ( featureCall . getFeature ( ) instanceof XVariableDeclaration ) { final XVariableDeclaration localVariable = ( XVariableDeclaration ) featureCall . getFeature ( ) ; if ( ( ! onlyWritable || localVariable . isWriteable ( ) ) && ! localVariables . containsKey ( localVariable ) ) { localVariables . put ( localVariable , featureCall ) ; } } } return localVariables ; }
Replies all the variables that are referenced into the given expression .
223
13
33,835
protected boolean isAtLeastJava8 ( EObject context ) { return this . generatorConfigProvider . get ( EcoreUtil . getRootContainer ( context ) ) . getJavaSourceVersion ( ) . isAtLeast ( JavaVersion . JAVA8 ) ; }
Replies if the generation is for Java version 8 at least .
58
13
33,836
protected void _toJavaExpression ( SarlAssertExpression assertExpression , ITreeAppendable appendable ) { if ( ! assertExpression . isIsStatic ( ) && isAtLeastJava8 ( assertExpression ) ) { appendable . append ( "/* error - couldn't compile nested assert */" ) ; //$NON-NLS-1$ } }
Generate the Java code related to the expression for the assert keyword .
83
14
33,837
protected void jvmOperationCallToJavaExpression ( final XExpression sourceObject , final JvmOperation operation , XExpression receiver , List < XExpression > arguments , ITreeAppendable appendable ) { String name = null ; assert operation != null ; if ( appendable . hasName ( operation ) ) { name = appendable . getName ( operation ) ; } else { name = this . featureNameProvider . getSimpleName ( operation ) ; } if ( name == null ) { name = "/* name is null */" ; //$NON-NLS-1$ } if ( operation . isStatic ( ) ) { final JvmDeclaredType operationContainer = operation . getDeclaringType ( ) ; final JvmIdentifiableElement container = getLogicalContainerProvider ( ) . getNearestLogicalContainer ( sourceObject ) ; final JvmType containerType = EcoreUtil2 . getContainerOfType ( container , JvmType . class ) ; final LightweightTypeReference reference = newTypeReferenceOwner ( sourceObject ) . toLightweightTypeReference ( operationContainer ) ; if ( ! reference . isAssignableFrom ( containerType ) ) { appendable . append ( operationContainer ) ; appendable . append ( "." ) ; //$NON-NLS-1$ } } else if ( receiver != null ) { internalToJavaExpression ( receiver , appendable ) ; appendable . append ( "." ) ; //$NON-NLS-1$ } else { appendable . append ( "this." ) ; //$NON-NLS-1$ } appendable . trace ( sourceObject , XbasePackage . Literals . XABSTRACT_FEATURE_CALL__FEATURE , 0 ) . append ( name ) ; appendable . append ( "(" ) ; //$NON-NLS-1$ if ( arguments != null && ! arguments . isEmpty ( ) ) { appendArguments ( arguments , appendable , true ) ; } appendable . append ( ")" ) ; //$NON-NLS-1$ }
Generate the Java expression for the given JVM operation .
447
12
33,838
@ SuppressWarnings ( "static-method" ) protected boolean canBeNotStaticAnonymousClass ( XClosure closure , LightweightTypeReference typeRef , JvmOperation operation ) { return ! typeRef . isSubtypeOf ( Serializable . class ) ; }
Replies if the given closure could be represented by an not static anonymous class .
56
16
33,839
Collection < V > wrapValues ( K key , Collection < V > values ) { final Object backEnd = DataViewDelegate . undelegate ( values ) ; if ( backEnd instanceof List < ? > ) { return new SingleKeyValueListView ( key , ( List < V > ) values ) ; } if ( backEnd instanceof Set < ? > ) { return new SingleKeyValueSetView ( key , ( Set < V > ) values ) ; } throw new IllegalStateException ( "Unsupported type of the backend multimap: " + values . getClass ( ) ) ; //$NON-NLS-1$ }
Wrap the given values into a dedicated view .
134
10
33,840
@ SuppressWarnings ( { "unchecked" , "checkstyle:illegaltype" } ) Collection < V > copyValues ( Collection < V > values ) { final Object backEnd = DataViewDelegate . undelegate ( values ) ; if ( backEnd instanceof List < ? > ) { return Lists . newArrayList ( values ) ; } if ( backEnd instanceof TreeSet < ? > ) { TreeSet < V > c = ( TreeSet < V > ) backEnd ; c = Sets . newTreeSet ( c . comparator ( ) ) ; c . addAll ( values ) ; return c ; } if ( backEnd instanceof LinkedHashSet < ? > ) { return Sets . newLinkedHashSet ( values ) ; } if ( backEnd instanceof Set < ? > ) { return Sets . newHashSet ( values ) ; } throw new IllegalStateException ( "Unsupported type of the backend multimap: " + values . getClass ( ) ) ; //$NON-NLS-1$ }
Copy the given values .
221
5
33,841
protected void generatePlistFile ( CombinedTmAppendable it ) { final String language = getLanguageSimpleName ( ) . toLowerCase ( ) ; final String newBasename = getBasename ( MessageFormat . format ( BASENAME_PATTERN_NEW , language ) ) ; writeFile ( newBasename , it . getNewSyntaxContent ( ) ) ; }
Generate the Plist file .
81
7
33,842
protected void generateLicenseFile ( ) { final CharSequence licenseText = getLicenseText ( ) ; if ( licenseText != null ) { final String text = licenseText . toString ( ) ; if ( ! Strings . isEmpty ( text ) ) { writeFile ( LICENSE_FILE , text . getBytes ( ) ) ; } } }
Generate the LICENSE file .
73
7
33,843
protected CharSequence getLicenseText ( ) { final URL url = getClass ( ) . getResource ( LICENSE_FILE ) ; if ( url != null ) { final File filename = new File ( url . getPath ( ) ) ; try { return Files . toString ( filename , Charset . defaultCharset ( ) ) ; } catch ( IOException exception ) { throw new RuntimeException ( exception ) ; } } return null ; }
Replies the text of the license to write to the generated output .
94
14
33,844
protected List < ? > createPatterns ( Set < String > literals , Set < String > expressionKeywords , Set < String > modifiers , Set < String > primitiveTypes , Set < String > punctuation , Set < String > ignored , Set < String > specialKeywords , Set < String > typeDeclarationKeywords ) { final List < Map < String , ? > > patterns = new ArrayList <> ( ) ; patterns . addAll ( generateComments ( ) ) ; patterns . addAll ( generateStrings ( ) ) ; patterns . addAll ( generateNumericConstants ( ) ) ; patterns . addAll ( generateAnnotations ( ) ) ; patterns . addAll ( generateLiterals ( literals ) ) ; patterns . addAll ( generatePrimitiveTypes ( primitiveTypes ) ) ; patterns . addAll ( generateSpecialKeywords ( specialKeywords ) ) ; patterns . addAll ( generateModifiers ( modifiers ) ) ; patterns . addAll ( generateTypeDeclarations ( typeDeclarationKeywords ) ) ; patterns . addAll ( generateStandardKeywords ( expressionKeywords ) ) ; patterns . addAll ( generatePunctuation ( punctuation ) ) ; return patterns ; }
Create the patterns .
249
4
33,845
protected List < Map < String , ? > > generateAnnotations ( ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; list . add ( pattern ( it -> { it . matches ( "\\@[_a-zA-Z$][_0-9a-zA-Z$]*" ) ; //$NON-NLS-1$ it . style ( ANNOTATION_STYLE ) ; it . comment ( "Annotations" ) ; //$NON-NLS-1$ } ) ) ; return list ; }
Generate the rules for the annotations .
128
8
33,846
protected List < Map < String , ? > > generateComments ( ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; // Block comment list . add ( pattern ( it -> { it . delimiters ( "(/\\*+)" , "(\\*/)" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . style ( BLOCK_COMMENT_STYLE ) ; it . beginStyle ( BLOCK_COMMENT_DELIMITER_STYLE ) ; it . endStyle ( BLOCK_COMMENT_DELIMITER_STYLE ) ; it . pattern ( it2 -> { it2 . matches ( "^\\s*(\\*)(?!/)" ) ; //$NON-NLS-1$ it2 . style ( BLOCK_COMMENT_DELIMITER_STYLE ) ; } ) ; it . comment ( "Multiline comments" ) ; //$NON-NLS-1$ } ) ) ; // Line comment list . add ( pattern ( it -> { it . matches ( "\\s*(//)(.*)$" ) ; //$NON-NLS-1$ it . substyle ( 1 , LINE_COMMENT_DELIMITER_STYLE ) ; it . substyle ( 2 , LINE_COMMENT_STYLE ) ; it . comment ( "Single-line comment" ) ; //$NON-NLS-1$ } ) ) ; return list ; }
Generate the rules for the comments .
342
8
33,847
protected List < Map < String , ? > > generateStrings ( ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; // Double quote list . add ( pattern ( it -> { it . delimiters ( "\"" , "\"" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . style ( DOUBLE_QUOTE_STRING_STYLE ) ; it . beginStyle ( STRING_BEGIN_STYLE ) ; it . endStyle ( STRING_END_STYLE ) ; it . pattern ( it2 -> { it2 . matches ( "\\\\." ) ; //$NON-NLS-1$ it2 . style ( ESCAPE_CHARACTER_STYLE ) ; } ) ; it . comment ( "Double quoted strings of characters" ) ; //$NON-NLS-1$ } ) ) ; // Single quote list . add ( pattern ( it -> { it . delimiters ( "'" , "'" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . style ( SINGLE_QUOTE_STRING_STYLE ) ; it . beginStyle ( STRING_BEGIN_STYLE ) ; it . endStyle ( STRING_END_STYLE ) ; it . pattern ( it2 -> { it2 . matches ( "\\\\." ) ; //$NON-NLS-1$ it2 . style ( ESCAPE_CHARACTER_STYLE ) ; } ) ; it . comment ( "Single quoted strings of characters" ) ; //$NON-NLS-1$ } ) ) ; return list ; }
Generates the rules for the strings of characters .
382
10
33,848
protected List < Map < String , ? > > generateNumericConstants ( ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; list . add ( pattern ( it -> { it . matches ( "(?:" //$NON-NLS-1$ + "[0-9][0-9]*\\.[0-9]+([eE][0-9]+)?[fFdD]?" //$NON-NLS-1$ + ")|(?:" //$NON-NLS-1$ + "0[xX][0-9a-fA-F]+" //$NON-NLS-1$ + ")|(?:" //$NON-NLS-1$ + "[0-9]+[lL]?" //$NON-NLS-1$ + ")" ) ; //$NON-NLS-1$ it . style ( NUMBER_STYLE ) ; it . comment ( "Numbers" ) ; //$NON-NLS-1$ } ) ) ; return list ; }
Generate the rules for the numeric constants .
242
9
33,849
protected List < Map < String , ? > > generatePrimitiveTypes ( Set < String > primitiveTypes ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; if ( ! primitiveTypes . isEmpty ( ) ) { list . add ( pattern ( it -> { it . matches ( keywordRegex ( primitiveTypes ) + "(?:\\s*\\[\\s*\\])*" ) ; //$NON-NLS-1$ it . style ( PRIMITIVE_TYPE_STYLE ) ; it . comment ( "Primitive types" ) ; //$NON-NLS-1$ } ) ) ; } return list ; }
Generate the rules for the primitive types .
148
9
33,850
protected List < Map < String , ? > > generateLiterals ( Set < String > literals ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; if ( ! literals . isEmpty ( ) ) { list . add ( pattern ( it -> { it . matches ( keywordRegex ( literals ) ) ; it . style ( LITERAL_STYLE ) ; it . comment ( "SARL Literals and Constants" ) ; //$NON-NLS-1$ } ) ) ; } return list ; }
Generate the rules for the literals .
124
9
33,851
protected List < Map < String , ? > > generatePunctuation ( Set < String > punctuation ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; if ( ! punctuation . isEmpty ( ) ) { list . add ( pattern ( it -> { it . matches ( orRegex ( punctuation ) ) ; it . style ( PUNCTUATION_STYLE ) ; it . comment ( "Operators and Punctuations" ) ; //$NON-NLS-1$ } ) ) ; } return list ; }
Generate the rules for the punctuation symbols .
125
10
33,852
protected List < Map < String , ? > > generateModifiers ( Set < String > modifiers ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; if ( ! modifiers . isEmpty ( ) ) { list . add ( pattern ( it -> { it . matches ( keywordRegex ( modifiers ) ) ; it . style ( MODIFIER_STYLE ) ; it . comment ( "Modifiers" ) ; //$NON-NLS-1$ } ) ) ; } return list ; }
Generate the rules for the modifier keywords .
115
9
33,853
protected List < Map < String , ? > > generateSpecialKeywords ( Set < String > keywords ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; if ( ! keywords . isEmpty ( ) ) { list . add ( pattern ( it -> { it . matches ( keywordRegex ( keywords ) ) ; it . style ( SPECIAL_KEYWORD_STYLE ) ; it . comment ( "Special Keywords" ) ; //$NON-NLS-1$ } ) ) ; } return list ; }
Generate the rules for the special keywords .
119
9
33,854
protected List < Map < String , ? > > generateStandardKeywords ( Set < String > keywords ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; if ( ! keywords . isEmpty ( ) ) { list . add ( pattern ( it -> { it . matches ( keywordRegex ( keywords ) ) ; it . style ( KEYWORD_STYLE ) ; it . comment ( "Standard Keywords" ) ; //$NON-NLS-1$ } ) ) ; } return list ; }
Generate the rules for the standard keywords .
117
9
33,855
protected List < Map < String , ? > > generateTypeDeclarations ( Set < String > declarators ) { final List < Map < String , ? > > list = new ArrayList <> ( ) ; if ( ! declarators . isEmpty ( ) ) { list . add ( pattern ( it -> { it . matches ( keywordRegex ( declarators ) ) ; it . style ( TYPE_DECLARATION_STYLE ) ; it . comment ( "Type Declarations" ) ; //$NON-NLS-1$ } ) ) ; } return list ; }
Generate the rules for the type declaration keywords .
126
10
33,856
protected Map < String , ? > pattern ( Procedure1 < ? super Pattern > proc ) { final Pattern patternDefinition = new Pattern ( ) ; proc . apply ( patternDefinition ) ; return patternDefinition . getDefinition ( ) ; }
Build a pattern definition .
47
5
33,857
@ SuppressWarnings ( "static-method" ) @ Provides @ Singleton public ExtraLanguageListCommand provideExtraLanguageListCommand ( BootLogger bootLogger , Provider < IExtraLanguageContributions > contributions ) { return new ExtraLanguageListCommand ( bootLogger , contributions ) ; }
Provide the command for displaying the available extra - language generators .
62
13
33,858
protected void _format ( SarlEvent event , IFormattableDocument document ) { formatAnnotations ( event , document , XbaseFormatterPreferenceKeys . newLineAfterClassAnnotations ) ; formatModifiers ( event , document ) ; final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( event ) ; document . append ( regionFor . keyword ( this . keywords . getEventKeyword ( ) ) , ONE_SPACE ) ; document . surround ( regionFor . keyword ( this . keywords . getExtendsKeyword ( ) ) , ONE_SPACE ) ; document . format ( event . getExtends ( ) ) ; formatBody ( event , document ) ; }
Format the given SARL event .
152
7
33,859
protected void _format ( SarlCapacity capacity , IFormattableDocument document ) { formatAnnotations ( capacity , document , XbaseFormatterPreferenceKeys . newLineAfterClassAnnotations ) ; formatModifiers ( capacity , document ) ; final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( capacity ) ; document . append ( regionFor . keyword ( this . keywords . getCapacityKeyword ( ) ) , ONE_SPACE ) ; document . surround ( regionFor . keyword ( this . keywords . getExtendsKeyword ( ) ) , ONE_SPACE ) ; formatCommaSeparatedList ( capacity . getExtends ( ) , document ) ; formatBody ( capacity , document ) ; }
Format the given SARL capacity .
160
7
33,860
protected void _format ( SarlAgent agent , IFormattableDocument document ) { formatAnnotations ( agent , document , XbaseFormatterPreferenceKeys . newLineAfterClassAnnotations ) ; formatModifiers ( agent , document ) ; final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( agent ) ; document . append ( regionFor . keyword ( this . keywords . getAgentKeyword ( ) ) , ONE_SPACE ) ; document . surround ( regionFor . keyword ( this . keywords . getExtendsKeyword ( ) ) , ONE_SPACE ) ; document . format ( agent . getExtends ( ) ) ; formatBody ( agent , document ) ; }
Format the given SARL agent .
152
7
33,861
protected void _format ( SarlBehavior behavior , IFormattableDocument document ) { formatAnnotations ( behavior , document , XbaseFormatterPreferenceKeys . newLineAfterClassAnnotations ) ; formatModifiers ( behavior , document ) ; final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( behavior ) ; document . append ( regionFor . keyword ( this . keywords . getBehaviorKeyword ( ) ) , ONE_SPACE ) ; document . surround ( regionFor . keyword ( this . keywords . getExtendsKeyword ( ) ) , ONE_SPACE ) ; document . format ( behavior . getExtends ( ) ) ; formatBody ( behavior , document ) ; }
Format the given SARL behavior .
154
7
33,862
protected void _format ( SarlSkill skill , IFormattableDocument document ) { formatAnnotations ( skill , document , XbaseFormatterPreferenceKeys . newLineAfterClassAnnotations ) ; formatModifiers ( skill , document ) ; final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( skill ) ; document . append ( regionFor . keyword ( this . keywords . getSkillKeyword ( ) ) , ONE_SPACE ) ; document . surround ( regionFor . keyword ( this . keywords . getExtendsKeyword ( ) ) , ONE_SPACE ) ; document . format ( skill . getExtends ( ) ) ; document . surround ( regionFor . keyword ( this . keywords . getImplementsKeyword ( ) ) , ONE_SPACE ) ; formatCommaSeparatedList ( skill . getImplements ( ) , document ) ; formatBody ( skill , document ) ; }
Format the given SARL skill .
201
7
33,863
protected void _format ( SarlBehaviorUnit behaviorUnit , IFormattableDocument document ) { formatAnnotations ( behaviorUnit , document , XbaseFormatterPreferenceKeys . newLineAfterMethodAnnotations ) ; final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( behaviorUnit ) ; document . append ( regionFor . keyword ( this . keywords . getOnKeyword ( ) ) , ONE_SPACE ) ; if ( behaviorUnit . getGuard ( ) != null ) { ISemanticRegion keyword = this . textRegionExtensions . immediatelyPreceding ( behaviorUnit . getGuard ( ) ) . keyword ( this . keywords . getLeftSquareBracketKeyword ( ) ) ; document . prepend ( keyword , ONE_SPACE ) ; document . append ( keyword , NO_SPACE ) ; keyword = this . textRegionExtensions . immediatelyFollowing ( behaviorUnit . getGuard ( ) ) . keyword ( this . keywords . getRightSquareBracketKeyword ( ) ) ; document . prepend ( keyword , NO_SPACE ) ; } document . format ( behaviorUnit . getName ( ) ) ; document . format ( behaviorUnit . getGuard ( ) ) ; final XExpression expression = behaviorUnit . getExpression ( ) ; if ( expression != null ) { final ISemanticRegionFinder finder = this . textRegionExtensions . regionFor ( expression ) ; final ISemanticRegion brace = finder . keyword ( this . keywords . getLeftCurlyBracketKeyword ( ) ) ; document . prepend ( brace , XbaseFormatterPreferenceKeys . bracesInNewLine ) ; document . format ( expression ) ; } }
Format a behavior unit .
361
5
33,864
protected void _format ( SarlCapacityUses capacityUses , IFormattableDocument document ) { final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( capacityUses ) ; document . append ( regionFor . keyword ( this . keywords . getUsesKeyword ( ) ) , ONE_SPACE ) ; formatCommaSeparatedList ( capacityUses . getCapacities ( ) , document ) ; document . prepend ( regionFor . keyword ( this . keywords . getSemicolonKeyword ( ) ) , NO_SPACE ) ; }
Format a capacity use .
130
5
33,865
protected void _format ( SarlRequiredCapacity requiredCapacity , IFormattableDocument document ) { final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( requiredCapacity ) ; document . append ( regionFor . keyword ( this . keywords . getRequiresKeyword ( ) ) , ONE_SPACE ) ; formatCommaSeparatedList ( requiredCapacity . getCapacities ( ) , document ) ; document . prepend ( regionFor . keyword ( this . keywords . getSemicolonKeyword ( ) ) , NO_SPACE ) ; }
Format a required capacity .
128
5
33,866
protected void formatCommaSeparatedList ( Collection < ? extends EObject > elements , IFormattableDocument document ) { for ( final EObject element : elements ) { document . format ( element ) ; final ISemanticRegionFinder immediatelyFollowing = this . textRegionExtensions . immediatelyFollowing ( element ) ; final ISemanticRegion keyword = immediatelyFollowing . keyword ( this . keywords . getCommaKeyword ( ) ) ; document . prepend ( keyword , NO_SPACE ) ; document . append ( keyword , ONE_SPACE ) ; } }
Format a list of comma separated elements .
119
8
33,867
public StyledString styledParameters ( JvmIdentifiableElement element ) { final StyledString str = new StyledString ( ) ; if ( element instanceof JvmExecutable ) { final JvmExecutable executable = ( JvmExecutable ) element ; str . append ( this . keywords . getLeftParenthesisKeyword ( ) ) ; str . append ( parametersToStyledString ( executable . getParameters ( ) , executable . isVarArgs ( ) , false ) ) ; str . append ( this . keywords . getRightParenthesisKeyword ( ) ) ; } return str ; }
Replies the styled parameters .
124
6
33,868
protected StyledString parametersToStyledString ( Iterable < ? extends JvmFormalParameter > elements , boolean isVarArgs , boolean includeName ) { return getParameterStyledString ( elements , isVarArgs , includeName , this . keywords , this . annotationFinder , this ) ; }
Replies the styled string representation of the parameters .
63
10
33,869
public static String getParameterString ( Iterable < ? extends JvmFormalParameter > elements , boolean isVarArgs , boolean includeName , SARLGrammarKeywordAccess keywords , AnnotationLookup annotationFinder , UIStrings utils ) { final StringBuilder result = new StringBuilder ( ) ; boolean needsSeparator = false ; final Iterator < ? extends JvmFormalParameter > iterator = elements . iterator ( ) ; while ( iterator . hasNext ( ) ) { final JvmFormalParameter parameter = iterator . next ( ) ; if ( needsSeparator ) { result . append ( keywords . getCommaKeyword ( ) ) . append ( " " ) ; //$NON-NLS-1$ } needsSeparator = true ; final boolean isDefaultValued = annotationFinder . findAnnotation ( parameter , DefaultValue . class ) != null ; if ( isDefaultValued ) { result . append ( keywords . getLeftSquareBracketKeyword ( ) ) ; } if ( includeName ) { result . append ( parameter . getName ( ) ) . append ( " " ) ; //$NON-NLS-1$ result . append ( keywords . getColonKeyword ( ) ) . append ( " " ) ; //$NON-NLS-1$ } JvmTypeReference typeRef = parameter . getParameterType ( ) ; if ( isVarArgs && ! iterator . hasNext ( ) && typeRef instanceof JvmGenericArrayTypeReference ) { typeRef = ( ( JvmGenericArrayTypeReference ) typeRef ) . getComponentType ( ) ; result . append ( utils . referenceToString ( typeRef , NULL_TYPE ) ) ; result . append ( keywords . getWildcardAsteriskKeyword ( ) ) ; } else { result . append ( utils . referenceToString ( typeRef , NULL_TYPE ) ) ; } if ( isDefaultValued ) { result . append ( keywords . getRightSquareBracketKeyword ( ) ) ; } } return result . toString ( ) ; }
Format the parameters .
441
4
33,870
@ Inject public void setFileExtensions ( @ Named ( Constants . FILE_EXTENSIONS ) String fileExtensions ) { this . fileExtensions . clear ( ) ; this . fileExtensions . addAll ( Arrays . asList ( fileExtensions . split ( "[,;: ]+" ) ) ) ; //$NON-NLS-1$ }
Set the file extensions .
81
5
33,871
@ SuppressWarnings ( "checkstyle:all" ) private ImageDescriptor getPackageFragmentIcon ( IPackageFragment fragment ) { boolean containsJavaElements = false ; try { containsJavaElements = fragment . hasChildren ( ) ; } catch ( JavaModelException e ) { // assuming no children; } try { if ( ! containsJavaElements ) { final Object [ ] resources = fragment . getNonJavaResources ( ) ; if ( resources . length > 0 ) { for ( final Object child : resources ) { if ( isSarlResource ( child ) ) { return JavaPluginImages . DESC_OBJS_PACKAGE ; } } return JavaPluginImages . DESC_OBJS_EMPTY_PACKAGE_RESOURCES ; } } } catch ( JavaModelException exception ) { // } if ( ! containsJavaElements ) { return JavaPluginImages . DESC_OBJS_EMPTY_PACKAGE ; } return JavaPluginImages . DESC_OBJS_PACKAGE ; }
Replies the image description of the package fragment .
222
10
33,872
protected boolean isSarlResource ( Object resource ) { if ( resource instanceof IFile ) { final IFile file = ( IFile ) resource ; return getFileExtensions ( ) . contains ( file . getFileExtension ( ) ) ; } return false ; }
Replies if the given resource is a SARL resource .
56
12
33,873
public void setJarFile ( IPath jarFile ) { if ( ! Objects . equal ( jarFile , this . jarFile ) ) { final PropertyChangeEvent event = new PropertyChangeEvent ( this , ISREInstallChangedListener . PROPERTY_JAR_FILE , this . jarFile , jarFile ) ; this . jarFile = jarFile ; setDirty ( true ) ; if ( getNotify ( ) ) { SARLRuntime . fireSREChanged ( event ) ; } } }
Change the path to the JAR file that is supporting this SRE installation .
105
16
33,874
private static IPath parsePath ( String path , IPath defaultPath , IPath rootPath ) { if ( ! Strings . isNullOrEmpty ( path ) ) { try { final IPath pathObject = Path . fromPortableString ( path ) ; if ( pathObject != null ) { if ( rootPath != null && ! pathObject . isAbsolute ( ) ) { return rootPath . append ( pathObject ) ; } return pathObject ; } } catch ( Throwable exception ) { // } } return defaultPath ; }
Path the given string for extracting a path .
112
9
33,875
public static List < Pair < String , String > > loadPropertyFile ( String filename , Plugin bundledPlugin , Class < ? > readerClass , Function1 < IOException , IStatus > statusBuilder ) { final URL url ; if ( bundledPlugin != null ) { url = FileLocator . find ( bundledPlugin . getBundle ( ) , Path . fromPortableString ( filename ) , null ) ; } else { url = readerClass . getClassLoader ( ) . getResource ( filename ) ; } if ( url == null ) { return Lists . newArrayList ( ) ; } final OrderedProperties properties = new OrderedProperties ( ) ; try ( InputStream is = url . openStream ( ) ) { properties . load ( is ) ; } catch ( IOException exception ) { if ( bundledPlugin != null ) { bundledPlugin . getLog ( ) . log ( statusBuilder . apply ( exception ) ) ; } else { throw new RuntimeException ( exception ) ; } } return properties . getOrderedProperties ( ) ; }
Load a property file from the resources . This function is able to get the resource from an OSGi bundles if it is specified or from the application classpath .
218
32
33,876
protected XExpression getAssociatedExpression ( JvmMember object ) { final XExpression expr = getTypeBuilder ( ) . getExpression ( object ) ; if ( expr == null ) { // The member may be a automatically generated code with dynamic code-building strategies final Procedure1 < ? super ITreeAppendable > strategy = getTypeExtensions ( ) . getCompilationStrategy ( object ) ; if ( strategy != null ) { // } else { final StringConcatenationClient template = getTypeExtensions ( ) . getCompilationTemplate ( object ) ; if ( template != null ) { // } } } return expr ; }
Replies the expression associated to the given object . Usually the expression is inside the given object .
136
19
33,877
protected String toFilename ( QualifiedName name , String separator ) { final List < String > segments = name . getSegments ( ) ; if ( segments . isEmpty ( ) ) { return "" ; //$NON-NLS-1$ } final StringBuilder builder = new StringBuilder ( ) ; builder . append ( name . toString ( separator ) ) ; builder . append ( getFilenameExtension ( ) ) ; return builder . toString ( ) ; }
Replies the filename for the qualified name .
100
9
33,878
protected boolean writeFile ( QualifiedName name , ExtraLanguageAppendable appendable , IExtraLanguageGeneratorContext context ) { final ExtraLanguageAppendable fileAppendable = createAppendable ( null , context ) ; generateFileHeader ( name , fileAppendable , context ) ; final ImportManager importManager = appendable . getImportManager ( ) ; if ( importManager != null && ! importManager . getImports ( ) . isEmpty ( ) ) { for ( final String imported : importManager . getImports ( ) ) { final QualifiedName qn = getQualifiedNameConverter ( ) . toQualifiedName ( imported ) ; generateImportStatement ( qn , fileAppendable , context ) ; } fileAppendable . newLine ( ) ; } fileAppendable . append ( appendable . getContent ( ) ) ; final String content = fileAppendable . getContent ( ) ; if ( ! Strings . isEmpty ( content ) ) { final String fileName = toFilename ( name , FILENAME_SEPARATOR ) ; final String outputConfiguration = getOutputConfigurationName ( ) ; if ( Strings . isEmpty ( outputConfiguration ) ) { context . getFileSystemAccess ( ) . generateFile ( fileName , content ) ; } else { context . getFileSystemAccess ( ) . generateFile ( fileName , outputConfiguration , content ) ; } return true ; } return false ; }
Write the given file .
306
5
33,879
protected IExtraLanguageGeneratorContext createGeneratorContext ( IFileSystemAccess2 fsa , IGeneratorContext context , Resource resource ) { if ( context instanceof IExtraLanguageGeneratorContext ) { return ( IExtraLanguageGeneratorContext ) context ; } return new ExtraLanguageGeneratorContext ( context , fsa , this , resource , getPreferenceID ( ) ) ; }
Create the generator context for this generator .
81
8
33,880
protected void _generate ( SarlScript script , IExtraLanguageGeneratorContext context ) { if ( script != null ) { for ( final XtendTypeDeclaration content : script . getXtendTypes ( ) ) { if ( context . getCancelIndicator ( ) . isCanceled ( ) ) { return ; } try { generate ( content , context ) ; } finally { context . clearData ( ) ; } } } }
Generate the given script .
95
6
33,881
protected static List < JvmTypeReference > getSuperTypes ( JvmTypeReference extension , List < ? extends JvmTypeReference > implemented ) { final List < JvmTypeReference > list = new ArrayList <> ( ) ; if ( extension != null ) { list . add ( extension ) ; } if ( implemented != null ) { list . addAll ( implemented ) ; } return list ; }
Replies the merged list with the extended and implemented types .
84
12
33,882
protected LightweightTypeReference getExpectedType ( XExpression expr ) { final IResolvedTypes resolvedTypes = getTypeResolver ( ) . resolveTypes ( expr ) ; final LightweightTypeReference actualType = resolvedTypes . getActualType ( expr ) ; return actualType ; }
Compute the expected type of the given expression .
61
10
33,883
protected LightweightTypeReference getExpectedType ( XtendExecutable executable , JvmTypeReference declaredReturnType ) { if ( declaredReturnType == null ) { // Try to get any inferred return type. if ( executable instanceof XtendFunction ) { final XtendFunction function = ( XtendFunction ) executable ; final JvmOperation operation = this . sarlAssociations . getDirectlyInferredOperation ( function ) ; if ( operation != null ) { return Utils . toLightweightTypeReference ( operation . getReturnType ( ) , this . services ) ; } } if ( ! getEarlyExitComputer ( ) . isEarlyExit ( executable . getExpression ( ) ) ) { return getExpectedType ( executable . getExpression ( ) ) ; } return null ; } if ( ! "void" . equals ( declaredReturnType . getIdentifier ( ) ) ) { //$NON-NLS-1$ return Utils . toLightweightTypeReference ( declaredReturnType , this . services ) ; } return null ; }
Replies the expected type of the given executable .
225
10
33,884
private Object readResolve ( ) throws ObjectStreamException { Constructor < ? > compatible = null ; for ( final Constructor < ? > candidate : this . proxyType . getDeclaredConstructors ( ) ) { if ( candidate != null && isCompatible ( candidate ) ) { if ( compatible != null ) { throw new IllegalStateException ( ) ; } compatible = candidate ; } } if ( compatible != null ) { if ( ! compatible . isAccessible ( ) ) { compatible . setAccessible ( true ) ; } try { final Object [ ] arguments = new Object [ this . values . length + 1 ] ; System . arraycopy ( this . values , 0 , arguments , 1 , this . values . length ) ; return compatible . newInstance ( arguments ) ; } catch ( Exception exception ) { throw new WriteAbortedException ( exception . getLocalizedMessage ( ) , exception ) ; } } throw new InvalidClassException ( "compatible constructor not found" ) ; //$NON-NLS-1$ }
This function enables to deserialize an instance of this proxy .
214
13
33,885
@ SuppressWarnings ( "static-method" ) protected void addPreferences ( IMavenProjectFacade facade , SARLConfiguration config , IProgressMonitor monitor ) throws CoreException { final IPath outputPath = makeProjectRelativePath ( facade , config . getOutput ( ) ) ; // Set the SARL preferences SARLPreferences . setSpecificSARLConfigurationFor ( facade . getProject ( ) , outputPath ) ; }
Invoked to add the preferences dedicated to SARL JRE etc .
93
14
33,886
@ SuppressWarnings ( { "checkstyle:magicnumber" , "checkstyle:npathcomplexity" } ) protected void addSourceFolders ( IMavenProjectFacade facade , SARLConfiguration config , IClasspathDescriptor classpath , IProgressMonitor monitor ) throws CoreException { assertHasNature ( facade . getProject ( ) , SARLEclipseConfig . NATURE_ID ) ; assertHasNature ( facade . getProject ( ) , SARLEclipseConfig . XTEXT_NATURE_ID ) ; assertHasNature ( facade . getProject ( ) , JavaCore . NATURE_ID ) ; final String encoding = config . getEncoding ( ) ; final SubMonitor subMonitor = SubMonitor . convert ( monitor , 4 ) ; // // Add the source folders // // Input folder, e.g. "src/main/sarl" final IPath inputPath = makeFullPath ( facade , config . getInput ( ) ) ; final IFolder inputFolder = ensureFolderExists ( facade , inputPath , false , subMonitor ) ; if ( encoding != null && inputFolder != null && inputFolder . exists ( ) ) { inputFolder . setDefaultCharset ( encoding , monitor ) ; } IClasspathEntryDescriptor descriptor = classpath . addSourceEntry ( inputPath , facade . getOutputLocation ( ) , false ) ; descriptor . setPomDerived ( true ) ; subMonitor . worked ( 1 ) ; // Input folder, e.g. "src/main/generated-sources/sarl" final IPath outputPath = makeFullPath ( facade , config . getOutput ( ) ) ; final IFolder outputFolder = ensureFolderExists ( facade , outputPath , true , subMonitor ) ; if ( encoding != null && outputFolder != null && outputFolder . exists ( ) ) { outputFolder . setDefaultCharset ( encoding , monitor ) ; } descriptor = classpath . addSourceEntry ( outputPath , facade . getOutputLocation ( ) , false ) ; descriptor . setPomDerived ( true ) ; descriptor . setClasspathAttribute ( IClasspathAttribute . IGNORE_OPTIONAL_PROBLEMS , Boolean . TRUE . toString ( ) ) ; subMonitor . worked ( 1 ) ; // Test input folder, e.g. "src/test/sarl" final IPath testInputPath = makeFullPath ( facade , config . getTestInput ( ) ) ; final IFolder testInputFolder = ensureFolderExists ( facade , testInputPath , false , subMonitor ) ; if ( encoding != null && testInputFolder != null && testInputFolder . exists ( ) ) { testInputFolder . setDefaultCharset ( encoding , monitor ) ; } descriptor = classpath . addSourceEntry ( testInputPath , facade . getTestOutputLocation ( ) , true ) ; descriptor . setPomDerived ( true ) ; descriptor . setClasspathAttribute ( IClasspathAttribute . TEST , Boolean . TRUE . toString ( ) ) ; subMonitor . worked ( 1 ) ; // Test input folder, e.g. "src/test/generated-sources/sarl" final IPath testOutputPath = makeFullPath ( facade , config . getTestOutput ( ) ) ; final IFolder testOutputFolder = ensureFolderExists ( facade , testOutputPath , true , subMonitor ) ; if ( encoding != null && testOutputFolder != null && testOutputFolder . exists ( ) ) { testOutputFolder . setDefaultCharset ( encoding , monitor ) ; } descriptor = classpath . addSourceEntry ( testOutputPath , facade . getTestOutputLocation ( ) , true ) ; descriptor . setPomDerived ( true ) ; descriptor . setClasspathAttribute ( IClasspathAttribute . IGNORE_OPTIONAL_PROBLEMS , Boolean . TRUE . toString ( ) ) ; descriptor . setClasspathAttribute ( IClasspathAttribute . TEST , Boolean . TRUE . toString ( ) ) ; subMonitor . done ( ) ; }
Invoked to add the source folders .
856
8
33,887
protected < T > T getParameterValue ( MavenProject project , String parameter , Class < T > asType , MojoExecution mojoExecution , IProgressMonitor monitor , T defaultValue ) throws CoreException { T value = getParameterValue ( project , parameter , asType , mojoExecution , monitor ) ; if ( value == null ) { value = defaultValue ; } return value ; }
Replies the configuration value .
85
6
33,888
protected SARLConfiguration readConfiguration ( ProjectConfigurationRequest request , IProgressMonitor monitor ) throws CoreException { SARLConfiguration initConfig = null ; SARLConfiguration compileConfig = null ; final List < MojoExecution > mojos = getMojoExecutions ( request , monitor ) ; for ( final MojoExecution mojo : mojos ) { final String goal = mojo . getGoal ( ) ; switch ( goal ) { case "initialize" : //$NON-NLS-1$ initConfig = readInitializeConfiguration ( request , mojo , monitor ) ; break ; case "compile" : //$NON-NLS-1$ compileConfig = readCompileConfiguration ( request , mojo , monitor ) ; break ; default : } } if ( compileConfig != null && initConfig != null ) { compileConfig . setFrom ( initConfig ) ; } return compileConfig ; }
Read the SARL configuration .
193
6
33,889
private SARLConfiguration readInitializeConfiguration ( ProjectConfigurationRequest request , MojoExecution mojo , IProgressMonitor monitor ) throws CoreException { final SARLConfiguration config = new SARLConfiguration ( ) ; final MavenProject project = request . getMavenProject ( ) ; final File input = getParameterValue ( project , "input" , File . class , mojo , monitor , //$NON-NLS-1$ new File ( SARLConfig . FOLDER_SOURCE_SARL ) ) ; final File output = getParameterValue ( project , "output" , File . class , mojo , monitor , //$NON-NLS-1$ new File ( SARLConfig . FOLDER_SOURCE_GENERATED ) ) ; final File binOutput = getParameterValue ( project , "binOutput" , File . class , mojo , monitor , //$NON-NLS-1$ new File ( SARLConfig . FOLDER_BIN ) ) ; final File testInput = getParameterValue ( project , "testInput" , File . class , mojo , monitor , //$NON-NLS-1$ new File ( SARLConfig . FOLDER_TEST_SOURCE_SARL ) ) ; final File testOutput = getParameterValue ( project , "testOutput" , File . class , mojo , monitor , //$NON-NLS-1$ new File ( SARLConfig . FOLDER_TEST_SOURCE_GENERATED ) ) ; final File testBinOutput = getParameterValue ( project , "testBinOutput" , File . class , mojo , monitor , //$NON-NLS-1$ new File ( SARLConfig . FOLDER_TEST_BIN ) ) ; config . setInput ( input ) ; config . setOutput ( output ) ; config . setBinOutput ( binOutput ) ; config . setTestInput ( testInput ) ; config . setTestOutput ( testOutput ) ; config . setTestBinOutput ( testBinOutput ) ; return config ; }
Read the configuration for the Initialize mojo .
450
10
33,890
private SARLConfiguration readCompileConfiguration ( ProjectConfigurationRequest request , MojoExecution mojo , IProgressMonitor monitor ) throws CoreException { final SARLConfiguration config = new SARLConfiguration ( ) ; final MavenProject project = request . getMavenProject ( ) ; final File input = getParameterValue ( project , "input" , File . class , mojo , monitor ) ; //$NON-NLS-1$ final File output = getParameterValue ( project , "output" , File . class , mojo , monitor ) ; //$NON-NLS-1$ final File binOutput = getParameterValue ( project , "binOutput" , File . class , mojo , monitor ) ; //$NON-NLS-1$ final File testInput = getParameterValue ( project , "testInput" , File . class , mojo , monitor ) ; //$NON-NLS-1$ final File testOutput = getParameterValue ( project , "testOutput" , File . class , mojo , monitor ) ; //$NON-NLS-1$ final File testBinOutput = getParameterValue ( project , "testBinOutput" , File . class , mojo , monitor ) ; //$NON-NLS-1$ config . setInput ( input ) ; config . setOutput ( output ) ; config . setBinOutput ( binOutput ) ; config . setTestInput ( testInput ) ; config . setTestOutput ( testOutput ) ; config . setTestBinOutput ( testBinOutput ) ; final String inputCompliance = getParameterValue ( project , "source" , String . class , mojo , monitor ) ; //$NON-NLS-1$ final String outputCompliance = getParameterValue ( project , "target" , String . class , mojo , monitor ) ; //$NON-NLS-1$ config . setInputCompliance ( inputCompliance ) ; config . setOutputCompliance ( outputCompliance ) ; final String encoding = getParameterValue ( project , "encoding" , String . class , mojo , monitor ) ; //$NON-NLS-1$ config . setEncoding ( encoding ) ; return config ; }
Read the configuration for the Compilation mojo .
479
10
33,891
@ SuppressWarnings ( "static-method" ) protected void addSarlLibraries ( IClasspathDescriptor classpath ) { final IClasspathEntry entry = JavaCore . newContainerEntry ( SARLClasspathContainerInitializer . CONTAINER_ID ) ; classpath . addEntry ( entry ) ; }
Add the SARL libraries into the given classpath .
70
11
33,892
public boolean hasConversion ( String type ) { if ( ( isImplicitSarlTypes ( ) && type . startsWith ( IMPLICIT_PACKAGE ) ) || isImplicitJvmTypes ( ) ) { return true ; } if ( this . mapping == null ) { this . mapping = initMapping ( ) ; } return this . mapping . containsKey ( type ) ; }
Indicates if the given name has a mapping to the extra language .
83
14
33,893
public String convert ( String type ) { if ( isImplicitSarlTypes ( ) && type . startsWith ( IMPLICIT_PACKAGE ) ) { return type ; } if ( this . mapping == null ) { this . mapping = initMapping ( ) ; } final String map = this . mapping . get ( type ) ; if ( map != null ) { if ( map . isEmpty ( ) && ! isImplicitJvmTypes ( ) ) { return null ; } return map ; } if ( isImplicitJvmTypes ( ) ) { return type ; } return null ; }
Convert the given type to its equivalent in the extra language .
126
13
33,894
public boolean isSarlAgent ( LightweightTypeReference type ) { return ! type . isInterfaceType ( ) && ( getSarlElementEcoreType ( type ) == SarlPackage . SARL_AGENT || type . isSubtypeOf ( Agent . class ) ) ; }
Replies if the given JVM element is a SARL agent .
60
14
33,895
public boolean isSarlBehavior ( LightweightTypeReference type ) { return ! type . isInterfaceType ( ) && ( getSarlElementEcoreType ( type ) == SarlPackage . SARL_BEHAVIOR || type . isSubtypeOf ( Behavior . class ) ) ; }
Replies if the given JVM element is a SARL behavior .
63
14
33,896
public boolean isSarlCapacity ( LightweightTypeReference type ) { return type . isInterfaceType ( ) && ( getSarlElementEcoreType ( type ) == SarlPackage . SARL_CAPACITY || type . isSubtypeOf ( Capacity . class ) ) ; }
Replies if the given JVM element is a SARL capacity .
61
14
33,897
public boolean isSarlEvent ( LightweightTypeReference type ) { return ! type . isInterfaceType ( ) && ( getSarlElementEcoreType ( type ) == SarlPackage . SARL_EVENT || type . isSubtypeOf ( Event . class ) ) ; }
Replies if the given JVM element is a SARL event .
60
14
33,898
public boolean isSarlSkill ( LightweightTypeReference type ) { return ! type . isInterfaceType ( ) && ( getSarlElementEcoreType ( type ) == SarlPackage . SARL_SKILL || type . isSubtypeOf ( Skill . class ) ) ; }
Replies if the given JVM element is a SARL skill .
60
14
33,899
public ADDRESST unregisterParticipant ( ADDRESST address , EventListener entity ) { synchronized ( mutex ( ) ) { removeListener ( address ) ; this . participants . remove ( entity . getID ( ) , address ) ; } return address ; }
Remove a participant from this repository .
56
7