idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
34,100 | protected static File toPackageFolder ( String packageName ) { File file = null ; for ( final String element : packageName . split ( "[.]" ) ) { if ( file == null ) { file = new File ( element ) ; } else { file = new File ( file , element ) ; } } return file ; } | Convert a a package name for therelative file . |
34,101 | protected String getBootClassPath ( ) throws IOException { final Toolchain toolchain = this . toolchainManager . getToolchainFromBuildContext ( "jdk" , this . session ) ; if ( toolchain instanceof JavaToolchain && toolchain instanceof ToolchainPrivate ) { final JavaToolchain javaToolChain = ( JavaToolchain ) toolchain ; final ToolchainPrivate privateJavaToolChain = ( ToolchainPrivate ) toolchain ; String [ ] includes = { "jre/lib/*" , "jre/lib/ext/*" , "jre/lib/endorsed/*" } ; String [ ] excludes = new String [ 0 ] ; final Xpp3Dom config = ( Xpp3Dom ) privateJavaToolChain . getModel ( ) . getConfiguration ( ) ; if ( config != null ) { final Xpp3Dom bootClassPath = config . getChild ( "bootClassPath" ) ; if ( bootClassPath != null ) { final Xpp3Dom includeParent = bootClassPath . getChild ( "includes" ) ; if ( includeParent != null ) { includes = getValues ( includeParent . getChildren ( "include" ) ) ; } final Xpp3Dom excludeParent = bootClassPath . getChild ( "excludes" ) ; if ( excludeParent != null ) { excludes = getValues ( excludeParent . getChildren ( "exclude" ) ) ; } } } try { return scanBootclasspath ( Objects . toString ( this . reflect . invoke ( javaToolChain , "getJavaHome" ) ) , includes , excludes ) ; } catch ( Exception e ) { throw new IOException ( e . getLocalizedMessage ( ) , e ) ; } } return "" ; } | Replies the boot classpath . |
34,102 | protected XExpression fromString ( String expression ) { if ( ! Strings . isEmpty ( expression ) ) { ResourceSet resourceSet = this . context . eResource ( ) . getResourceSet ( ) ; URI uri = computeUnusedUri ( resourceSet ) ; Resource resource = getResourceFactory ( ) . createResource ( uri ) ; resourceSet . getResources ( ) . add ( resource ) ; try ( StringInputStream is = new StringInputStream ( generateExpressionCode ( expression ) ) ) { resource . load ( is , null ) ; SarlScript script = resource . getContents ( ) . isEmpty ( ) ? null : ( SarlScript ) resource . getContents ( ) . get ( 0 ) ; SarlEvent topElement = ( SarlEvent ) script . getXtendTypes ( ) . get ( 0 ) ; SarlField member = ( SarlField ) topElement . getMembers ( ) . get ( 0 ) ; return member . getInitialValue ( ) ; } catch ( Throwable exception ) { throw new RuntimeException ( exception ) ; } finally { resourceSet . getResources ( ) . remove ( resource ) ; } } throw new IllegalArgumentException ( "not a valid expression" ) ; } | Create an expression but does not change the container . |
34,103 | public XExpression getDefaultXExpressionForType ( String type ) { XExpression expr = null ; if ( type != null && ! "void" . equals ( type ) && ! Void . class . getName ( ) . equals ( type ) ) { switch ( type ) { case "boolean" : case "java.lang.Boolean" : XBooleanLiteral booleanLiteral = XbaseFactory . eINSTANCE . createXBooleanLiteral ( ) ; booleanLiteral . setIsTrue ( false ) ; expr = booleanLiteral ; break ; case "float" : case "java.lang.Float" : XNumberLiteral numberLiteral = XbaseFactory . eINSTANCE . createXNumberLiteral ( ) ; numberLiteral . setValue ( "0.0f" ) ; expr = numberLiteral ; break ; case "double" : case "java.lang.Double" : case "java.lang.BigDecimal" : numberLiteral = XbaseFactory . eINSTANCE . createXNumberLiteral ( ) ; numberLiteral . setValue ( "0.0" ) ; expr = numberLiteral ; break ; case "int" : case "long" : case "java.lang.Integer" : case "java.lang.Long" : case "java.lang.BigInteger" : numberLiteral = XbaseFactory . eINSTANCE . createXNumberLiteral ( ) ; numberLiteral . setValue ( "0" ) ; expr = numberLiteral ; break ; case "byte" : case "short" : case "char" : case "java.lang.Byte" : case "java.lang.Short" : case "java.lang.Character" : numberLiteral = XbaseFactory . eINSTANCE . createXNumberLiteral ( ) ; numberLiteral . setValue ( "0" ) ; XCastedExpression castExpression = XbaseFactory . eINSTANCE . createXCastedExpression ( ) ; castExpression . setTarget ( numberLiteral ) ; castExpression . setType ( newTypeRef ( this . context , type ) ) ; expr = numberLiteral ; break ; default : expr = XbaseFactory . eINSTANCE . createXNullLiteral ( ) ; break ; } } return expr ; } | Replies the XExpression for the default value associated to the given type . |
34,104 | public String getDefaultValueForType ( String type ) { String defaultValue = "" ; if ( ! Strings . isEmpty ( type ) && ! "void" . equals ( type ) ) { switch ( type ) { case "boolean" : defaultValue = "true" ; break ; case "double" : defaultValue = "0.0" ; break ; case "float" : defaultValue = "0.0f" ; break ; case "int" : defaultValue = "0" ; break ; case "long" : defaultValue = "0" ; break ; case "byte" : defaultValue = "(0 as byte)" ; break ; case "short" : defaultValue = "(0 as short)" ; break ; case "char" : defaultValue = "(0 as char)" ; break ; default : defaultValue = "null" ; break ; } } return defaultValue ; } | Replies the default value for the given type . |
34,105 | public XFeatureCall createReferenceToThis ( ) { final XExpression expr = getXExpression ( ) ; XtendTypeDeclaration type = EcoreUtil2 . getContainerOfType ( expr , XtendTypeDeclaration . class ) ; JvmType jvmObject = getAssociatedElement ( JvmType . class , type , expr . eResource ( ) ) ; final XFeatureCall thisFeature = XbaseFactory . eINSTANCE . createXFeatureCall ( ) ; thisFeature . setFeature ( jvmObject ) ; return thisFeature ; } | Create a reference to this object or to the current type . |
34,106 | public XFeatureCall createReferenceToSuper ( ) { final XExpression expr = getXExpression ( ) ; XtendTypeDeclaration type = EcoreUtil2 . getContainerOfType ( expr , XtendTypeDeclaration . class ) ; JvmType jvmObject = getAssociatedElement ( JvmType . class , type , expr . eResource ( ) ) ; final XFeatureCall superFeature = XbaseFactory . eINSTANCE . createXFeatureCall ( ) ; JvmIdentifiableElement feature ; if ( jvmObject instanceof JvmDeclaredType ) { feature = ( ( JvmDeclaredType ) jvmObject ) . getExtendedClass ( ) . getType ( ) ; } else { feature = findType ( expr , getQualifiedName ( type ) ) . getType ( ) ; if ( feature instanceof JvmDeclaredType ) { feature = ( ( JvmDeclaredType ) feature ) . getExtendedClass ( ) . getType ( ) ; } else { feature = null ; } } if ( feature == null ) { return null ; } superFeature . setFeature ( feature ) ; return superFeature ; } | Create a reference to super object or to the super type . |
34,107 | public static InetAddress getLoopbackAddress ( ) { try { final Enumeration < NetworkInterface > interfaces = NetworkInterface . getNetworkInterfaces ( ) ; if ( interfaces != null ) { NetworkInterface inter ; InetAddress adr ; Enumeration < InetAddress > addrs ; while ( interfaces . hasMoreElements ( ) ) { inter = interfaces . nextElement ( ) ; addrs = inter . getInetAddresses ( ) ; if ( addrs != null ) { while ( addrs . hasMoreElements ( ) ) { adr = addrs . nextElement ( ) ; if ( adr != null && adr . isLoopbackAddress ( ) && ( adr instanceof Inet4Address ) ) { return adr ; } } } } } } catch ( SocketException e ) { } return null ; } | Replies the IPv4 loopback address . |
34,108 | public static URI toURI ( String uri ) throws URISyntaxException { final URI u = new URI ( uri ) ; String adr = u . getAuthority ( ) ; if ( adr == null ) { adr = u . getPath ( ) ; } if ( adr != null && adr . endsWith ( ":*" ) ) { return new URI ( u . getScheme ( ) , u . getUserInfo ( ) , adr . substring ( 0 , adr . length ( ) - 2 ) , - 1 , null , u . getQuery ( ) , u . getFragment ( ) ) ; } return u ; } | Convert a string URI to an object URI . |
34,109 | public static URI toURI ( InetAddress adr ) { try { return new URI ( "tcp" , adr . getHostAddress ( ) , null , null ) ; } catch ( URISyntaxException e ) { throw new IOError ( e ) ; } } | Convert an inet address to an URI . |
34,110 | protected LightweightTypeReference toLightweightTypeReference ( JvmType type , EObject context ) { final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner ( getServices ( ) , context ) ; final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory ( owner , false ) ; return factory . toLightweightReference ( type ) ; } | Create a lightweight type reference from the given type . |
34,111 | protected boolean isIgnored ( String issueCode , EObject currentObject ) { final IssueSeverities severities = getIssueSeverities ( getContext ( ) , currentObject ) ; return severities . isIgnored ( issueCode ) ; } | Replies if the given issue is ignored for the given object . |
34,112 | protected String canonicalName ( EObject object ) { if ( object instanceof JvmIdentifiableElement ) { return ( ( JvmIdentifiableElement ) object ) . getQualifiedName ( ) ; } final EObject jvmElement = this . associations . getPrimaryJvmElement ( object ) ; if ( jvmElement instanceof JvmIdentifiableElement ) { return ( ( JvmIdentifiableElement ) jvmElement ) . getQualifiedName ( ) ; } return null ; } | Replies the canonical name of the given object . |
34,113 | public void checkSpaceUse ( SarlSpace space ) { error ( MessageFormat . format ( Messages . SARLValidator_0 , this . grammarAccess . getSpaceKeyword ( ) ) , space , null ) ; } | Space keyword is reserved . |
34,114 | public void checkArtifactUse ( SarlArtifact artifact ) { error ( MessageFormat . format ( Messages . SARLValidator_0 , this . grammarAccess . getSpaceKeyword ( ) ) , artifact , null ) ; } | Artifact keyword is reserved . |
34,115 | public void checkEarlyExitEventInFires ( SarlAction action ) { int i = 0 ; for ( final JvmTypeReference event : action . getFiredEvents ( ) ) { if ( ! this . earlyExitComputer . isEarlyExitEvent ( event ) ) { warning ( MessageFormat . format ( Messages . SARLValidator_95 , event . getSimpleName ( ) ) , action , SarlPackage . eINSTANCE . getSarlAction_FiredEvents ( ) , i ) ; } ++ i ; } } | Emit a warning when the events after the fires keyword are not early - exit events . |
34,116 | public void checkRequiredCapacityUse ( SarlRequiredCapacity statement ) { warning ( MessageFormat . format ( Messages . SARLValidator_0 , this . grammarAccess . getRequiresKeyword ( ) ) , statement , null ) ; } | Emit a warning when the requires keyword is used . |
34,117 | protected void checkModifiers ( SarlAgent agent ) { this . agentModifierValidator . checkModifiers ( agent , MessageFormat . format ( Messages . SARLValidator_9 , agent . getName ( ) ) ) ; } | Check the modifiers for the SARL agents . |
34,118 | protected void checkModifiers ( SarlBehavior behavior ) { this . behaviorModifierValidator . checkModifiers ( behavior , MessageFormat . format ( Messages . SARLValidator_9 , behavior . getName ( ) ) ) ; } | Check the modifiers for the SARL behaviors . |
34,119 | protected void checkModifiers ( SarlCapacity capacity ) { this . capacityModifierValidator . checkModifiers ( capacity , MessageFormat . format ( Messages . SARLValidator_9 , capacity . getName ( ) ) ) ; } | Check the modifiers for the SARL capacities . |
34,120 | protected void checkModifiers ( SarlSkill skill ) { this . skillModifierValidator . checkModifiers ( skill , MessageFormat . format ( Messages . SARLValidator_9 , skill . getName ( ) ) ) ; } | Check the modifiers for the SARL skills . |
34,121 | public void checkContainerType ( SarlAgent agent ) { final XtendTypeDeclaration declaringType = agent . getDeclaringType ( ) ; if ( declaringType != null ) { final String name = canonicalName ( declaringType ) ; assert name != null ; error ( MessageFormat . format ( Messages . SARLValidator_28 , name ) , agent , null , INVALID_NESTED_DEFINITION ) ; } } | Check the container for the SARL agents . |
34,122 | public void checkContainerType ( SarlBehavior behavior ) { final XtendTypeDeclaration declaringType = behavior . getDeclaringType ( ) ; if ( declaringType != null ) { final String name = canonicalName ( declaringType ) ; assert name != null ; error ( MessageFormat . format ( Messages . SARLValidator_29 , name ) , behavior , null , INVALID_NESTED_DEFINITION ) ; } } | Check the container for the SARL behaviors . |
34,123 | public void checkContainerType ( SarlCapacity capacity ) { final XtendTypeDeclaration declaringType = capacity . getDeclaringType ( ) ; if ( declaringType != null ) { final String name = canonicalName ( declaringType ) ; assert name != null ; error ( MessageFormat . format ( Messages . SARLValidator_30 , name ) , capacity , null , INVALID_NESTED_DEFINITION ) ; } } | Check the container for the SARL capacities . |
34,124 | public void checkContainerType ( SarlSkill skill ) { final XtendTypeDeclaration declaringType = skill . getDeclaringType ( ) ; if ( declaringType != null ) { final String name = canonicalName ( declaringType ) ; assert name != null ; error ( MessageFormat . format ( Messages . SARLValidator_31 , name ) , skill , null , INVALID_NESTED_DEFINITION ) ; } } | Check the container for the SARL skills . |
34,125 | public void checkFinalFieldInitialization ( SarlEvent event ) { final JvmGenericType inferredType = this . associations . getInferredType ( event ) ; if ( inferredType != null ) { checkFinalFieldInitialization ( inferredType ) ; } } | Check if all the fields are initialized in a SARL event . |
34,126 | public void checkFinalFieldInitialization ( SarlBehavior behavior ) { final JvmGenericType inferredType = this . associations . getInferredType ( behavior ) ; if ( inferredType != null ) { checkFinalFieldInitialization ( inferredType ) ; } } | Check if all the fields are initialized in a SARL behavior . |
34,127 | public void checkFinalFieldInitialization ( SarlSkill skill ) { final JvmGenericType inferredType = this . associations . getInferredType ( skill ) ; if ( inferredType != null ) { checkFinalFieldInitialization ( inferredType ) ; } } | Check if all the fields are initialized in a SARL skill . |
34,128 | public void checkFinalFieldInitialization ( SarlAgent agent ) { final JvmGenericType inferredType = this . associations . getInferredType ( agent ) ; if ( inferredType != null ) { checkFinalFieldInitialization ( inferredType ) ; } } | Check if all the fields are initialized in a SARL agent . |
34,129 | @ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:npathcomplexity" , "checkstyle:nestedifdepth" } ) protected void checkSuperConstructor ( XtendTypeDeclaration container , EStructuralFeature feature , Collection < ActionParameterTypes > defaultSignatures ) { final JvmDeclaredType jvmElement = this . associations . getInferredType ( container ) ; if ( jvmElement != null ) { final Map < ActionParameterTypes , JvmConstructor > superConstructors = CollectionLiterals . newTreeMap ( ( Comparator < ActionParameterTypes > ) null ) ; final JvmTypeReference typeRef = jvmElement . getExtendedClass ( ) ; final JvmType supertype = ( typeRef == null ) ? null : typeRef . getType ( ) ; if ( supertype instanceof JvmGenericType ) { final JvmGenericType jvmSuperElement = ( JvmGenericType ) supertype ; for ( final JvmConstructor superConstructor : jvmSuperElement . getDeclaredConstructors ( ) ) { final ActionParameterTypes sig = this . sarlActionSignatures . createParameterTypesFromJvmModel ( superConstructor . isVarArgs ( ) , superConstructor . getParameters ( ) ) ; superConstructors . put ( sig , superConstructor ) ; } } final ActionParameterTypes voidKey = this . sarlActionSignatures . createParameterTypesForVoid ( ) ; for ( final XtendMember member : container . getMembers ( ) ) { if ( member instanceof SarlConstructor ) { final SarlConstructor constructor = ( SarlConstructor ) member ; boolean invokeDefaultConstructor = true ; final XExpression body = constructor . getExpression ( ) ; if ( body instanceof XBlockExpression ) { final XBlockExpression block = ( XBlockExpression ) body ; if ( ! block . getExpressions ( ) . isEmpty ( ) ) { final XExpression firstStatement = block . getExpressions ( ) . get ( 0 ) ; if ( firstStatement instanceof XConstructorCall || isDelegateConstructorCall ( firstStatement ) ) { invokeDefaultConstructor = false ; } } } else if ( body instanceof XConstructorCall || isDelegateConstructorCall ( body ) ) { invokeDefaultConstructor = false ; } if ( invokeDefaultConstructor && ! superConstructors . containsKey ( voidKey ) ) { final List < String > issueData = new ArrayList < > ( ) ; for ( final ActionParameterTypes defaultSignature : defaultSignatures ) { issueData . add ( defaultSignature . toString ( ) ) ; } error ( Messages . SARLValidator_33 , member , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , MUST_INVOKE_SUPER_CONSTRUCTOR , toArray ( issueData , String . class ) ) ; } } } } } | Check the super constructors . |
34,130 | @ Check ( CheckType . FAST ) public void checkForbiddenCalls ( XAbstractFeatureCall expression ) { if ( this . featureCallValidator . isDisallowedCall ( expression ) ) { error ( MessageFormat . format ( Messages . SARLValidator_36 , expression . getFeature ( ) . getIdentifier ( ) ) , expression , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , FORBIDDEN_REFERENCE ) ; } } | Check if the call is forbidden . |
34,131 | @ Check ( CheckType . FAST ) public void checkDiscouragedCalls ( XAbstractFeatureCall expression ) { if ( ! isIgnored ( DISCOURAGED_REFERENCE ) && this . featureCallValidator . isDiscouragedCall ( expression ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_37 , expression . getConcreteSyntaxFeatureName ( ) ) , expression , DISCOURAGED_REFERENCE ) ; } } | Check if the call is discouraged . |
34,132 | public void checkDefaultValueTypeCompatibleWithParameterType ( SarlFormalParameter param ) { final XExpression defaultValue = param . getDefaultValue ( ) ; if ( defaultValue != null ) { final JvmTypeReference rawType = param . getParameterType ( ) ; assert rawType != null ; final LightweightTypeReference toType = toLightweightTypeReference ( rawType , true ) ; if ( toType == null ) { error ( MessageFormat . format ( Messages . SARLValidator_20 , param . getName ( ) ) , param , XtendPackage . Literals . XTEND_PARAMETER__PARAMETER_TYPE , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_TYPE ) ; return ; } LightweightTypeReference fromType = getExpectedType ( defaultValue ) ; if ( fromType == null ) { fromType = getActualType ( defaultValue ) ; if ( fromType == null ) { error ( MessageFormat . format ( Messages . SARLValidator_21 , param . getName ( ) ) , param , SARL_FORMAL_PARAMETER__DEFAULT_VALUE , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_TYPE ) ; return ; } } if ( ! Utils . canCast ( fromType , toType , true , false , true ) ) { error ( MessageFormat . format ( Messages . SARLValidator_38 , getNameOfTypes ( fromType ) , canonicalName ( toType ) ) , param , SARL_FORMAL_PARAMETER__DEFAULT_VALUE , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INCOMPATIBLE_TYPES , canonicalName ( fromType ) , canonicalName ( toType ) ) ; } } } | Check if the default values of the formal parameters have a compatible type with the formal parameter . |
34,133 | public void checkDefaultValueFieldReference ( SarlFormalParameter param ) { final XExpression defaultValue = param . getDefaultValue ( ) ; if ( defaultValue != null ) { final Iterator < XFeatureCall > iter ; if ( defaultValue instanceof XFeatureCall ) { iter = Iterators . singletonIterator ( ( XFeatureCall ) defaultValue ) ; } else { iter = Iterators . filter ( defaultValue . eAllContents ( ) , XFeatureCall . class ) ; } while ( iter . hasNext ( ) ) { final XFeatureCall call = iter . next ( ) ; final JvmIdentifiableElement feature = call . getFeature ( ) ; String invalidFieldName = null ; if ( feature instanceof XtendField ) { final XtendField field = ( XtendField ) feature ; if ( ! field . isFinal ( ) ) { invalidFieldName = field . getName ( ) ; } } else if ( feature instanceof JvmField ) { final JvmField field = ( JvmField ) feature ; if ( ! field . isFinal ( ) ) { invalidFieldName = field . getSimpleName ( ) ; } } if ( invalidFieldName != null ) { error ( MessageFormat . format ( Messages . SARLValidator_19 , invalidFieldName ) , call , XbasePackage . Literals . XABSTRACT_FEATURE_CALL__FEATURE , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , FORBIDDEN_REFERENCE ) ; } } } } | Check if the default values has not a reference to the not final fields . |
34,134 | @ Check ( CheckType . FAST ) public void checkActionName ( SarlAction action ) { final JvmOperation inferredType = this . associations . getDirectlyInferredOperation ( action ) ; final QualifiedName name = QualifiedName . create ( inferredType . getQualifiedName ( '.' ) . split ( "\\." ) ) ; if ( this . featureNames . isDisallowedName ( name ) ) { final String validName = Utils . fixHiddenMember ( action . getName ( ) ) ; error ( MessageFormat . format ( Messages . SARLValidator_39 , action . getName ( ) ) , action , XTEND_FUNCTION__NAME , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_MEMBER_NAME , validName ) ; } else if ( ! isIgnored ( DISCOURAGED_FUNCTION_NAME ) && this . featureNames . isDiscouragedName ( name ) ) { warning ( MessageFormat . format ( Messages . SARLValidator_39 , action . getName ( ) ) , action , XTEND_FUNCTION__NAME , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , DISCOURAGED_FUNCTION_NAME ) ; } } | Check if the given action has a valid name . |
34,135 | @ Check ( CheckType . FAST ) public void checkFieldName ( SarlField field ) { final JvmField inferredType = this . associations . getJvmField ( field ) ; final QualifiedName name = Utils . getQualifiedName ( inferredType ) ; if ( this . featureNames . isDisallowedName ( name ) ) { final String validName = Utils . fixHiddenMember ( field . getName ( ) ) ; error ( MessageFormat . format ( Messages . SARLValidator_41 , field . getName ( ) ) , field , XTEND_FIELD__NAME , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , VARIABLE_NAME_DISALLOWED , validName ) ; } else if ( this . grammarAccess . getOccurrenceKeyword ( ) . equals ( field . getName ( ) ) ) { error ( MessageFormat . format ( Messages . SARLValidator_41 , this . grammarAccess . getOccurrenceKeyword ( ) ) , field , XTEND_FIELD__NAME , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , VARIABLE_NAME_DISALLOWED ) ; } } | Check if the given field has a valid name . |
34,136 | public void checkFieldNameShadowing ( SarlField field ) { if ( ! isIgnored ( VARIABLE_NAME_SHADOWING ) && ! Utils . isHiddenMember ( field . getName ( ) ) ) { final JvmField inferredField = this . associations . getJvmField ( field ) ; final Map < String , JvmField > inheritedFields = new TreeMap < > ( ) ; Utils . populateInheritanceContext ( inferredField . getDeclaringType ( ) , null , null , inheritedFields , null , null , this . sarlActionSignatures ) ; final JvmField inheritedField = inheritedFields . get ( field . getName ( ) ) ; if ( inheritedField != null ) { int nameIndex = 0 ; String newName = field . getName ( ) + nameIndex ; while ( inheritedFields . containsKey ( newName ) ) { ++ nameIndex ; newName = field . getName ( ) + nameIndex ; } addIssue ( MessageFormat . format ( Messages . SARLValidator_42 , field . getName ( ) , inferredField . getDeclaringType ( ) . getQualifiedName ( ) , inheritedField . getQualifiedName ( ) ) , field , XTEND_FIELD__NAME , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , VARIABLE_NAME_SHADOWING , newName ) ; } } } | Check if the given field has a name that is shadowing an inherited field . |
34,137 | @ Check ( CheckType . FAST ) public void checkParameterName ( SarlFormalParameter parameter ) { if ( this . grammarAccess . getOccurrenceKeyword ( ) . equals ( parameter . getName ( ) ) ) { error ( MessageFormat . format ( Messages . SARLValidator_14 , this . grammarAccess . getOccurrenceKeyword ( ) ) , parameter , XtendPackage . Literals . XTEND_PARAMETER__NAME , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , VARIABLE_NAME_DISALLOWED ) ; } } | Check if the given parameter has a valid name . |
34,138 | @ Check ( CheckType . FAST ) public void checkParameterName ( XVariableDeclaration variable ) { if ( this . grammarAccess . getOccurrenceKeyword ( ) . equals ( variable . getName ( ) ) ) { error ( MessageFormat . format ( Messages . SARLValidator_15 , this . grammarAccess . getOccurrenceKeyword ( ) ) , variable , XbasePackage . Literals . XVARIABLE_DECLARATION__NAME , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , VARIABLE_NAME_DISALLOWED ) ; } } | Check if the given local variable has a valid name . |
34,139 | public void checkRedundantImplementedInterfaces ( SarlSkill skill ) { checkRedundantInterfaces ( skill , SARL_SKILL__IMPLEMENTS , skill . getImplements ( ) , Utils . singletonList ( skill . getExtends ( ) ) ) ; } | Check if implemented interfaces of a skill are redundant . |
34,140 | public void checkRedundantImplementedInterfaces ( SarlClass xtendClass ) { checkRedundantInterfaces ( xtendClass , XTEND_CLASS__IMPLEMENTS , xtendClass . getImplements ( ) , Utils . singletonList ( xtendClass . getExtends ( ) ) ) ; } | Check if implemented interfaces of a Xtend Class are redundant . |
34,141 | public void checkRedundantImplementedInterfaces ( SarlInterface xtendInterface ) { checkRedundantInterfaces ( xtendInterface , XTEND_INTERFACE__EXTENDS , xtendInterface . getExtends ( ) , Collections . < JvmTypeReference > emptyList ( ) ) ; } | Check if implemented interfaces of a Xtend Interface are redundant . |
34,142 | @ Check ( CheckType . FAST ) public void checkBehaviorUnitGuardType ( SarlBehaviorUnit behaviorUnit ) { final XExpression guard = behaviorUnit . getGuard ( ) ; if ( guard != null ) { if ( this . operationHelper . hasSideEffects ( null , guard ) ) { error ( Messages . SARLValidator_53 , guard , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_INNER_EXPRESSION ) ; return ; } if ( guard instanceof XBooleanLiteral ) { final XBooleanLiteral booleanLiteral = ( XBooleanLiteral ) guard ; if ( booleanLiteral . isIsTrue ( ) ) { if ( ! isIgnored ( DISCOURAGED_BOOLEAN_EXPRESSION ) ) { addIssue ( Messages . SARLValidator_54 , booleanLiteral , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , DISCOURAGED_BOOLEAN_EXPRESSION ) ; } } else if ( ! isIgnored ( UNREACHABLE_BEHAVIOR_UNIT ) ) { addIssue ( Messages . SARLValidator_55 , behaviorUnit , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , UNREACHABLE_BEHAVIOR_UNIT , behaviorUnit . getName ( ) . getSimpleName ( ) ) ; } return ; } final LightweightTypeReference fromType = getActualType ( guard ) ; if ( ! fromType . isAssignableFrom ( Boolean . TYPE ) ) { error ( MessageFormat . format ( Messages . SARLValidator_38 , getNameOfTypes ( fromType ) , boolean . class . getName ( ) ) , guard , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INCOMPATIBLE_TYPES ) ; } } } | Check the type of the behavior unit s guard . |
34,143 | @ Check ( CheckType . FAST ) public void checkCapacityTypeForUses ( SarlCapacityUses uses ) { for ( final JvmParameterizedTypeReference usedType : uses . getCapacities ( ) ) { final LightweightTypeReference ref = toLightweightTypeReference ( usedType ) ; if ( ref != null && ! this . inheritanceHelper . isSarlCapacity ( ref ) ) { error ( MessageFormat . format ( Messages . SARLValidator_57 , usedType . getQualifiedName ( ) , Messages . SARLValidator_58 , this . grammarAccess . getUsesKeyword ( ) ) , usedType , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_CAPACITY_TYPE , usedType . getSimpleName ( ) ) ; } } } | Check the type of the capacity uses . |
34,144 | @ Check ( CheckType . FAST ) public void checkActionFires ( SarlAction action ) { for ( final JvmTypeReference event : action . getFiredEvents ( ) ) { final LightweightTypeReference ref = toLightweightTypeReference ( event ) ; if ( ref != null && ! this . inheritanceHelper . isSarlEvent ( ref ) ) { error ( MessageFormat . format ( Messages . SARLValidator_57 , event . getQualifiedName ( ) , Messages . SARLValidator_62 , this . grammarAccess . getFiresKeyword ( ) ) , event , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_FIRING_EVENT_TYPE , event . getSimpleName ( ) ) ; } } } | Check the types of the parameters of the fires statement . |
34,145 | @ Check ( CheckType . FAST ) public void checkSuperTypes ( SarlCapacity capacity ) { checkSuperTypes ( capacity , SARL_CAPACITY__EXTENDS , capacity . getExtends ( ) , Capacity . class , false ) ; } | Check if the supertype of the given capacity is a subtype of Capacity . |
34,146 | @ Check ( CheckType . FAST ) public void checkSuperType ( SarlSkill skill ) { final int nbSuperTypes = checkSuperTypes ( skill , SARL_SKILL__EXTENDS , Utils . singletonList ( skill . getExtends ( ) ) , Skill . class , false ) ; checkImplementedTypes ( skill , SARL_SKILL__IMPLEMENTS , skill . getImplements ( ) , Capacity . class , nbSuperTypes > 0 ? 0 : 1 , true ) ; } | Check if the supertype of the given skill is a subtype of Skill . |
34,147 | @ Check ( CheckType . FAST ) public void checkSuperType ( SarlEvent event ) { checkSuperTypes ( event , SARL_EVENT__EXTENDS , Utils . singletonList ( event . getExtends ( ) ) , Event . class , false ) ; } | Check if the supertype of the given event is a subtype of Event . |
34,148 | @ Check ( CheckType . FAST ) public void checkSuperType ( SarlBehavior behavior ) { checkSuperTypes ( behavior , SARL_BEHAVIOR__EXTENDS , Utils . singletonList ( behavior . getExtends ( ) ) , Behavior . class , false ) ; } | Check if the supertype of the given behavior is a subtype of Behavior . |
34,149 | @ Check ( CheckType . FAST ) public void checkSuperType ( SarlAgent agent ) { checkSuperTypes ( agent , SARL_AGENT__EXTENDS , Utils . singletonList ( agent . getExtends ( ) ) , Agent . class , false ) ; } | Check if the supertype of the given agent is a subtype of Agent . |
34,150 | protected boolean checkImplementedTypes ( XtendTypeDeclaration element , EReference feature , List < ? extends JvmTypeReference > implementedTypes , Class < ? > expectedType , int mandatoryNumberOfTypes , boolean onlySubTypes ) { boolean success = true ; int nb = 0 ; int index = 0 ; for ( final JvmTypeReference superType : implementedTypes ) { final LightweightTypeReference ref = toLightweightTypeReference ( superType ) ; if ( ref != null && ( ! ref . isInterfaceType ( ) || ! ref . isSubtypeOf ( expectedType ) || ( onlySubTypes && ref . isType ( expectedType ) ) ) ) { final String msg ; if ( onlySubTypes ) { msg = Messages . SARLValidator_72 ; } else { msg = Messages . SARLValidator_73 ; } error ( MessageFormat . format ( msg , superType . getQualifiedName ( ) , expectedType . getName ( ) , element . getName ( ) ) , element , feature , index , INVALID_IMPLEMENTED_TYPE , superType . getSimpleName ( ) ) ; success = false ; } else { ++ nb ; } ++ index ; } if ( nb < mandatoryNumberOfTypes ) { error ( MessageFormat . format ( Messages . SARLValidator_74 , expectedType . getName ( ) , element . getName ( ) ) , element , feature , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , MISSING_TYPE ) ; success = false ; } return success ; } | Check the implemeted type . |
34,151 | @ Check ( CheckType . FAST ) public void checkBehaviorUnitEventType ( SarlBehaviorUnit behaviorUnit ) { final JvmTypeReference event = behaviorUnit . getName ( ) ; final LightweightTypeReference ref = toLightweightTypeReference ( event ) ; if ( ref == null || ! this . inheritanceHelper . isSarlEvent ( ref ) ) { error ( MessageFormat . format ( Messages . SARLValidator_75 , event . getQualifiedName ( ) , Messages . SARLValidator_62 , this . grammarAccess . getOnKeyword ( ) ) , event , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , TYPE_BOUNDS_MISMATCH ) ; } } | Check if the parameter of the bahavior unit is an event . |
34,152 | @ Check ( CheckType . FAST ) public void checkCapacityFeatures ( SarlCapacity capacity ) { if ( capacity . getMembers ( ) . isEmpty ( ) ) { if ( ! isIgnored ( DISCOURAGED_CAPACITY_DEFINITION ) ) { addIssue ( Messages . SARLValidator_77 , capacity , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , DISCOURAGED_CAPACITY_DEFINITION , capacity . getName ( ) , "aFunction" ) ; } } } | Check if a capacity has a feature defined inside . |
34,153 | @ Check ( CheckType . NORMAL ) public void checkUnusedCapacities ( SarlCapacityUses uses ) { if ( ! isIgnored ( UNUSED_AGENT_CAPACITY ) ) { final XtendTypeDeclaration container = uses . getDeclaringType ( ) ; final JvmDeclaredType jvmContainer = ( JvmDeclaredType ) this . associations . getPrimaryJvmElement ( container ) ; final Map < String , JvmOperation > importedFeatures = CollectionLiterals . newHashMap ( ) ; for ( final JvmOperation operation : jvmContainer . getDeclaredOperations ( ) ) { if ( Utils . isNameForHiddenCapacityImplementationCallingMethod ( operation . getSimpleName ( ) ) ) { importedFeatures . put ( operation . getSimpleName ( ) , operation ) ; } } final boolean isSkill = container instanceof SarlSkill ; int index = 0 ; for ( final JvmTypeReference capacity : uses . getCapacities ( ) ) { final LightweightTypeReference lreference = toLightweightTypeReference ( capacity ) ; if ( isSkill && lreference . isAssignableFrom ( jvmContainer ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_22 , capacity . getSimpleName ( ) ) , uses , SARL_CAPACITY_USES__CAPACITIES , index , UNUSED_AGENT_CAPACITY , capacity . getSimpleName ( ) ) ; } else { final String fieldName = Utils . createNameForHiddenCapacityImplementationAttribute ( capacity . getIdentifier ( ) ) ; final String operationName = Utils . createNameForHiddenCapacityImplementationCallingMethodFromFieldName ( fieldName ) ; final JvmOperation operation = importedFeatures . get ( operationName ) ; if ( operation != null && ! isLocallyUsed ( operation , container ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_78 , capacity . getSimpleName ( ) ) , uses , SARL_CAPACITY_USES__CAPACITIES , index , UNUSED_AGENT_CAPACITY , capacity . getSimpleName ( ) ) ; } } ++ index ; } } } | Check for unused capacities . |
34,154 | @ Check ( CheckType . NORMAL ) public void checkMultipleCapacityUses ( SarlCapacityUses uses ) { if ( ! isIgnored ( REDUNDANT_CAPACITY_USE ) ) { final XtendTypeDeclaration declaringType = uses . getDeclaringType ( ) ; if ( declaringType != null ) { final Set < String > previousCapacityUses = doGetPreviousCapacities ( uses , declaringType . getMembers ( ) . iterator ( ) ) ; int index = 0 ; for ( final JvmTypeReference capacity : uses . getCapacities ( ) ) { if ( previousCapacityUses . contains ( capacity . getIdentifier ( ) ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_79 , capacity . getSimpleName ( ) ) , uses , SARL_CAPACITY_USES__CAPACITIES , index , REDUNDANT_CAPACITY_USE , capacity . getSimpleName ( ) ) ; } else { previousCapacityUses . add ( capacity . getIdentifier ( ) ) ; } ++ index ; } } } } | Check for multiple capacity use declaration . |
34,155 | public void checkReservedAnnotation ( XtendAnnotationTarget annotationTarget ) { if ( ! isIgnored ( USED_RESERVED_SARL_ANNOTATION ) ) { if ( annotationTarget . getAnnotations ( ) . isEmpty ( ) || ! isRelevantAnnotationTarget ( annotationTarget ) ) { return ; } final QualifiedName reservedPackage = this . qualifiedNameConverter . toQualifiedName ( EarlyExit . class . getPackage ( ) . getName ( ) ) ; final String earlyExitAnnotation = EarlyExit . class . getName ( ) ; for ( final XAnnotation annotation : annotationTarget . getAnnotations ( ) ) { final JvmType type = annotation . getAnnotationType ( ) ; if ( type != null && ! type . eIsProxy ( ) ) { if ( Objects . equal ( type . getIdentifier ( ) , earlyExitAnnotation ) ) { if ( ! ( annotationTarget instanceof SarlEvent ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_87 , type . getSimpleName ( ) ) , annotation , USED_RESERVED_SARL_ANNOTATION ) ; } } else { final QualifiedName annotationName = this . qualifiedNameConverter . toQualifiedName ( type . getIdentifier ( ) ) ; if ( annotationName . startsWith ( reservedPackage ) ) { addIssue ( MessageFormat . format ( Messages . SARLValidator_87 , type . getSimpleName ( ) ) , annotation , USED_RESERVED_SARL_ANNOTATION ) ; } } } } } } | Check for reserved annotations . |
34,156 | protected static XMemberFeatureCall getRootOfMemberFeatureCallSequence ( EObject leaf , EObject container , Procedure1 < XMemberFeatureCall > feedback ) { EObject call = leaf ; EObject obj = EcoreUtil2 . getContainerOfType ( leaf . eContainer ( ) , XExpression . class ) ; while ( obj != null && ( container == null || obj != container ) ) { if ( ! ( obj instanceof XMemberFeatureCall ) ) { obj = null ; } else { final EObject previous = call ; final XMemberFeatureCall fcall = ( XMemberFeatureCall ) obj ; call = fcall ; if ( fcall . getActualReceiver ( ) == previous ) { if ( feedback != null ) { feedback . apply ( fcall ) ; } obj = EcoreUtil2 . getContainerOfType ( call . eContainer ( ) , XExpression . class ) ; } else if ( fcall . getActualArguments ( ) . contains ( previous ) ) { call = previous ; obj = null ; } else { obj = null ; } } } return call instanceof XMemberFeatureCall ? ( XMemberFeatureCall ) call : null ; } | Replies the member feature call that is the root of a sequence of member feature calls . |
34,157 | protected List < LightweightTypeReference > getParamTypeReferences ( JvmExecutable jvmExecutable , boolean wrapFromPrimitives , boolean wrapToPrimitives ) { assert ( wrapFromPrimitives && ! wrapToPrimitives ) || ( wrapToPrimitives && ! wrapFromPrimitives ) ; final List < LightweightTypeReference > types = newArrayList ( ) ; for ( final JvmFormalParameter parameter : jvmExecutable . getParameters ( ) ) { LightweightTypeReference typeReference = toLightweightTypeReference ( parameter . getParameterType ( ) ) ; if ( wrapFromPrimitives ) { typeReference = typeReference . getWrapperTypeIfPrimitive ( ) ; } else if ( wrapToPrimitives ) { typeReference = typeReference . getPrimitiveIfWrapperType ( ) ; } types . add ( typeReference ) ; } return types ; } | Retrieve the types of the formal parameters of the given JVM executable object . |
34,158 | public void checkUnmodifiableEventAccess ( SarlBehaviorUnit unit ) { final boolean enable1 = ! isIgnored ( DISCOURAGED_OCCURRENCE_READONLY_USE ) ; final XExpression root = unit . getExpression ( ) ; final String occurrenceKw = this . grammarAccess . getOccurrenceKeyword ( ) ; for ( final XFeatureCall child : EcoreUtil2 . getAllContentsOfType ( root , XFeatureCall . class ) ) { if ( occurrenceKw . equals ( child . getFeature ( ) . getIdentifier ( ) ) ) { checkUnmodifiableFeatureAccess ( enable1 , child , occurrenceKw ) ; } } } | Check for usage of the event functions in the behavior units . |
34,159 | 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 . |
34,160 | 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 . |
34,161 | @ 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 { synchronizationIssue = true ; } 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 . |
34,162 | protected boolean isLocallyAssigned ( EObject target , EObject containerToFindUsage ) { if ( this . readAndWriteTracking . isAssigned ( target ) ) { return true ; } final Collection < Setting > usages = XbaseUsageCrossReferencer . find ( target , containerToFindUsage ) ; for ( final Setting usage : usages ) { final EObject object = usage . getEObject ( ) ; if ( object instanceof XAssignment ) { final XAssignment assignment = ( XAssignment ) object ; if ( assignment . getFeature ( ) == target ) { this . readAndWriteTracking . markAssignmentAccess ( target ) ; return true ; } } } return false ; } | Replies if the given object is locally assigned . |
34,163 | @ 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 . |
34,164 | @ 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 . |
34,165 | @ 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 . |
34,166 | @ 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 . |
34,167 | @ 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 . |
34,168 | 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 . |
34,169 | @ 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 . |
34,170 | 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 . |
34,171 | 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 . |
34,172 | public ISarlEventBuilder addSarlEvent ( String name ) { ISarlEventBuilder builder = this . sarlEventProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlEvent builder . |
34,173 | public ISarlCapacityBuilder addSarlCapacity ( String name ) { ISarlCapacityBuilder builder = this . sarlCapacityProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlCapacity builder . |
34,174 | public ISarlAgentBuilder addSarlAgent ( String name ) { ISarlAgentBuilder builder = this . sarlAgentProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlAgent builder . |
34,175 | public ISarlBehaviorBuilder addSarlBehavior ( String name ) { ISarlBehaviorBuilder builder = this . sarlBehaviorProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlBehavior builder . |
34,176 | public ISarlSkillBuilder addSarlSkill ( String name ) { ISarlSkillBuilder builder = this . sarlSkillProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlSkill builder . |
34,177 | public ISarlSpaceBuilder addSarlSpace ( String name ) { ISarlSpaceBuilder builder = this . sarlSpaceProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlSpace builder . |
34,178 | public ISarlArtifactBuilder addSarlArtifact ( String name ) { ISarlArtifactBuilder builder = this . sarlArtifactProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlArtifact builder . |
34,179 | public ISarlClassBuilder addSarlClass ( String name ) { ISarlClassBuilder builder = this . sarlClassProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlClass builder . |
34,180 | public ISarlInterfaceBuilder addSarlInterface ( String name ) { ISarlInterfaceBuilder builder = this . sarlInterfaceProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlInterface builder . |
34,181 | public ISarlEnumerationBuilder addSarlEnumeration ( String name ) { ISarlEnumerationBuilder builder = this . sarlEnumerationProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlEnumeration builder . |
34,182 | public ISarlAnnotationTypeBuilder addSarlAnnotationType ( String name ) { ISarlAnnotationTypeBuilder builder = this . sarlAnnotationTypeProvider . get ( ) ; builder . eInit ( getScript ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlAnnotationType builder . |
34,183 | 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" ) 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 ( ) { public void widgetDefaultSelected ( SelectionEvent event ) { } public void widgetSelected ( SelectionEvent event ) { handleAgentNameSearchButtonSelected ( ) ; } } ) ; } | Creates the widgets for specifying a agent name . |
34,184 | 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 . |
34,185 | 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 . |
34,186 | 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 . |
34,187 | 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 . |
34,188 | 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 . |
34,189 | 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 . |
34,190 | protected void initializeAgentName ( IJavaElement javaElement , ILaunchConfigurationWorkingCopy config ) { String name = extractNameFromJavaElement ( javaElement ) ; this . configurator . setAgent ( config , name ) ; 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 . |
34,191 | protected void handleAgentNameSearchButtonSelected ( ) { final IType [ ] types = searchAgentNames ( ) ; final DebugTypeSelectionDialog mmsd = new DebugTypeSelectionDialog ( getShell ( ) , types , "" ) ; 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 . |
34,192 | @ 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 . |
34,193 | public static int compareOsgiVersions ( String v1 , String v2 ) { return Version . parseVersion ( v1 ) . compareTo ( Version . parseVersion ( v2 ) ) ; } | Compare two OSGI versions . |
34,194 | public static int compareMavenVersions ( String v1 , String v2 ) { return parseMavenVersion ( v1 ) . compareTo ( parseMavenVersion ( v2 ) ) ; } | Compare two Maven versions . |
34,195 | public static Version parseMavenVersion ( String version ) { if ( Strings . isNullOrEmpty ( version ) ) { return new Version ( 0 , 0 , 0 ) ; } 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 ; } } final String [ ] parts = coreVersion . split ( "[.]" ) ; 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 ) { i = numbers . length ; } } 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 . |
34,196 | public static < S extends Capacity > S getInternalSkill ( Agent agent , Class < S > type ) { return agent . getSkill ( type ) ; } | Replies the internal skill of an agent . |
34,197 | 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 . |
34,198 | protected void generateIMemberBuilder ( MemberDescription description ) { if ( description . isTopElement ( ) ) { return ; } final TypeReference builder = description . getElementDescription ( ) . getBuilderInterfaceType ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Builder of a " + getLanguageName ( ) + " " + description . getElementDescription ( ) . getName ( ) + "." ) ; 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 ( description , true , false ) ) ; it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( builder , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the member builder interface . |
34,199 | 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 ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Source appender of a " + getLanguageName ( ) + " " + description . getElementDescription ( ) . getName ( ) + "." ) ; 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 ( description . getElementDescription ( ) . getBuilderInterfaceType ( ) ) ; it . append ( " {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateAppenderMembers ( appender . getSimpleName ( ) , description . getElementDescription ( ) . getBuilderInterfaceType ( ) , generatedFieldAccessor ) ) ; it . append ( generateMembers ( description , false , true ) ) ; it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( appender , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the member appender . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.