idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
33,900
public SynchronizedCollection < ADDRESST > getAddresses ( UUID participant ) { final Object mutex = mutex ( ) ; synchronized ( mutex ) { return Collections3 . synchronizedCollection ( this . participants . get ( participant ) , mutex ) ; } }
Replies all the addresses of the participant with the given identifier .
58
13
33,901
public boolean markAssignmentAccess ( EObject object ) { assert object != null ; if ( ! isAssigned ( object ) ) { return object . eAdapters ( ) . add ( ASSIGNMENT_MARKER ) ; } return false ; }
Mark the given object as an assigned object after its initialization .
53
12
33,902
@ SuppressWarnings ( "static-method" ) public boolean isAssigned ( final EObject object ) { assert object != null ; return object . eAdapters ( ) . contains ( ASSIGNMENT_MARKER ) ; }
Replies if the given object was marked as assigned within the current compilation unit .
51
16
33,903
protected ISourceAppender appendFiresClause ( ISourceAppender appendable ) { final List < LightweightTypeReference > types = getFires ( ) ; final Iterator < LightweightTypeReference > iterator = types . iterator ( ) ; if ( iterator . hasNext ( ) ) { appendable . append ( " " ) . append ( this . keywords . getFiresKeyword ( ) ) . append ( " " ) ; //$NON-NLS-1$ //$NON-NLS-2$ do { final LightweightTypeReference type = iterator . next ( ) ; appendable . append ( type ) ; if ( iterator . hasNext ( ) ) { appendable . append ( this . keywords . getCommaKeyword ( ) ) . append ( " " ) ; //$NON-NLS-1$ } } while ( iterator . hasNext ( ) ) ; } return appendable ; }
Append the fires clause .
197
6
33,904
public static IPreferenceStore getSARLPreferencesFor ( IProject project ) { if ( project != null ) { final Injector injector = LangActivator . getInstance ( ) . getInjector ( LangActivator . IO_SARL_LANG_SARL ) ; final IPreferenceStoreAccess preferenceStoreAccess = injector . getInstance ( IPreferenceStoreAccess . class ) ; return preferenceStoreAccess . getWritablePreferenceStore ( project ) ; } return null ; }
Replies the preference store for the given project .
107
10
33,905
public static Set < OutputConfiguration > getXtextConfigurationsFor ( IProject project ) { final Injector injector = LangActivator . getInstance ( ) . getInjector ( LangActivator . IO_SARL_LANG_SARL ) ; final EclipseOutputConfigurationProvider configurationProvider = injector . getInstance ( EclipseOutputConfigurationProvider . class ) ; return configurationProvider . getOutputConfigurations ( project ) ; }
Replies the Xtext output configurations related to the given project .
93
13
33,906
public static void setSystemSARLConfigurationFor ( IProject project ) { final IPreferenceStore preferenceStore = getSARLPreferencesFor ( project ) ; preferenceStore . setValue ( IS_PROJECT_SPECIFIC , false ) ; }
Configure the given project for using the system - wide configuration related to SARL .
52
17
33,907
public static void setSpecificSARLConfigurationFor ( IProject project , IPath outputPath ) { final IPreferenceStore preferenceStore = getSARLPreferencesFor ( project ) ; // Force to use a specific configuration for the SARL preferenceStore . setValue ( IS_PROJECT_SPECIFIC , true ) ; // Loop on the Xtext configurations embedded in the SARL compiler. String key ; for ( final OutputConfiguration projectConfiguration : getXtextConfigurationsFor ( project ) ) { // // OUTPUT PATH key = BuilderPreferenceAccess . getKey ( projectConfiguration , EclipseOutputConfigurationProvider . OUTPUT_DIRECTORY ) ; preferenceStore . setValue ( key , outputPath . toOSString ( ) ) ; // // CREATE THE OUTPUT DIRECTORY key = BuilderPreferenceAccess . getKey ( projectConfiguration , EclipseOutputConfigurationProvider . OUTPUT_CREATE_DIRECTORY ) ; preferenceStore . setValue ( key , true ) ; // // OVERWRITE THE EXISTING FILES key = BuilderPreferenceAccess . getKey ( projectConfiguration , EclipseOutputConfigurationProvider . OUTPUT_OVERRIDE ) ; preferenceStore . setValue ( key , true ) ; // // SET GENERATED FILES AS DERIVED key = BuilderPreferenceAccess . getKey ( projectConfiguration , EclipseOutputConfigurationProvider . OUTPUT_DERIVED ) ; preferenceStore . setValue ( key , true ) ; // // CLEAN THE GENERATED FILES key = BuilderPreferenceAccess . getKey ( projectConfiguration , EclipseOutputConfigurationProvider . OUTPUT_CLEANUP_DERIVED ) ; preferenceStore . setValue ( key , true ) ; // // CLEAN THE OUTPUT DIRECTORY key = BuilderPreferenceAccess . getKey ( projectConfiguration , EclipseOutputConfigurationProvider . OUTPUT_CLEAN_DIRECTORY ) ; preferenceStore . setValue ( key , true ) ; } }
Configure the given project for using a specific configuration related to SARL .
401
15
33,908
public static IPath getGlobalSARLOutputPath ( ) { final Injector injector = LangActivator . getInstance ( ) . getInjector ( LangActivator . IO_SARL_LANG_SARL ) ; final IOutputConfigurationProvider configurationProvider = injector . getInstance ( IOutputConfigurationProvider . class ) ; final OutputConfiguration config = Iterables . find ( configurationProvider . getOutputConfigurations ( ) , it -> Objects . equals ( it . getName ( ) , IFileSystemAccess . DEFAULT_OUTPUT ) ) ; if ( config != null ) { final String path = config . getOutputDirectory ( ) ; if ( ! Strings . isNullOrEmpty ( path ) ) { final IPath pathObject = Path . fromOSString ( path ) ; if ( pathObject != null ) { return pathObject ; } } } throw new IllegalStateException ( "No global preferences found for SARL." ) ; //$NON-NLS-1$ }
Replies the SARL output path in the global preferences .
214
12
33,909
protected String ensureMemberDeclarationKeyword ( CodeElementExtractor . ElementDescription memberDescription ) { final List < String > modifiers = getCodeBuilderConfig ( ) . getModifiers ( ) . get ( memberDescription . getName ( ) ) ; if ( modifiers != null && ! modifiers . isEmpty ( ) ) { return modifiers . get ( 0 ) ; } return null ; }
Replies a keyword for declaring a member .
79
9
33,910
protected BlockExpressionContextDescription getBlockExpressionContextDescription ( ) { for ( final CodeElementExtractor . ElementDescription containerDescription : getCodeElementExtractor ( ) . getTopElements ( getGrammar ( ) , getCodeBuilderConfig ( ) ) ) { if ( ! getCodeBuilderConfig ( ) . getNoActionBodyTypes ( ) . contains ( containerDescription . getName ( ) ) ) { final AbstractRule rule = getMemberRule ( containerDescription ) ; if ( rule != null ) { final BlockExpressionContextDescription description = getCodeElementExtractor ( ) . visitMemberElements ( containerDescription , rule , null , ( it , grammarContainer , memberContainer , classifier ) -> { final Assignment expressionAssignment = findAssignmentFromTerminalPattern ( memberContainer , getExpressionConfig ( ) . getBlockExpressionGrammarPattern ( ) ) ; final CodeElementExtractor . ElementDescription memberDescription = it . newElementDescription ( classifier . getName ( ) , memberContainer , classifier , XExpression . class ) ; final String keyword = ensureMemberDeclarationKeyword ( memberDescription ) ; if ( expressionAssignment != null && keyword != null ) { return new BlockExpressionContextDescription ( containerDescription , memberDescription , ensureContainerKeyword ( containerDescription . getGrammarComponent ( ) ) , keyword , expressionAssignment ) ; } return null ; } , null ) ; if ( description != null ) { return description ; } } } } return null ; }
Replies the description of the block expression context .
316
10
33,911
public < T > int getRegisteredEventListeners ( Class < T > type , Collection < ? super T > collection ) { synchronized ( this . behaviorGuardEvaluatorRegistry ) { return this . behaviorGuardEvaluatorRegistry . getRegisteredEventListeners ( type , collection ) ; } }
Extract the registered listeners with the given type .
65
10
33,912
private void executeBehaviorMethodsInParalellWithSynchroAtTheEnd ( Collection < Runnable > behaviorsMethodsToExecute ) throws InterruptedException , ExecutionException { final CountDownLatch doneSignal = new CountDownLatch ( behaviorsMethodsToExecute . size ( ) ) ; final OutputParameter < Throwable > runException = new OutputParameter <> ( ) ; for ( final Runnable runnable : behaviorsMethodsToExecute ) { this . executor . execute ( new JanusRunnable ( ) { @ Override public void run ( ) { try { runnable . run ( ) ; } catch ( EarlyExitException e ) { // Ignore this exception } catch ( RuntimeException e ) { // Catch exception for notifying the caller runException . set ( e ) ; // Do the standard behavior too -> logging throw e ; } catch ( Exception e ) { // Catch exception for notifying the caller runException . set ( e ) ; // Do the standard behavior too -> logging throw new RuntimeException ( e ) ; } finally { doneSignal . countDown ( ) ; } } } ) ; } // Wait for all Behaviors runnable to complete before continuing try { doneSignal . await ( ) ; } catch ( InterruptedException ex ) { // This exception occurs when one of the launched task kills the agent before all the // submitted tasks are finished. Keep in mind that killing an agent should kill the // launched tasks. // Example of code that is generating this issue: // // on Initialize { // in (100) [ // killMe // ] // } // // In this example, the killMe is launched before the Initialize code is finished; // and because the Initialize event is fired through the current function, it // causes the InterruptedException. } // Re-throw the run-time exception if ( runException . get ( ) != null ) { throw new ExecutionException ( runException . get ( ) ) ; } }
Execute every single Behaviors runnable a dedicated thread will created by the executor local to this class and be used to execute each runnable in parallel and this method waits until its future has been completed before leaving .
415
47
33,913
private void executeAsynchronouslyBehaviorMethods ( Collection < Runnable > behaviorsMethodsToExecute ) { for ( final Runnable runnable : behaviorsMethodsToExecute ) { this . executor . execute ( runnable ) ; } }
Execute every single Behaviors runnable a dedicated thread will created by the executor local to this class and be used to execute each runnable in parallel .
54
35
33,914
protected void selectSREFromConfig ( ILaunchConfiguration config ) { final boolean notify = this . sreBlock . getNotify ( ) ; final boolean changed ; try { this . sreBlock . setNotify ( false ) ; if ( this . accessor . getUseSystemSREFlag ( config ) ) { changed = this . sreBlock . selectSystemWideSRE ( ) ; } else if ( this . accessor . getUseProjectSREFlag ( config ) ) { changed = this . sreBlock . selectProjectSRE ( ) ; } else { final String sreId = this . accessor . getSREId ( config ) ; final ISREInstall sre = SARLRuntime . getSREFromId ( Strings . nullToEmpty ( sreId ) ) ; changed = this . sreBlock . selectSpecificSRE ( sre ) ; } } finally { this . sreBlock . setNotify ( notify ) ; } if ( changed ) { updateLaunchConfigurationDialog ( ) ; } }
Loads the SARL runtime environment from the launch configuration s preference store .
219
15
33,915
protected boolean isValidJREVersion ( ILaunchConfiguration config ) { final IVMInstall install = this . fJREBlock . getJRE ( ) ; if ( install instanceof IVMInstall2 ) { final String version = ( ( IVMInstall2 ) install ) . getJavaVersion ( ) ; if ( version == null ) { setErrorMessage ( MessageFormat . format ( Messages . RuntimeEnvironmentTab_3 , install . getName ( ) ) ) ; return false ; } if ( ! Utils . isCompatibleJREVersion ( version ) ) { setErrorMessage ( MessageFormat . format ( Messages . RuntimeEnvironmentTab_4 , install . getName ( ) , version , SARLVersion . MINIMAL_JDK_VERSION , SARLVersion . MAXIMAL_JDK_VERSION ) ) ; return false ; } } return true ; }
Replies if the selected configuration has a valid version for a SARL application .
181
16
33,916
public ImageDescriptor image ( SarlAgent agent ) { final JvmDeclaredType jvmElement = this . jvmModelAssociations . getInferredType ( agent ) ; return this . images . forAgent ( agent . getVisibility ( ) , this . adornments . get ( jvmElement ) ) ; }
Replies the image for an agent .
71
8
33,917
public ImageDescriptor image ( SarlBehavior behavior ) { final JvmDeclaredType jvmElement = this . jvmModelAssociations . getInferredType ( behavior ) ; return this . images . forBehavior ( behavior . getVisibility ( ) , this . adornments . get ( jvmElement ) ) ; }
Replies the image for a behavior .
73
8
33,918
public ImageDescriptor image ( SarlCapacity capacity ) { final JvmDeclaredType jvmElement = this . jvmModelAssociations . getInferredType ( capacity ) ; return this . images . forCapacity ( capacity . getVisibility ( ) , this . adornments . get ( jvmElement ) ) ; }
Replies the image for a capacity .
73
8
33,919
public ImageDescriptor image ( SarlSkill skill ) { final JvmDeclaredType jvmElement = this . jvmModelAssociations . getInferredType ( skill ) ; return this . images . forSkill ( skill . getVisibility ( ) , this . adornments . get ( jvmElement ) ) ; }
Replies the image for a skill .
71
8
33,920
public ImageDescriptor image ( SarlEvent event ) { final JvmDeclaredType jvmElement = this . jvmModelAssociations . getInferredType ( event ) ; return this . images . forEvent ( event . getVisibility ( ) , this . adornments . get ( jvmElement ) ) ; }
Replies the image for an event .
71
8
33,921
public ImageDescriptor image ( SarlAction action ) { final JvmOperation jvmElement = this . jvmModelAssociations . getDirectlyInferredOperation ( action ) ; return this . images . forOperation ( action . getVisibility ( ) , this . adornments . get ( jvmElement ) ) ; }
Replies the image for an action .
71
8
33,922
public ImageDescriptor image ( SarlField attribute ) { return this . images . forField ( attribute . getVisibility ( ) , this . adornments . get ( this . jvmModelAssociations . getJvmField ( attribute ) ) ) ; }
Replies the image for an attribute .
57
8
33,923
public ImageDescriptor image ( SarlConstructor constructor ) { if ( constructor . isStatic ( ) ) { return this . images . forStaticConstructor ( ) ; } return this . images . forConstructor ( constructor . getVisibility ( ) , this . adornments . get ( this . jvmModelAssociations . getInferredConstructor ( constructor ) ) ) ; }
Replies the image for a constructor .
83
8
33,924
public static IJavaBatchCompiler newDefaultJavaBatchCompiler ( ) { try { synchronized ( SarlBatchCompiler . class ) { if ( defaultJavaBatchCompiler == null ) { final ImplementedBy annotation = IJavaBatchCompiler . class . getAnnotation ( ImplementedBy . class ) ; assert annotation != null ; final Class < ? > type = annotation . value ( ) ; assert type != null ; defaultJavaBatchCompiler = type . asSubclass ( IJavaBatchCompiler . class ) ; } return defaultJavaBatchCompiler . newInstance ( ) ; } } catch ( Exception exception ) { throw new RuntimeException ( exception ) ; } }
Create a default Java batch compiler without injection .
150
9
33,925
private void notifiesIssueMessageListeners ( Issue issue , org . eclipse . emf . common . util . URI uri , String message ) { for ( final IssueMessageListener listener : this . messageListeners ) { listener . onIssue ( issue , uri , message ) ; } }
Replies the message for the given issue .
61
9
33,926
public void setLogger ( Logger logger ) { this . logger = logger == null ? LoggerFactory . getLogger ( getClass ( ) ) : logger ; }
Set the logger .
36
4
33,927
public void setBaseURI ( org . eclipse . emf . common . util . URI basePath ) { this . baseUri = basePath ; }
Change the base URI .
32
5
33,928
@ Pure public List < File > getBootClassPath ( ) { if ( this . bootClasspath == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . bootClasspath ) ; }
Replies the boot classpath . This option is only supported on JDK 8 and older and will be ignored when source level is 9 or newer .
50
30
33,929
public void setClassPath ( String classpath ) { this . classpath = new ArrayList <> ( ) ; for ( final String path : Strings . split ( classpath , Pattern . quote ( File . pathSeparator ) ) ) { this . classpath . add ( normalizeFile ( path ) ) ; } }
Change the classpath .
69
5
33,930
@ Pure public List < File > getClassPath ( ) { if ( this . classpath == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . classpath ) ; }
Replies the classpath .
47
6
33,931
@ SuppressWarnings ( "static-method" ) protected File createTempDirectory ( ) { final File tmpPath = new File ( System . getProperty ( "java.io.tmpdir" ) ) ; //$NON-NLS-1$ int i = 0 ; File tmp = new File ( tmpPath , "sarlc" + i ) ; //$NON-NLS-1$ while ( tmp . exists ( ) ) { ++ i ; tmp = new File ( tmpPath , "sarlc" + i ) ; //$NON-NLS-1$ } return tmp ; }
Create the temp directory that should be used by the compiler .
132
12
33,932
public void setJavaSourceVersion ( String version ) { final JavaVersion javaVersion = JavaVersion . fromQualifier ( version ) ; if ( javaVersion == null ) { final List < String > qualifiers = new ArrayList <> ( ) ; for ( final JavaVersion vers : JavaVersion . values ( ) ) { qualifiers . addAll ( vers . getAllQualifiers ( ) ) ; } throw new RuntimeException ( MessageFormat . format ( Messages . SarlBatchCompiler_0 , version , Joiner . on ( Messages . SarlBatchCompiler_1 ) . join ( qualifiers ) ) ) ; } getGeneratorConfig ( ) . setJavaSourceVersion ( javaVersion ) ; }
Change the version of the Java source to be used for the generated Java files .
146
16
33,933
public void setSourcePath ( String sourcePath ) { this . sourcePath = new ArrayList <> ( ) ; for ( final String path : Strings . split ( sourcePath , Pattern . quote ( File . pathSeparator ) ) ) { this . sourcePath . add ( normalizeFile ( path ) ) ; } }
Change the source path .
69
5
33,934
public void addSourcePath ( File sourcePath ) { if ( this . sourcePath == null ) { this . sourcePath = new ArrayList <> ( ) ; } this . sourcePath . add ( sourcePath ) ; }
Add a folder to the source path .
47
8
33,935
@ Pure public List < File > getSourcePaths ( ) { if ( this . sourcePath == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . sourcePath ) ; }
Replies the source path .
48
6
33,936
protected void overrideXtextInternalLoggers ( ) { final Logger logger = getLogger ( ) ; final org . apache . log4j . spi . LoggerFactory factory = new InternalXtextLoggerFactory ( logger ) ; final org . apache . log4j . Logger internalLogger = org . apache . log4j . Logger . getLogger ( MessageFormat . format ( Messages . SarlBatchCompiler_40 , logger . getName ( ) ) , factory ) ; setStaticField ( BatchLinkableResourceStorageWritable . class , "LOG" , internalLogger ) ; //$NON-NLS-1$ setStaticField ( BatchLinkableResource . class , "log" , internalLogger ) ; //$NON-NLS-1$ setStaticField ( ProcessorInstanceForJvmTypeProvider . class , "logger" , internalLogger ) ; //$NON-NLS-1$ }
Change the loggers that are internally used by Xtext .
210
12
33,937
protected String createIssueMessage ( Issue issue ) { final IssueMessageFormatter formatter = getIssueMessageFormatter ( ) ; final org . eclipse . emf . common . util . URI uriToProblem = issue . getUriToProblem ( ) ; if ( formatter != null ) { final String message = formatter . format ( issue , uriToProblem ) ; if ( message != null ) { return message ; } } if ( uriToProblem != null ) { final org . eclipse . emf . common . util . URI resourceUri = uriToProblem . trimFragment ( ) ; return MessageFormat . format ( Messages . SarlBatchCompiler_4 , issue . getSeverity ( ) , resourceUri . lastSegment ( ) , resourceUri . isFile ( ) ? resourceUri . toFileString ( ) : "" , //$NON-NLS-1$ issue . getLineNumber ( ) , issue . getColumn ( ) , issue . getCode ( ) , issue . getMessage ( ) ) ; } return MessageFormat . format ( Messages . SarlBatchCompiler_5 , issue . getSeverity ( ) , issue . getLineNumber ( ) , issue . getColumn ( ) , issue . getCode ( ) , issue . getMessage ( ) ) ; }
Create a message for the issue .
284
7
33,938
protected boolean reportCompilationIssues ( Iterable < Issue > issues ) { boolean hasError = false ; for ( final Issue issue : issues ) { final String issueMessage = createIssueMessage ( issue ) ; switch ( issue . getSeverity ( ) ) { case ERROR : hasError = true ; getLogger ( ) . error ( issueMessage ) ; break ; case WARNING : getLogger ( ) . warn ( issueMessage ) ; break ; case INFO : getLogger ( ) . info ( issueMessage ) ; break ; case IGNORE : default : break ; } notifiesIssueMessageListeners ( issue , issue . getUriToProblem ( ) , issueMessage ) ; } return hasError ; }
Output the given issues that result from the compilation of the SARL code .
149
15
33,939
protected void reportInternalError ( String message , Object ... parameters ) { getLogger ( ) . error ( message , parameters ) ; if ( getReportInternalProblemsAsIssues ( ) ) { final org . eclipse . emf . common . util . URI uri = null ; final Issue . IssueImpl issue = new Issue . IssueImpl ( ) ; issue . setCode ( INTERNAL_ERROR_CODE ) ; issue . setMessage ( message ) ; issue . setUriToProblem ( uri ) ; issue . setSeverity ( Severity . ERROR ) ; notifiesIssueMessageListeners ( issue , uri , message ) ; } }
Reports the given error message .
139
6
33,940
protected void generateJavaFiles ( Iterable < Resource > validatedResources , IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_49 ) ; getLogger ( ) . info ( Messages . SarlBatchCompiler_28 , getOutputPath ( ) ) ; final JavaIoFileSystemAccess javaIoFileSystemAccess = this . javaIoFileSystemAccessProvider . get ( ) ; javaIoFileSystemAccess . setOutputConfigurations ( this . outputConfigurations ) ; // The function configureWorkspace should set the output paths with absolute paths. //javaIoFileSystemAccess.setOutputPath(getOutputPath().getAbsolutePath()); javaIoFileSystemAccess . setWriteTrace ( isWriteTraceFiles ( ) ) ; if ( progress . isCanceled ( ) ) { return ; } final GeneratorContext context = new GeneratorContext ( ) ; context . setCancelIndicator ( ( ) -> progress . isCanceled ( ) ) ; for ( final Resource resource : validatedResources ) { if ( progress . isCanceled ( ) ) { return ; } if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_23 , resource . getURI ( ) . lastSegment ( ) ) ; } if ( isWriteStorageFiles ( ) && resource instanceof StorageAwareResource ) { final StorageAwareResource storageAwareResource = ( StorageAwareResource ) resource ; storageAwareResource . getResourceStorageFacade ( ) . saveResource ( storageAwareResource , javaIoFileSystemAccess ) ; } if ( progress . isCanceled ( ) ) { return ; } this . generator . generate ( resource , javaIoFileSystemAccess , context ) ; notifiesCompiledResourceReceiver ( resource ) ; } }
Generate the Java files from the SARL scripts .
405
11
33,941
protected void generateJvmElements ( ResourceSet resourceSet , IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_21 ) ; getLogger ( ) . info ( Messages . SarlBatchCompiler_21 ) ; final List < Resource > originalResources = resourceSet . getResources ( ) ; final List < Resource > toBeResolved = new ArrayList <> ( originalResources . size ( ) ) ; for ( final Resource resource : originalResources ) { if ( progress . isCanceled ( ) ) { return ; } if ( isSourceFile ( resource ) ) { toBeResolved . add ( resource ) ; } } for ( final Resource resource : toBeResolved ) { if ( progress . isCanceled ( ) ) { return ; } if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_26 , resource . getURI ( ) . lastSegment ( ) ) ; } EcoreUtil . resolveAll ( resource ) ; EcoreUtil2 . resolveLazyCrossReferences ( resource , CancelIndicator . NullImpl ) ; } }
Generate the JVM model elements .
258
8
33,942
@ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:npathcomplexity" , "checkstyle:nestedifdepth" } ) protected List < Issue > validate ( ResourceSet resourceSet , Collection < Resource > validResources , IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_38 ) ; getLogger ( ) . info ( Messages . SarlBatchCompiler_38 ) ; final List < Resource > resources = new LinkedList <> ( resourceSet . getResources ( ) ) ; final List < Issue > issuesToReturn = new ArrayList <> ( ) ; for ( final Resource resource : resources ) { if ( progress . isCanceled ( ) ) { return issuesToReturn ; } if ( isSourceFile ( resource ) ) { if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_22 , resource . getURI ( ) . lastSegment ( ) ) ; } final IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider . Registry . INSTANCE . getResourceServiceProvider ( resource . getURI ( ) ) ; if ( resourceServiceProvider != null ) { final IResourceValidator resourceValidator = resourceServiceProvider . getResourceValidator ( ) ; final List < Issue > result = resourceValidator . validate ( resource , CheckMode . ALL , null ) ; if ( progress . isCanceled ( ) ) { return issuesToReturn ; } final SortedSet < Issue > issues = new TreeSet <> ( getIssueComparator ( ) ) ; boolean hasValidationError = false ; for ( final Issue issue : result ) { if ( progress . isCanceled ( ) ) { return issuesToReturn ; } if ( issue . isSyntaxError ( ) || issue . getSeverity ( ) == Severity . ERROR ) { hasValidationError = true ; } issues . add ( issue ) ; } if ( ! hasValidationError ) { if ( ! issues . isEmpty ( ) ) { if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_39 , resource . getURI ( ) . lastSegment ( ) ) ; } issuesToReturn . addAll ( issues ) ; } validResources . add ( resource ) ; } else { if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_39 , resource . getURI ( ) . lastSegment ( ) ) ; } issuesToReturn . addAll ( issues ) ; } } } } return issuesToReturn ; }
Generate the JVM model elements and validate generated elements .
593
12
33,943
@ SuppressWarnings ( "static-method" ) protected boolean isSourceFile ( Resource resource ) { if ( resource instanceof BatchLinkableResource ) { return ! ( ( BatchLinkableResource ) resource ) . isLoadedFromStorage ( ) ; } return false ; }
Replies if the given resource is a script .
60
10
33,944
protected boolean preCompileStubs ( File sourceDirectory , File classDirectory , IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_50 ) ; return runJavaCompiler ( classDirectory , Collections . singletonList ( sourceDirectory ) , getClassPath ( ) , false , false , progress ) ; }
Compile the stub files before the compilation of the project s files .
77
14
33,945
protected boolean preCompileJava ( File sourceDirectory , File classDirectory , IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_51 ) ; return runJavaCompiler ( classDirectory , getSourcePaths ( ) , Iterables . concat ( Collections . singleton ( sourceDirectory ) , getClassPath ( ) ) , false , true , progress ) ; }
Compile the java files before the compilation of the project s files .
89
14
33,946
protected boolean postCompileJava ( IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_52 ) ; final File classOutputPath = getClassOutputPath ( ) ; if ( classOutputPath == null ) { getLogger ( ) . info ( Messages . SarlBatchCompiler_24 ) ; return true ; } getLogger ( ) . info ( Messages . SarlBatchCompiler_25 ) ; final Iterable < File > sources = Iterables . concat ( getSourcePaths ( ) , Collections . singleton ( getOutputPath ( ) ) ) ; if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_29 , toPathString ( sources ) ) ; } final List < File > classpath = getClassPath ( ) ; if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_30 , toPathString ( classpath ) ) ; } return runJavaCompiler ( classOutputPath , sources , classpath , true , true , progress ) ; }
Compile the java files after the compilation of the project s files .
259
14
33,947
@ SuppressWarnings ( { "resource" } ) protected boolean runJavaCompiler ( File classDirectory , Iterable < File > sourcePathDirectories , Iterable < File > classPathEntries , boolean enableCompilerOutput , boolean enableOptimization , IProgressMonitor progress ) { String encoding = this . encodingProvider . getDefaultEncoding ( ) ; if ( Strings . isEmpty ( encoding ) ) { encoding = null ; } if ( progress . isCanceled ( ) ) { return false ; } final PrintWriter outWriter = getStubCompilerOutputWriter ( ) ; final PrintWriter errWriter ; if ( enableCompilerOutput ) { errWriter = getErrorCompilerOutputWriter ( ) ; } else { errWriter = getStubCompilerOutputWriter ( ) ; } if ( progress . isCanceled ( ) ) { return false ; } return getJavaCompiler ( ) . compile ( classDirectory , sourcePathDirectories , classPathEntries , getBootClassPath ( ) , getJavaSourceVersion ( ) , encoding , isJavaCompilerVerbose ( ) , enableOptimization ? getOptimizationLevel ( ) : null , outWriter , errWriter , getLogger ( ) , progress ) ; }
Run the Java compiler .
265
5
33,948
protected File createStubs ( ResourceSet resourceSet , IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_53 ) ; final File outputDirectory = createTempDir ( STUB_FOLDER_PREFIX ) ; if ( progress . isCanceled ( ) ) { return null ; } if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_19 , outputDirectory ) ; } final JavaIoFileSystemAccess fileSystemAccess = this . javaIoFileSystemAccessProvider . get ( ) ; if ( progress . isCanceled ( ) ) { return null ; } fileSystemAccess . setOutputPath ( outputDirectory . toString ( ) ) ; final List < Resource > resources = new ArrayList <> ( resourceSet . getResources ( ) ) ; for ( final Resource resource : resources ) { if ( progress . isCanceled ( ) ) { return null ; } if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_20 , resource . getURI ( ) ) ; } final IResourceDescription description = this . resourceDescriptionManager . getResourceDescription ( resource ) ; this . stubGenerator . doGenerateStubs ( fileSystemAccess , description ) ; } return outputDirectory ; }
Create the stubs .
307
5
33,949
protected void loadSARLFiles ( ResourceSet resourceSet , IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_54 ) ; this . encodingProvider . setDefaultEncoding ( getFileEncoding ( ) ) ; final NameBasedFilter nameBasedFilter = new NameBasedFilter ( ) ; nameBasedFilter . setExtension ( this . fileExtensionProvider . getPrimaryFileExtension ( ) ) ; final PathTraverser pathTraverser = new PathTraverser ( ) ; final List < String > sourcePathDirectories = getSourcePathStrings ( ) ; if ( progress . isCanceled ( ) ) { return ; } final Multimap < String , org . eclipse . emf . common . util . URI > pathes = pathTraverser . resolvePathes ( sourcePathDirectories , input -> nameBasedFilter . matches ( input ) ) ; if ( progress . isCanceled ( ) ) { return ; } for ( final String source : pathes . keySet ( ) ) { for ( final org . eclipse . emf . common . util . URI uri : pathes . get ( source ) ) { if ( progress . isCanceled ( ) ) { return ; } if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_7 , uri ) ; } resourceSet . getResource ( uri , true ) ; } } }
Load the SARL files in the given resource set .
324
11
33,950
protected File createTempDir ( String namePrefix ) { final File tempDir = new File ( getTempDirectory ( ) , namePrefix ) ; cleanFolder ( tempDir , ACCEPT_ALL_FILTER , true , true ) ; if ( ! tempDir . mkdirs ( ) ) { throw new RuntimeException ( MessageFormat . format ( Messages . SarlBatchCompiler_8 , tempDir . getAbsolutePath ( ) ) ) ; } this . tempFolders . add ( tempDir ) ; return tempDir ; }
Create a temporary subdirectory inside the root temp directory .
116
11
33,951
protected boolean cleanFolder ( File parentFolder , FileFilter filter , boolean continueOnError , boolean deleteParentFolder ) { try { if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_9 , parentFolder . toString ( ) ) ; } return Files . cleanFolder ( parentFolder , null , continueOnError , deleteParentFolder ) ; } catch ( FileNotFoundException e ) { return true ; } }
Clean the folders .
105
4
33,952
protected boolean checkConfiguration ( IProgressMonitor progress ) { assert progress != null ; progress . subTask ( Messages . SarlBatchCompiler_55 ) ; final File output = getOutputPath ( ) ; if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_35 , output ) ; } if ( output == null ) { reportInternalError ( Messages . SarlBatchCompiler_36 ) ; return false ; } progress . subTask ( Messages . SarlBatchCompiler_56 ) ; for ( final File sourcePath : getSourcePaths ( ) ) { if ( progress . isCanceled ( ) ) { return false ; } try { if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( Messages . SarlBatchCompiler_37 , sourcePath ) ; } if ( isContainedIn ( output . getCanonicalFile ( ) , sourcePath . getCanonicalFile ( ) ) ) { reportInternalError ( Messages . SarlBatchCompiler_10 , output , sourcePath ) ; return false ; } } catch ( IOException e ) { reportInternalError ( Messages . SarlBatchCompiler_11 , e ) ; } } return true ; }
Check the compiler configuration ; and logs errors .
284
9
33,953
@ SuppressWarnings ( "static-method" ) protected ClassLoader createClassLoader ( Iterable < File > jarsAndFolders , ClassLoader parentClassLoader ) { return new URLClassLoader ( Iterables . toArray ( Iterables . transform ( jarsAndFolders , from -> { try { final URL url = from . toURI ( ) . toURL ( ) ; assert url != null ; return url ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } ) , URL . class ) , parentClassLoader ) ; }
Create the project class loader .
120
6
33,954
protected void destroyClassLoader ( ClassLoader classLoader ) { if ( classLoader instanceof Closeable ) { try { ( ( Closeable ) classLoader ) . close ( ) ; } catch ( Exception e ) { reportInternalWarning ( Messages . SarlBatchCompiler_18 , e ) ; } } }
Null - safe destruction of the given class loaders .
65
11
33,955
public void setWarningSeverity ( String warningId , Severity severity ) { if ( ! Strings . isEmpty ( warningId ) && severity != null ) { this . issueSeverityProvider . setSeverity ( warningId , severity ) ; } }
Change the severity level of a warning .
56
8
33,956
protected EventListener addListener ( ADDRESST key , EventListener value ) { synchronized ( mutex ( ) ) { return this . listeners . put ( key , value ) ; } }
Add a participant with the given address in this repository .
39
11
33,957
protected SynchronizedSet < ADDRESST > getAdresses ( ) { final Object mutex = mutex ( ) ; synchronized ( mutex ) { return Collections3 . synchronizedSet ( this . listeners . keySet ( ) , mutex ) ; } }
Replies all the addresses from the inside of this repository .
55
12
33,958
public SynchronizedCollection < EventListener > getListeners ( ) { final Object mutex = mutex ( ) ; synchronized ( mutex ) { return Collections3 . synchronizedCollection ( this . listeners . values ( ) , mutex ) ; } }
Replies all the participants from the inside of this repository .
52
12
33,959
protected Set < Entry < ADDRESST , EventListener > > listenersEntrySet ( ) { final Object mutex = mutex ( ) ; synchronized ( mutex ) { return Collections3 . synchronizedSet ( this . listeners . entrySet ( ) , mutex ) ; } }
Replies the pairs of addresses and participants in this repository .
58
12
33,960
private void searchAndLaunch ( String mode , Object ... scope ) { final ElementDescription element = searchAndSelect ( true , scope ) ; if ( element != null ) { try { launch ( element . projectName , element . elementName , mode ) ; } catch ( CoreException e ) { SARLEclipsePlugin . getDefault ( ) . openError ( getShell ( ) , io . sarl . eclipse . util . Messages . AbstractSarlScriptInteractiveSelector_1 , e . getStatus ( ) . getMessage ( ) , e ) ; } } }
Resolves an element type that can be launched from the given scope and launches in the specified mode .
118
20
33,961
protected void launch ( String projectName , String fullyQualifiedName , String mode ) throws CoreException { final List < ILaunchConfiguration > configs = getCandidates ( projectName , fullyQualifiedName ) ; ILaunchConfiguration config = null ; final int count = configs . size ( ) ; if ( count == 1 ) { config = configs . get ( 0 ) ; } else if ( count > 1 ) { config = chooseConfiguration ( configs ) ; if ( config == null ) { return ; } } if ( config == null ) { config = createConfiguration ( projectName , fullyQualifiedName ) ; } if ( config != null ) { DebugUITools . launch ( config , mode ) ; } }
Launches the given element type in the specified mode .
151
11
33,962
@ Pure protected URI computeUnusedUri ( ResourceSet resourceSet ) { String name = "__synthetic" ; for ( int i = 0 ; i < Integer . MAX_VALUE ; ++ i ) { URI syntheticUri = URI . createURI ( name + i + "." + getScriptFileExtension ( ) ) ; if ( resourceSet . getResource ( syntheticUri , false ) == null ) { return syntheticUri ; } } throw new IllegalStateException ( ) ; }
Compute a unused URI for a synthetic resource .
105
10
33,963
@ Pure protected Resource createResource ( ResourceSet resourceSet ) { URI uri = computeUnusedUri ( resourceSet ) ; Resource resource = getResourceFactory ( ) . createResource ( uri ) ; resourceSet . getResources ( ) . add ( resource ) ; return resource ; }
Create a synthetic resource .
60
5
33,964
@ Pure protected Injector getInjector ( ) { if ( this . builderInjector == null ) { ImportManager importManager = this . importManagerProvider . get ( ) ; this . builderInjector = createOverridingInjector ( this . originalInjector , new CodeBuilderModule ( importManager ) ) ; } return builderInjector ; }
Replies the injector .
80
6
33,965
@ Pure public IExpressionBuilder getGuard ( ) { IExpressionBuilder exprBuilder = this . expressionProvider . get ( ) ; exprBuilder . eInit ( getSarlBehaviorUnit ( ) , new Procedures . Procedure1 < XExpression > ( ) { public void apply ( XExpression expr ) { getSarlBehaviorUnit ( ) . setGuard ( expr ) ; } } , getTypeResolutionContext ( ) ) ; return exprBuilder ; }
Change the guard .
98
4
33,966
public IBlockExpressionBuilder getExpression ( ) { IBlockExpressionBuilder block = this . blockExpressionProvider . get ( ) ; block . eInit ( getTypeResolutionContext ( ) ) ; XBlockExpression expr = block . getXBlockExpression ( ) ; this . sarlBehaviorUnit . setExpression ( expr ) ; return block ; }
Create the block of code .
79
6
33,967
protected IStatus validateNameAgainstOtherSREs ( String name ) { IStatus nameStatus = SARLEclipsePlugin . getDefault ( ) . createOkStatus ( ) ; if ( isDuplicateName ( name ) ) { nameStatus = SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , ISREInstall . CODE_NAME , Messages . SREInstallWizard_1 ) ; } else { final IStatus status = ResourcesPlugin . getWorkspace ( ) . validateName ( name , IResource . FILE ) ; if ( ! status . isOK ( ) ) { nameStatus = SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , ISREInstall . CODE_NAME , MessageFormat . format ( Messages . SREInstallWizard_2 , status . getMessage ( ) ) ) ; } } return nameStatus ; }
Replies if the name of the SRE is valid against the names of the other SRE .
187
20
33,968
protected void setPageStatus ( IStatus status ) { this . status = status == null ? SARLEclipsePlugin . getDefault ( ) . createOkStatus ( ) : status ; }
Change the status associated to this page . Any previous status is overrided by the given value .
38
19
33,969
private boolean isDuplicateName ( String name ) { if ( this . existingNames != null ) { final String newName = Strings . nullToEmpty ( name ) ; for ( final String existingName : this . existingNames ) { if ( newName . equals ( existingName ) ) { return true ; } } } return false ; }
Returns whether the name is already in use by an existing SRE .
72
14
33,970
void setExistingNames ( String ... names ) { this . existingNames = names ; for ( int i = 0 ; i < this . existingNames . length ; ++ i ) { this . existingNames [ i ] = Strings . nullToEmpty ( this . existingNames [ i ] ) ; } }
Sets the names of existing SREs not including the SRE being edited . This method is called by the wizard and clients should not call this method .
64
32
33,971
protected void updatePageStatus ( ) { if ( this . status . isOK ( ) ) { setMessage ( null , IMessageProvider . NONE ) ; } else { switch ( this . status . getSeverity ( ) ) { case IStatus . ERROR : setMessage ( this . status . getMessage ( ) , IMessageProvider . ERROR ) ; break ; case IStatus . INFO : setMessage ( this . status . getMessage ( ) , IMessageProvider . INFORMATION ) ; break ; case IStatus . WARNING : setMessage ( this . status . getMessage ( ) , IMessageProvider . WARNING ) ; break ; default : break ; } } setPageComplete ( this . status . isOK ( ) || this . status . getSeverity ( ) == IStatus . INFO ) ; }
Updates the status message on the page based on the status of the SRE and other status provided by the page .
168
24
33,972
public String toActionId ( ) { final StringBuilder b = new StringBuilder ( ) ; b . append ( getActionName ( ) ) ; for ( final String type : this . signature ) { b . append ( "_" ) ; //$NON-NLS-1$ for ( final char c : type . replaceAll ( "(\\[\\])|\\*" , "Array" ) . toCharArray ( ) ) { //$NON-NLS-1$//$NON-NLS-2$ if ( Character . isJavaIdentifierPart ( c ) ) { b . append ( c ) ; } } } return b . toString ( ) ; }
Replies the string that permits to identify the action prototype according to the Java variable name .
145
18
33,973
public final void emit ( UUID eventSource , Event event , Scope < Address > scope ) { assert event != null ; ensureEventSource ( eventSource , event ) ; assert getSpaceID ( ) . equals ( event . getSource ( ) . getSpaceID ( ) ) : "The source address must belong to this space" ; //$NON-NLS-1$ try { final Scope < Address > scopeInstance = ( scope == null ) ? Scopes . < Address > allParticipants ( ) : scope ; try { this . network . publish ( scopeInstance , event ) ; } catch ( Throwable e ) { this . logger . getKernelLogger ( ) . severe ( MessageFormat . format ( Messages . AbstractEventSpace_2 , event , scope , e ) ) ; } doEmit ( event , scopeInstance ) ; } catch ( Throwable e ) { this . logger . getKernelLogger ( ) . severe ( MessageFormat . format ( Messages . AbstractEventSpace_0 , event , scope , e ) ) ; } }
Emit the given event in the given scope .
222
10
33,974
protected void ensureEventSource ( UUID eventSource , Event event ) { if ( event . getSource ( ) == null ) { if ( eventSource != null ) { event . setSource ( new Address ( getSpaceID ( ) , eventSource ) ) ; } else { throw new AssertionError ( "Every event must have a source" ) ; //$NON-NLS-1$ } } }
Ensure that the given event has a source .
87
10
33,975
protected void doEmit ( Event event , Scope < ? super Address > scope ) { assert scope != null ; assert event != null ; final UniqueAddressParticipantRepository < Address > particips = getParticipantInternalDataStructure ( ) ; final SynchronizedCollection < EventListener > listeners = particips . getListeners ( ) ; synchronized ( listeners . mutex ( ) ) { for ( final EventListener listener : listeners ) { final Address adr = getAddress ( listener ) ; if ( scope . matches ( adr ) ) { this . executorService . submit ( new AsyncRunner ( listener , event ) ) ; } } } }
Do the emission of the event .
136
7
33,976
public static Object undelegate ( Object object ) { Object obj = object ; while ( obj instanceof Delegator ) { obj = ( ( Delegator < ? > ) obj ) . getDelegatedObject ( ) ; } return obj ; }
Find the delegated object .
52
5
33,977
protected void formatRegion ( IXtextDocument document , int offset , int length ) { try { final int startLineIndex = document . getLineOfOffset ( previousSiblingChar ( document , offset ) ) ; final int endLineIndex = document . getLineOfOffset ( offset + length ) ; int regionLength = 0 ; for ( int i = startLineIndex ; i <= endLineIndex ; ++ i ) { regionLength += document . getLineLength ( i ) ; } if ( regionLength > 0 ) { final int startOffset = document . getLineOffset ( startLineIndex ) ; for ( final IRegion region : document . computePartitioning ( startOffset , regionLength ) ) { this . contentFormatter . format ( document , region ) ; } } } catch ( BadLocationException exception ) { Exceptions . sneakyThrow ( exception ) ; } }
Called for formatting a region .
180
7
33,978
@ Pure public static ServiceLoader < SREBootstrap > getServiceLoader ( boolean onlyInstalledInJRE ) { synchronized ( SRE . class ) { ServiceLoader < SREBootstrap > sl = loader == null ? null : loader . get ( ) ; if ( sl == null ) { if ( onlyInstalledInJRE ) { sl = ServiceLoader . loadInstalled ( SREBootstrap . class ) ; } else { sl = ServiceLoader . load ( SREBootstrap . class ) ; } loader = new SoftReference <> ( sl ) ; } return sl ; } }
Replies all the installed SRE into the class path .
125
12
33,979
public static Set < URL > getBootstrappedLibraries ( ) { final String name = PREFIX + SREBootstrap . class . getName ( ) ; final Set < URL > result = new TreeSet <> ( ) ; try { final Enumeration < URL > enumr = ClassLoader . getSystemResources ( name ) ; while ( enumr . hasMoreElements ( ) ) { final URL url = enumr . nextElement ( ) ; if ( url != null ) { result . add ( url ) ; } } } catch ( Exception exception ) { // } return result ; }
Replies all the libraries that contains a SRE bootstrap .
125
13
33,980
@ Pure public static SREBootstrap getBootstrap ( ) { synchronized ( SRE . class ) { if ( currentSRE == null ) { final Iterator < SREBootstrap > iterator = getServiceLoader ( ) . iterator ( ) ; if ( iterator . hasNext ( ) ) { currentSRE = iterator . next ( ) ; } else { currentSRE = new VoidSREBootstrap ( ) ; } } return currentSRE ; } }
Find and reply the current SRE .
97
8
33,981
protected String _signature ( XCastedExpression castExpression , boolean typeAtEnd ) { if ( castExpression instanceof SarlCastedExpression ) { final JvmOperation delegate = ( ( SarlCastedExpression ) castExpression ) . getFeature ( ) ; if ( delegate != null ) { return _signature ( delegate , typeAtEnd ) ; } } return MessageFormat . format ( Messages . SARLHoverSignatureProvider_0 , getTypeName ( castExpression . getType ( ) ) ) ; }
Replies the hover for a SARL casted expression .
116
12
33,982
protected String getTypeName ( JvmType type ) { if ( type != null ) { if ( type instanceof JvmDeclaredType ) { final ITypeReferenceOwner owner = new StandardTypeReferenceOwner ( this . services , type ) ; return owner . toLightweightTypeReference ( type ) . getHumanReadableName ( ) ; } return type . getSimpleName ( ) ; } return Messages . SARLHoverSignatureProvider_1 ; }
Replies the type name for the given type .
96
10
33,983
protected static ISREInstall getSREInstallFor ( ILaunchConfiguration configuration , ILaunchConfigurationAccessor configAccessor , IJavaProjectAccessor projectAccessor ) throws CoreException { assert configAccessor != null ; assert projectAccessor != null ; final ISREInstall sre ; if ( configAccessor . getUseProjectSREFlag ( configuration ) ) { sre = getProjectSpecificSRE ( configuration , true , projectAccessor ) ; } else if ( configAccessor . getUseSystemSREFlag ( configuration ) ) { sre = SARLRuntime . getDefaultSREInstall ( ) ; verifySREValidity ( sre , sre . getId ( ) ) ; } else { final String runtime = configAccessor . getSREId ( configuration ) ; sre = SARLRuntime . getSREFromId ( runtime ) ; verifySREValidity ( sre , runtime ) ; } if ( sre == null ) { throw new CoreException ( SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , Messages . SARLLaunchConfigurationDelegate_0 ) ) ; } return sre ; }
Replies the SRE installation to be used for the given configuration .
244
14
33,984
private static ISREInstall getProjectSpecificSRE ( ILaunchConfiguration configuration , boolean verify , IJavaProjectAccessor projectAccessor ) throws CoreException { assert projectAccessor != null ; final IJavaProject jprj = projectAccessor . get ( configuration ) ; if ( jprj != null ) { final IProject prj = jprj . getProject ( ) ; assert prj != null ; // Get the SRE from the extension point ISREInstall sre = getSREFromExtension ( prj , verify ) ; if ( sre != null ) { return sre ; } // Get the SRE from the default project configuration final ProjectSREProvider provider = new EclipseIDEProjectSREProvider ( prj ) ; sre = provider . getProjectSREInstall ( ) ; if ( sre != null ) { if ( verify ) { verifySREValidity ( sre , sre . getId ( ) ) ; } return sre ; } } final ISREInstall sre = SARLRuntime . getDefaultSREInstall ( ) ; if ( verify ) { verifySREValidity ( sre , ( sre == null ) ? Messages . SARLLaunchConfigurationDelegate_8 : sre . getId ( ) ) ; } return sre ; }
Replies the project SRE from the given configuration .
273
11
33,985
protected static String join ( String ... values ) { final StringBuilder buffer = new StringBuilder ( ) ; for ( final String value : values ) { if ( ! Strings . isNullOrEmpty ( value ) ) { if ( buffer . length ( ) > 0 ) { buffer . append ( " " ) ; //$NON-NLS-1$ } buffer . append ( value ) ; } } return buffer . toString ( ) ; }
Replies a string that is the concatenation of the given values .
93
15
33,986
private IRuntimeClasspathEntry [ ] getOrComputeUnresolvedSARLRuntimeClasspath ( ILaunchConfiguration configuration ) throws CoreException { // Get the buffered entries IRuntimeClasspathEntry [ ] entries = null ; synchronized ( this ) { if ( this . unresolvedClasspathEntries != null ) { entries = this . unresolvedClasspathEntries . get ( ) ; } } if ( entries != null ) { return entries ; } // Get the classpath from the configuration. entries = computeUnresolvedSARLRuntimeClasspath ( configuration , this . configAccessor , cfg -> getJavaProject ( cfg ) ) ; // synchronized ( this ) { this . unresolvedClasspathEntries = new SoftReference <> ( entries ) ; } return entries ; }
Replies the class path for the SARL application .
163
11
33,987
public static IRuntimeClasspathEntry [ ] computeUnresolvedSARLRuntimeClasspath ( ILaunchConfiguration configuration , ILaunchConfigurationAccessor configAccessor , IJavaProjectAccessor projectAccessor ) throws CoreException { // Get the classpath from the configuration. final IRuntimeClasspathEntry [ ] entries = JavaRuntime . computeUnresolvedRuntimeClasspath ( configuration ) ; // final List < IRuntimeClasspathEntry > filteredEntries = new ArrayList <> ( ) ; List < IRuntimeClasspathEntry > sreClasspathEntries = null ; // Filtering the entries by replacing the "SARL Libraries" with the SARL runtime environment. for ( final IRuntimeClasspathEntry entry : entries ) { if ( entry . getPath ( ) . equals ( SARLClasspathContainerInitializer . CONTAINER_ID ) ) { if ( sreClasspathEntries == null ) { sreClasspathEntries = getSREClasspathEntries ( configuration , configAccessor , projectAccessor ) ; } filteredEntries . addAll ( sreClasspathEntries ) ; } else { filteredEntries . add ( entry ) ; } } return filteredEntries . toArray ( new IRuntimeClasspathEntry [ filteredEntries . size ( ) ] ) ; }
Compute the class path for the given launch configuration .
274
11
33,988
private static List < IRuntimeClasspathEntry > getSREClasspathEntries ( ILaunchConfiguration configuration , ILaunchConfigurationAccessor configAccessor , IJavaProjectAccessor projectAccessor ) throws CoreException { final ISREInstall sre = getSREInstallFor ( configuration , configAccessor , projectAccessor ) ; return sre . getClassPathEntries ( ) ; }
Replies the classpath entries associated to the SRE of the given configuration .
82
16
33,989
private static boolean isNotSREEntry ( IRuntimeClasspathEntry entry ) { try { final File file = new File ( entry . getLocation ( ) ) ; if ( file . isDirectory ( ) ) { return ! SARLRuntime . isUnpackedSRE ( file ) ; } else if ( file . canRead ( ) ) { return ! SARLRuntime . isPackedSRE ( file ) ; } } catch ( Throwable e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } return true ; }
Replies if the given classpath entry is a SRE .
116
13
33,990
@ SuppressWarnings ( "static-method" ) protected Runnable createTask ( Runnable runnable ) { if ( runnable instanceof JanusRunnable ) { return runnable ; } return new JanusRunnable ( runnable ) ; }
Create a task with the given runnable .
62
10
33,991
@ SuppressWarnings ( "static-method" ) protected < T > Callable < T > createTask ( Callable < T > callable ) { if ( callable instanceof JanusCallable < ? > ) { return callable ; } return new JanusCallable <> ( callable ) ; }
Create a task with the given callable .
68
9
33,992
protected void verifyAgentName ( ILaunchConfiguration configuration ) throws CoreException { final String name = getAgentName ( configuration ) ; if ( name == null ) { abort ( io . sarl . eclipse . launching . dialog . Messages . MainLaunchConfigurationTab_2 , null , SARLEclipseConfig . ERR_UNSPECIFIED_AGENT_NAME ) ; } }
Verifies a main type name is specified by the given launch configuration and returns the main type name .
77
20
33,993
public ISarlInterfaceBuilder addSarlInterface ( String name ) { ISarlInterfaceBuilder builder = this . iSarlInterfaceBuilderProvider . get ( ) ; builder . eInit ( getSarlAgent ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlInterface .
60
6
33,994
public ISarlEnumerationBuilder addSarlEnumeration ( String name ) { ISarlEnumerationBuilder builder = this . iSarlEnumerationBuilderProvider . get ( ) ; builder . eInit ( getSarlAgent ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlEnumeration .
68
8
33,995
public ISarlAnnotationTypeBuilder addSarlAnnotationType ( String name ) { ISarlAnnotationTypeBuilder builder = this . iSarlAnnotationTypeBuilderProvider . get ( ) ; builder . eInit ( getSarlAgent ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlAnnotationType .
68
8
33,996
public void removeTask ( AgentTask task ) { final Iterator < WeakReference < AgentTask > > iterator = this . tasks . iterator ( ) ; while ( iterator . hasNext ( ) ) { final WeakReference < AgentTask > reference = iterator . next ( ) ; final AgentTask knownTask = reference . get ( ) ; if ( knownTask == null ) { iterator . remove ( ) ; } else if ( Objects . equals ( knownTask . getName ( ) , task . getName ( ) ) ) { iterator . remove ( ) ; return ; } } }
Remove task .
118
3
33,997
public void bind ( Class < ? > type , Class < ? extends SARLSemanticModification > modification ) { this . modificationTypes . put ( type , modification ) ; }
Add a semantic modification related to the given element type .
37
11
33,998
@ SuppressWarnings ( "static-method" ) protected Boolean _generate ( CharSequence expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { output . appendStringConstant ( expression . toString ( ) ) ; return Boolean . TRUE ; }
Append the inline code for the given character sequence .
70
11
33,999
@ SuppressWarnings ( "static-method" ) protected Boolean _generate ( Number expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { final Class < ? > type = ReflectionUtil . getRawType ( expression . getClass ( ) ) ; if ( Byte . class . equals ( type ) || byte . class . equals ( type ) ) { output . appendConstant ( "(byte) (" + expression . toString ( ) + ")" ) ; //$NON-NLS-1$ //$NON-NLS-2$ } else if ( Short . class . equals ( type ) || short . class . equals ( type ) ) { output . appendConstant ( "(short) (" + expression . toString ( ) + ")" ) ; //$NON-NLS-1$ //$NON-NLS-2$ } else if ( Float . class . equals ( type ) || float . class . equals ( type ) ) { output . appendConstant ( expression . toString ( ) + "f" ) ; //$NON-NLS-1$ } else { output . appendConstant ( expression . toString ( ) ) ; } return Boolean . TRUE ; }
Append the inline code for the given number value .
274
11