idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
34,000
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 .
34,001
@ 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 .
34,002
@ 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 .
34,003
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 .
34,004
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 .
34,005
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 .
34,006
@ 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 .
34,007
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 .
34,008
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 .
34,009
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 .
34,010
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 .
34,011
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 .
34,012
@ 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 .
34,013
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 .
34,014
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 .
34,015
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 .
34,016
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 .
34,017
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 .
34,018
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 .
34,019
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 .
34,020
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 .
34,021
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 .
34,022
protected Resource createResource ( ResourceSet resourceSet ) { URI uri = computeUnusedUri ( resourceSet ) ; Resource resource = getResourceFactory ( ) . createResource ( uri ) ; resourceSet . getResources ( ) . add ( resource ) ; return resource ; }
Create a synthetic resource .
34,023
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 .
34,024
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 .
34,025
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 .
34,026
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 .
34,027
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 .
34,028
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 .
34,029
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 .
34,030
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 .
34,031
public String toActionId ( ) { final StringBuilder b = new StringBuilder ( ) ; b . append ( getActionName ( ) ) ; for ( final String type : this . signature ) { b . append ( "_" ) ; for ( final char c : type . replaceAll ( "(\\[\\])|\\*" , "Array" ) . toCharArray ( ) ) { 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 .
34,032
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" ; 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 .
34,033
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" ) ; } } }
Ensure that the given event has a source .
34,034
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 .
34,035
public static Object undelegate ( Object object ) { Object obj = object ; while ( obj instanceof Delegator ) { obj = ( ( Delegator < ? > ) obj ) . getDelegatedObject ( ) ; } return obj ; }
Find the delegated object .
34,036
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 .
34,037
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 .
34,038
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 .
34,039
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 .
34,040
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 .
34,041
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 .
34,042
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 .
34,043
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 ; ISREInstall sre = getSREFromExtension ( prj , verify ) ; if ( sre != null ) { return sre ; } 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 .
34,044
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 ( " " ) ; } buffer . append ( value ) ; } } return buffer . toString ( ) ; }
Replies a string that is the concatenation of the given values .
34,045
private IRuntimeClasspathEntry [ ] getOrComputeUnresolvedSARLRuntimeClasspath ( ILaunchConfiguration configuration ) throws CoreException { IRuntimeClasspathEntry [ ] entries = null ; synchronized ( this ) { if ( this . unresolvedClasspathEntries != null ) { entries = this . unresolvedClasspathEntries . get ( ) ; } } if ( entries != null ) { return entries ; } 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 .
34,046
public static IRuntimeClasspathEntry [ ] computeUnresolvedSARLRuntimeClasspath ( ILaunchConfiguration configuration , ILaunchConfigurationAccessor configAccessor , IJavaProjectAccessor projectAccessor ) throws CoreException { final IRuntimeClasspathEntry [ ] entries = JavaRuntime . computeUnresolvedRuntimeClasspath ( configuration ) ; final List < IRuntimeClasspathEntry > filteredEntries = new ArrayList < > ( ) ; List < IRuntimeClasspathEntry > sreClasspathEntries = null ; 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 .
34,047
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 .
34,048
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 .
34,049
@ 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 .
34,050
@ 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 .
34,051
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 .
34,052
public ISarlInterfaceBuilder addSarlInterface ( String name ) { ISarlInterfaceBuilder builder = this . iSarlInterfaceBuilderProvider . get ( ) ; builder . eInit ( getSarlAgent ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlInterface .
34,053
public ISarlEnumerationBuilder addSarlEnumeration ( String name ) { ISarlEnumerationBuilder builder = this . iSarlEnumerationBuilderProvider . get ( ) ; builder . eInit ( getSarlAgent ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlEnumeration .
34,054
public ISarlAnnotationTypeBuilder addSarlAnnotationType ( String name ) { ISarlAnnotationTypeBuilder builder = this . iSarlAnnotationTypeBuilderProvider . get ( ) ; builder . eInit ( getSarlAgent ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlAnnotationType .
34,055
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 .
34,056
public void bind ( Class < ? > type , Class < ? extends SARLSemanticModification > modification ) { this . modificationTypes . put ( type , modification ) ; }
Add a semantic modification related to the given element type .
34,057
@ 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 .
34,058
@ 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 ( ) + ")" ) ; } else if ( Short . class . equals ( type ) || short . class . equals ( type ) ) { output . appendConstant ( "(short) (" + expression . toString ( ) + ")" ) ; } else if ( Float . class . equals ( type ) || float . class . equals ( type ) ) { output . appendConstant ( expression . toString ( ) + "f" ) ; } else { output . appendConstant ( expression . toString ( ) ) ; } return Boolean . TRUE ; }
Append the inline code for the given number value .
34,059
@ SuppressWarnings ( "static-method" ) protected Boolean _generate ( XBooleanLiteral expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { output . appendConstant ( Boolean . toString ( expression . isIsTrue ( ) ) ) ; return Boolean . TRUE ; }
Append the inline code for the given XBooleanLiteral .
34,060
protected Boolean _generate ( XNullLiteral expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { if ( parentExpression == null && feature instanceof XtendFunction ) { final XtendFunction function = ( XtendFunction ) feature ; output . append ( "(" ) ; final JvmTypeReference reference = getFunctionTypeReference ( function ) ; if ( reference != null ) { final JvmType type = reference . getType ( ) ; if ( type != null ) { output . append ( type ) ; } else { output . append ( Object . class ) ; } } else { output . append ( Object . class ) ; } output . append ( ")" ) ; output . append ( Objects . toString ( null ) ) ; output . setConstant ( true ) ; } else { output . appendConstant ( Objects . toString ( null ) ) ; } return Boolean . TRUE ; }
Append the inline code for the given XNullLiteral .
34,061
@ SuppressWarnings ( "static-method" ) protected Boolean _generate ( XNumberLiteral expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { output . appendConstant ( expression . getValue ( ) ) ; return Boolean . TRUE ; }
Append the inline code for the given XNumberLiteral .
34,062
@ SuppressWarnings ( "static-method" ) protected Boolean _generate ( XStringLiteral expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { output . appendStringConstant ( expression . getValue ( ) ) ; return Boolean . TRUE ; }
Append the inline code for the given XStringLiteral .
34,063
@ SuppressWarnings ( "static-method" ) protected Boolean _generate ( XTypeLiteral expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { output . appendTypeConstant ( expression . getType ( ) ) ; return Boolean . TRUE ; }
Append the inline code for the given XTypeLiteral .
34,064
protected Boolean _generate ( XCastedExpression expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { final InlineAnnotationTreeAppendable child = newAppendable ( output . getImportManager ( ) ) ; boolean bool = generate ( expression . getTarget ( ) , expression , feature , child ) ; final String childContent = child . getContent ( ) ; if ( ! Strings . isEmpty ( childContent ) ) { output . append ( "(" ) ; output . append ( expression . getType ( ) . getType ( ) ) ; output . append ( ")" ) ; output . append ( childContent ) ; output . setConstant ( child . isConstant ( ) ) ; bool = true ; } return bool ; }
Append the inline code for the given XCastedExpression .
34,065
protected Boolean _generate ( XReturnExpression expression , XExpression parentExpression , XtendExecutable feature , InlineAnnotationTreeAppendable output ) { return generate ( expression . getExpression ( ) , parentExpression , feature , output ) ; }
Append the inline code for the given XReturnLiteral .
34,066
public void getExportedPackages ( Set < String > exportedPackages ) { if ( exportedPackages != null ) { exportedPackages . add ( getCodeElementExtractor ( ) . getBasePackage ( ) ) ; exportedPackages . add ( getCodeElementExtractor ( ) . getBuilderPackage ( ) ) ; if ( getCodeBuilderConfig ( ) . isISourceAppendableEnable ( ) ) { exportedPackages . add ( getCodeElementExtractor ( ) . getAppenderPackage ( ) ) ; } } }
Fill the given set with the exported packages for this fragment .
34,067
protected String getLanguageScriptMemberGetter ( ) { final Grammar grammar = getGrammar ( ) ; final AbstractRule scriptRule = GrammarUtil . findRuleForName ( grammar , getCodeBuilderConfig ( ) . getScriptRuleName ( ) ) ; for ( final Assignment assignment : GrammarUtil . containedAssignments ( scriptRule ) ) { if ( ( assignment . getTerminal ( ) instanceof RuleCall ) && Objects . equals ( ( ( RuleCall ) assignment . getTerminal ( ) ) . getRule ( ) . getName ( ) , getCodeBuilderConfig ( ) . getTopElementRuleName ( ) ) ) { return "get" + Strings . toFirstUpper ( assignment . getFeature ( ) ) ; } } throw new IllegalStateException ( "member not found" ) ; }
Replies the getter function for accessing to the top element collection of the script .
34,068
protected TypeReference getXFactoryFor ( TypeReference type ) { final String packageName = type . getPackageName ( ) ; final Grammar grammar = getGrammar ( ) ; TypeReference reference = getXFactoryFor ( packageName , grammar ) ; if ( reference != null ) { return reference ; } for ( final Grammar usedGrammar : GrammarUtil . allUsedGrammars ( grammar ) ) { reference = getXFactoryFor ( packageName , usedGrammar ) ; if ( reference != null ) { return reference ; } } throw new IllegalStateException ( "Cannot find the XFactory for " + type ) ; }
Replies the type for the factory for the given type .
34,069
@ SuppressWarnings ( "static-method" ) protected StringConcatenationClient generateAppenderMembers ( String appenderSimpleName , TypeReference builderInterface , String elementAccessor ) { return new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "\tprivate final " ) ; it . append ( builderInterface ) ; it . append ( " builder;" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\tpublic " ) ; it . append ( appenderSimpleName ) ; it . append ( "(" ) ; it . append ( builderInterface ) ; it . append ( " builder) {" ) ; it . newLine ( ) ; it . append ( "\t\tthis.builder = builder;" ) ; it . newLine ( ) ; it . append ( "\t}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\tpublic void build(" ) ; it . append ( ISourceAppender . class ) ; it . append ( " appender) throws " ) ; it . append ( IOException . class ) ; it . append ( " {" ) ; it . newLine ( ) ; it . append ( "\t\tbuild(this.builder." ) ; it . append ( elementAccessor ) ; it . append ( ", appender);" ) ; it . newLine ( ) ; it . append ( "\t}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; }
Generate the members related to appenders .
34,070
protected static String getAorAnArticle ( String word ) { if ( Arrays . asList ( 'a' , 'e' , 'i' , 'o' , 'u' , 'y' ) . contains ( Character . toLowerCase ( word . charAt ( 0 ) ) ) ) { return "an" ; } return "a" ; }
Replies the an or a article according to the given word .
34,071
protected static String toSingular ( String word ) { if ( word . endsWith ( "ies" ) ) { return word . substring ( 0 , word . length ( ) - 3 ) + "y" ; } if ( word . endsWith ( "s" ) ) { return word . substring ( 0 , word . length ( ) - 1 ) ; } return word ; }
Replies the singular version of the word .
34,072
protected static boolean nameMatches ( EObject element , String pattern ) { if ( element instanceof RuleCall ) { return nameMatches ( ( ( RuleCall ) element ) . getRule ( ) , pattern ) ; } if ( element instanceof AbstractRule ) { final String name = ( ( AbstractRule ) element ) . getName ( ) ; final Pattern compilerPattern = Pattern . compile ( pattern ) ; final Matcher matcher = compilerPattern . matcher ( name ) ; if ( matcher . find ( ) ) { return true ; } } return false ; }
Replies if the name of the given element is matching the pattern .
34,073
protected void bindElementDescription ( BindingFactory factory , CodeElementExtractor . ElementDescription ... descriptions ) { for ( final CodeElementExtractor . ElementDescription description : descriptions ) { bindTypeReferences ( factory , description . getBuilderInterfaceType ( ) , description . getBuilderImplementationType ( ) , description . getBuilderCustomImplementationType ( ) ) ; } }
Binds the given descriptions according to the standard policy .
34,074
protected void bindTypeReferences ( BindingFactory factory , TypeReference interfaceType , TypeReference implementationType , TypeReference customImplementationType ) { final IFileSystemAccess2 fileSystem = getSrc ( ) ; final TypeReference type ; if ( ( fileSystem . isFile ( implementationType . getJavaPath ( ) ) ) || ( fileSystem . isFile ( customImplementationType . getXtendPath ( ) ) ) ) { type = customImplementationType ; } else { type = implementationType ; } factory . addfinalTypeToType ( interfaceType , type ) ; }
Binds the given references according to the standard policy .
34,075
protected AbstractRule getMemberRule ( CodeElementExtractor . ElementDescription description ) { for ( final Assignment assignment : GrammarUtil . containedAssignments ( description . getGrammarComponent ( ) ) ) { if ( Objects . equals ( getCodeBuilderConfig ( ) . getMemberCollectionExtensionGrammarName ( ) , assignment . getFeature ( ) ) ) { if ( assignment . getTerminal ( ) instanceof RuleCall ) { return ( ( RuleCall ) assignment . getTerminal ( ) ) . getRule ( ) ; } } } return null ; }
Replies the rule used for defining the members of the given element .
34,076
public String getConfig ( String key ) throws MojoExecutionException { ResourceBundle resource = null ; try { resource = ResourceBundle . getBundle ( "io/sarl/maven/compiler/config" , java . util . Locale . getDefault ( ) , MavenHelper . class . getClassLoader ( ) ) ; } catch ( MissingResourceException e ) { throw new MojoExecutionException ( e . getLocalizedMessage ( ) , e ) ; } String value = resource . getString ( key ) ; if ( value == null || value . isEmpty ( ) ) { value = Strings . nullToEmpty ( value ) ; this . log . warn ( MessageFormat . format ( Messages . MavenHelper_1 , key ) ) ; } return value ; }
Extract the value from the hard - coded configuration .
34,077
public PluginDescriptor loadPlugin ( Plugin plugin ) throws MojoExecutionException { try { final Object repositorySessionObject = this . getRepositorySessionMethod . invoke ( this . session ) ; return ( PluginDescriptor ) this . loadPluginMethod . invoke ( this . buildPluginManager , plugin , getSession ( ) . getCurrentProject ( ) . getRemotePluginRepositories ( ) , repositorySessionObject ) ; } catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) { throw new MojoExecutionException ( e . getLocalizedMessage ( ) , e ) ; } }
Load the given plugin .
34,078
public void executeMojo ( MojoExecution mojo ) throws MojoExecutionException , MojoFailureException { try { this . buildPluginManager . executeMojo ( this . session , mojo ) ; } catch ( PluginConfigurationException | PluginManagerException e ) { throw new MojoFailureException ( e . getLocalizedMessage ( ) , e ) ; } }
Execute the given mojo .
34,079
@ SuppressWarnings ( "static-method" ) public Dependency toDependency ( Artifact artifact ) { final Dependency result = new Dependency ( ) ; result . setArtifactId ( artifact . getArtifactId ( ) ) ; result . setClassifier ( artifact . getClassifier ( ) ) ; result . setGroupId ( artifact . getGroupId ( ) ) ; result . setOptional ( artifact . isOptional ( ) ) ; result . setScope ( artifact . getScope ( ) ) ; result . setType ( artifact . getType ( ) ) ; result . setVersion ( artifact . getVersion ( ) ) ; return result ; }
Convert an artifact to a dependency .
34,080
public synchronized Map < String , Dependency > getPluginDependencies ( ) throws MojoExecutionException { if ( this . pluginDependencies == null ) { final String groupId = getConfig ( "plugin.groupId" ) ; final String artifactId = getConfig ( "plugin.artifactId" ) ; final String pluginArtifactKey = ArtifactUtils . versionlessKey ( groupId , artifactId ) ; final Set < Artifact > dependencies = resolveDependencies ( pluginArtifactKey , true ) ; final Map < String , Dependency > deps = new TreeMap < > ( ) ; for ( final Artifact artifact : dependencies ) { final Dependency dep = toDependency ( artifact ) ; deps . put ( ArtifactUtils . versionlessKey ( artifact ) , dep ) ; } this . pluginDependencies = deps ; } return this . pluginDependencies ; }
Build the map of dependencies for the current plugin .
34,081
public Set < Artifact > resolve ( String groupId , String artifactId ) throws MojoExecutionException { final ArtifactResolutionRequest request = new ArtifactResolutionRequest ( ) ; request . setResolveRoot ( true ) ; request . setResolveTransitively ( true ) ; request . setLocalRepository ( getSession ( ) . getLocalRepository ( ) ) ; request . setRemoteRepositories ( getSession ( ) . getCurrentProject ( ) . getRemoteArtifactRepositories ( ) ) ; request . setOffline ( getSession ( ) . isOffline ( ) ) ; request . setForceUpdate ( getSession ( ) . getRequest ( ) . isUpdateSnapshots ( ) ) ; request . setServers ( getSession ( ) . getRequest ( ) . getServers ( ) ) ; request . setMirrors ( getSession ( ) . getRequest ( ) . getMirrors ( ) ) ; request . setProxies ( getSession ( ) . getRequest ( ) . getProxies ( ) ) ; request . setArtifact ( createArtifact ( groupId , artifactId ) ) ; final ArtifactResolutionResult result = resolve ( request ) ; return result . getArtifacts ( ) ; }
Resolve the artifacts with the given key .
34,082
public Artifact createArtifact ( String groupId , String artifactId ) { return this . repositorySystem . createArtifact ( groupId , artifactId , "RELEASE" , "jar" ) ; }
Create an instance of artifact with a version range that corresponds to all versions .
34,083
public Set < Artifact > resolveDependencies ( String artifactId , boolean plugins ) throws MojoExecutionException { final Artifact pluginArtifact ; if ( plugins ) { pluginArtifact = getSession ( ) . getCurrentProject ( ) . getPluginArtifactMap ( ) . get ( artifactId ) ; } else { pluginArtifact = getSession ( ) . getCurrentProject ( ) . getArtifactMap ( ) . get ( artifactId ) ; } final ArtifactResolutionRequest request = new ArtifactResolutionRequest ( ) ; request . setResolveRoot ( false ) ; request . setResolveTransitively ( true ) ; request . setLocalRepository ( getSession ( ) . getLocalRepository ( ) ) ; request . setRemoteRepositories ( getSession ( ) . getCurrentProject ( ) . getRemoteArtifactRepositories ( ) ) ; request . setOffline ( getSession ( ) . isOffline ( ) ) ; request . setForceUpdate ( getSession ( ) . getRequest ( ) . isUpdateSnapshots ( ) ) ; request . setServers ( getSession ( ) . getRequest ( ) . getServers ( ) ) ; request . setMirrors ( getSession ( ) . getRequest ( ) . getMirrors ( ) ) ; request . setProxies ( getSession ( ) . getRequest ( ) . getProxies ( ) ) ; request . setArtifact ( pluginArtifact ) ; final ArtifactResolutionResult result = resolve ( request ) ; try { this . resolutionErrorHandler . throwErrors ( request , result ) ; } catch ( MultipleArtifactsNotFoundException e ) { final Collection < Artifact > missing = new HashSet < > ( e . getMissingArtifacts ( ) ) ; if ( ! missing . isEmpty ( ) ) { throw new MojoExecutionException ( e . getLocalizedMessage ( ) , e ) ; } } catch ( ArtifactResolutionException e ) { throw new MojoExecutionException ( e . getLocalizedMessage ( ) , e ) ; } return result . getArtifacts ( ) ; }
Replies the dependencies for the given artifact .
34,084
public String getPluginDependencyVersion ( String groupId , String artifactId ) throws MojoExecutionException { final Map < String , Dependency > deps = getPluginDependencies ( ) ; final String key = ArtifactUtils . versionlessKey ( groupId , artifactId ) ; this . log . debug ( "COMPONENT DEPENDENCIES(getPluginVersionFromDependencies):" ) ; this . log . debug ( deps . toString ( ) ) ; final Dependency dep = deps . get ( key ) ; if ( dep != null ) { final String version = dep . getVersion ( ) ; if ( version != null && ! version . isEmpty ( ) ) { return version ; } throw new MojoExecutionException ( MessageFormat . format ( Messages . MavenHelper_2 , key ) ) ; } throw new MojoExecutionException ( MessageFormat . format ( Messages . MavenHelper_3 , key , deps ) ) ; }
Replies the version of the given plugin that is specified in the POM of the plugin in which this mojo is located .
34,085
@ SuppressWarnings ( "static-method" ) public Xpp3Dom toXpp3Dom ( String content , Log logger ) { if ( content != null && ! content . isEmpty ( ) ) { try ( StringReader sr = new StringReader ( content ) ) { return Xpp3DomBuilder . build ( sr ) ; } catch ( Exception exception ) { if ( logger != null ) { logger . debug ( exception ) ; } } } return null ; }
Parse the given string for extracting an XML tree .
34,086
@ SuppressWarnings ( "static-method" ) public IJavaBatchCompiler providesJavaBatchCompiler ( Injector injector , Provider < SarlConfig > config ) { final SarlConfig cfg = config . get ( ) ; final IJavaBatchCompiler compiler = cfg . getCompiler ( ) . getJavaCompiler ( ) . newCompilerInstance ( ) ; injector . injectMembers ( compiler ) ; return compiler ; }
Provide a Java batch compiler based on the Bootique configuration .
34,087
private static void uninstallSkillsPreStage ( Iterable < ? extends Skill > skills ) { try { for ( final Skill s : skills ) { SREutils . doSkillUninstallation ( s , UninstallationStage . PRE_DESTROY_EVENT ) ; } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Run the uninstallation functions of the skills for the pre stage of the uninstallation process .
34,088
private static void uninstallSkillsFinalStage ( Iterable < ? extends Skill > skills ) { try { for ( final Skill s : skills ) { SREutils . doSkillUninstallation ( s , UninstallationStage . POST_DESTROY_EVENT ) ; } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Run the uninstallation functions of the skills for the final stage of the uninstallation process .
34,089
protected void fireKernelDiscovered ( URI uri ) { this . logger . getKernelLogger ( ) . info ( MessageFormat . format ( Messages . HazelcastKernelDiscoveryService_0 , uri , getCurrentKernel ( ) ) ) ; for ( final KernelDiscoveryServiceListener listener : this . listeners . getListeners ( KernelDiscoveryServiceListener . class ) ) { listener . kernelDiscovered ( uri ) ; } }
Notifies the listeners about the discovering of a kernel .
34,090
protected void fireKernelDisconnected ( URI uri ) { this . logger . getKernelLogger ( ) . info ( MessageFormat . format ( Messages . HazelcastKernelDiscoveryService_1 , uri , getCurrentKernel ( ) ) ) ; for ( final KernelDiscoveryServiceListener listener : this . listeners . getListeners ( KernelDiscoveryServiceListener . class ) ) { listener . kernelDisconnected ( uri ) ; } }
Notifies the listeners about the killing of a kernel .
34,091
public static SarlConfig getConfiguration ( ConfigurationFactory configFactory ) { assert configFactory != null ; return configFactory . config ( SarlConfig . class , PREFIX ) ; }
Replies the configuration for SARLC .
34,092
protected static File unix2os ( String filename ) { File file = null ; for ( final String base : filename . split ( Pattern . quote ( "/" ) ) ) { if ( file == null ) { file = new File ( base ) ; } else { file = new File ( file , base ) ; } } return file ; }
Create a file from a unix - like representation of the filename .
34,093
protected File makeAbsolute ( File file ) { if ( ! file . isAbsolute ( ) ) { final File basedir = this . mavenHelper . getSession ( ) . getCurrentProject ( ) . getBasedir ( ) ; return new File ( basedir , file . getPath ( ) ) . getAbsoluteFile ( ) ; } return file ; }
Make absolute the given filename relatively to the project s folder .
34,094
protected void executeMojo ( String groupId , String artifactId , String version , String goal , String configuration , Dependency ... dependencies ) throws MojoExecutionException , MojoFailureException { final Plugin plugin = new Plugin ( ) ; plugin . setArtifactId ( artifactId ) ; plugin . setGroupId ( groupId ) ; plugin . setVersion ( version ) ; plugin . setDependencies ( Arrays . asList ( dependencies ) ) ; getLog ( ) . debug ( MessageFormat . format ( Messages . AbstractSarlMojo_0 , plugin . getId ( ) ) ) ; final PluginDescriptor pluginDescriptor = this . mavenHelper . loadPlugin ( plugin ) ; if ( pluginDescriptor == null ) { throw new MojoExecutionException ( MessageFormat . format ( Messages . AbstractSarlMojo_1 , plugin . getId ( ) ) ) ; } final MojoDescriptor mojoDescriptor = pluginDescriptor . getMojo ( goal ) ; if ( mojoDescriptor == null ) { throw new MojoExecutionException ( MessageFormat . format ( Messages . AbstractSarlMojo_2 , goal ) ) ; } final Xpp3Dom mojoXml ; try { mojoXml = this . mavenHelper . toXpp3Dom ( mojoDescriptor . getMojoConfiguration ( ) ) ; } catch ( PlexusConfigurationException e1 ) { throw new MojoExecutionException ( e1 . getLocalizedMessage ( ) , e1 ) ; } Xpp3Dom configurationXml = this . mavenHelper . toXpp3Dom ( configuration , getLog ( ) ) ; if ( configurationXml != null ) { configurationXml = Xpp3DomUtils . mergeXpp3Dom ( configurationXml , mojoXml ) ; } else { configurationXml = mojoXml ; } getLog ( ) . debug ( MessageFormat . format ( Messages . AbstractSarlMojo_3 , plugin . getId ( ) , configurationXml . toString ( ) ) ) ; final MojoExecution execution = new MojoExecution ( mojoDescriptor , configurationXml ) ; this . mavenHelper . executeMojo ( execution ) ; }
Execute another MOJO .
34,095
protected String internalExecute ( ) { getLog ( ) . info ( Messages . AbstractDocumentationMojo_1 ) ; final Map < File , File > files = getFiles ( ) ; getLog ( ) . info ( MessageFormat . format ( Messages . AbstractDocumentationMojo_2 , files . size ( ) ) ) ; return internalExecute ( files ) ; }
Internal run .
34,096
protected String formatErrorMessage ( File inputFile , Throwable exception ) { File filename ; int lineno = 0 ; final boolean addExceptionName ; if ( exception instanceof ParsingException ) { addExceptionName = false ; final ParsingException pexception = ( ParsingException ) exception ; final File file = pexception . getFile ( ) ; if ( file != null ) { filename = file ; } else { filename = inputFile ; } lineno = pexception . getLineno ( ) ; } else { addExceptionName = true ; filename = inputFile ; } for ( final String sourceDir : this . session . getCurrentProject ( ) . getCompileSourceRoots ( ) ) { final File root = new File ( sourceDir ) ; if ( isParentFile ( filename , root ) ) { try { filename = FileSystem . makeRelative ( filename , root ) ; } catch ( IOException exception1 ) { } break ; } } final StringBuilder msg = new StringBuilder ( ) ; msg . append ( filename . toString ( ) ) ; if ( lineno > 0 ) { msg . append ( ":" ) . append ( lineno ) ; } msg . append ( ": " ) ; final Throwable rootEx = Throwables . getRootCause ( exception ) ; if ( addExceptionName ) { msg . append ( rootEx . getClass ( ) . getName ( ) ) ; msg . append ( " - " ) ; } msg . append ( rootEx . getLocalizedMessage ( ) ) ; return msg . toString ( ) ; }
Format the error message .
34,097
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) protected AbstractMarkerLanguageParser createLanguageParser ( File inputFile ) throws MojoExecutionException , IOException { final AbstractMarkerLanguageParser parser ; if ( isFileExtension ( inputFile , MarkdownParser . MARKDOWN_FILE_EXTENSIONS ) ) { parser = this . injector . getInstance ( MarkdownParser . class ) ; } else { throw new MojoExecutionException ( MessageFormat . format ( Messages . AbstractDocumentationMojo_3 , inputFile ) ) ; } parser . setGithubExtensionEnable ( this . githubExtension ) ; final SarlDocumentationParser internalParser = parser . getDocumentParser ( ) ; if ( this . isLineContinuationEnable ) { internalParser . setLineContinuation ( SarlDocumentationParser . DEFAULT_LINE_CONTINUATION ) ; } else { internalParser . addLowPropertyProvider ( createProjectProperties ( ) ) ; } final ScriptExecutor scriptExecutor = internalParser . getScriptExecutor ( ) ; final StringBuilder cp = new StringBuilder ( ) ; for ( final File cpElement : getClassPath ( ) ) { if ( cp . length ( ) > 0 ) { cp . append ( ":" ) ; } cp . append ( cpElement . getAbsolutePath ( ) ) ; } scriptExecutor . setClassPath ( cp . toString ( ) ) ; final String bootPath = getBootClassPath ( ) ; if ( ! Strings . isEmpty ( bootPath ) ) { scriptExecutor . setBootClassPath ( bootPath ) ; } JavaVersion version = null ; if ( ! Strings . isEmpty ( this . source ) ) { version = JavaVersion . fromQualifier ( this . source ) ; } if ( version == null ) { version = JavaVersion . JAVA8 ; } scriptExecutor . setJavaSourceVersion ( version . getQualifier ( ) ) ; scriptExecutor . setTempFolder ( this . tempDirectory . getAbsoluteFile ( ) ) ; internalParser . addLowPropertyProvider ( createProjectProperties ( ) ) ; internalParser . addLowPropertyProvider ( this . session . getCurrentProject ( ) . getProperties ( ) ) ; internalParser . addLowPropertyProvider ( this . session . getUserProperties ( ) ) ; internalParser . addLowPropertyProvider ( this . session . getSystemProperties ( ) ) ; internalParser . addLowPropertyProvider ( createGeneratorProperties ( ) ) ; final Properties defaultValues = createDefaultValueProperties ( ) ; if ( defaultValues != null ) { internalParser . addLowPropertyProvider ( defaultValues ) ; } return parser ; }
Create a parser for the given file .
34,098
protected Map < File , File > getFiles ( ) { final Map < File , File > files = new TreeMap < > ( ) ; for ( final String rootName : this . inferredSourceDirectories ) { File root = FileSystem . convertStringToFile ( rootName ) ; if ( ! root . isAbsolute ( ) ) { root = FileSystem . makeAbsolute ( root , this . baseDirectory ) ; } getLog ( ) . debug ( MessageFormat . format ( Messages . AbstractDocumentationMojo_4 , root . getName ( ) ) ) ; for ( final File file : Files . fileTreeTraverser ( ) . breadthFirstTraversal ( root ) ) { if ( file . exists ( ) && file . isFile ( ) && ! file . isHidden ( ) && file . canRead ( ) && hasExtension ( file ) ) { files . put ( file , root ) ; } } } return files ; }
Replies the source files .
34,099
protected static String toPackageName ( String rootPackage , File packageName ) { final StringBuilder name = new StringBuilder ( ) ; File tmp = packageName ; while ( tmp != null ) { final String elementName = tmp . getName ( ) ; if ( ! Strings . equal ( FileSystem . CURRENT_DIRECTORY , elementName ) && ! Strings . equal ( FileSystem . PARENT_DIRECTORY , elementName ) ) { if ( name . length ( ) > 0 ) { name . insert ( 0 , "." ) ; } name . insert ( 0 , elementName ) ; } tmp = tmp . getParentFile ( ) ; } if ( ! Strings . isEmpty ( rootPackage ) ) { if ( name . length ( ) > 0 ) { name . insert ( 0 , "." ) ; } name . insert ( 0 , rootPackage ) ; } return name . toString ( ) ; }
Convert a file to a package name .