idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
33,600 | @ SuppressWarnings ( "checkstyle:npathcomplexity" ) private void createImplicitActionReturnType ( XtextResource resource , IAcceptor < ? super ICodeMining > acceptor ) { final List < XtendFunction > actions = EcoreUtil2 . eAllOfType ( resource . getContents ( ) . get ( 0 ) , XtendFunction . class ) ; for ( final XtendFunction action : actions ) { if ( action . getReturnType ( ) != null ) { continue ; } final JvmOperation inferredOperation = ( JvmOperation ) this . jvmModelAssocitions . getPrimaryJvmElement ( action ) ; if ( inferredOperation == null || inferredOperation . getReturnType ( ) == null ) { continue ; } final ICompositeNode node = NodeModelUtils . findActualNodeFor ( action ) ; final Keyword parenthesis = this . grammar . getAOPMemberAccess ( ) . getRightParenthesisKeyword_2_5_6_2 ( ) ; final Assignment fctname = this . grammar . getAOPMemberAccess ( ) . getNameAssignment_2_5_5 ( ) ; int offsetFctname = - 1 ; int offsetParenthesis = - 1 ; for ( Iterator < INode > it = node . getAsTreeIterable ( ) . iterator ( ) ; it . hasNext ( ) ; ) { final INode child = it . next ( ) ; if ( child != node ) { final EObject grammarElement = child . getGrammarElement ( ) ; if ( grammarElement instanceof RuleCall ) { if ( fctname . equals ( grammarElement . eContainer ( ) ) ) { offsetFctname = child . getTotalEndOffset ( ) ; } } else if ( parenthesis . equals ( grammarElement ) ) { offsetParenthesis = child . getTotalEndOffset ( ) ; break ; } } } int offset = - 1 ; if ( offsetParenthesis >= 0 ) { offset = offsetParenthesis ; } else if ( offsetFctname >= 0 ) { offset = offsetFctname ; } if ( offset >= 0 ) { final String returnType = inferredOperation . getReturnType ( ) . getSimpleName ( ) ; final String text = " " + this . keywords . getColonKeyword ( ) + " " + returnType ; acceptor . accept ( createNewLineContentCodeMining ( offset , text ) ) ; } } } | Add an annotation when the action s return type is implicit and inferred by the SARL compiler . |
33,601 | public Set < String > getPureKeywords ( ) { Set < String > kws = this . pureSarlKeywords == null ? null : this . pureSarlKeywords . get ( ) ; if ( kws == null ) { kws = new HashSet < > ( ) ; kws . add ( getAsKeyword ( ) ) ; kws . add ( getRequiresKeyword ( ) ) ; kws . add ( getWithKeyword ( ) ) ; kws . add ( getItKeyword ( ) ) ; kws . add ( getArtifactKeyword ( ) ) ; kws . add ( getAnnotationKeyword ( ) ) ; kws . add ( getSpaceKeyword ( ) ) ; kws . add ( getOnKeyword ( ) ) ; kws . add ( getCapacityKeyword ( ) ) ; kws . add ( getEventKeyword ( ) ) ; kws . add ( getVarKeyword ( ) ) ; kws . add ( getAgentKeyword ( ) ) ; kws . add ( getDispatchKeyword ( ) ) ; kws . add ( getUsesKeyword ( ) ) ; kws . add ( getSkillKeyword ( ) ) ; kws . add ( getDefKeyword ( ) ) ; kws . add ( getFiresKeyword ( ) ) ; kws . add ( getOverrideKeyword ( ) ) ; kws . add ( getIsStaticAssumeKeyword ( ) ) ; kws . add ( getBehaviorKeyword ( ) ) ; kws . add ( getExtensionExtensionKeyword ( ) ) ; kws . add ( getValKeyword ( ) ) ; kws . add ( getTypeofKeyword ( ) ) ; kws . add ( getOccurrenceKeyword ( ) ) ; this . pureSarlKeywords = new SoftReference < > ( kws ) ; } return Collections . unmodifiableSet ( kws ) ; } | Replies the pure SARL keywords . Pure SARL keywords are SARL keywords that are not Java keywords . |
33,602 | public String protectKeyword ( String text ) { if ( ! Strings . isEmpty ( text ) && isKeyword ( text ) ) { return "^" + text ; } return text ; } | Protect the given text if it is a keyword . |
33,603 | public void checkImportsMapping ( XImportDeclaration importDeclaration ) { final JvmDeclaredType type = importDeclaration . getImportedType ( ) ; doTypeMappingCheck ( importDeclaration , type , this . typeErrorHandler1 ) ; } | Check that import mapping are known . |
33,604 | public static void importMavenProject ( IWorkspaceRoot workspaceRoot , String projectName , boolean addSarlSpecificSourceFolders , IProgressMonitor monitor ) { final WorkspaceJob bugFixJob = new WorkspaceJob ( "Creating Simple Maven project" ) { @ SuppressWarnings ( "synthetic-access" ) public IStatus runInWorkspace ( IProgressMonitor monitor ) throws CoreException { try { final SubMonitor submon = SubMonitor . convert ( monitor , 3 ) ; forceSimplePom ( workspaceRoot , projectName , submon . newChild ( 1 ) ) ; final AbstractProjectScanner < MavenProjectInfo > scanner = getProjectScanner ( workspaceRoot , projectName ) ; scanner . run ( submon . newChild ( 1 ) ) ; final ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration ( ) ; runFixedImportJob ( addSarlSpecificSourceFolders , scanner . getProjects ( ) , importConfiguration , null , submon . newChild ( 1 ) ) ; } catch ( Exception exception ) { return SARLMavenEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , exception ) ; } return Status . OK_STATUS ; } } ; bugFixJob . setRule ( MavenPlugin . getProjectConfigurationManager ( ) . getRule ( ) ) ; bugFixJob . schedule ( ) ; } | Create a fresh Maven project from existing files assuming a pom file exists . |
33,605 | static List < IMavenProjectImportResult > runFixedImportJob ( boolean addSarlSpecificSourceFolders , Collection < MavenProjectInfo > projectInfos , ProjectImportConfiguration importConfiguration , IProjectCreationListener projectCreationListener , IProgressMonitor monitor ) throws CoreException { final List < IMavenProjectImportResult > importResults = MavenPlugin . getProjectConfigurationManager ( ) . importProjects ( projectInfos , importConfiguration , projectCreationListener , monitor ) ; if ( addSarlSpecificSourceFolders ) { final SubMonitor submon = SubMonitor . convert ( monitor , importResults . size ( ) ) ; for ( final IMavenProjectImportResult importResult : importResults ) { SARLProjectConfigurator . configureSARLSourceFolders ( importResult . getProject ( ) , true , submon . newChild ( 1 ) ) ; final WorkspaceJob job = new WorkspaceJob ( "Creating Maven project" ) { @ SuppressWarnings ( "synthetic-access" ) public IStatus runInWorkspace ( IProgressMonitor monitor ) throws CoreException { try { runBugFix ( importResult . getProject ( ) , monitor ) ; } catch ( Exception exception ) { return SARLMavenEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , exception ) ; } return Status . OK_STATUS ; } } ; job . setRule ( MavenPlugin . getProjectConfigurationManager ( ) . getRule ( ) ) ; job . schedule ( ) ; } } return importResults ; } | Run the job that execute a fixed import of a Maven project . |
33,606 | static void forceSimplePom ( File projectDir , IProgressMonitor monitor ) throws IOException { final File pomFile = new File ( projectDir , POM_FILE ) ; if ( pomFile . exists ( ) ) { final SubMonitor submon = SubMonitor . convert ( monitor , 4 ) ; final File savedPomFile = new File ( projectDir , POM_BACKUP_FILE ) ; if ( savedPomFile . exists ( ) ) { savedPomFile . delete ( ) ; } submon . worked ( 1 ) ; Files . copy ( pomFile , savedPomFile ) ; submon . worked ( 1 ) ; final StringBuilder content = new StringBuilder ( ) ; try ( BufferedReader stream = new BufferedReader ( new FileReader ( pomFile ) ) ) { String line = stream . readLine ( ) ; while ( line != null ) { line = line . replaceAll ( "<extensions>\\s*true\\s*</extensions>" , "" ) ; content . append ( line ) . append ( "\n" ) ; line = stream . readLine ( ) ; } } submon . worked ( 1 ) ; Files . write ( content . toString ( ) . getBytes ( ) , pomFile ) ; submon . worked ( 1 ) ; } } | Force the pom file of a project to be simple . |
33,607 | public final Set < String > getBundleDependencies ( ) { final Set < String > bundles = new TreeSet < > ( ) ; updateBundleList ( bundles ) ; return bundles ; } | Replies the list of the symbolic names of the bundle dependencies . |
33,608 | @ SuppressWarnings ( "static-method" ) @ Inline ( value = "$1.getCaller()" , imported = Capacities . class , constantExpression = true ) protected AgentTrait getCaller ( ) { return Capacities . getCaller ( ) ; } | Replies the caller of the capacity functions . |
33,609 | void unregisterUse ( ) { final int value = this . uses . decrementAndGet ( ) ; if ( value == 0 ) { uninstall ( UninstallationStage . PRE_DESTROY_EVENT ) ; uninstall ( UninstallationStage . POST_DESTROY_EVENT ) ; } } | Mark this skill as release by one user . |
33,610 | protected void generateIFormalParameterBuilder ( ) { final TypeReference builder = getFormalParameterBuilderInterface ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Builder of a " + getLanguageName ( ) + " formal parameter." ) ; it . newLine ( ) ; it . append ( " */" ) ; it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; it . newLine ( ) ; it . append ( "public interface " ) ; it . append ( builder . getSimpleName ( ) ) ; it . append ( " {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateMembers ( true , false ) ) ; it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( builder , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the formal parameter builder interface . |
33,611 | protected void generateFormalParameterAppender ( ) { final CodeElementExtractor . ElementDescription parameter = getCodeElementExtractor ( ) . getFormalParameter ( ) ; final String accessor = "get" + Strings . toFirstUpper ( parameter . getElementType ( ) . getSimpleName ( ) ) + "()" ; final TypeReference builderInterface = getFormalParameterBuilderInterface ( ) ; final TypeReference appender = getCodeElementExtractor ( ) . getElementAppenderImpl ( "FormalParameter" ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Appender of a " + getLanguageName ( ) + " formal parameter." ) ; it . newLine ( ) ; it . append ( " */" ) ; it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; it . newLine ( ) ; it . append ( "public class " ) ; it . append ( appender . getSimpleName ( ) ) ; it . append ( " extends " ) ; it . append ( getCodeElementExtractor ( ) . getAbstractAppenderImpl ( ) ) ; it . append ( " implements " ) ; it . append ( builderInterface ) ; it . append ( " {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateAppenderMembers ( appender . getSimpleName ( ) , builderInterface , accessor ) ) ; it . append ( generateMembers ( false , true ) ) ; it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( appender , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the formal parameter appender . |
33,612 | protected void fireContextCreated ( AgentContext context ) { final ContextRepositoryListener [ ] ilisteners = this . listeners . getListeners ( ContextRepositoryListener . class ) ; this . logger . getKernelLogger ( ) . info ( MessageFormat . format ( Messages . StandardContextSpaceService_0 , context . getID ( ) ) ) ; for ( final ContextRepositoryListener listener : ilisteners ) { listener . contextCreated ( context ) ; } } | Notifies the listeners about a context creation . |
33,613 | protected void fireContextDestroyed ( AgentContext context ) { final ContextRepositoryListener [ ] ilisteners = this . listeners . getListeners ( ContextRepositoryListener . class ) ; this . logger . getKernelLogger ( ) . info ( MessageFormat . format ( Messages . StandardContextSpaceService_1 , context . getID ( ) ) ) ; for ( final ContextRepositoryListener listener : ilisteners ) { listener . contextDestroyed ( context ) ; } } | Notifies the listeners about a context destruction . |
33,614 | protected void removeDefaultSpaceDefinition ( SpaceID spaceID ) { AgentContext context = null ; synchronized ( mutex ( ) ) { context = this . contexts . remove ( spaceID . getContextID ( ) ) ; } if ( context != null ) { fireContextDestroyed ( context ) ; } } | Update the internal data structure when a default space was removed . |
33,615 | public void addRequirement ( String requirement ) { if ( ! Strings . isEmpty ( requirement ) ) { if ( this . requirements == null ) { this . requirements = new ArrayList < > ( ) ; } this . requirements . add ( requirement ) ; } } | Add a TeX requirement . |
33,616 | @ SuppressWarnings ( "static-method" ) protected boolean generateOptions ( IStyleAppendable it ) { it . appendNl ( "\\newif\\ifusesarlcolors\\usesarlcolorstrue" ) ; it . appendNl ( "\\DeclareOption{sarlcolors}{\\global\\usesarlcolorstrue}" ) ; it . appendNl ( "\\DeclareOption{nosarlcolors}{\\global\\usesarlcolorsfalse}" ) ; return true ; } | Generate the optional extensions . |
33,617 | public void setKey ( @ Named ( NetworkConfig . AES_KEY ) String key ) throws Exception { final byte [ ] raw = key . getBytes ( NetworkConfig . getStringEncodingCharset ( ) ) ; final int keySize = raw . length ; if ( ( keySize % 16 ) == 0 || ( keySize % 24 ) == 0 || ( keySize % 32 ) == 0 ) { this . skeySpec = new SecretKeySpec ( raw , "AES" ) ; } else { throw new IllegalArgumentException ( Messages . AESEventEncrypter_0 ) ; } } | Change the encryption key . |
33,618 | @ SuppressWarnings ( "static-method" ) protected void getLinkForPrimitive ( Content link , LinkInfo linkInfo , Type type ) { link . addContent ( type . typeName ( ) ) ; } | Build the link for the primitive . |
33,619 | protected void getLinkForAnnotationType ( Content link , LinkInfo linkInfo , Type type ) { link . addContent ( getTypeAnnotationLinks ( linkInfo ) ) ; linkInfo . type = type . asAnnotatedType ( ) . underlyingType ( ) ; link . addContent ( getLink ( linkInfo ) ) ; } | Build the link for the annotation type . |
33,620 | protected void getLinkForWildcard ( Content link , LinkInfo linkInfo , Type type ) { linkInfo . isTypeBound = true ; link . addContent ( "?" ) ; final WildcardType wildcardType = type . asWildcardType ( ) ; final Type [ ] extendsBounds = wildcardType . extendsBounds ( ) ; final SARLFeatureAccess kw = Utils . getKeywords ( ) ; for ( int i = 0 ; i < extendsBounds . length ; i ++ ) { link . addContent ( i > 0 ? kw . getCommaKeyword ( ) + " " : " " + kw . getExtendsKeyword ( ) + " " ) ; setBoundsLinkInfo ( linkInfo , extendsBounds [ i ] ) ; link . addContent ( getLink ( linkInfo ) ) ; } final Type [ ] superBounds = wildcardType . superBounds ( ) ; for ( int i = 0 ; i < superBounds . length ; i ++ ) { link . addContent ( i > 0 ? kw . getCommaKeyword ( ) + " " : " " + kw . getSuperKeyword ( ) + " " ) ; setBoundsLinkInfo ( linkInfo , superBounds [ i ] ) ; link . addContent ( getLink ( linkInfo ) ) ; } } | Build the link for the wildcard . |
33,621 | protected void getLinkForTypeVariable ( Content link , LinkInfo linkInfo , Type type ) { link . addContent ( getTypeAnnotationLinks ( linkInfo ) ) ; linkInfo . isTypeBound = true ; final Doc owner = type . asTypeVariable ( ) . owner ( ) ; if ( ( ! linkInfo . excludeTypeParameterLinks ) && owner instanceof ClassDoc ) { linkInfo . classDoc = ( ClassDoc ) owner ; final Content label = newContent ( ) ; label . addContent ( type . typeName ( ) ) ; linkInfo . label = label ; link . addContent ( getClassLink ( linkInfo ) ) ; } else { link . addContent ( type . typeName ( ) ) ; } final Type [ ] bounds = type . asTypeVariable ( ) . bounds ( ) ; if ( ! linkInfo . excludeTypeBounds ) { linkInfo . excludeTypeBounds = true ; final SARLFeatureAccess kw = Utils . getKeywords ( ) ; for ( int i = 0 ; i < bounds . length ; ++ i ) { link . addContent ( i > 0 ? " " + kw . getAmpersandKeyword ( ) + " " : " " + kw . getExtendsKeyword ( ) + " " ) ; setBoundsLinkInfo ( linkInfo , bounds [ i ] ) ; link . addContent ( getLink ( linkInfo ) ) ; } } } | Build the link for the type variable . |
33,622 | protected void setBoundsLinkInfo ( LinkInfo linkInfo , Type bound ) { Reflect . callProc ( this , LinkFactory . class , "setBoundsLinkInfo" , new Class < ? > [ ] { LinkInfo . class , Type . class } , linkInfo , bound ) ; } | Change the bounds into the link info . |
33,623 | protected Content getLinkForClass ( Content link , LinkInfo linkInfo , Type type ) { if ( linkInfo . isTypeBound && linkInfo . excludeTypeBoundsLinks ) { link . addContent ( type . typeName ( ) ) ; link . addContent ( getTypeParameterLinks ( linkInfo ) ) ; return null ; } linkInfo . classDoc = type . asClassDoc ( ) ; final Content nlink = newContent ( ) ; nlink . addContent ( getClassLink ( linkInfo ) ) ; if ( linkInfo . includeTypeAsSepLink ) { nlink . addContent ( getTypeParameterLinks ( linkInfo , false ) ) ; } return nlink ; } | Build the link for the class . |
33,624 | protected void updateLinkLabel ( LinkInfo linkInfo ) { if ( linkInfo . type != null && linkInfo instanceof LinkInfoImpl ) { final LinkInfoImpl impl = ( LinkInfoImpl ) linkInfo ; final ClassDoc classdoc = linkInfo . type . asClassDoc ( ) ; if ( classdoc != null ) { final SARLFeatureAccess kw = Utils . getKeywords ( ) ; final String name = classdoc . qualifiedName ( ) ; if ( isPrefix ( name , kw . getProceduresName ( ) ) ) { linkInfo . label = createProcedureLambdaLabel ( impl ) ; } else if ( isPrefix ( name , kw . getFunctionsName ( ) ) ) { linkInfo . label = createFunctionLambdaLabel ( impl ) ; } } } } | Update the label of the given link with the SARL notation for lambdas . |
33,625 | protected Content createProcedureLambdaLabel ( LinkInfoImpl linkInfo ) { final ParameterizedType type = linkInfo . type . asParameterizedType ( ) ; if ( type != null ) { final Type [ ] arguments = type . typeArguments ( ) ; if ( arguments != null && arguments . length > 0 ) { return createLambdaLabel ( linkInfo , arguments , arguments . length ) ; } } return linkInfo . label ; } | Create the label for a procedure lambda . |
33,626 | @ SuppressWarnings ( "static-method" ) public CompilerCommand provideSarlcCompilerCommand ( Provider < SarlBatchCompiler > compiler , Provider < SarlConfig > configuration , Provider < PathDetector > pathDetector , Provider < ProgressBarConfig > commandConfig ) { return new CompilerCommand ( compiler , configuration , pathDetector , commandConfig ) ; } | Provide the command for running the compiler . |
33,627 | @ SuppressWarnings ( "static-method" ) public ProgressBarConfig getProgressBarConfig ( ConfigurationFactory configFactory , Injector injector ) { final ProgressBarConfig config = ProgressBarConfig . getConfiguration ( configFactory ) ; injector . injectMembers ( config ) ; return config ; } | Replies the instance of the compiler command configuration . |
33,628 | public static JvmType filterActiveProcessorType ( JvmType type , CommonTypeComputationServices services ) { if ( AccessorsProcessor . class . getName ( ) . equals ( type . getQualifiedName ( ) ) ) { return services . getTypeReferences ( ) . findDeclaredType ( SarlAccessorsProcessor . class , type ) ; } return type ; } | Filter the type in order to create the correct processor . |
33,629 | public ImageDescriptor forAgent ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . AGENT , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the agents . |
33,630 | public ImageDescriptor forBehavior ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . BEHAVIOR , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the behaviors . |
33,631 | public ImageDescriptor forCapacity ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . CAPACITY , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the capacities . |
33,632 | public ImageDescriptor forSkill ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . SKILL , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the skills . |
33,633 | public ImageDescriptor forEvent ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . EVENT , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the events . |
33,634 | public ImageDescriptor forBehaviorUnit ( ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . BEHAVIOR_UNIT , false , false , toFlags ( JvmVisibility . PUBLIC ) , USE_LIGHT_ICONS ) , 0 ) ; } | Replies the image descriptor for the behavior units . |
33,635 | public ImageDescriptor forStaticConstructor ( ) { return getDecorated ( getMethodImageDescriptor ( false , toFlags ( JvmVisibility . PUBLIC ) ) , JavaElementImageDescriptor . CONSTRUCTOR | JavaElementImageDescriptor . STATIC ) ; } | Replies the image descriptor for the static constructors . |
33,636 | public static URL getPomTemplateLocation ( ) { final URL url = Resources . getResource ( NewSarlProjectWizard . class , POM_TEMPLATE_BASENAME ) ; assert url != null ; return url ; } | Replies the location of a template for the pom files . |
33,637 | protected boolean validateSARLSpecificElements ( IJavaProject javaProject ) { final IPath outputPath = SARLPreferences . getSARLOutputPathFor ( javaProject . getProject ( ) ) ; if ( outputPath == null ) { final String message = MessageFormat . format ( Messages . BuildSettingWizardPage_0 , SARLConfig . FOLDER_SOURCE_GENERATED ) ; final IStatus status = SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , message ) ; handleFinishException ( getShell ( ) , new InvocationTargetException ( new CoreException ( status ) ) ) ; return false ; } if ( ! hasSourcePath ( javaProject , outputPath ) ) { final String message = MessageFormat . format ( Messages . SARLProjectCreationWizard_0 , toOSString ( outputPath ) , buildInvalidOutputPathMessageFragment ( javaProject ) ) ; final IStatus status = SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , message ) ; handleFinishException ( getShell ( ) , new InvocationTargetException ( new CoreException ( status ) ) ) ; return false ; } return true ; } | Validate the SARL properties of the new projects . |
33,638 | protected void createDefaultMavenPom ( IJavaProject project , String compilerCompliance ) { final URL templateUrl = getPomTemplateLocation ( ) ; if ( templateUrl != null ) { final String compliance = Strings . isNullOrEmpty ( compilerCompliance ) ? SARLVersion . MINIMAL_JDK_VERSION : compilerCompliance ; final String groupId = getDefaultMavenGroupId ( ) ; final StringBuilder content = new StringBuilder ( ) ; try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( templateUrl . openStream ( ) ) ) ) { String line = reader . readLine ( ) ; while ( line != null ) { line = line . replaceAll ( Pattern . quote ( "@GROUP_ID@" ) , groupId ) ; line = line . replaceAll ( Pattern . quote ( "@PROJECT_NAME@" ) , project . getElementName ( ) ) ; line = line . replaceAll ( Pattern . quote ( "@PROJECT_VERSION@" ) , DEFAULT_MAVEN_PROJECT_VERSION ) ; line = line . replaceAll ( Pattern . quote ( "@SARL_VERSION@" ) , SARLVersion . SARL_RELEASE_VERSION_MAVEN ) ; line = line . replaceAll ( Pattern . quote ( "@JAVA_VERSION@" ) , compliance ) ; line = line . replaceAll ( Pattern . quote ( "@FILE_ENCODING@" ) , Charset . defaultCharset ( ) . displayName ( ) ) ; content . append ( line ) . append ( "\n" ) ; line = reader . readLine ( ) ; } } catch ( IOException exception ) { throw new RuntimeIOException ( exception ) ; } final IFile pomFile = project . getProject ( ) . getFile ( "pom.xml" ) ; try ( StringInputStream is = new StringInputStream ( content . toString ( ) ) ) { pomFile . create ( is , true , new NullProgressMonitor ( ) ) ; } catch ( CoreException exception ) { throw new RuntimeException ( exception ) ; } catch ( IOException exception ) { throw new RuntimeIOException ( exception ) ; } } } | Create the default Maven pom file for the project . |
33,639 | @ SuppressWarnings ( "static-method" ) protected String getDefaultMavenGroupId ( ) { final String userdomain = System . getenv ( "userdomain" ) ; if ( Strings . isNullOrEmpty ( userdomain ) ) { return "com.foo" ; } final String [ ] elements = userdomain . split ( Pattern . quote ( "." ) ) ; final StringBuilder groupId = new StringBuilder ( ) ; for ( int i = elements . length - 1 ; i >= 0 ; -- i ) { if ( groupId . length ( ) > 0 ) { groupId . append ( "." ) ; } groupId . append ( elements [ i ] ) ; } return groupId . toString ( ) ; } | Replies the default group id for a maven project . |
33,640 | IWorkbenchPart getActivePart ( ) { final IWorkbenchWindow activeWindow = getWorkbench ( ) . getActiveWorkbenchWindow ( ) ; if ( activeWindow != null ) { final IWorkbenchPage activePage = activeWindow . getActivePage ( ) ; if ( activePage != null ) { return activePage . getActivePart ( ) ; } } return null ; } | Replies the active part in the workbench . |
33,641 | public static String getCurrentClasspath ( ) { final StringBuilder path = new StringBuilder ( ) ; for ( final URL url : getCurrentClassLoader ( ) . getURLs ( ) ) { if ( path . length ( ) > 0 ) { path . append ( File . pathSeparator ) ; } final File file = FileSystem . convertURLToFile ( url ) ; if ( file != null ) { path . append ( file . getAbsolutePath ( ) ) ; } } return path . toString ( ) ; } | Replies the current class path . |
33,642 | private static URLClassLoader getCurrentClassLoader ( ) { synchronized ( Boot . class ) { if ( dynamicClassLoader == null ) { final ClassLoader cl = ClassLoader . getSystemClassLoader ( ) ; if ( cl instanceof URLClassLoader ) { dynamicClassLoader = ( URLClassLoader ) cl ; } else { dynamicClassLoader = URLClassLoader . newInstance ( new URL [ 0 ] , cl ) ; } } return dynamicClassLoader ; } } | Replies the current class loader . |
33,643 | @ SuppressWarnings ( "checkstyle:nestedifdepth" ) public static void addToSystemClasspath ( String entries ) { if ( ! Strings . isNullOrEmpty ( entries ) ) { final List < URL > cp = new ArrayList < > ( ) ; final String [ ] individualEntries = entries . split ( Pattern . quote ( File . pathSeparator ) ) ; for ( final String entry : individualEntries ) { if ( ! Strings . isNullOrEmpty ( entry ) ) { URL url = FileSystem . convertStringToURL ( entry , false ) ; if ( url != null ) { if ( URISchemeType . FILE . isURL ( url ) ) { final File file = FileSystem . convertURLToFile ( url ) ; if ( file != null && file . isDirectory ( ) ) { try { url = new URL ( URISchemeType . FILE . name ( ) , "" , file . getAbsolutePath ( ) + "/" ) ; } catch ( MalformedURLException e ) { } } } cp . add ( url ) ; } } } final URL [ ] newcp = new URL [ cp . size ( ) ] ; cp . toArray ( newcp ) ; synchronized ( Boot . class ) { dynamicClassLoader = URLClassLoader . newInstance ( newcp , ClassLoader . getSystemClassLoader ( ) ) ; } } } | Add the given entries to the system classpath . |
33,644 | public static void main ( String [ ] args ) { try { Object [ ] freeArgs = parseCommandLine ( args ) ; if ( JanusConfig . getSystemPropertyAsBoolean ( JanusConfig . JANUS_LOGO_SHOW_NAME , JanusConfig . JANUS_LOGO_SHOW . booleanValue ( ) ) ) { showJanusLogo ( ) ; } if ( freeArgs . length == 0 ) { showError ( Messages . Boot_3 , null ) ; return ; } final String agentToLaunch = freeArgs [ 0 ] . toString ( ) ; freeArgs = Arrays . copyOfRange ( freeArgs , 1 , freeArgs . length , String [ ] . class ) ; final Class < ? extends Agent > agent = loadAgentClass ( agentToLaunch ) ; assert agent != null ; startJanus ( agent , freeArgs ) ; } catch ( EarlyExitException exception ) { return ; } catch ( Throwable e ) { showError ( MessageFormat . format ( Messages . Boot_4 , e . getLocalizedMessage ( ) ) , e ) ; return ; } } | Main function that is parsing the command line and launching the first agent . |
33,645 | public static Options getOptions ( ) { final Options options = new Options ( ) ; options . addOption ( CLI_OPTION_CLASSPATH_SHORT , CLI_OPTION_CLASSPATH_LONG , true , Messages . Boot_24 ) ; options . addOption ( CLI_OPTION_EMBEDDED_SHORT , CLI_OPTION_EMBEDDED_LONG , false , Messages . Boot_5 ) ; options . addOption ( CLI_OPTION_BOOTID_SHORT , CLI_OPTION_BOOTID_LONG , false , MessageFormat . format ( Messages . Boot_6 , JanusConfig . BOOT_DEFAULT_CONTEXT_ID_NAME , JanusConfig . RANDOM_DEFAULT_CONTEXT_ID_NAME ) ) ; options . addOption ( CLI_OPTION_FILE_SHORT , CLI_OPTION_FILE_LONG , true , Messages . Boot_7 ) ; options . addOption ( CLI_OPTION_HELP_SHORT , CLI_OPTION_HELP_LONG , false , Messages . Boot_8 ) ; options . addOption ( null , CLI_OPTION_NOLOGO_LONG , false , Messages . Boot_9 ) ; options . addOption ( CLI_OPTION_OFFLINE_SHORT , CLI_OPTION_OFFLINE_LONG , false , MessageFormat . format ( Messages . Boot_10 , JanusConfig . OFFLINE ) ) ; options . addOption ( CLI_OPTION_QUIET_SHORT , CLI_OPTION_QUIET_LONG , false , Messages . Boot_11 ) ; options . addOption ( CLI_OPTION_RANDOMID_SHORT , CLI_OPTION_RANDOMID_LONG , false , MessageFormat . format ( Messages . Boot_12 , JanusConfig . BOOT_DEFAULT_CONTEXT_ID_NAME , JanusConfig . RANDOM_DEFAULT_CONTEXT_ID_NAME ) ) ; options . addOption ( CLI_OPTION_SHOWDEFAULTS_SHORT , CLI_OPTION_SHOWDEFAULTS_LONG , false , Messages . Boot_13 ) ; options . addOption ( CLI_OPTION_SHOWCLASSPATH , false , Messages . Boot_23 ) ; options . addOption ( null , CLI_OPTION_SHOWCLIARGUMENTS_LONG , false , Messages . Boot_14 ) ; options . addOption ( CLI_OPTION_VERBOSE_SHORT , CLI_OPTION_VERBOSE_LONG , false , Messages . Boot_15 ) ; options . addOption ( CLI_OPTION_VERSION , false , Messages . Boot_25 ) ; options . addOption ( CLI_OPTION_WORLDID_SHORT , CLI_OPTION_WORLDID_LONG , false , MessageFormat . format ( Messages . Boot_16 , JanusConfig . BOOT_DEFAULT_CONTEXT_ID_NAME , JanusConfig . RANDOM_DEFAULT_CONTEXT_ID_NAME ) ) ; final StringBuilder b = new StringBuilder ( ) ; int level = 0 ; for ( final String logLevel : LoggerCreator . getLevelStrings ( ) ) { if ( b . length ( ) > 0 ) { b . append ( ", " ) ; } b . append ( logLevel ) ; b . append ( " (" ) ; b . append ( level ) ; b . append ( ")" ) ; ++ level ; } Option opt = new Option ( CLI_OPTION_LOG_SHORT , CLI_OPTION_LOG_LONG , true , MessageFormat . format ( Messages . Boot_17 , JanusConfig . VERBOSE_LEVEL_VALUE , b ) ) ; opt . setArgs ( 1 ) ; options . addOption ( opt ) ; opt = new Option ( CLI_OPTION_DEFINE_SHORT , CLI_OPTION_DEFINE_LONG , true , Messages . Boot_18 ) ; opt . setArgs ( 2 ) ; opt . setValueSeparator ( '=' ) ; opt . setArgName ( Messages . Boot_19 ) ; options . addOption ( opt ) ; return options ; } | Replies the command line options supported by this boot class . |
33,646 | @ SuppressWarnings ( "checkstyle:regexp" ) public static void showError ( String message , Throwable exception ) { try ( PrintWriter logger = new PrintWriter ( getConsoleLogger ( ) ) ) { if ( message != null && ! message . isEmpty ( ) ) { logger . println ( message ) ; } else if ( exception != null ) { exception . printStackTrace ( logger ) ; } logger . println ( ) ; logger . flush ( ) ; showHelp ( logger , false ) ; showVersion ( true ) ; } } | Show an error message and exit . |
33,647 | public static String getProgramName ( ) { String programName = JanusConfig . getSystemProperty ( JanusConfig . JANUS_PROGRAM_NAME , null ) ; if ( Strings . isNullOrEmpty ( programName ) ) { programName = JanusConfig . JANUS_PROGRAM_NAME_VALUE ; } return programName ; } | Replies the name of the program . |
33,648 | @ SuppressWarnings ( "checkstyle:regexp" ) public static void showDefaults ( ) { final Properties defaultValues = new Properties ( ) ; JanusConfig . getDefaultValues ( defaultValues ) ; NetworkConfig . getDefaultValues ( defaultValues ) ; try ( OutputStream os = getConsoleLogger ( ) ) { defaultValues . storeToXML ( os , null ) ; os . flush ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } getExiter ( ) . exit ( ) ; } | Show the default values of the system properties . This function never returns . |
33,649 | @ SuppressWarnings ( { "resource" } ) public static void showClasspath ( ) { final String cp = getCurrentClasspath ( ) ; if ( ! Strings . isNullOrEmpty ( cp ) ) { final PrintStream ps = getConsoleLogger ( ) ; for ( final String entry : cp . split ( Pattern . quote ( File . pathSeparator ) ) ) { ps . println ( entry ) ; } ps . flush ( ) ; } getExiter ( ) . exit ( ) ; } | Show the classpath of the system properties . This function never returns . |
33,650 | public static void showVersion ( boolean exit ) { try ( PrintWriter logger = new PrintWriter ( getConsoleLogger ( ) ) ) { logger . println ( MessageFormat . format ( Messages . Boot_26 , JanusVersion . JANUS_RELEASE_VERSION ) ) ; logger . println ( MessageFormat . format ( Messages . Boot_27 , SARLVersion . SPECIFICATION_RELEASE_VERSION_STRING ) ) ; logger . flush ( ) ; } if ( exit ) { getExiter ( ) . exit ( ) ; } } | Show the version of Janus . |
33,651 | @ SuppressWarnings ( "checkstyle:regexp" ) public static void showCommandLineArguments ( String [ ] args ) { try ( PrintStream os = getConsoleLogger ( ) ) { for ( int i = 0 ; i < args . length ; ++ i ) { os . println ( i + ": " + args [ i ] ) ; } os . flush ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } getExiter ( ) . exit ( ) ; } | Show the command line arguments . This function never returns . |
33,652 | public static void setBootAgentTypeContextUUID ( ) { System . setProperty ( JanusConfig . BOOT_DEFAULT_CONTEXT_ID_NAME , Boolean . TRUE . toString ( ) ) ; System . setProperty ( JanusConfig . RANDOM_DEFAULT_CONTEXT_ID_NAME , Boolean . FALSE . toString ( ) ) ; } | Force the Janus platform to use a default context identifier that tis build upon the classname of the boot agent . It means that the UUID is always the same for a given classname . |
33,653 | public static void setDefaultContextUUID ( ) { System . setProperty ( JanusConfig . BOOT_DEFAULT_CONTEXT_ID_NAME , Boolean . FALSE . toString ( ) ) ; System . setProperty ( JanusConfig . RANDOM_DEFAULT_CONTEXT_ID_NAME , Boolean . FALSE . toString ( ) ) ; } | Force the Janus platform to use the identifier hard - coded in the source code for its default context . |
33,654 | public static Integer getSarlClassification ( ProgramElementDoc type ) { final AnnotationDesc annotation = Utils . findFirst ( type . annotations ( ) , it -> qualifiedNameEquals ( it . annotationType ( ) . qualifiedTypeName ( ) , getKeywords ( ) . getSarlElementTypeAnnotationName ( ) ) ) ; if ( annotation != null ) { final ElementValuePair [ ] pairs = annotation . elementValues ( ) ; if ( pairs != null && pairs . length > 0 ) { return ( ( Number ) pairs [ 0 ] . value ( ) . value ( ) ) . intValue ( ) ; } } return null ; } | Replies the SARL element type of the given type . |
33,655 | public static String fixHiddenMember ( String name ) { return name . replaceAll ( Pattern . quote ( HIDDEN_MEMBER_CHARACTER ) , Matcher . quoteReplacement ( HIDDEN_MEMBER_REPLACEMENT_CHARACTER ) ) ; } | Replies a fixed version of the given name assuming that it is an hidden action and reformating the reserved text . |
33,656 | public static boolean qualifiedNameEquals ( String s1 , String s2 ) { if ( isNullOrEmpty ( s1 ) ) { return isNullOrEmpty ( s2 ) ; } if ( ! s1 . equals ( s2 ) ) { final String simple1 = simpleName ( s1 ) ; final String simple2 = simpleName ( s2 ) ; return simpleNameEquals ( simple1 , simple2 ) ; } return true ; } | Replies if the given qualified names are equal . |
33,657 | public static String simpleName ( String name ) { if ( name == null ) { return null ; } final int index = name . lastIndexOf ( '.' ) ; if ( index > 0 ) { return name . substring ( index + 1 ) ; } return name ; } | Replies the simple name for the given name . |
33,658 | public static Throwable getCause ( Throwable thr ) { Throwable cause = thr . getCause ( ) ; while ( cause != null && cause != thr && cause != cause . getCause ( ) && cause . getCause ( ) != null ) { cause = cause . getCause ( ) ; } return cause == null ? thr : cause ; } | Replies the cause of the given exception . |
33,659 | public static void performCopy ( String filename , SarlConfiguration configuration ) { if ( filename . isEmpty ( ) ) { return ; } try { final DocFile fromfile = DocFile . createFileForInput ( configuration , filename ) ; final DocPath path = DocPath . create ( fromfile . getName ( ) ) ; final DocFile toFile = DocFile . createFileForOutput ( configuration , path ) ; if ( toFile . isSameFile ( fromfile ) ) { return ; } configuration . message . notice ( ( SourcePosition ) null , "doclet.Copying_File_0_To_File_1" , fromfile . toString ( ) , path . getPath ( ) ) ; toFile . copyFile ( fromfile ) ; } catch ( IOException exc ) { configuration . message . error ( ( SourcePosition ) null , "doclet.perform_copy_exception_encountered" , exc . toString ( ) ) ; throw new DocletAbortException ( exc ) ; } } | Copy the given file . |
33,660 | public static < T > com . sun . tools . javac . util . List < T > emptyList ( ) { return com . sun . tools . javac . util . List . from ( Collections . emptyList ( ) ) ; } | Create an empty Java list . |
33,661 | @ SuppressWarnings ( "unchecked" ) public static < T > T [ ] toArray ( T [ ] source , Collection < ? extends T > newContent ) { final Object array = Array . newInstance ( source . getClass ( ) . getComponentType ( ) , newContent . size ( ) ) ; int i = 0 ; for ( final T element : newContent ) { Array . set ( array , i , element ) ; ++ i ; } return ( T [ ] ) array ; } | Convert to an array . |
33,662 | protected IPreferenceStoreAccess getPreferenceStoreAccess ( ) { if ( this . preferenceStoreAccess == null ) { final Injector injector = LangActivator . getInstance ( ) . getInjector ( LangActivator . IO_SARL_LANG_SARL ) ; this . preferenceStoreAccess = injector . getInstance ( IPreferenceStoreAccess . class ) ; } return this . preferenceStoreAccess ; } | Replies the preference accessor . |
33,663 | public IPreferenceStore getWritablePreferenceStore ( Object context ) { if ( this . preferenceStore == null ) { this . preferenceStore = getPreferenceStoreAccess ( ) . getWritablePreferenceStore ( context ) ; } return this . preferenceStore ; } | Replies the writable preference store to be used for the SARL editor . |
33,664 | public static String getSystemProperty ( String name , String defaultValue ) { String value ; value = System . getProperty ( name , null ) ; if ( value != null ) { return value ; } value = System . getenv ( name ) ; if ( value != null ) { return value ; } return defaultValue ; } | Replies the value of the system property . |
33,665 | public static boolean getSystemPropertyAsBoolean ( String name , boolean defaultValue ) { final String value = getSystemProperty ( name , null ) ; if ( value != null ) { try { return Boolean . parseBoolean ( value ) ; } catch ( Throwable exception ) { } } return defaultValue ; } | Replies the value of the boolean system property . |
33,666 | public static float getSystemPropertyAsFloat ( String name , float defaultValue ) { final String value = getSystemProperty ( name , null ) ; if ( value != null ) { try { return Float . parseFloat ( value ) ; } catch ( Throwable exception ) { } } return defaultValue ; } | Replies the value of the single precision floating point value system property . |
33,667 | public static < S extends Enum < S > > S getSystemPropertyAsEnum ( Class < S > type , String name ) { return getSystemPropertyAsEnum ( type , name , null ) ; } | Replies the value of the enumeration system property . |
33,668 | protected boolean isSarlFile ( IPackageFragment packageFragment , String filename ) { if ( isFileExists ( packageFragment , filename , this . sarlFileExtension ) ) { return true ; } final IJavaProject project = getPackageFragmentRoot ( ) . getJavaProject ( ) ; if ( project != null ) { try { final String packageName = packageFragment . getElementName ( ) ; for ( final IPackageFragmentRoot root : project . getPackageFragmentRoots ( ) ) { final IPackageFragment fragment = root . getPackageFragment ( packageName ) ; if ( isFileExists ( fragment , filename , JAVA_FILE_EXTENSION ) ) { return true ; } } } catch ( JavaModelException exception ) { } } return false ; } | Replies if the given filename is a SARL script or a generated Java file . |
33,669 | protected static boolean isFileExists ( IPackageFragment packageFragment , String filename , String extension ) { if ( packageFragment != null ) { final IResource resource = packageFragment . getResource ( ) ; if ( resource instanceof IFolder ) { final IFolder folder = ( IFolder ) resource ; if ( folder . getFile ( filename + "." + extension ) . exists ( ) ) { return true ; } } } return false ; } | Replies if the given filename is a SARL script in the given package . |
33,670 | protected void init ( IStructuredSelection selection ) { final IJavaElement elem = this . fieldInitializer . getSelectedResource ( selection ) ; initContainerPage ( elem ) ; initTypePage ( elem ) ; try { getRootSuperType ( ) ; reinitSuperClass ( ) ; } catch ( Throwable exception ) { } try { getRootSuperInterface ( ) ; reinitSuperInterfaces ( ) ; } catch ( Throwable exception ) { } doStatusUpdate ( ) ; } | Invoked by the wizard for initializing the page with the given selection . |
33,671 | protected Composite createCommonControls ( Composite parent ) { initializeDialogUnits ( parent ) ; final Composite composite = SWTFactory . createComposite ( parent , parent . getFont ( ) , COLUMNS , 1 , GridData . FILL_HORIZONTAL ) ; createContainerControls ( composite , COLUMNS ) ; createPackageControls ( composite , COLUMNS ) ; createSeparator ( composite , COLUMNS ) ; createTypeNameControls ( composite , COLUMNS ) ; return composite ; } | Create the components that are common to the creation of all the SARL elements . |
33,672 | protected final int asyncCreateType ( ) { final int [ ] size = { 0 } ; final IRunnableWithProgress op = new WorkspaceModifyOperation ( ) { protected void execute ( IProgressMonitor monitor ) throws CoreException , InvocationTargetException , InterruptedException { size [ 0 ] = createSARLType ( monitor ) ; } } ; try { getContainer ( ) . run ( true , false , op ) ; } catch ( InterruptedException e ) { return 0 ; } catch ( InvocationTargetException e ) { final Throwable realException = e . getTargetException ( ) ; SARLEclipsePlugin . getDefault ( ) . openError ( getShell ( ) , getTitle ( ) , realException . getMessage ( ) , realException ) ; } return size [ 0 ] ; } | Create the type from the data gathered in the wizard . |
33,673 | protected void readSettings ( ) { boolean createConstructors = false ; boolean createUnimplemented = true ; boolean createEventHandlers = true ; boolean createLifecycleFunctions = true ; final IDialogSettings dialogSettings = getDialogSettings ( ) ; if ( dialogSettings != null ) { final IDialogSettings section = dialogSettings . getSection ( getName ( ) ) ; if ( section != null ) { createConstructors = section . getBoolean ( SETTINGS_CREATECONSTR ) ; createUnimplemented = section . getBoolean ( SETTINGS_CREATEUNIMPLEMENTED ) ; createEventHandlers = section . getBoolean ( SETTINGS_GENERATEEVENTHANDLERS ) ; createLifecycleFunctions = section . getBoolean ( SETTINGS_GENERATELIFECYCLEFUNCTIONS ) ; } } setMethodStubSelection ( createConstructors , createUnimplemented , createEventHandlers , createLifecycleFunctions , true ) ; } | Read the settings of the dialog box . |
33,674 | protected void saveSettings ( ) { final IDialogSettings dialogSettings = getDialogSettings ( ) ; if ( dialogSettings != null ) { IDialogSettings section = dialogSettings . getSection ( getName ( ) ) ; if ( section == null ) { section = dialogSettings . addNewSection ( getName ( ) ) ; } section . put ( SETTINGS_CREATECONSTR , isCreateConstructors ( ) ) ; section . put ( SETTINGS_CREATEUNIMPLEMENTED , isCreateInherited ( ) ) ; section . put ( SETTINGS_GENERATEEVENTHANDLERS , isCreateStandardEventHandlers ( ) ) ; section . put ( SETTINGS_GENERATELIFECYCLEFUNCTIONS , isCreateStandardLifecycleFunctions ( ) ) ; } } | Save the settings of the dialog box . |
33,675 | protected void createMethodStubControls ( Composite composite , int columns , boolean enableConstructors , boolean enableInherited , boolean defaultEvents , boolean lifecycleFunctions ) { this . isConstructorCreationEnabled = enableConstructors ; this . isInheritedCreationEnabled = enableInherited ; this . isDefaultEventGenerated = defaultEvents ; this . isDefaultLifecycleFunctionsGenerated = lifecycleFunctions ; final List < String > nameList = new ArrayList < > ( 4 ) ; if ( enableConstructors ) { nameList . add ( Messages . AbstractNewSarlElementWizardPage_0 ) ; } if ( enableInherited ) { nameList . add ( Messages . AbstractNewSarlElementWizardPage_1 ) ; } if ( defaultEvents ) { nameList . add ( Messages . AbstractNewSarlElementWizardPage_17 ) ; } if ( lifecycleFunctions ) { nameList . add ( Messages . AbstractNewSarlElementWizardPage_18 ) ; } if ( nameList . isEmpty ( ) ) { return ; } final String [ ] buttonNames = new String [ nameList . size ( ) ] ; nameList . toArray ( buttonNames ) ; this . methodStubsButtons = new SelectionButtonDialogFieldGroup ( SWT . CHECK , buttonNames , 1 ) ; this . methodStubsButtons . setLabelText ( Messages . AbstractNewSarlElementWizardPage_2 ) ; final Control labelControl = this . methodStubsButtons . getLabelControl ( composite ) ; LayoutUtil . setHorizontalSpan ( labelControl , columns ) ; DialogField . createEmptySpace ( composite ) ; final Control buttonGroup = this . methodStubsButtons . getSelectionButtonsGroup ( composite ) ; LayoutUtil . setHorizontalSpan ( buttonGroup , columns - 1 ) ; } | Create the controls related to the behavior units to generate . |
33,676 | protected boolean isCreateStandardEventHandlers ( ) { int idx = 0 ; if ( this . isConstructorCreationEnabled ) { ++ idx ; } if ( this . isInheritedCreationEnabled ) { ++ idx ; } return this . isDefaultEventGenerated && this . methodStubsButtons . isSelected ( idx ) ; } | Returns the current selection state of the Create standard event handlers checkbox . |
33,677 | protected boolean isCreateStandardLifecycleFunctions ( ) { int idx = 0 ; if ( this . isConstructorCreationEnabled ) { ++ idx ; } if ( this . isInheritedCreationEnabled ) { ++ idx ; } if ( this . isDefaultEventGenerated ) { ++ idx ; } return this . isDefaultLifecycleFunctionsGenerated && this . methodStubsButtons . isSelected ( idx ) ; } | Returns the current selection state of the Create standard lifecycle functions checkbox . |
33,678 | protected void setMethodStubSelection ( boolean createConstructors , boolean createInherited , boolean createEventHandlers , boolean createLifecycleFunctions , boolean canBeModified ) { if ( this . methodStubsButtons != null ) { int idx = 0 ; if ( this . isConstructorCreationEnabled ) { this . methodStubsButtons . setSelection ( idx , createConstructors ) ; ++ idx ; } if ( this . isInheritedCreationEnabled ) { this . methodStubsButtons . setSelection ( idx , createInherited ) ; ++ idx ; } if ( this . isDefaultEventGenerated ) { this . methodStubsButtons . setSelection ( idx , createEventHandlers ) ; ++ idx ; } if ( this . isDefaultLifecycleFunctionsGenerated ) { this . methodStubsButtons . setSelection ( idx , createLifecycleFunctions ) ; ++ idx ; } this . methodStubsButtons . setEnabled ( canBeModified ) ; } } | Sets the selection state of the method stub checkboxes . |
33,679 | @ SuppressWarnings ( "static-method" ) protected AbstractSuperTypeSelectionDialog < ? > createSuperClassSelectionDialog ( Shell parent , IRunnableContext context , IJavaProject project , SarlSpecificTypeSelectionExtension extension , boolean multi ) { return null ; } | Create an instanceof the super - class selection dialog . |
33,680 | protected boolean createStandardSARLEventTemplates ( String elementTypeName , Function1 < ? super String , ? extends ISarlBehaviorUnitBuilder > behaviorUnitAdder , Procedure1 < ? super String > usesAdder ) { if ( ! isCreateStandardEventHandlers ( ) ) { return false ; } Object type ; try { type = getTypeFinder ( ) . findType ( INITIALIZE_EVENT_NAME ) ; } catch ( JavaModelException e ) { type = null ; } if ( type != null ) { usesAdder . apply ( LOGGING_CAPACITY_NAME ) ; ISarlBehaviorUnitBuilder unit = behaviorUnitAdder . apply ( INITIALIZE_EVENT_NAME ) ; IBlockExpressionBuilder block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_9 , elementTypeName ) ) ; IExpressionBuilder expr = block . addExpression ( ) ; createInfoCall ( expr , "The " + elementTypeName + " was started." ) ; unit = behaviorUnitAdder . apply ( DESTROY_EVENT_NAME ) ; block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_10 , elementTypeName ) ) ; expr = block . addExpression ( ) ; createInfoCall ( expr , "The " + elementTypeName + " was stopped." ) ; unit = behaviorUnitAdder . apply ( AGENTSPAWNED_EVENT_NAME ) ; block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_11 , elementTypeName ) ) ; unit = behaviorUnitAdder . apply ( AGENTKILLED_EVENT_NAME ) ; block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_12 , elementTypeName ) ) ; unit = behaviorUnitAdder . apply ( CONTEXTJOINED_EVENT_NAME ) ; block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_13 , elementTypeName ) ) ; unit = behaviorUnitAdder . apply ( CONTEXTLEFT_EVENT_NAME ) ; block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_14 , elementTypeName ) ) ; unit = behaviorUnitAdder . apply ( MEMBERJOINED_EVENT_NAME ) ; block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_15 , elementTypeName ) ) ; unit = behaviorUnitAdder . apply ( MEMBERLEFT_EVENT_NAME ) ; block = unit . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_16 , elementTypeName ) ) ; return true ; } return false ; } | Create the default standard SARL event templates . |
33,681 | protected boolean createStandardSARLLifecycleFunctionTemplates ( String elementTypeName , Function1 < ? super String , ? extends ISarlActionBuilder > actionAdder , Procedure1 < ? super String > usesAdder ) { if ( ! isCreateStandardLifecycleFunctions ( ) ) { return false ; } usesAdder . apply ( LOGGING_CAPACITY_NAME ) ; ISarlActionBuilder action = actionAdder . apply ( INSTALL_SKILL_NAME ) ; IBlockExpressionBuilder block = action . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_19 , elementTypeName ) ) ; IExpressionBuilder expr = block . addExpression ( ) ; createInfoCall ( expr , "Installing the " + elementTypeName ) ; action = actionAdder . apply ( UNINSTALL_SKILL_NAME ) ; block = action . getExpression ( ) ; block . setInnerDocumentation ( MessageFormat . format ( Messages . AbstractNewSarlElementWizardPage_20 , elementTypeName ) ) ; expr = block . addExpression ( ) ; createInfoCall ( expr , "Uninstalling the " + elementTypeName ) ; return true ; } | Create the default standard lifecycle function templates . |
33,682 | public static IProject getProject ( Resource resource ) { ProjectAdapter adapter = ( ProjectAdapter ) EcoreUtil . getAdapter ( resource . getResourceSet ( ) . eAdapters ( ) , ProjectAdapter . class ) ; if ( adapter == null ) { final String platformString = resource . getURI ( ) . toPlatformString ( true ) ; final IProject project = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( new Path ( platformString ) ) . getProject ( ) ; adapter = new ProjectAdapter ( project ) ; resource . getResourceSet ( ) . eAdapters ( ) . add ( adapter ) ; } return adapter . getProject ( ) ; } | Get the project associated to the resource . |
33,683 | protected MavenImportWizardPage getMavenImportWizardPage ( ) { if ( this . mainPageBuffer == null ) { try { final Field field = MavenImportWizard . class . getDeclaredField ( "page" ) ; field . setAccessible ( true ) ; this . mainPageBuffer = ( MavenImportWizardPage ) field . get ( this ) ; } catch ( Exception exception ) { throw new RuntimeException ( exception ) ; } } return this . mainPageBuffer ; } | Replies the main configuration page . |
33,684 | protected WorkspaceJob createImportJob ( Collection < MavenProjectInfo > projects ) { final WorkspaceJob job = new ImportMavenSarlProjectsJob ( projects , this . workingSets , this . importConfiguration ) ; job . setRule ( MavenPlugin . getProjectConfigurationManager ( ) . getRule ( ) ) ; return job ; } | Create the import job . |
33,685 | public static Version parseVersion ( String version ) { if ( ! Strings . isNullOrEmpty ( version ) ) { try { return Version . parseVersion ( version ) ; } catch ( Throwable exception ) { } } return null ; } | Null - safe version parser . |
33,686 | public static int compareVersionToRange ( Version version , Version minVersion , Version maxVersion ) { assert minVersion == null || maxVersion == null || minVersion . compareTo ( maxVersion ) < 0 ; if ( version == null ) { return Integer . MIN_VALUE ; } if ( minVersion != null && compareVersionsNoQualifier ( version , minVersion ) < 0 ) { return - 1 ; } if ( maxVersion != null && compareVersionsNoQualifier ( version , maxVersion ) >= 0 ) { return 1 ; } return 0 ; } | Null - safe compare a version number to a range of version numbers . |
33,687 | public static < T > int compareTo ( Comparable < T > object1 , T object2 ) { if ( object1 == object2 ) { return 0 ; } if ( object1 == null ) { return Integer . MIN_VALUE ; } if ( object2 == null ) { return Integer . MAX_VALUE ; } assert object1 != null && object2 != null ; return object1 . compareTo ( object2 ) ; } | Null - safe comparison . |
33,688 | public static String getNameWithTypeParameters ( IType type ) { assert type != null ; final String superName = type . getFullyQualifiedName ( '.' ) ; if ( ! JavaModelUtil . is50OrHigher ( type . getJavaProject ( ) ) ) { return superName ; } try { final ITypeParameter [ ] typeParameters = type . getTypeParameters ( ) ; if ( typeParameters != null && typeParameters . length > 0 ) { final StringBuffer buf = new StringBuffer ( superName ) ; buf . append ( '<' ) ; for ( int k = 0 ; k < typeParameters . length ; ++ k ) { if ( k != 0 ) { buf . append ( ',' ) . append ( ' ' ) ; } buf . append ( typeParameters [ k ] . getElementName ( ) ) ; } buf . append ( '>' ) ; return buf . toString ( ) ; } } catch ( JavaModelException e ) { } return superName ; } | Replies the fully qualified name with generic parameters . |
33,689 | public static IClasspathEntry newLibraryEntry ( Bundle bundle , IPath precomputedBundlePath , BundleURLMappings javadocURLs ) { assert bundle != null ; final IPath bundlePath ; if ( precomputedBundlePath == null ) { bundlePath = BundleUtil . getBundlePath ( bundle ) ; } else { bundlePath = precomputedBundlePath ; } final IPath sourceBundlePath = BundleUtil . getSourceBundlePath ( bundle , bundlePath ) ; final IPath javadocPath = BundleUtil . getJavadocBundlePath ( bundle , bundlePath ) ; final IClasspathAttribute [ ] extraAttributes ; if ( javadocPath == null ) { if ( javadocURLs != null ) { final String url = javadocURLs . getURLForBundle ( bundle ) ; if ( ! Strings . isNullOrEmpty ( url ) ) { final IClasspathAttribute attr = JavaCore . newClasspathAttribute ( IClasspathAttribute . JAVADOC_LOCATION_ATTRIBUTE_NAME , url ) ; extraAttributes = new IClasspathAttribute [ ] { attr } ; } else { extraAttributes = ClasspathEntry . NO_EXTRA_ATTRIBUTES ; } } else { extraAttributes = ClasspathEntry . NO_EXTRA_ATTRIBUTES ; } } else { final IClasspathAttribute attr = JavaCore . newClasspathAttribute ( IClasspathAttribute . JAVADOC_LOCATION_ATTRIBUTE_NAME , javadocPath . makeAbsolute ( ) . toOSString ( ) ) ; extraAttributes = new IClasspathAttribute [ ] { attr } ; } return JavaCore . newLibraryEntry ( bundlePath , sourceBundlePath , null , null , extraAttributes , false ) ; } | Create the classpath library linked to the bundle with the given name . |
33,690 | @ SuppressWarnings ( "static-method" ) protected BQRuntime createRuntime ( String ... args ) { SARLStandaloneSetup . doPreSetup ( ) ; final BQRuntime runtime = Bootique . app ( args ) . autoLoadModules ( ) . createRuntime ( ) ; SARLStandaloneSetup . doPostSetup ( runtime . getInstance ( Injector . class ) ) ; return runtime ; } | Create the compiler runtime . |
33,691 | public int runCompiler ( String ... args ) { try { final BQRuntime runtime = createRuntime ( args ) ; final CommandOutcome outcome = runtime . run ( ) ; if ( ! outcome . isSuccess ( ) && outcome . getException ( ) != null ) { Logger . getRootLogger ( ) . error ( outcome . getMessage ( ) , outcome . getException ( ) ) ; } return outcome . getExitCode ( ) ; } catch ( ProvisionException exception ) { final Throwable ex = Throwables . getRootCause ( exception ) ; if ( ex != null ) { Logger . getRootLogger ( ) . error ( ex . getLocalizedMessage ( ) ) ; } else { Logger . getRootLogger ( ) . error ( exception . getLocalizedMessage ( ) ) ; } } catch ( Throwable exception ) { Logger . getRootLogger ( ) . error ( exception . getLocalizedMessage ( ) ) ; } return Constants . ERROR_CODE ; } | Run the batch compiler . |
33,692 | public List < HelpOption > getOptions ( ) { final BQRuntime runtime = createRuntime ( ) ; final ApplicationMetadata application = runtime . getInstance ( ApplicationMetadata . class ) ; final HelpOptions helpOptions = new HelpOptions ( ) ; application . getCommands ( ) . forEach ( c -> { helpOptions . add ( c . asOption ( ) ) ; c . getOptions ( ) . forEach ( o -> helpOptions . add ( o ) ) ; } ) ; application . getOptions ( ) . forEach ( o -> helpOptions . add ( o ) ) ; return helpOptions . getOptions ( ) ; } | Replies the options of the program . |
33,693 | protected void addAnnotations ( ExecutableMemberDoc member , Content htmlTree ) { WriterUtils . addAnnotations ( member , htmlTree , this . configuration , this . writer ) ; } | Add annotations except the reserved annotations . |
33,694 | public static void setCurrentPreferenceKey ( String key ) { LOCK . lock ( ) ; try { currentPreferenceKey = ( Strings . isNullOrEmpty ( key ) ) ? DEFAULT_PREFERENCE_KEY : key ; } finally { LOCK . unlock ( ) ; } } | Change the key used for storing the SARL runtime configuration into the preferences . |
33,695 | public static void fireSREChanged ( PropertyChangeEvent event ) { for ( final Object listener : SRE_LISTENERS . getListeners ( ) ) { ( ( ISREInstallChangedListener ) listener ) . sreChanged ( event ) ; } } | Notifies all SRE install changed listeners of the given property change . |
33,696 | public static void fireSREAdded ( ISREInstall installation ) { for ( final Object listener : SRE_LISTENERS . getListeners ( ) ) { ( ( ISREInstallChangedListener ) listener ) . sreAdded ( installation ) ; } } | Notifies all SRE install changed listeners of the addition of a SRE . |
33,697 | public static void fireSRERemoved ( ISREInstall installation ) { for ( final Object listener : SRE_LISTENERS . getListeners ( ) ) { ( ( ISREInstallChangedListener ) listener ) . sreRemoved ( installation ) ; } } | Notifies all SRE install changed listeners of the removed of a SRE . |
33,698 | public static ISREInstall getSREFromId ( String id ) { if ( Strings . isNullOrEmpty ( id ) ) { return null ; } initializeSREs ( ) ; LOCK . lock ( ) ; try { return ALL_SRE_INSTALLS . get ( id ) ; } finally { LOCK . unlock ( ) ; } } | Return the SRE corresponding to the specified Id . |
33,699 | @ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static void setSREInstalls ( ISREInstall [ ] sres , IProgressMonitor monitor ) throws CoreException { final SubMonitor mon = SubMonitor . convert ( monitor , io . sarl . eclipse . runtime . Messages . SARLRuntime_0 , sres . length * 2 + ALL_SRE_INSTALLS . size ( ) ) ; initializeSREs ( ) ; final String oldDefaultId ; String newDefaultId ; final List < ISREInstall > newElements = new ArrayList < > ( ) ; final Map < String , ISREInstall > allKeys ; LOCK . lock ( ) ; try { oldDefaultId = getDefaultSREId ( ) ; newDefaultId = oldDefaultId ; allKeys = new TreeMap < > ( ALL_SRE_INSTALLS ) ; for ( final ISREInstall sre : sres ) { if ( allKeys . remove ( sre . getId ( ) ) == null ) { newElements . add ( sre ) ; ALL_SRE_INSTALLS . put ( sre . getId ( ) , sre ) ; } mon . worked ( 1 ) ; } for ( final ISREInstall sre : allKeys . values ( ) ) { ALL_SRE_INSTALLS . remove ( sre . getId ( ) ) ; platformSREInstalls . remove ( sre . getId ( ) ) ; mon . worked ( 1 ) ; } if ( oldDefaultId != null && ! ALL_SRE_INSTALLS . containsKey ( oldDefaultId ) ) { newDefaultId = null ; } } finally { LOCK . unlock ( ) ; } boolean changed = false ; mon . subTask ( io . sarl . eclipse . runtime . Messages . SARLRuntime_1 ) ; if ( oldDefaultId != null && newDefaultId == null ) { changed = true ; setDefaultSREInstall ( null , monitor ) ; } mon . worked ( 1 ) ; mon . subTask ( io . sarl . eclipse . runtime . Messages . SARLRuntime_2 ) ; for ( final ISREInstall sre : allKeys . values ( ) ) { changed = true ; fireSRERemoved ( sre ) ; } for ( final ISREInstall sre : newElements ) { changed = true ; fireSREAdded ( sre ) ; } mon . worked ( 1 ) ; if ( changed ) { saveSREConfiguration ( mon . newChild ( sres . length - 2 ) ) ; } } | Sets the installed SREs . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.