idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
34,100 | @ Check public void checkBreakKeywordUse ( SarlBreakExpression expression ) { final EObject container = Utils . getFirstContainerForPredicate ( expression , it -> ! ( it instanceof XExpression ) || it instanceof XAbstractWhileExpression || it instanceof XBasicForLoopExpression || it instanceof XForLoopExpression ) ; if ( container instanceof XExpression ) { if ( ! isIgnored ( DISCOURAGED_LOOP_BREAKING_KEYWORD_USE ) && container instanceof XBasicForLoopExpression ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_17 , this . grammarAccess . getBreakKeyword ( ) ) , expression , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , DISCOURAGED_LOOP_BREAKING_KEYWORD_USE ) ; } } else { error ( MessageFormat . format ( Messages . SARLValidator_18 , this . grammarAccess . getBreakKeyword ( ) ) , expression , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_USE_OF_LOOP_BREAKING_KEYWORD ) ; } } | Check for usage of break inside loops . | 262 | 8 |
34,101 | @ Check public void checkStaticConstructorPrototype ( XtendConstructor constructor ) { if ( constructor . isStatic ( ) ) { if ( ! constructor . getAnnotations ( ) . isEmpty ( ) ) { error ( Messages . SARLValidator_23 , constructor , XtendPackage . eINSTANCE . getXtendAnnotationTarget_Annotations ( ) , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , ANNOTATION_WRONG_TARGET ) ; } if ( ! constructor . getTypeParameters ( ) . isEmpty ( ) ) { error ( Messages . SARLValidator_24 , constructor , XtendPackage . eINSTANCE . getXtendExecutable_TypeParameters ( ) , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , CONSTRUCTOR_TYPE_PARAMS_NOT_SUPPORTED ) ; } if ( ! constructor . getParameters ( ) . isEmpty ( ) ) { error ( Messages . SARLValidator_26 , constructor , XtendPackage . eINSTANCE . getXtendExecutable_Parameters ( ) , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , UNEXPECTED_FORMAL_PARAMETER ) ; } if ( ! constructor . getExceptions ( ) . isEmpty ( ) ) { error ( Messages . SARLValidator_27 , constructor , XtendPackage . eINSTANCE . getXtendExecutable_Parameters ( ) , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , UNEXPECTED_EXCEPTION_THROW ) ; } if ( constructor . getExpression ( ) == null ) { error ( Messages . SARLValidator_83 , constructor , XtendPackage . eINSTANCE . getXtendExecutable_Expression ( ) , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , MISSING_BODY ) ; } } } | Check for a valid prototype of a static constructor . | 417 | 10 |
34,102 | @ Check @ SuppressWarnings ( { "checkstyle:nestedifdepth" , "checkstyle:npathcomplexity" , "checkstyle:cyclomaticcomplexity" } ) public void checkUnsynchronizedField ( XtendField field ) { if ( doCheckValidMemberName ( field ) && ! isIgnored ( POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM ) ) { final JvmField jvmField = this . associations . getJvmField ( field ) ; if ( jvmField == null || jvmField . eContainer ( ) == null || jvmField . isConstant ( ) || jvmField . isFinal ( ) ) { return ; } final EObject scope = getOutermostType ( field ) ; if ( ( scope instanceof SarlAgent || scope instanceof SarlBehavior || scope instanceof SarlSkill ) && isLocallyAssigned ( jvmField , scope ) ) { final Collection < Setting > usages = XbaseUsageCrossReferencer . find ( jvmField , scope ) ; final Set < XtendMember > blocks = new HashSet <> ( ) ; boolean isAccessibleFromOutside = jvmField . getVisibility ( ) != JvmVisibility . PRIVATE ; final Collection < Setting > pbUsages = new ArrayList <> ( ) ; for ( final Setting usage : usages ) { final XtendMember member = EcoreUtil2 . getContainerOfType ( usage . getEObject ( ) , XtendMember . class ) ; if ( member instanceof XtendFunction ) { final XtendFunction fct = ( XtendFunction ) member ; blocks . add ( member ) ; if ( member . getVisibility ( ) != JvmVisibility . PRIVATE ) { isAccessibleFromOutside = true ; } if ( ! fct . isSynchonized ( ) ) { pbUsages . add ( usage ) ; } } else if ( member instanceof SarlBehaviorUnit ) { blocks . add ( member ) ; isAccessibleFromOutside = true ; pbUsages . add ( usage ) ; } } for ( final Setting usage : pbUsages ) { boolean synchronizationIssue = false ; if ( isAccessibleFromOutside || blocks . size ( ) > 1 ) { synchronizationIssue = true ; } else { // TODO: Refine the function call detection synchronizationIssue = true ; } // Check if the field is already locally synchronized if ( synchronizationIssue ) { final XSynchronizedExpression syncExpr = EcoreUtil2 . getContainerOfType ( usage . getEObject ( ) , XSynchronizedExpression . class ) ; if ( syncExpr != null ) { synchronizationIssue = false ; } } if ( synchronizationIssue && ! isIgnored ( POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM , usage . getEObject ( ) ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_91 , field . getName ( ) ) , usage . getEObject ( ) , usage . getEStructuralFeature ( ) , POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM ) ; } } } } } | Check if a field needs to be synchronized . | 712 | 9 |
34,103 | protected boolean isLocallyAssigned ( EObject target , EObject containerToFindUsage ) { if ( this . readAndWriteTracking . isAssigned ( target ) ) { return true ; } final Collection < Setting > usages = XbaseUsageCrossReferencer . find ( target , containerToFindUsage ) ; // field are assigned when they are not used as the left operand of an assignment operator. for ( final Setting usage : usages ) { final EObject object = usage . getEObject ( ) ; if ( object instanceof XAssignment ) { final XAssignment assignment = ( XAssignment ) object ; if ( assignment . getFeature ( ) == target ) { // Mark the field as assigned in order to be faster during the next assignment test. this . readAndWriteTracking . markAssignmentAccess ( target ) ; return true ; } } } return false ; } | Replies if the given object is locally assigned . | 189 | 10 |
34,104 | @ SuppressWarnings ( "static-method" ) protected boolean isOOType ( XtendTypeDeclaration type ) { return type instanceof XtendClass || type instanceof XtendInterface || type instanceof XtendEnum || type instanceof XtendAnnotationType ; } | Replies if the given element is an object oriented type . | 66 | 12 |
34,105 | @ SuppressWarnings ( "static-method" ) protected boolean isOOActiveAnnotation ( XAnnotation annotation ) { final String name = annotation . getAnnotationType ( ) . getQualifiedName ( ) ; return Strings . equal ( Accessors . class . getName ( ) , name ) || Strings . equal ( Data . class . getName ( ) , name ) || Strings . equal ( Delegate . class . getName ( ) , name ) || Strings . equal ( ToString . class . getName ( ) , name ) ; } | Replies if the given annotation is an active annotation for object - oriented elements . | 120 | 16 |
34,106 | @ SuppressWarnings ( "static-method" ) protected boolean isAOActiveAnnotation ( XAnnotation annotation ) { final String name = annotation . getAnnotationType ( ) . getQualifiedName ( ) ; return Strings . equal ( Accessors . class . getName ( ) , name ) ; } | Replies if the given container can receive an active annotation . | 68 | 12 |
34,107 | @ SuppressWarnings ( "static-method" ) protected boolean isAOActiveAnnotationReceiver ( XtendTypeDeclaration container ) { return container instanceof SarlAgent || container instanceof SarlBehavior || container instanceof SarlSkill ; } | Replies if the given annotation is an active annotation for agent - oriented elements . | 57 | 16 |
34,108 | @ SuppressWarnings ( "static-method" ) protected boolean isForbiddenActiveAnnotation ( XAnnotation annotation ) { final String name = annotation . getAnnotationType ( ) . getQualifiedName ( ) ; return Strings . equal ( EqualsHashCode . class . getName ( ) , name ) || Strings . equal ( FinalFieldsConstructor . class . getName ( ) , name ) ; } | Replies if the given annotation is a forbidden active annotation . | 91 | 12 |
34,109 | @ Check public void checkTopElementsAreUnique ( SarlScript script ) { final Multimap < String , XtendTypeDeclaration > name2type = HashMultimap . create ( ) ; for ( final XtendTypeDeclaration declaration : script . getXtendTypes ( ) ) { final String name = declaration . getName ( ) ; if ( ! Strings . isEmpty ( name ) ) { name2type . put ( name , declaration ) ; } } for ( final String name : name2type . keySet ( ) ) { final Collection < XtendTypeDeclaration > types = name2type . get ( name ) ; if ( types . size ( ) > 1 ) { for ( final XtendTypeDeclaration type : types ) { error ( MessageFormat . format ( Messages . SARLValidator_93 , name ) , type , XtendPackage . Literals . XTEND_TYPE_DECLARATION__NAME , DUPLICATE_TYPE_NAME ) ; } } } } | Check the top elements within a script are not duplicated . | 219 | 12 |
34,110 | @ SuppressWarnings ( "static-method" ) protected boolean isDefaultValuedParameterFunction ( XtendFunction function ) { for ( final XtendParameter parameter : function . getParameters ( ) ) { if ( parameter instanceof SarlFormalParameter ) { final SarlFormalParameter sarlParameter = ( SarlFormalParameter ) parameter ; if ( sarlParameter . getDefaultValue ( ) != null ) { return true ; } } } return false ; } | Replies if the given function has a default value for one of its parameters . | 102 | 16 |
34,111 | protected void reportCastWarnings ( JvmTypeReference concreteSyntax , LightweightTypeReference toType , LightweightTypeReference fromType ) { if ( ! isIgnored ( OBSOLETE_CAST ) && toType . isAssignableFrom ( fromType ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_96 , fromType . getHumanReadableName ( ) , toType . getHumanReadableName ( ) ) , concreteSyntax , OBSOLETE_CAST ) ; } } | Report the warnings associated to the casted expressions . | 116 | 10 |
34,112 | public void finalizeScript ( ) { if ( this . isFinalized ) { throw new IllegalStateException ( "already finalized" ) ; } this . isFinalized = true ; ImportManager concreteImports = new ImportManager ( true ) ; XImportSection importSection = getScript ( ) . getImportSection ( ) ; if ( importSection != null ) { for ( XImportDeclaration decl : importSection . getImportDeclarations ( ) ) { concreteImports . addImportFor ( decl . getImportedType ( ) ) ; } } for ( String importName : getImportManager ( ) . getImports ( ) ) { JvmType type = findType ( getScript ( ) , importName ) . getType ( ) ; if ( concreteImports . addImportFor ( type ) && type instanceof JvmDeclaredType ) { XImportDeclaration declaration = XtypeFactory . eINSTANCE . createXImportDeclaration ( ) ; declaration . setImportedType ( ( JvmDeclaredType ) type ) ; if ( importSection == null ) { importSection = XtypeFactory . eINSTANCE . createXImportSection ( ) ; getScript ( ) . setImportSection ( importSection ) ; } importSection . getImportDeclarations ( ) . add ( declaration ) ; } } Resource resource = getScript ( ) . eResource ( ) ; if ( resource instanceof DerivedStateAwareResource ) { ( ( DerivedStateAwareResource ) resource ) . discardDerivedState ( ) ; } } | Finalize the script . | 323 | 5 |
34,113 | public ISarlEventBuilder addSarlEvent ( String name ) { ISarlEventBuilder builder = this . sarlEventProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlEvent builder . | 56 | 7 |
34,114 | public ISarlCapacityBuilder addSarlCapacity ( String name ) { ISarlCapacityBuilder builder = this . sarlCapacityProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlCapacity builder . | 60 | 8 |
34,115 | public ISarlAgentBuilder addSarlAgent ( String name ) { ISarlAgentBuilder builder = this . sarlAgentProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlAgent builder . | 56 | 7 |
34,116 | public ISarlBehaviorBuilder addSarlBehavior ( String name ) { ISarlBehaviorBuilder builder = this . sarlBehaviorProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlBehavior builder . | 60 | 8 |
34,117 | public ISarlSkillBuilder addSarlSkill ( String name ) { ISarlSkillBuilder builder = this . sarlSkillProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlSkill builder . | 56 | 7 |
34,118 | public ISarlSpaceBuilder addSarlSpace ( String name ) { ISarlSpaceBuilder builder = this . sarlSpaceProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlSpace builder . | 56 | 7 |
34,119 | public ISarlArtifactBuilder addSarlArtifact ( String name ) { ISarlArtifactBuilder builder = this . sarlArtifactProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlArtifact builder . | 60 | 8 |
34,120 | public ISarlClassBuilder addSarlClass ( String name ) { ISarlClassBuilder builder = this . sarlClassProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlClass builder . | 56 | 7 |
34,121 | public ISarlInterfaceBuilder addSarlInterface ( String name ) { ISarlInterfaceBuilder builder = this . sarlInterfaceProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlInterface builder . | 56 | 7 |
34,122 | public ISarlEnumerationBuilder addSarlEnumeration ( String name ) { ISarlEnumerationBuilder builder = this . sarlEnumerationProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlEnumeration builder . | 64 | 9 |
34,123 | public ISarlAnnotationTypeBuilder addSarlAnnotationType ( String name ) { ISarlAnnotationTypeBuilder builder = this . sarlAnnotationTypeProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlAnnotationType builder . | 64 | 9 |
34,124 | protected void createAgentNameEditor ( Composite parent , String text ) { final Group group = SWTFactory . createGroup ( parent , text , 2 , 1 , GridData . FILL_HORIZONTAL ) ; this . agentNameTextField = SWTFactory . createSingleText ( group , 1 ) ; this . agentNameTextField . addModifyListener ( new ModifyListener ( ) { @ SuppressWarnings ( "synthetic-access" ) @ Override public void modifyText ( ModifyEvent event ) { SARLAgentMainLaunchConfigurationTab . this . lastAgentNameError = null ; updateLaunchConfigurationDialog ( ) ; } } ) ; ControlAccessibleListener . addListener ( this . agentNameTextField , group . getText ( ) ) ; this . agentNameSearchButton = createPushButton ( group , Messages . MainLaunchConfigurationTab_1 , null ) ; this . agentNameSearchButton . addSelectionListener ( new SelectionListener ( ) { @ Override public void widgetDefaultSelected ( SelectionEvent event ) { // } @ Override public void widgetSelected ( SelectionEvent event ) { handleAgentNameSearchButtonSelected ( ) ; } } ) ; } | Creates the widgets for specifying a agent name . | 254 | 10 |
34,125 | protected void createContextIdentifierTypeEditor ( Composite parent , String text ) { final Group group = SWTFactory . createGroup ( parent , text , 1 , 1 , GridData . FILL_HORIZONTAL ) ; this . defaultContextIdentifierButton = createRadioButton ( group , Messages . MainLaunchConfigurationTab_11 ) ; this . defaultContextIdentifierButton . addSelectionListener ( this . defaultListener ) ; this . randomContextIdentifierButton = createRadioButton ( group , Messages . MainLaunchConfigurationTab_12 ) ; this . randomContextIdentifierButton . addSelectionListener ( this . defaultListener ) ; this . bootContextIdentifierButton = createRadioButton ( group , Messages . MainLaunchConfigurationTab_13 ) ; this . bootContextIdentifierButton . addSelectionListener ( this . defaultListener ) ; } | Creates the widgets for configuring the context identifier . | 178 | 11 |
34,126 | protected RootContextIdentifierType getSelectedContextIdentifierType ( ) { if ( this . randomContextIdentifierButton . getSelection ( ) ) { return RootContextIdentifierType . RANDOM_CONTEXT_ID ; } if ( this . bootContextIdentifierButton . getSelection ( ) ) { return RootContextIdentifierType . BOOT_AGENT_CONTEXT_ID ; } return RootContextIdentifierType . DEFAULT_CONTEXT_ID ; } | Replies the type of context identifier selected by the user . | 101 | 12 |
34,127 | protected void updateContextIdentifierTypeFromConfig ( ILaunchConfiguration config ) { final RootContextIdentifierType type = this . accessor . getDefaultContextIdentifier ( config ) ; assert type != null ; switch ( type ) { case RANDOM_CONTEXT_ID : this . randomContextIdentifierButton . setSelection ( true ) ; break ; case BOOT_AGENT_CONTEXT_ID : this . bootContextIdentifierButton . setSelection ( true ) ; break ; case DEFAULT_CONTEXT_ID : default : this . defaultContextIdentifierButton . setSelection ( true ) ; break ; } } | Loads the context identifier type from the launch configuration s preference store . | 133 | 14 |
34,128 | protected void updateAgentNameFromConfig ( ILaunchConfiguration config ) { final String agentName = this . accessor . getAgent ( config ) ; this . agentNameTextField . setText ( Strings . nullToEmpty ( agentName ) ) ; } | Loads the agent name from the launch configuration s preference store . | 53 | 13 |
34,129 | protected boolean isValidAgentName ( ) { if ( this . lastAgentNameError != null ) { final boolean isValid = Strings . isNullOrEmpty ( this . lastAgentNameError ) ; if ( ! isValid ) { setErrorMessage ( this . lastAgentNameError ) ; } return isValid ; } final String name = this . agentNameTextField . getText ( ) ; if ( Strings . isNullOrEmpty ( name ) ) { this . lastAgentNameError = Messages . MainLaunchConfigurationTab_2 ; setErrorMessage ( this . lastAgentNameError ) ; return false ; } if ( ! isAgentNameDefined ( name ) ) { this . lastAgentNameError = MessageFormat . format ( Messages . MainLaunchConfigurationTab_8 , name ) ; setErrorMessage ( this . lastAgentNameError ) ; return false ; } this . lastAgentNameError = Utilities . EMPTY_STRING ; return true ; } | Replies if the agent name is valid . | 201 | 9 |
34,130 | protected boolean isValidProjectName ( ) { final String name = this . fProjText . getText ( ) ; if ( Strings . isNullOrEmpty ( name ) ) { setErrorMessage ( Messages . MainLaunchConfigurationTab_3 ) ; return false ; } final IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; final IStatus status = workspace . validateName ( name , IResource . PROJECT ) ; if ( status . isOK ( ) ) { final IProject project = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( name ) ; if ( ! project . exists ( ) ) { setErrorMessage ( MessageFormat . format ( Messages . MainLaunchConfigurationTab_4 , name ) ) ; return false ; } if ( ! project . isOpen ( ) ) { setErrorMessage ( MessageFormat . format ( Messages . MainLaunchConfigurationTab_5 , name ) ) ; return false ; } } else { setErrorMessage ( MessageFormat . format ( Messages . MainLaunchConfigurationTab_6 , status . getMessage ( ) ) ) ; return false ; } return true ; } | Replies if the project name is valid . | 237 | 9 |
34,131 | protected void initializeAgentName ( IJavaElement javaElement , ILaunchConfigurationWorkingCopy config ) { String name = extractNameFromJavaElement ( javaElement ) ; // Set the attribute this . configurator . setAgent ( config , name ) ; // Rename the launch configuration if ( name . length ( ) > 0 ) { final int index = name . lastIndexOf ( ' ' ) ; if ( index > 0 ) { name = name . substring ( index + 1 ) ; } name = getLaunchConfigurationDialog ( ) . generateName ( name ) ; config . rename ( name ) ; } } | Reset the given configuration with the agent name attributes associated to the given element . | 126 | 16 |
34,132 | protected void handleAgentNameSearchButtonSelected ( ) { final IType [ ] types = searchAgentNames ( ) ; // Ask to the user final DebugTypeSelectionDialog mmsd = new DebugTypeSelectionDialog ( getShell ( ) , types , "" ) ; //$NON-NLS-1$ if ( mmsd . open ( ) == Window . CANCEL ) { return ; } final IType type = ( IType ) mmsd . getFirstResult ( ) ; if ( type != null ) { this . agentNameTextField . setText ( type . getFullyQualifiedName ( ) ) ; this . fProjText . setText ( type . getJavaProject ( ) . getElementName ( ) ) ; } } | Invoked when the search button for the agent agent was clocked . | 162 | 14 |
34,133 | @ SuppressWarnings ( "static-method" ) protected boolean saveProjectSpecificOptions ( IProject project , boolean useSpecificOptions ) { if ( project != null ) { try { project . setPersistentProperty ( qualify ( PROPERTY_NAME_HAS_PROJECT_SPECIFIC ) , Boolean . toString ( useSpecificOptions ) ) ; return true ; } catch ( CoreException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } } return false ; } | Save the flag that indicates if the specific project options must be used . | 107 | 14 |
34,134 | public static int compareOsgiVersions ( String v1 , String v2 ) { return Version . parseVersion ( v1 ) . compareTo ( Version . parseVersion ( v2 ) ) ; } | Compare two OSGI versions . | 41 | 6 |
34,135 | public static int compareMavenVersions ( String v1 , String v2 ) { return parseMavenVersion ( v1 ) . compareTo ( parseMavenVersion ( v2 ) ) ; } | Compare two Maven versions . | 41 | 6 |
34,136 | public static Version parseMavenVersion ( String version ) { if ( Strings . isNullOrEmpty ( version ) ) { return new Version ( 0 , 0 , 0 ) ; } // Detect the snapshot final boolean isSnapshot ; final String coreVersion ; Matcher matcher = Artifact . VERSION_FILE_PATTERN . matcher ( version ) ; if ( matcher . matches ( ) ) { coreVersion = matcher . group ( 1 ) ; isSnapshot = true ; } else { matcher = SNAPSHOT_VERSION_PATTERN . matcher ( version ) ; if ( matcher . matches ( ) ) { coreVersion = matcher . group ( 1 ) ; isSnapshot = true ; } else { coreVersion = version ; isSnapshot = false ; } } // Parse the numbers final String [ ] parts = coreVersion . split ( "[.]" ) ; //$NON-NLS-1$ final int [ ] numbers = new int [ ] { 0 , 0 , 0 } ; int i = 0 ; while ( i < numbers . length && i < parts . length ) { try { numbers [ i ] = Integer . parseInt ( parts [ i ] ) ; ++ i ; } catch ( Exception exception ) { // Force the exit of the loop since a number cannot be find. i = numbers . length ; } } // Reply if ( isSnapshot ) { return new Version ( numbers [ 0 ] , numbers [ 1 ] , numbers [ 2 ] , SNAPSHOT_QUALIFIER ) ; } return new Version ( numbers [ 0 ] , numbers [ 1 ] , numbers [ 2 ] ) ; } | Maven version parser . | 346 | 5 |
34,137 | @ Pure public static < S extends Capacity > S getInternalSkill ( Agent agent , Class < S > type ) { return agent . getSkill ( type ) ; } | Replies the internal skill of an agent . | 34 | 9 |
34,138 | public static Charset getStringEncodingCharset ( ) { if ( currentStringEncoding == null ) { final String value = JanusConfig . getSystemProperty ( BYTE_ARRAY_STRING_CHARSET_NAME , null ) ; if ( value != null ) { try { currentStringEncoding = Charset . forName ( value ) ; if ( currentStringEncoding == null ) { currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE ; } } catch ( Throwable exception ) { currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE ; } } else { currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE ; } } return currentStringEncoding ; } | Replies the charset that must be used for encoding the strings . | 171 | 14 |
34,139 | protected void generateIMemberBuilder ( MemberDescription description ) { if ( description . isTopElement ( ) ) { return ; } final TypeReference builder = description . getElementDescription ( ) . getBuilderInterfaceType ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Builder of a " + getLanguageName ( ) //$NON-NLS-1$ + " " + description . getElementDescription ( ) . getName ( ) + "." ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; it . append ( " */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "public interface " ) ; //$NON-NLS-1$ it . append ( builder . getSimpleName ( ) ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateMembers ( description , true , false ) ) ; it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( builder , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the member builder interface . | 376 | 7 |
34,140 | protected void generateMemberAppender ( MemberDescription description ) { if ( description . isTopElement ( ) ) { return ; } final TypeReference appender = description . getElementDescription ( ) . getAppenderType ( ) ; final String generatedFieldAccessor = getGeneratedMemberAccessor ( description ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Source appender of a " + getLanguageName ( ) //$NON-NLS-1$ + " " + description . getElementDescription ( ) . getName ( ) + "." ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; it . append ( " */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "public class " ) ; //$NON-NLS-1$ it . append ( appender . getSimpleName ( ) ) ; it . append ( " extends " ) ; //$NON-NLS-1$ it . append ( getCodeElementExtractor ( ) . getAbstractAppenderImpl ( ) ) ; it . append ( " implements " ) ; //$NON-NLS-1$ it . append ( description . getElementDescription ( ) . getBuilderInterfaceType ( ) ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateAppenderMembers ( appender . getSimpleName ( ) , description . getElementDescription ( ) . getBuilderInterfaceType ( ) , generatedFieldAccessor ) ) ; it . append ( generateMembers ( description , false , true ) ) ; it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( appender , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the member appender . | 517 | 7 |
34,141 | @ SuppressWarnings ( "static-method" ) protected String getGeneratedMemberAccessor ( MemberDescription description ) { return "get" //$NON-NLS-1$ + Strings . toFirstUpper ( description . getElementDescription ( ) . getElementType ( ) . getSimpleName ( ) ) + "()" ; //$NON-NLS-1$ } | Replies the name of the accessor that replies the generated member . | 86 | 14 |
34,142 | protected Binding bindAnnotatedWith ( TypeReference bind , TypeReference annotatedWith , TypeReference to , String functionName ) { final StringConcatenationClient client = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation builder ) { builder . append ( "binder.bind(" ) ; //$NON-NLS-1$ builder . append ( bind ) ; builder . append ( ".class).annotatedWith(" ) ; //$NON-NLS-1$ builder . append ( annotatedWith ) ; builder . append ( ".class).to(" ) ; //$NON-NLS-1$ builder . append ( to ) ; builder . append ( ".class);" ) ; //$NON-NLS-1$ } } ; String fctname = functionName ; if ( Strings . isEmpty ( fctname ) ) { fctname = bind . getSimpleName ( ) ; } final BindKey key = new GuiceModuleAccess . BindKey ( formatFunctionName ( fctname ) , null , false , false ) ; final BindValue statements = new BindValue ( null , null , false , Collections . singletonList ( client ) ) ; return new Binding ( key , statements , true , this . name ) ; } | Bind an annotated element . | 281 | 6 |
34,143 | protected Binding bindAnnotatedWithNameToInstance ( TypeReference bind , String name , String to , String functionName ) { String tmpName = Strings . emptyIfNull ( name ) ; if ( tmpName . startsWith ( REFERENCE_PREFIX ) ) { tmpName = tmpName . substring ( REFERENCE_PREFIX . length ( ) ) . trim ( ) ; } else { tmpName = "\"" + tmpName + "\"" ; //$NON-NLS-1$//$NON-NLS-2$ } final String unferencedName = tmpName ; final StringConcatenationClient client = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation builder ) { builder . append ( "binder.bind(" ) ; //$NON-NLS-1$ builder . append ( bind ) ; builder . append ( ".class).annotatedWith(Names.named(" ) ; //$NON-NLS-1$ builder . append ( unferencedName ) ; builder . append ( ")).toInstance(" ) ; //$NON-NLS-1$ builder . append ( to ) ; builder . append ( ".class);" ) ; //$NON-NLS-1$ } } ; String fctname = functionName ; if ( Strings . isEmpty ( fctname ) ) { fctname = name ; } final BindKey key = new GuiceModuleAccess . BindKey ( formatFunctionName ( fctname ) , null , false , false ) ; final BindValue statements = new BindValue ( null , null , false , Collections . singletonList ( client ) ) ; return new Binding ( key , statements , true , this . name ) ; } | Bind a type annotated with a name of the given value . | 385 | 13 |
34,144 | protected Binding bindToInstance ( TypeReference bind , String functionName , String instanceExpression , boolean isSingleton , boolean isEager ) { final BindKey type ; final BindValue value ; if ( ! Strings . isEmpty ( functionName ) && functionName . startsWith ( CONFIGURE_PREFIX ) ) { final String fname = functionName . substring ( CONFIGURE_PREFIX . length ( ) ) ; type = new BindKey ( Strings . toFirstUpper ( fname ) , null , isSingleton , isEager ) ; final StringConcatenationClient client = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation builder ) { builder . append ( "binder.bind(" ) ; //$NON-NLS-1$ builder . append ( bind ) ; builder . append ( ".class).toInstance(" ) ; //$NON-NLS-1$ builder . append ( instanceExpression ) ; builder . append ( ");" ) ; //$NON-NLS-1$ } } ; value = new BindValue ( null , null , false , Collections . singletonList ( client ) ) ; } else { String fname = functionName ; if ( fname != null && fname . startsWith ( BIND_PREFIX ) ) { fname = fname . substring ( BIND_PREFIX . length ( ) ) ; } type = new BindKey ( Strings . toFirstUpper ( fname ) , bind , isSingleton , isEager ) ; final StringConcatenationClient client = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation builder ) { builder . append ( instanceExpression ) ; } } ; value = new BindValue ( client , null , false , Collections . emptyList ( ) ) ; } return new Binding ( type , value , true , this . name ) ; } | Bind a type to an instance expression . | 428 | 8 |
34,145 | public void add ( Binding binding , boolean override ) { final Set < Binding > moduleBindings = this . module . get ( ) . getBindings ( ) ; final Binding otherBinding = findBinding ( moduleBindings , binding ) ; if ( ! override ) { if ( otherBinding != null ) { throw new IllegalArgumentException ( MessageFormat . format ( "Forbidden override of {0} by {1}." , //$NON-NLS-1$ otherBinding , binding ) ) ; } } else if ( otherBinding != null ) { this . removableBindings . add ( otherBinding ) ; } if ( ! this . bindings . add ( binding ) ) { throw new IllegalArgumentException ( MessageFormat . format ( "Duplicate binding for {0} in {1}" , binding . getKey ( ) , this . name ) ) ; //$NON-NLS-1$ } } | Add the binding . | 200 | 4 |
34,146 | public void contributeToModule ( ) { final GuiceModuleAccess module = this . module . get ( ) ; if ( ! this . removableBindings . isEmpty ( ) ) { // Ok, we are broking the Java secutiry manager. // But it's for having something working! try { final Field field = module . getClass ( ) . getDeclaredField ( "bindings" ) ; //$NON-NLS-1$ final boolean accessible = field . isAccessible ( ) ; try { field . setAccessible ( true ) ; final Collection < ? > hiddenBindings = ( Collection < ? > ) field . get ( module ) ; hiddenBindings . removeAll ( this . removableBindings ) ; } finally { field . setAccessible ( accessible ) ; } } catch ( Exception exception ) { throw new IllegalStateException ( exception ) ; } } module . addAll ( this . bindings ) ; } | Put the bindings to the associated module . | 196 | 8 |
34,147 | public Binding toBinding ( BindingElement element ) { final TypeReference typeReference = typeRef ( element . getBind ( ) ) ; final String annotatedWith = element . getAnnotatedWith ( ) ; final String annotatedWithName = element . getAnnotatedWithName ( ) ; if ( ! Strings . isEmpty ( annotatedWith ) ) { final TypeReference annotationType = typeRef ( annotatedWith ) ; if ( element . isInstance ( ) ) { return bindAnnotatedWithToInstance ( typeReference , annotationType , element . getTo ( ) , element . getFunctionName ( ) ) ; } final TypeReference typeReference2 = typeRef ( element . getTo ( ) ) ; return bindAnnotatedWith ( typeReference , annotationType , typeReference2 , element . getFunctionName ( ) ) ; } if ( ! Strings . isEmpty ( annotatedWithName ) ) { if ( element . isInstance ( ) ) { return bindAnnotatedWithNameToInstance ( typeReference , annotatedWithName , element . getTo ( ) , element . getFunctionName ( ) ) ; } final TypeReference typeReference2 = typeRef ( element . getTo ( ) ) ; return bindAnnotatedWithName ( typeReference , annotatedWithName , typeReference2 , element . getFunctionName ( ) ) ; } if ( element . isInstance ( ) ) { return bindToInstance ( typeReference , element . getFunctionName ( ) , element . getTo ( ) , element . isSingleton ( ) , element . isEager ( ) ) ; } final TypeReference typeReference2 = typeRef ( element . getTo ( ) ) ; return bindToType ( typeReference , element . getFunctionName ( ) , typeReference2 , element . isSingleton ( ) , element . isEager ( ) , element . isProvider ( ) ) ; } | Convert a binding element to a Guive binding . | 401 | 11 |
34,148 | protected void enableNature ( IProject project ) { final IFile pom = project . getFile ( IMavenConstants . POM_FILE_NAME ) ; final Job job ; if ( pom . exists ( ) ) { job = createJobForMavenProject ( project ) ; } else { job = createJobForJavaProject ( project ) ; } if ( job != null ) { job . schedule ( ) ; } } | Enable the SARL Maven nature . | 90 | 8 |
34,149 | @ SuppressWarnings ( "static-method" ) protected Job createJobForMavenProject ( IProject project ) { return new Job ( Messages . EnableSarlMavenNatureAction_0 ) { @ Override protected IStatus run ( IProgressMonitor monitor ) { final SubMonitor mon = SubMonitor . convert ( monitor , 3 ) ; try { // The project should be a Maven project. final IPath descriptionFilename = project . getFile ( new Path ( IProjectDescription . DESCRIPTION_FILE_NAME ) ) . getLocation ( ) ; final File projectDescriptionFile = descriptionFilename . toFile ( ) ; final IPath classpathFilename = project . getFile ( new Path ( FILENAME_CLASSPATH ) ) . getLocation ( ) ; final File classpathFile = classpathFilename . toFile ( ) ; // Project was open by the super class. Close it because Maven fails when a project already exists. project . close ( mon . newChild ( 1 ) ) ; // Delete the Eclipse project and classpath definitions because Maven fails when a project already exists. project . delete ( false , true , mon . newChild ( 1 ) ) ; if ( projectDescriptionFile . exists ( ) ) { projectDescriptionFile . delete ( ) ; } if ( classpathFile . exists ( ) ) { classpathFile . delete ( ) ; } // Import MavenImportUtils . importMavenProject ( project . getWorkspace ( ) . getRoot ( ) , project . getName ( ) , true , mon . newChild ( 1 ) ) ; } catch ( CoreException exception ) { SARLMavenEclipsePlugin . getDefault ( ) . log ( exception ) ; } return Status . OK_STATUS ; } } ; } | Create the configuration job for a Maven project . | 369 | 10 |
34,150 | @ SuppressWarnings ( "static-method" ) protected Job createJobForJavaProject ( IProject project ) { return new Job ( Messages . EnableSarlMavenNatureAction_0 ) { @ Override protected IStatus run ( IProgressMonitor monitor ) { final SubMonitor mon = SubMonitor . convert ( monitor , 3 ) ; // Force the project configuration to SARL. SARLProjectConfigurator . configureSARLProject ( // Project to configure project , // Add SARL natures true , // Force java configuration true , // Create folders true , // Monitor mon . newChild ( 3 ) ) ; return Status . OK_STATUS ; } } ; } | Create the configuration job for a Java project . | 142 | 9 |
34,151 | protected void fireAgentSpawnedOutsideAgent ( UUID spawningAgent , AgentContext context , Class < ? extends Agent > agentClazz , List < Agent > agents , Object ... initializationParameters ) { // Notify the listeners on the spawn events (not restricted to a single agent) for ( final SpawnServiceListener l : this . globalListeners . getListeners ( SpawnServiceListener . class ) ) { l . agentSpawned ( spawningAgent , context , agents , initializationParameters ) ; } // Send the event in the default space. final EventSpace defSpace = context . getDefaultSpace ( ) ; assert defSpace != null : "A context does not contain a default space" ; //$NON-NLS-1$ final UUID spawner = spawningAgent == null ? context . getID ( ) : spawningAgent ; final Address source = new Address ( defSpace . getSpaceID ( ) , spawner ) ; assert source != null ; final Collection < UUID > spawnedAgentIds = Collections3 . serializableCollection ( Collections2 . transform ( agents , it -> it . getID ( ) ) ) ; final AgentSpawned event = new AgentSpawned ( source , agentClazz . getName ( ) , spawnedAgentIds ) ; final Scope < Address > scope = address -> { final UUID receiver = address . getUUID ( ) ; return ! spawnedAgentIds . parallelStream ( ) . anyMatch ( it -> it . equals ( receiver ) ) ; } ; // Event must not be received by the spawned agent. defSpace . emit ( // No need to give an event source because it is explicitly set above. null , event , scope ) ; } | Notify the listeners about the agents spawning . | 350 | 9 |
34,152 | protected void fireAgentSpawnedInAgent ( UUID spawningAgent , AgentContext context , Agent agent , Object ... initializationParameters ) { // Notify the listeners on the lifecycle events inside // the just spawned agent. // Usually, only BICs and the AgentLifeCycleSupport in // io.janusproject.kernel.bic.StandardBuiltinCapacitiesProvider // is invoked. final ListenerCollection < SpawnServiceListener > list ; synchronized ( this . agentLifecycleListeners ) { list = this . agentLifecycleListeners . get ( agent . getID ( ) ) ; } if ( list != null ) { final List < Agent > singleton = Collections . singletonList ( agent ) ; for ( final SpawnServiceListener l : list . getListeners ( SpawnServiceListener . class ) ) { l . agentSpawned ( spawningAgent , context , singleton , initializationParameters ) ; } } } | Notify the agent s listeners about its spawning . | 193 | 10 |
34,153 | public SynchronizedSet < UUID > getAgents ( ) { final Object mutex = getAgentRepositoryMutex ( ) ; synchronized ( mutex ) { return Collections3 . synchronizedSet ( this . agents . keySet ( ) , mutex ) ; } } | Replies the registered agents . | 57 | 6 |
34,154 | Agent getAgent ( UUID id ) { assert id != null ; synchronized ( getAgentRepositoryMutex ( ) ) { return this . agents . get ( id ) ; } } | Replies the registered agent . | 38 | 6 |
34,155 | @ SuppressWarnings ( "static-method" ) public boolean canKillAgent ( Agent agent ) { try { final AgentContext ac = BuiltinCapacityUtil . getContextIn ( agent ) ; if ( ac != null ) { final SynchronizedSet < UUID > participants = ac . getDefaultSpace ( ) . getParticipants ( ) ; if ( participants != null ) { synchronized ( participants . mutex ( ) ) { if ( participants . size ( ) > 1 || ( participants . size ( ) == 1 && ! participants . contains ( agent . getID ( ) ) ) ) { return false ; } } } } return true ; } catch ( Throwable exception ) { return false ; } } | Replies if the given agent can be killed . | 150 | 10 |
34,156 | @ SuppressWarnings ( { "checkstyle:npathcomplexity" } ) protected void fireAgentDestroyed ( Agent agent ) { final ListenerCollection < SpawnServiceListener > list ; synchronized ( getAgentLifecycleListenerMutex ( ) ) { list = this . agentLifecycleListeners . get ( agent . getID ( ) ) ; } final SpawnServiceListener [ ] ilisteners ; if ( list != null ) { ilisteners = list . getListeners ( SpawnServiceListener . class ) ; } else { ilisteners = null ; } final SpawnServiceListener [ ] ilisteners2 = this . globalListeners . getListeners ( SpawnServiceListener . class ) ; // Retrieve the agent's contexts final List < Pair < AgentContext , Address > > contextRegistrations = new ArrayList <> ( ) ; try { final SynchronizedIterable < AgentContext > allContexts = BuiltinCapacityUtil . getContextsOf ( agent ) ; synchronized ( allContexts . mutex ( ) ) { for ( final AgentContext context : allContexts ) { final EventSpace defSpace = context . getDefaultSpace ( ) ; final Address address = defSpace . getAddress ( agent . getID ( ) ) ; contextRegistrations . add ( Pair . of ( context , address ) ) ; } } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } // Local agent and framework destruction if ( ilisteners != null ) { for ( final SpawnServiceListener l : ilisteners ) { l . agentDestroy ( agent ) ; } } for ( final SpawnServiceListener l : ilisteners2 ) { l . agentDestroy ( agent ) ; } // Fire AgentKilled into the associated contexts try { final UUID killedAgentId = agent . getID ( ) ; final Scope < Address > scope = address -> { final UUID receiver = address . getUUID ( ) ; return ! receiver . equals ( killedAgentId ) ; } ; final String killedAgentType = agent . getClass ( ) . getName ( ) ; for ( final Pair < AgentContext , Address > registration : contextRegistrations ) { final EventSpace defSpace = registration . getKey ( ) . getDefaultSpace ( ) ; defSpace . emit ( // No need to give an event source because it is explicitly set below. null , new AgentKilled ( registration . getValue ( ) , killedAgentId , killedAgentType ) , scope ) ; } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Notifies the listeners about the agent destruction . | 565 | 9 |
34,157 | protected void initFields ( ) { final IEclipsePreferences prefs = SARLEclipsePlugin . getDefault ( ) . getPreferences ( ) ; this . trackerLogin . setText ( prefs . get ( PREFERENCE_LOGIN , "" ) ) ; //$NON-NLS-1$ } | Set the initial values to the fields . | 67 | 8 |
34,158 | protected void updatePageStatus ( ) { final boolean ok ; if ( Strings . isEmpty ( this . titleField . getText ( ) ) ) { ok = false ; setMessage ( Messages . IssueInformationPage_5 , IMessageProvider . ERROR ) ; } else if ( Strings . isEmpty ( this . trackerLogin . getText ( ) ) ) { ok = false ; setMessage ( Messages . IssueInformationPage_6 , IMessageProvider . ERROR ) ; } else if ( Strings . isEmpty ( this . trackerPassword . getText ( ) ) ) { ok = false ; setMessage ( Messages . IssueInformationPage_7 , IMessageProvider . ERROR ) ; } else { ok = true ; if ( Strings . isEmpty ( this . descriptionField . getText ( ) ) ) { setMessage ( Messages . IssueInformationPage_8 , IMessageProvider . WARNING ) ; } else { setMessage ( null , IMessageProvider . NONE ) ; } } setPageComplete ( ok ) ; } | Update the page status and change the finish state button . | 213 | 11 |
34,159 | public boolean performFinish ( ) { final IEclipsePreferences prefs = SARLEclipsePlugin . getDefault ( ) . getPreferences ( ) ; final String login = this . trackerLogin . getText ( ) ; if ( Strings . isEmpty ( login ) ) { prefs . remove ( PREFERENCE_LOGIN ) ; } else { prefs . put ( PREFERENCE_LOGIN , login ) ; } try { prefs . sync ( ) ; return true ; } catch ( BackingStoreException e ) { ErrorDialog . openError ( getShell ( ) , e . getLocalizedMessage ( ) , e . getLocalizedMessage ( ) , SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , e ) ) ; return false ; } } | Invoked when the wizard is closed with the Finish button . | 167 | 12 |
34,160 | @ Pure public String format ( String sarlCode , ResourceSet resourceSet ) { try { final URI createURI = URI . createURI ( "synthetic://to-be-formatted." + this . fileExtension ) ; //$NON-NLS-1$ final Resource res = this . resourceFactory . createResource ( createURI ) ; if ( res instanceof XtextResource ) { final XtextResource resource = ( XtextResource ) res ; final EList < Resource > resources = resourceSet . getResources ( ) ; resources . add ( resource ) ; try ( StringInputStream stringInputStream = new StringInputStream ( sarlCode ) ) { resource . load ( stringInputStream , Collections . emptyMap ( ) ) ; return formatResource ( resource ) ; } finally { resources . remove ( resource ) ; } } return sarlCode ; } catch ( Exception exception ) { throw Exceptions . sneakyThrow ( exception ) ; } } | Format the given code . | 200 | 5 |
34,161 | @ SuppressWarnings ( "static-method" ) public Boolean toBooleanPrimitiveWrapperConstant ( XExpression expression ) { if ( expression instanceof XBooleanLiteral ) { return ( ( XBooleanLiteral ) expression ) . isIsTrue ( ) ? Boolean . TRUE : Boolean . FALSE ; } if ( expression instanceof XMemberFeatureCall ) { final XMemberFeatureCall call = ( XMemberFeatureCall ) expression ; final XExpression receiver = call . getMemberCallTarget ( ) ; if ( receiver instanceof XFeatureCall ) { final XFeatureCall call2 = ( XFeatureCall ) receiver ; final String call2Identifier = call2 . getConcreteSyntaxFeatureName ( ) ; if ( Boolean . class . getSimpleName ( ) . equals ( call2Identifier ) || Boolean . class . getName ( ) . equals ( call2Identifier ) ) { final String callIdentifier = call . getConcreteSyntaxFeatureName ( ) ; if ( "TRUE" . equals ( callIdentifier ) ) { //$NON-NLS-1$ return Boolean . TRUE ; } else if ( "FALSE" . equals ( callIdentifier ) ) { //$NON-NLS-1$ return Boolean . FALSE ; } } } } return null ; } | Convert the boolean constant to the object equivalent if possible . | 283 | 12 |
34,162 | @ Pure public boolean isFrom ( UUID entityId ) { final Address iSource = getSource ( ) ; return ( entityId != null ) && ( iSource != null ) && entityId . equals ( iSource . getUUID ( ) ) ; } | Replies if the event was emitted by an entity with the given identifier . | 54 | 15 |
34,163 | protected void generateClosureDefinition ( XClosure closure , IAppendable it , IExtraLanguageGeneratorContext context ) { if ( ! it . hasName ( closure ) ) { final LightweightTypeReference closureType0 = getExpectedType ( closure ) ; LightweightTypeReference closureType = closureType0 ; if ( closureType0 . isFunctionType ( ) ) { final FunctionTypeReference fctRef = closureType0 . tryConvertToFunctionTypeReference ( true ) ; if ( fctRef != null ) { closureType = Utils . toLightweightTypeReference ( fctRef . getType ( ) , this . typeServices ) . getRawTypeReference ( ) ; } } final String closureName = it . declareSyntheticVariable ( closure , "__Jclosure_" //$NON-NLS-1$ + closureType . getSimpleName ( ) ) ; final JvmDeclaredType rawType = ( JvmDeclaredType ) closureType . getType ( ) ; final JvmOperation function = rawType . getDeclaredOperations ( ) . iterator ( ) . next ( ) ; // Add the object type as super type because of an issue in the Python language. final JvmTypeReference objType = getTypeReferences ( ) . getTypeForName ( Object . class , closure ) ; it . openPseudoScope ( ) ; it . append ( "class " ) . append ( closureName ) . append ( "(" ) //$NON-NLS-1$//$NON-NLS-2$ . append ( closureType ) . append ( "," ) . append ( objType . getType ( ) ) . append ( "):" ) //$NON-NLS-1$ //$NON-NLS-2$ . increaseIndentation ( ) . newLine ( ) . append ( "def " ) //$NON-NLS-1$ . append ( function . getSimpleName ( ) ) . append ( "(" ) //$NON-NLS-1$ . append ( getExtraLanguageKeywordProvider ( ) . getThisKeywordLambda ( ) . apply ( ) ) ; for ( final JvmFormalParameter param : closure . getFormalParameters ( ) ) { it . append ( ", " ) ; //$NON-NLS-1$ final String name = it . declareUniqueNameVariable ( param , param . getName ( ) ) ; it . append ( name ) ; } it . append ( "):" ) ; //$NON-NLS-1$ it . increaseIndentation ( ) . newLine ( ) ; if ( closure . getExpression ( ) != null ) { LightweightTypeReference returnType = closureType0 ; if ( returnType . isFunctionType ( ) ) { final FunctionTypeReference fctRef = returnType . tryConvertToFunctionTypeReference ( true ) ; if ( fctRef != null ) { returnType = fctRef . getReturnType ( ) ; } else { returnType = null ; } } else { returnType = null ; } //LightweightTypeReference returnType = getClosureOperationReturnType(type, operation); generate ( closure . getExpression ( ) , returnType , it , context ) ; } else { it . append ( "pass" ) ; //$NON-NLS-1$ } it . decreaseIndentation ( ) . decreaseIndentation ( ) . newLine ( ) ; it . closeScope ( ) ; } } | Generate the closure definition . | 750 | 6 |
34,164 | protected void generateAnonymousClassDefinition ( AnonymousClass anonClass , IAppendable it , IExtraLanguageGeneratorContext context ) { if ( ! it . hasName ( anonClass ) && it instanceof PyAppendable ) { final LightweightTypeReference jvmAnonType = getExpectedType ( anonClass ) ; final String anonName = it . declareSyntheticVariable ( anonClass , jvmAnonType . getSimpleName ( ) ) ; QualifiedName anonQualifiedName = QualifiedName . create ( jvmAnonType . getType ( ) . getQualifiedName ( ) . split ( Pattern . quote ( "." ) ) ) ; //$NON-NLS-1$ anonQualifiedName = anonQualifiedName . skipLast ( 1 ) ; if ( anonQualifiedName . isEmpty ( ) ) { // The type resolver does not include the enclosing class. assert anonClass . getDeclaringType ( ) == null : "The Xtend API has changed the AnonymousClass definition!" ; //$NON-NLS-1$ final XtendTypeDeclaration container = EcoreUtil2 . getContainerOfType ( anonClass . eContainer ( ) , XtendTypeDeclaration . class ) ; anonQualifiedName = anonQualifiedName . append ( this . qualifiedNameProvider . getFullyQualifiedName ( container ) ) ; } anonQualifiedName = anonQualifiedName . append ( anonName ) ; it . openPseudoScope ( ) ; final IRootGenerator rootGenerator = context . getRootGenerator ( ) ; assert rootGenerator instanceof PyGenerator ; final List < JvmTypeReference > types = new ArrayList <> ( ) ; for ( final JvmTypeReference superType : anonClass . getConstructorCall ( ) . getConstructor ( ) . getDeclaringType ( ) . getSuperTypes ( ) ) { if ( ! Object . class . getCanonicalName ( ) . equals ( superType . getIdentifier ( ) ) ) { types . add ( superType ) ; } } ( ( PyGenerator ) rootGenerator ) . generateTypeDeclaration ( anonQualifiedName . toString ( ) , anonName , false , types , getTypeBuilder ( ) . getDocumentation ( anonClass ) , false , anonClass . getMembers ( ) , ( PyAppendable ) it , context , null ) ; it . closeScope ( ) ; } } | Generate the anonymous class definition . | 548 | 7 |
34,165 | @ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:booleanexpressioncomplexity" , "checkstyle:npathcomplexity" } ) public static String toDefaultValue ( JvmTypeReference type ) { final String id = type . getIdentifier ( ) ; if ( ! "void" . equals ( id ) ) { //$NON-NLS-1$ if ( Strings . equal ( Boolean . class . getName ( ) , id ) || Strings . equal ( Boolean . TYPE . getName ( ) , id ) ) { return "False" ; //$NON-NLS-1$ } if ( Strings . equal ( Float . class . getName ( ) , id ) || Strings . equal ( Float . TYPE . getName ( ) , id ) || Strings . equal ( Double . class . getName ( ) , id ) || Strings . equal ( Double . TYPE . getName ( ) , id ) ) { return "0.0" ; //$NON-NLS-1$ } if ( Strings . equal ( Integer . class . getName ( ) , id ) || Strings . equal ( Integer . TYPE . getName ( ) , id ) || Strings . equal ( Long . class . getName ( ) , id ) || Strings . equal ( Long . TYPE . getName ( ) , id ) || Strings . equal ( Byte . class . getName ( ) , id ) || Strings . equal ( Byte . TYPE . getName ( ) , id ) || Strings . equal ( Short . class . getName ( ) , id ) || Strings . equal ( Short . TYPE . getName ( ) , id ) ) { return "0" ; //$NON-NLS-1$ } if ( Strings . equal ( Character . class . getName ( ) , id ) || Strings . equal ( Character . TYPE . getName ( ) , id ) ) { return "\"\\0\"" ; //$NON-NLS-1$ } } return "None" ; //$NON-NLS-1$ } | Replies the Python default value for the given type . | 459 | 11 |
34,166 | protected PyFeatureCallGenerator newFeatureCallGenerator ( IExtraLanguageGeneratorContext context , IAppendable it ) { return new PyFeatureCallGenerator ( context , ( ExtraLanguageAppendable ) it ) ; } | Generate a feature call . | 48 | 6 |
34,167 | protected String readSarlEclipseSetting ( String sourceDirectory ) { if ( this . propertiesFileLocation != null ) { final File file = new File ( this . propertiesFileLocation ) ; if ( file . canRead ( ) ) { final Properties sarlSettings = new Properties ( ) ; try ( FileInputStream stream = new FileInputStream ( file ) ) { sarlSettings . load ( stream ) ; final String sarlOutputDirProp = sarlSettings . getProperty ( "outlet.DEFAULT_OUTPUT.directory" , null ) ; //$NON-NLS-1$ if ( sarlOutputDirProp != null ) { final File srcDir = new File ( sourceDirectory ) ; getLog ( ) . debug ( MessageFormat . format ( Messages . AbstractSarlBatchCompilerMojo_7 , srcDir . getPath ( ) , srcDir . exists ( ) ) ) ; if ( srcDir . exists ( ) && srcDir . getParent ( ) != null ) { final String path = new File ( srcDir . getParent ( ) , sarlOutputDirProp ) . getPath ( ) ; getLog ( ) . debug ( MessageFormat . format ( Messages . AbstractSarlBatchCompilerMojo_8 , sarlOutputDirProp ) ) ; return path ; } } } catch ( FileNotFoundException e ) { getLog ( ) . warn ( e ) ; } catch ( IOException e ) { getLog ( ) . warn ( e ) ; } } else { getLog ( ) . debug ( MessageFormat . format ( Messages . AbstractSarlBatchCompilerMojo_9 , this . propertiesFileLocation ) ) ; } } return null ; } | Read the SARL Eclipse settings for the project if existing . | 361 | 12 |
34,168 | protected List < File > getClassPath ( ) throws MojoExecutionException { if ( this . bufferedClasspath == null ) { final Set < String > classPath = new LinkedHashSet <> ( ) ; final MavenProject project = getProject ( ) ; classPath . add ( project . getBuild ( ) . getSourceDirectory ( ) ) ; try { classPath . addAll ( project . getCompileClasspathElements ( ) ) ; } catch ( DependencyResolutionRequiredException e ) { throw new MojoExecutionException ( e . getLocalizedMessage ( ) , e ) ; } for ( final Artifact dep : project . getArtifacts ( ) ) { classPath . add ( dep . getFile ( ) . getAbsolutePath ( ) ) ; } classPath . remove ( project . getBuild ( ) . getOutputDirectory ( ) ) ; final List < File > files = new ArrayList <> ( ) ; for ( final String filename : classPath ) { final File file = new File ( filename ) ; if ( file . exists ( ) ) { files . add ( file ) ; } else { getLog ( ) . warn ( MessageFormat . format ( Messages . AbstractSarlBatchCompilerMojo_10 , filename ) ) ; } } this . bufferedClasspath = files ; } return this . bufferedClasspath ; } | Replies the classpath for the standard code . | 291 | 10 |
34,169 | protected boolean executeExportOperation ( IJarExportRunnable op , IStatus wizardPageStatus ) { try { getContainer ( ) . run ( true , true , op ) ; } catch ( InterruptedException e ) { return false ; } catch ( InvocationTargetException ex ) { if ( ex . getTargetException ( ) != null ) { ExceptionHandler . handle ( ex , getShell ( ) , FatJarPackagerMessages . JarPackageWizard_jarExportError_title , FatJarPackagerMessages . JarPackageWizard_jarExportError_message ) ; return false ; } } IStatus status = op . getStatus ( ) ; if ( ! status . isOK ( ) ) { if ( ! wizardPageStatus . isOK ( ) ) { if ( ! ( status instanceof MultiStatus ) ) status = new MultiStatus ( status . getPlugin ( ) , status . getCode ( ) , status . getMessage ( ) , status . getException ( ) ) ; ( ( MultiStatus ) status ) . add ( wizardPageStatus ) ; } ErrorDialog . openError ( getShell ( ) , FatJarPackagerMessages . JarPackageWizard_jarExport_title , null , status ) ; return ! ( status . matches ( IStatus . ERROR ) ) ; } else if ( ! wizardPageStatus . isOK ( ) ) { ErrorDialog . openError ( getShell ( ) , FatJarPackagerMessages . JarPackageWizard_jarExport_title , null , wizardPageStatus ) ; } return true ; } | Exports the JAR package . | 325 | 7 |
34,170 | public void init ( IWorkbench workbench , JarPackageData jarPackage ) { Assert . isNotNull ( workbench ) ; Assert . isNotNull ( jarPackage ) ; fJarPackage = jarPackage ; setInitializeFromJarPackage ( true ) ; setWindowTitle ( FatJarPackagerMessages . JarPackageWizard_windowTitle ) ; setDefaultPageImageDescriptor ( JavaPluginImages . DESC_WIZBAN_FAT_JAR_PACKAGER ) ; setNeedsProgressMonitor ( true ) ; } | Initializes this wizard from the given JAR package description . | 118 | 12 |
34,171 | protected Image convertToImage ( Object imageDescription ) { if ( imageDescription instanceof Image ) { return ( Image ) imageDescription ; } else if ( imageDescription instanceof ImageDescriptor ) { return this . imageHelper . getImage ( ( ImageDescriptor ) imageDescription ) ; } else if ( imageDescription instanceof String ) { return this . imageHelper . getImage ( ( String ) imageDescription ) ; } return null ; } | Replies the image that corresponds to the given object . | 92 | 11 |
34,172 | @ SuppressWarnings ( "static-method" ) protected int getIssueAdornment ( XtendMember element ) { final ICompositeNode node = NodeModelUtils . getNode ( element ) ; if ( node == null ) { return 0 ; } // Error markers are more important than warning markers. // Order of checks: // - parser error (from the resource) or semantic error (from Diagnostician) // - parser warning or semantic warning final Resource resource = element . eResource ( ) ; if ( ! resource . getURI ( ) . isArchive ( ) ) { if ( hasParserIssue ( node , resource . getErrors ( ) ) ) { return JavaElementImageDescriptor . ERROR ; } final Diagnostic diagnostic = Diagnostician . INSTANCE . validate ( element ) ; switch ( diagnostic . getSeverity ( ) ) { case Diagnostic . ERROR : return JavaElementImageDescriptor . ERROR ; case Diagnostic . WARNING : return JavaElementImageDescriptor . WARNING ; default : } if ( hasParserIssue ( node , resource . getWarnings ( ) ) ) { return JavaElementImageDescriptor . WARNING ; } } return 0 ; } | Replies the diagnotic adornment for the given element . | 254 | 15 |
34,173 | @ SuppressWarnings ( "static-method" ) public IJavaElement getSelectedResource ( IStructuredSelection selection ) { IJavaElement elem = null ; if ( selection != null && ! selection . isEmpty ( ) ) { final Object object = selection . getFirstElement ( ) ; if ( object instanceof IAdaptable ) { final IAdaptable adaptable = ( IAdaptable ) object ; elem = adaptable . getAdapter ( IJavaElement . class ) ; if ( elem == null ) { elem = getPackage ( adaptable ) ; } } } if ( elem == null ) { final IWorkbenchPage activePage = PlatformUI . getWorkbench ( ) . getActiveWorkbenchWindow ( ) . getActivePage ( ) ; IWorkbenchPart part = activePage . getActivePart ( ) ; if ( part instanceof ContentOutline ) { part = activePage . getActiveEditor ( ) ; } if ( part instanceof XtextEditor ) { final IXtextDocument doc = ( ( XtextEditor ) part ) . getDocument ( ) ; final IFile file = doc . getAdapter ( IFile . class ) ; elem = getPackage ( file ) ; } } if ( elem == null || elem . getElementType ( ) == IJavaElement . JAVA_MODEL ) { try { final IJavaProject [ ] projects = JavaCore . create ( ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ) . getJavaProjects ( ) ; if ( projects . length == 1 ) { elem = projects [ 0 ] ; } } catch ( JavaModelException e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } } return elem ; } | Replies the Java element that corresponds to the given selection . | 371 | 12 |
34,174 | @ Pure public String getBasePackage ( ) { final Grammar grammar = getGrammar ( ) ; final String basePackage = this . naming . getRuntimeBasePackage ( grammar ) ; return basePackage + ".services" ; //$NON-NLS-1$ } | Replies the base package for the language . | 58 | 9 |
34,175 | protected static Iterable < Keyword > getAllKeywords ( Grammar grammar ) { final Map < String , Keyword > keywords = new HashMap <> ( ) ; final List < ParserRule > rules = GrammarUtil . allParserRules ( grammar ) ; for ( final ParserRule parserRule : rules ) { final List < Keyword > list = typeSelect ( eAllContentsAsList ( parserRule ) , Keyword . class ) ; for ( final Keyword keyword : list ) { keywords . put ( keyword . getValue ( ) , keyword ) ; } } final List < EnumRule > enumRules = GrammarUtil . allEnumRules ( grammar ) ; for ( final EnumRule enumRule : enumRules ) { final List < Keyword > list = typeSelect ( eAllContentsAsList ( enumRule ) , Keyword . class ) ; for ( final Keyword keyword : list ) { keywords . put ( keyword . getValue ( ) , keyword ) ; } } return keywords . values ( ) ; } | Replies the keywords in the given grammar . | 219 | 9 |
34,176 | protected StringConcatenationClient generateKeyword ( final String keyword , final String comment , Map < String , String > getters ) { final String fieldName = keyword . toUpperCase ( ) . replaceAll ( "[^a-zA-Z0-9_]+" , "_" ) ; //$NON-NLS-1$ //$NON-NLS-2$ final String methodName = Strings . toFirstUpper ( keyword . replaceAll ( "[^a-zA-Z0-9_]+" , "_" ) ) //$NON-NLS-1$ //$NON-NLS-2$ + "Keyword" ; //$NON-NLS-1$ if ( getters != null ) { getters . put ( methodName , keyword ) ; } return new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "\tprivate static final String " ) ; //$NON-NLS-1$ it . append ( fieldName ) ; it . append ( " = \"" ) ; //$NON-NLS-1$ it . append ( Strings . convertToJavaString ( keyword ) ) ; it . append ( "\";" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\t/** Keyword: {@code " ) ; //$NON-NLS-1$ it . append ( protectCommentKeyword ( keyword ) ) ; it . append ( "}." ) ; //$NON-NLS-1$ it . newLine ( ) ; if ( ! Strings . isEmpty ( comment ) ) { it . append ( "\t * Source: " ) ; //$NON-NLS-1$ it . append ( comment ) ; it . newLine ( ) ; } it . append ( "\t */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\tpublic String get" ) ; //$NON-NLS-1$ it . append ( methodName ) ; it . append ( "() {" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t\treturn " ) ; //$NON-NLS-1$ it . append ( fieldName ) ; it . append ( ";" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; } | Generate a basic keyword . | 602 | 6 |
34,177 | protected StringConcatenationClient generateKeyword ( final Keyword keyword , final String comment , Map < String , String > getters ) { try { final String methodName = getIdentifier ( keyword ) ; final String accessor = GrammarKeywordAccessFragment2 . this . grammarAccessExtensions . gaAccessor ( keyword ) ; if ( ! Strings . isEmpty ( methodName ) && ! Strings . isEmpty ( accessor ) ) { if ( getters != null ) { getters . put ( methodName , keyword . getValue ( ) ) ; } return new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "\t/** Keyword: {@code " ) ; //$NON-NLS-1$ it . append ( protectCommentKeyword ( keyword . getValue ( ) ) ) ; it . append ( "}." ) ; //$NON-NLS-1$ it . newLine ( ) ; if ( ! Strings . isEmpty ( comment ) ) { it . append ( "\t * Source: " ) ; //$NON-NLS-1$ it . append ( comment ) ; it . newLine ( ) ; } it . append ( "\t */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\tpublic String get" ) ; //$NON-NLS-1$ it . append ( methodName ) ; it . append ( "() {" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t\treturn this.grammarAccess." ) ; //$NON-NLS-1$ it . append ( accessor ) ; it . append ( ".getValue();" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\t}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; } } catch ( Exception e ) { // } return null ; } | Generate a grammar keyword . | 469 | 6 |
34,178 | @ SuppressWarnings ( "static-method" ) protected String protectCommentKeyword ( String keyword ) { if ( "*/" . equals ( keyword ) ) { //$NON-NLS-1$ return "* /" ; //$NON-NLS-1$ } if ( "/*" . equals ( keyword ) ) { //$NON-NLS-1$ return "/ *" ; //$NON-NLS-1$ } if ( "//" . equals ( keyword ) ) { //$NON-NLS-1$ return "/ /" ; //$NON-NLS-1$ } return keyword ; } | Protect the keywword for Java comments . | 143 | 9 |
34,179 | @ SuppressWarnings ( { "checkstyle:npathcomplexity" , "checkstyle:cyclomaticcomplexity" } ) protected boolean isIgnorableCallToFeature ( ILinkingCandidate candidate ) { final JvmIdentifiableElement feature = candidate . getFeature ( ) ; // // @Deprecated // if ( feature instanceof JvmOperation ) { JvmAnnotationTarget target = ( JvmOperation ) feature ; JvmAnnotationReference reference = this . annotationLookup . findAnnotation ( target , Deprecated . class ) ; if ( reference == null ) { do { target = EcoreUtil2 . getContainerOfType ( target . eContainer ( ) , JvmAnnotationTarget . class ) ; if ( target != null ) { reference = this . annotationLookup . findAnnotation ( target , Deprecated . class ) ; } } while ( reference == null && target != null ) ; } if ( reference != null ) { return true ; } } return false ; } | Replies if ambiguity could be removed for the given feature . | 210 | 12 |
34,180 | protected void _computeTypes ( SarlBreakExpression object , ITypeComputationState state ) { final LightweightTypeReference primitiveVoid = getPrimitiveVoid ( state ) ; state . acceptActualType ( primitiveVoid ) ; } | Compute the type of a break expression . | 54 | 9 |
34,181 | protected void _computeTypes ( SarlAssertExpression object , ITypeComputationState state ) { state . withExpectation ( getTypeForName ( Boolean . class , state ) ) . computeTypes ( object . getCondition ( ) ) ; } | Compute the type of an assert expression . | 56 | 9 |
34,182 | @ SuppressWarnings ( "checkstyle:nestedifdepth" ) protected void _computeTypes ( SarlCastedExpression cast , ITypeComputationState state ) { if ( state instanceof AbstractTypeComputationState ) { final JvmTypeReference type = cast . getType ( ) ; if ( type != null ) { state . withNonVoidExpectation ( ) . computeTypes ( cast . getTarget ( ) ) ; // Set the linked feature try { final AbstractTypeComputationState computationState = ( AbstractTypeComputationState ) state ; final CastedExpressionTypeComputationState astate = new CastedExpressionTypeComputationState ( cast , computationState , this . castOperationValidator ) ; astate . resetFeature ( cast ) ; if ( astate . isCastOperatorLinkingEnabled ( cast ) ) { final List < ? extends ILinkingCandidate > candidates = astate . getLinkingCandidates ( cast ) ; if ( ! candidates . isEmpty ( ) ) { final ILinkingCandidate best = getBestCandidate ( candidates ) ; if ( best != null ) { best . applyToModel ( computationState . getResolvedTypes ( ) ) ; } } } } catch ( Throwable exception ) { final Throwable cause = Throwables . getRootCause ( exception ) ; state . addDiagnostic ( new EObjectDiagnosticImpl ( Severity . ERROR , IssueCodes . INTERNAL_ERROR , cause . getLocalizedMessage ( ) , cast , null , - 1 , null ) ) ; } state . acceptActualType ( state . getReferenceOwner ( ) . toLightweightTypeReference ( type ) ) ; } else { state . computeTypes ( cast . getTarget ( ) ) ; } } else { super . _computeTypes ( cast , state ) ; } } | Compute the type of a casted expression . | 398 | 10 |
34,183 | @ SuppressWarnings ( "unchecked" ) protected void fireEntryRemoved ( K key , V value ) { if ( this . listeners != null ) { for ( final DMapListener < ? super K , ? super V > listener : this . listeners . getListeners ( DMapListener . class ) ) { listener . entryRemoved ( key , value ) ; } } } | Fire the removal event . | 80 | 5 |
34,184 | @ SuppressWarnings ( "unchecked" ) protected void fireEntryUpdated ( K key , V value ) { for ( final DMapListener < ? super K , ? super V > listener : this . listeners . getListeners ( DMapListener . class ) ) { listener . entryUpdated ( key , value ) ; } } | Fire the update event . | 70 | 5 |
34,185 | @ SuppressWarnings ( "unchecked" ) protected void fireCleared ( boolean localClearing ) { for ( final DMapListener < ? super K , ? super V > listener : this . listeners . getListeners ( DMapListener . class ) ) { listener . mapCleared ( localClearing ) ; } } | Fire the clearing event . | 70 | 5 |
34,186 | protected Xpp3Dom createSREConfiguration ( ) throws MojoExecutionException , MojoFailureException { final Xpp3Dom xmlConfiguration = new Xpp3Dom ( "configuration" ) ; //$NON-NLS-1$ final Xpp3Dom xmlArchive = new Xpp3Dom ( "archive" ) ; //$NON-NLS-1$ xmlConfiguration . addChild ( xmlArchive ) ; final String mainClass = getMainClass ( ) ; if ( mainClass . isEmpty ( ) ) { throw new MojoFailureException ( "the main class of the SRE is missed" ) ; //$NON-NLS-1$ } final Xpp3Dom xmlManifest = new Xpp3Dom ( "manifest" ) ; //$NON-NLS-1$ xmlArchive . addChild ( xmlManifest ) ; final Xpp3Dom xmlManifestMainClass = new Xpp3Dom ( "mainClass" ) ; //$NON-NLS-1$ xmlManifestMainClass . setValue ( mainClass ) ; xmlManifest . addChild ( xmlManifestMainClass ) ; final Xpp3Dom xmlSections = new Xpp3Dom ( "manifestSections" ) ; //$NON-NLS-1$ xmlArchive . addChild ( xmlSections ) ; final Xpp3Dom xmlSection = new Xpp3Dom ( "manifestSection" ) ; //$NON-NLS-1$ xmlSections . addChild ( xmlSection ) ; final Xpp3Dom xmlSectionName = new Xpp3Dom ( "name" ) ; //$NON-NLS-1$ xmlSectionName . setValue ( SREConstants . MANIFEST_SECTION_SRE ) ; xmlSection . addChild ( xmlSectionName ) ; final Xpp3Dom xmlManifestEntries = new Xpp3Dom ( "manifestEntries" ) ; //$NON-NLS-1$ xmlSection . addChild ( xmlManifestEntries ) ; ManifestUpdater updater = getManifestUpdater ( ) ; if ( updater == null ) { updater = new ManifestUpdater ( ) { @ Override public void addSREAttribute ( String name , String value ) { assert name != null && ! name . isEmpty ( ) ; if ( value != null && ! value . isEmpty ( ) ) { getLog ( ) . debug ( "Adding to SRE manifest: " + name + " = " + value ) ; //$NON-NLS-1$//$NON-NLS-2$ final Xpp3Dom xmlManifestEntry = new Xpp3Dom ( name ) ; xmlManifestEntry . setValue ( value ) ; xmlManifestEntries . addChild ( xmlManifestEntry ) ; } } @ Override public void addMainAttribute ( String name , String value ) { // } } ; } buildManifest ( updater , mainClass ) ; return xmlConfiguration ; } | Create the configuration of the SRE with the maven archive format . | 662 | 14 |
34,187 | private void runInitializationStage ( Event event ) { // Immediate synchronous dispatching of Initialize event try { setOwnerState ( OwnerState . INITIALIZING ) ; try { this . eventDispatcher . immediateDispatch ( event ) ; } finally { setOwnerState ( OwnerState . ALIVE ) ; } this . agentAsEventListener . fireEnqueuedEvents ( this ) ; if ( this . agentAsEventListener . isKilled . get ( ) ) { this . agentAsEventListener . killOwner ( InternalEventBusSkill . this ) ; } } catch ( Exception e ) { // Log the exception final Logging loggingCapacity = getLoggingSkill ( ) ; if ( loggingCapacity != null ) { loggingCapacity . error ( Messages . InternalEventBusSkill_3 , e ) ; } else { final LogRecord record = new LogRecord ( Level . SEVERE , Messages . InternalEventBusSkill_3 ) ; this . logger . getKernelLogger ( ) . log ( this . logger . prepareLogRecord ( record , this . logger . getKernelLogger ( ) . getName ( ) , Throwables . getRootCause ( e ) ) ) ; } // If we have an exception within the agent's initialization, we kill the agent. setOwnerState ( OwnerState . ALIVE ) ; // Asynchronous kill of the event. this . agentAsEventListener . killOrMarkAsKilled ( ) ; } } | This function runs the initialization of the agent . | 309 | 9 |
34,188 | private void runDestructionStage ( Event event ) { // Immediate synchronous dispatching of Destroy event try { setOwnerState ( OwnerState . DYING ) ; try { this . eventDispatcher . immediateDispatch ( event ) ; } finally { setOwnerState ( OwnerState . DEAD ) ; } } catch ( Exception e ) { // Log the exception final Logging loggingCapacity = getLoggingSkill ( ) ; if ( loggingCapacity != null ) { loggingCapacity . error ( Messages . InternalEventBusSkill_4 , e ) ; } else { final LogRecord record = new LogRecord ( Level . SEVERE , Messages . InternalEventBusSkill_4 ) ; this . logger . getKernelLogger ( ) . log ( this . logger . prepareLogRecord ( record , this . logger . getKernelLogger ( ) . getName ( ) , Throwables . getRootCause ( e ) ) ) ; } } } | This function runs the destruction of the agent . | 199 | 9 |
34,189 | protected boolean isCapacityMethodCall ( JvmOperation feature ) { if ( feature != null ) { final JvmDeclaredType container = feature . getDeclaringType ( ) ; if ( container instanceof JvmGenericType ) { return this . inheritanceHelper . isSarlCapacity ( ( JvmGenericType ) container ) ; } } return false ; } | Replies if the given call is for a capacity function call . | 76 | 13 |
34,190 | protected void completeJavaTypes ( ContentAssistContext context , ITypesProposalProvider . Filter filter , ICompletionProposalAcceptor acceptor ) { completeJavaTypes ( context , TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE , true , getQualifiedNameValueConverter ( ) , filter , acceptor ) ; } | Complete for Java types . | 82 | 5 |
34,191 | protected void completeSarlEvents ( boolean allowEventType , boolean isExtensionFilter , ContentAssistContext context , ICompletionProposalAcceptor acceptor ) { if ( isSarlProposalEnabled ( ) ) { completeSubJavaTypes ( Event . class , allowEventType , context , TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE , getQualifiedNameValueConverter ( ) , isExtensionFilter ? createExtensionFilter ( context , IJavaSearchConstants . CLASS ) : createVisibilityFilter ( context , IJavaSearchConstants . CLASS ) , acceptor ) ; } } | Complete for obtaining SARL events if the proposals are enabled . | 140 | 12 |
34,192 | protected void completeSarlCapacities ( boolean allowCapacityType , boolean isExtensionFilter , ContentAssistContext context , ICompletionProposalAcceptor acceptor ) { if ( isSarlProposalEnabled ( ) ) { completeSubJavaTypes ( Capacity . class , allowCapacityType , context , TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE , getQualifiedNameValueConverter ( ) , isExtensionFilter ? createExtensionFilter ( context , IJavaSearchConstants . INSTANCEOF_TYPE_REFERENCE ) : createVisibilityFilter ( context , IJavaSearchConstants . INTERFACE ) , acceptor ) ; } } | Complete for obtaining SARL capacities if the proposals are enabled . | 154 | 12 |
34,193 | protected void completeSarlAgents ( boolean allowAgentType , boolean isExtensionFilter , ContentAssistContext context , ICompletionProposalAcceptor acceptor ) { if ( isSarlProposalEnabled ( ) ) { completeSubJavaTypes ( Agent . class , allowAgentType , context , TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE , getQualifiedNameValueConverter ( ) , isExtensionFilter ? createExtensionFilter ( context , IJavaSearchConstants . CLASS ) : createVisibilityFilter ( context , IJavaSearchConstants . CLASS ) , acceptor ) ; } } | Complete for obtaining SARL agents if the proposals are enabled . | 141 | 12 |
34,194 | protected void completeSarlBehaviors ( boolean allowBehaviorType , boolean isExtensionFilter , ContentAssistContext context , ICompletionProposalAcceptor acceptor ) { if ( isSarlProposalEnabled ( ) ) { completeSubJavaTypes ( Behavior . class , allowBehaviorType , context , TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE , getQualifiedNameValueConverter ( ) , isExtensionFilter ? createExtensionFilter ( context , IJavaSearchConstants . CLASS ) : createVisibilityFilter ( context , IJavaSearchConstants . CLASS ) , acceptor ) ; } } | Complete for obtaining SARL behaviors if the proposals are enabled . | 144 | 12 |
34,195 | protected void completeSarlSkills ( boolean allowSkillType , boolean isExtensionFilter , ContentAssistContext context , ICompletionProposalAcceptor acceptor ) { if ( isSarlProposalEnabled ( ) ) { completeSubJavaTypes ( Skill . class , allowSkillType , context , TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE , getQualifiedNameValueConverter ( ) , isExtensionFilter ? createExtensionFilter ( context , IJavaSearchConstants . CLASS ) : createVisibilityFilter ( context , IJavaSearchConstants . CLASS ) , acceptor ) ; } } | Complete for obtaining SARL skills if proposals are enabled . | 141 | 11 |
34,196 | protected void completeExceptions ( boolean allowExceptionType , ContentAssistContext context , ICompletionProposalAcceptor acceptor ) { if ( isSarlProposalEnabled ( ) ) { completeSubJavaTypes ( Exception . class , allowExceptionType , context , TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE , getQualifiedNameValueConverter ( ) , createVisibilityFilter ( context , IJavaSearchConstants . CLASS ) , acceptor ) ; } } | Complete for obtaining exception types if proposals are enabled . | 112 | 10 |
34,197 | protected void completeSubJavaTypes ( Class < ? > superType , boolean allowSuperTypeItself , ContentAssistContext context , EReference reference , IValueConverter < String > valueConverter , final ITypesProposalProvider . Filter filter , ICompletionProposalAcceptor acceptor ) { assert superType != null ; final INode lastCompleteNode = context . getLastCompleteNode ( ) ; if ( lastCompleteNode instanceof ILeafNode && ! ( ( ILeafNode ) lastCompleteNode ) . isHidden ( ) ) { if ( lastCompleteNode . getLength ( ) > 0 && lastCompleteNode . getTotalEndOffset ( ) == context . getOffset ( ) ) { final String text = lastCompleteNode . getText ( ) ; final char lastChar = text . charAt ( text . length ( ) - 1 ) ; if ( Character . isJavaIdentifierPart ( lastChar ) ) { return ; } } } final ITypesProposalProvider . Filter subTypeFilter ; if ( allowSuperTypeItself ) { subTypeFilter = filter ; } else { final String superTypeQualifiedName = superType . getName ( ) ; subTypeFilter = new ITypesProposalProvider . Filter ( ) { @ Override public boolean accept ( int modifiers , char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , String path ) { final String fullName = JavaModelUtil . concatenateName ( packageName , simpleTypeName ) ; if ( Objects . equals ( superTypeQualifiedName , fullName ) ) { return false ; } return filter . accept ( modifiers , packageName , simpleTypeName , enclosingTypeNames , path ) ; } @ Override public int getSearchFor ( ) { return filter . getSearchFor ( ) ; } } ; } getTypesProposalProvider ( ) . createSubTypeProposals ( this . typeReferences . findDeclaredType ( superType , context . getCurrentModel ( ) ) , this , context , reference , subTypeFilter , valueConverter , acceptor ) ; } | Complete for obtaining SARL types that are subtypes of the given type . | 448 | 15 |
34,198 | protected String getExpectedPackageName ( EObject model ) { final URI fileURI = model . eResource ( ) . getURI ( ) ; for ( final Pair < IStorage , IProject > storage : this . storage2UriMapper . getStorages ( fileURI ) ) { if ( storage . getFirst ( ) instanceof IFile ) { final IPath fileWorkspacePath = storage . getFirst ( ) . getFullPath ( ) ; final IJavaProject javaProject = JavaCore . create ( storage . getSecond ( ) ) ; return extractProjectPath ( fileWorkspacePath , javaProject ) ; } } return null ; } | Replies the expected package for the given model . | 137 | 10 |
34,199 | protected void completeExtends ( EObject model , ContentAssistContext context , ICompletionProposalAcceptor acceptor ) { if ( isSarlProposalEnabled ( ) ) { if ( model instanceof SarlAgent ) { completeSarlAgents ( false , true , context , acceptor ) ; } else if ( model instanceof SarlBehavior ) { completeSarlBehaviors ( false , true , context , acceptor ) ; } else if ( model instanceof SarlCapacity ) { completeSarlCapacities ( false , true , context , acceptor ) ; } else if ( model instanceof SarlSkill ) { completeSarlSkills ( false , true , context , acceptor ) ; } else if ( model instanceof SarlEvent ) { completeSarlEvents ( false , true , context , acceptor ) ; } else if ( model instanceof SarlClass ) { completeJavaTypes ( context , createExtensionFilter ( context , IJavaSearchConstants . CLASS ) , acceptor ) ; } else if ( model instanceof SarlInterface ) { completeJavaTypes ( context , createExtensionFilter ( context , IJavaSearchConstants . INTERFACE ) , acceptor ) ; } } } | Complete the extends if the proposals are enabled . | 260 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.