idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
1,300
|
public String javaName ( final JvmVisibility visibility ) { if ( ( visibility != null ) ) { String _switchResult = null ; if ( visibility != null ) { switch ( visibility ) { case PRIVATE : _switchResult = "private " ; break ; case PUBLIC : _switchResult = "public " ; break ; case PROTECTED : _switchResult = "protected " ; break ; case DEFAULT : _switchResult = "" ; break ; default : break ; } } return _switchResult ; } else { return "" ; } }
|
Returns the visibility modifier and a space as suffix if not empty
|
1,301
|
protected String getInvalidWritableVariableAccessMessage ( XVariableDeclaration variable , XAbstractFeatureCall featureCall , IResolvedTypes resolvedTypes ) { XClosure containingClosure = EcoreUtil2 . getContainerOfType ( featureCall , XClosure . class ) ; if ( containingClosure != null && ! EcoreUtil . isAncestor ( containingClosure , variable ) ) { return String . format ( "Cannot %srefer to the non-final variable %s inside a lambda expression" , getImplicitlyMessagePart ( featureCall ) , variable . getSimpleName ( ) ) ; } return null ; }
|
Provide the error message for mutable variables that may not be captured in lambdas .
|
1,302
|
public void setDocumentation ( JvmIdentifiableElement jvmElement , String documentation ) { if ( jvmElement == null || documentation == null ) return ; DocumentationAdapter documentationAdapter = new DocumentationAdapter ( ) ; documentationAdapter . setDocumentation ( documentation ) ; jvmElement . eAdapters ( ) . add ( documentationAdapter ) ; }
|
Attaches the given documentation to the given jvmElement .
|
1,303
|
public void copyDocumentationTo ( final EObject source , JvmIdentifiableElement jvmElement ) { if ( source == null || jvmElement == null ) return ; DocumentationAdapter documentationAdapter = new DocumentationAdapter ( ) { private boolean computed = false ; public String getDocumentation ( ) { if ( computed ) { return super . getDocumentation ( ) ; } String result = JvmTypesBuilder . this . getDocumentation ( source ) ; setDocumentation ( result ) ; return result ; } public void setDocumentation ( String documentation ) { computed = true ; super . setDocumentation ( documentation ) ; } } ; jvmElement . eAdapters ( ) . add ( documentationAdapter ) ; }
|
Attaches the given documentation of the source element to the given jvmElement .
|
1,304
|
protected boolean isPrimitiveBoolean ( JvmTypeReference typeRef ) { if ( InferredTypeIndicator . isInferred ( typeRef ) ) { return false ; } return typeRef != null && typeRef . getType ( ) != null && ! typeRef . getType ( ) . eIsProxy ( ) && "boolean" . equals ( typeRef . getType ( ) . getIdentifier ( ) ) ; }
|
Detects whether the type reference refers to primitive boolean .
|
1,305
|
public void setGeneratorProjectName ( String generatorProjectName ) { if ( generatorProjectName == null || "" . equals ( generatorProjectName . trim ( ) ) ) { return ; } this . generatorProjectName = generatorProjectName . trim ( ) ; }
|
Sets the name of the generator project .
|
1,306
|
public void setFileExtension ( String modelFileExtension ) { if ( modelFileExtension == null || "" . equals ( modelFileExtension . trim ( ) ) ) { return ; } this . modelFileExtension = modelFileExtension . trim ( ) ; }
|
Sets the file extension used when creating the initial sample model .
|
1,307
|
public static String getCharacterName ( char character ) { String transliterated = transliterator . transliterate ( String . valueOf ( character ) ) ; return transliterated . substring ( "\\N{" . length ( ) , transliterated . length ( ) - "}" . length ( ) ) ; }
|
Returns the Unicode string name for a character .
|
1,308
|
protected List < String > getSignificantContent ( ) { final List < String > result = super . getSignificantContent ( ) ; if ( ( ( result . size ( ) >= 1 ) && Objects . equal ( this . getLineDelimiter ( ) , IterableExtensions . < String > last ( result ) ) ) ) { int _size = result . size ( ) ; int _minus = ( _size - 1 ) ; return result . subList ( 0 , _minus ) ; } return result ; }
|
A potentially contained trailing line delimiter is ignored .
|
1,309
|
public void selectStrategy ( ) { LightweightTypeReference expectedType = expectation . getExpectedType ( ) ; if ( expectedType == null ) { strategy = getClosureWithoutExpectationHelper ( ) ; } else { JvmOperation operation = functionTypes . findImplementingOperation ( expectedType ) ; JvmType type = expectedType . getType ( ) ; int closureParameterSize ; if ( closure . isExplicitSyntax ( ) ) { closureParameterSize = closure . getDeclaredFormalParameters ( ) . size ( ) ; } else if ( operation != null ) { closureParameterSize = operation . getParameters ( ) . size ( ) ; } else { closureParameterSize = 1 ; } if ( operation == null || operation . getParameters ( ) . size ( ) != closureParameterSize || type == null ) { strategy = getClosureWithoutExpectationHelper ( ) ; } else { strategy = createClosureWithExpectationHelper ( operation ) ; } } }
|
This method is only public for testing purpose .
|
1,310
|
protected void validateResourceState ( Resource resource ) { if ( resource instanceof StorageAwareResource && ( ( StorageAwareResource ) resource ) . isLoadedFromStorage ( ) ) { LOG . error ( "Discouraged attempt to compute types for resource that was loaded from storage. Resource was : " + resource . getURI ( ) , new Exception ( ) ) ; } }
|
Checks the internal state of the resource and logs if type resolution was triggered unexpectedly .
|
1,311
|
public synchronized String getString ( ) { if ( outputFileName == null ) throw new IllegalStateException ( ) ; StringBuffer out = new StringBuffer ( ) ; out . append ( "SMAP\n" ) ; out . append ( outputFileName + '\n' ) ; out . append ( defaultStratum + '\n' ) ; if ( doEmbedded ) { int nEmbedded = embedded . size ( ) ; for ( int i = 0 ; i < nEmbedded ; i ++ ) { out . append ( embedded . get ( i ) ) ; } } int nStrata = strata . size ( ) ; for ( int i = 0 ; i < nStrata ; i ++ ) { SmapStratum s = strata . get ( i ) ; out . append ( s . getString ( ) ) ; } out . append ( "*E\n" ) ; return out . toString ( ) ; }
|
Methods for serializing the logical SMAP
|
1,312
|
protected boolean doValidateLambdaContents ( XClosure closure , DiagnosticChain diagnostics , Map < Object , Object > context ) { return true ; }
|
This was here for EMF 2 . 5 compatibility and was refactored to a no - op .
|
1,313
|
public boolean isJavaSwitchExpression ( final XSwitchExpression it ) { boolean _xblockexpression = false ; { final LightweightTypeReference switchType = this . getSwitchVariableType ( it ) ; if ( ( switchType == null ) ) { return false ; } boolean _isSubtypeOf = switchType . isSubtypeOf ( Integer . TYPE ) ; if ( _isSubtypeOf ) { return true ; } boolean _isSubtypeOf_1 = switchType . isSubtypeOf ( Enum . class ) ; if ( _isSubtypeOf_1 ) { return true ; } _xblockexpression = false ; } return _xblockexpression ; }
|
Determine whether the given switch expression is valid for Java version 6 or lower .
|
1,314
|
public boolean isJava7SwitchExpression ( final XSwitchExpression it ) { boolean _xblockexpression = false ; { final LightweightTypeReference switchType = this . getSwitchVariableType ( it ) ; if ( ( switchType == null ) ) { return false ; } boolean _isSubtypeOf = switchType . isSubtypeOf ( Integer . TYPE ) ; if ( _isSubtypeOf ) { return true ; } boolean _isSubtypeOf_1 = switchType . isSubtypeOf ( Enum . class ) ; if ( _isSubtypeOf_1 ) { return true ; } boolean _isSubtypeOf_2 = switchType . isSubtypeOf ( String . class ) ; if ( _isSubtypeOf_2 ) { return true ; } _xblockexpression = false ; } return _xblockexpression ; }
|
Determine whether the given switch expression is valid for Java version 7 or higher .
|
1,315
|
protected boolean isMultilineLambda ( final XClosure closure ) { final ILeafNode closingBracket = this . _nodeModelAccess . nodeForKeyword ( closure , "]" ) ; HiddenLeafs _hiddenLeafsBefore = null ; if ( closingBracket != null ) { _hiddenLeafsBefore = this . _hiddenLeafAccess . getHiddenLeafsBefore ( closingBracket ) ; } boolean _tripleNotEquals = ( _hiddenLeafsBefore != null ) ; if ( _tripleNotEquals ) { int _newLines = this . _hiddenLeafAccess . getHiddenLeafsBefore ( closingBracket ) . getNewLines ( ) ; return ( _newLines > 0 ) ; } boolean _switchResult = false ; XExpression _expression = closure . getExpression ( ) ; final XExpression block = _expression ; boolean _matched = false ; if ( block instanceof XBlockExpression ) { _matched = true ; _switchResult = ( ( ( ( XBlockExpression ) block ) . getExpressions ( ) . size ( ) > 1 ) && this . isEachExpressionInOwnLine ( ( ( XBlockExpression ) block ) . getExpressions ( ) ) ) ; } if ( ! _matched ) { _switchResult = false ; } return _switchResult ; }
|
checks whether the given lambda should be formatted as a block . That includes newlines after and before the brackets and a fresh line for each expression .
|
1,316
|
protected List < ICompositeNode > internalFindValidReplaceRootNodeForChangeRegion ( List < ICompositeNode > nodesEnclosingRegion ) { List < ICompositeNode > result = new ArrayList < ICompositeNode > ( ) ; boolean mustSkipNext = false ; for ( int i = 0 ; i < nodesEnclosingRegion . size ( ) ; i ++ ) { ICompositeNode node = nodesEnclosingRegion . get ( i ) ; if ( node . getGrammarElement ( ) != null ) { if ( ! mustSkipNext ) { result . add ( node ) ; if ( isActionNode ( node ) ) { mustSkipNext = true ; } } else { mustSkipNext = isActionNode ( node ) ; } } } return result ; }
|
Investigates the composite nodes containing the changed region and collects a list of nodes which could possibly replaced by a partial parse . Such a node has a parent that consumes all his current lookahead tokens and all of these tokens are located before the changed region .
|
1,317
|
public ResolvedFeatures getResolvedFeatures ( LightweightTypeReference contextType , JavaVersion targetVersion ) { return new ResolvedFeatures ( contextType , overrideTester , targetVersion ) ; }
|
Returns the resolved features targeting a specific Java version in order to support new language features .
|
1,318
|
public Class < ? extends org . eclipse . xtext . parsetree . reconstr . IParseTreeConstructor > bindIParseTreeConstructor ( ) { return org . eclipse . xtext . generator . parser . antlr . debug . parseTreeConstruction . SimpleAntlrParsetreeConstructor . class ; }
|
contributed by org . eclipse . xtext . generator . parseTreeConstructor . ParseTreeConstructorFragment
|
1,319
|
@ org . eclipse . xtext . service . SingletonBinding ( eager = true ) public Class < ? extends org . eclipse . xtext . generator . parser . antlr . debug . validation . SimpleAntlrJavaValidator > bindSimpleAntlrJavaValidator ( ) { return org . eclipse . xtext . generator . parser . antlr . debug . validation . SimpleAntlrJavaValidator . class ; }
|
contributed by org . eclipse . xtext . generator . validation . JavaValidatorFragment
|
1,320
|
public Class < ? extends org . eclipse . xtext . formatting . IFormatter > bindIFormatter ( ) { return org . eclipse . xtext . generator . parser . antlr . debug . formatting . SimpleAntlrFormatter . class ; }
|
contributed by org . eclipse . xtext . generator . formatting . FormatterFragment
|
1,321
|
protected void addLocalToCurrentScope ( XExpression expression , ITypeComputationState state ) { if ( expression instanceof XVariableDeclaration ) { addLocalToCurrentScope ( ( XVariableDeclaration ) expression , state ) ; } }
|
If the expression is a variable declaration then add it to the current scope ; DSLs introducing new containers for variable declarations should override this method and explicitly add nested variable declarations .
|
1,322
|
protected void _computeTypes ( XDoWhileExpression object , ITypeComputationState state ) { ITypeComputationResult loopBodyResult = computeWhileLoopBody ( object , state , false ) ; boolean noImplicitReturn = ( loopBodyResult . getConformanceFlags ( ) & ConformanceFlags . NO_IMPLICIT_RETURN ) != 0 ; LightweightTypeReference primitiveVoid = getPrimitiveVoid ( state ) ; if ( noImplicitReturn ) state . acceptActualType ( primitiveVoid , ConformanceFlags . NO_IMPLICIT_RETURN | ConformanceFlags . UNCHECKED ) ; else state . acceptActualType ( primitiveVoid ) ; }
|
Since we are sure that the loop body is executed at least once the early exit information of the loop body expression can be used for the outer expression .
|
1,323
|
protected EObject findAccessibleType ( String fragment , ResourceSet resourceSet , Iterator < IEObjectDescription > fromIndex ) throws UnknownNestedTypeException { IEObjectDescription description = fromIndex . next ( ) ; return getAccessibleType ( description , fragment , resourceSet ) ; }
|
Returns the first type that was found in the index . May be overridden to honor visibility semantics . The given iterator is never empty .
|
1,324
|
protected EObject getAccessibleType ( IEObjectDescription description , String fragment , ResourceSet resourceSet ) throws UnknownNestedTypeException { EObject typeProxy = description . getEObjectOrProxy ( ) ; if ( typeProxy . eIsProxy ( ) ) { typeProxy = EcoreUtil . resolve ( typeProxy , resourceSet ) ; } if ( ! typeProxy . eIsProxy ( ) && typeProxy instanceof JvmType ) { if ( fragment != null ) { EObject result = resolveJavaObject ( ( JvmType ) typeProxy , fragment ) ; if ( result != null ) return result ; } else return typeProxy ; } return null ; }
|
Read and resolve the EObject from the given description and navigate to its children according to the given fragment .
|
1,325
|
public EObject resolveJavaObject ( JvmType rootType , String fragment ) throws UnknownNestedTypeException { if ( fragment . endsWith ( "[]" ) ) { return resolveJavaArrayObject ( rootType , fragment ) ; } int slash = fragment . indexOf ( '/' ) ; if ( slash != - 1 ) { if ( slash == 0 ) return null ; String containerFragment = fragment . substring ( 0 , slash ) ; EObject container = resolveJavaObject ( rootType , containerFragment ) ; if ( container != null ) { String parameterName = fragment . substring ( slash + 1 ) ; if ( container instanceof JvmTypeParameterDeclarator ) { JvmTypeParameterDeclarator executable = ( JvmTypeParameterDeclarator ) container ; for ( JvmTypeParameter parameter : executable . getTypeParameters ( ) ) { if ( parameter . getName ( ) . equals ( parameterName ) ) return parameter ; } } } } else { if ( rootType . getIdentifier ( ) . equals ( fragment ) ) { return rootType ; } if ( ! fragment . startsWith ( rootType . getIdentifier ( ) ) ) { return null ; } int rootNameLength = rootType . getIdentifier ( ) . length ( ) ; char sep = fragment . charAt ( rootNameLength ) ; Iterator < String > iter = Splitter . on ( sep ) . split ( fragment . substring ( rootNameLength + 1 ) ) . iterator ( ) ; JvmDeclaredType current = ( JvmDeclaredType ) rootType ; while ( iter . hasNext ( ) ) { String segment = iter . next ( ) ; Iterator < JvmDeclaredType > members = current . findAllNestedTypesByName ( segment ) . iterator ( ) ; if ( members . hasNext ( ) ) { current = members . next ( ) ; } else { throw new UnknownNestedTypeException ( "Couldn't resolve nested type for " + rootType . getIdentifier ( ) + " and fragment " + fragment ) ; } } return current ; } return null ; }
|
Locate a locale type with the given fragment . Does not consider types that are defined in operations or constructors as inner classes .
|
1,326
|
protected void cumulateDistance ( final List < LightweightTypeReference > references , Multimap < JvmType , LightweightTypeReference > all , Multiset < JvmType > cumulatedDistance ) { for ( LightweightTypeReference other : references ) { Multiset < JvmType > otherDistance = LinkedHashMultiset . create ( ) ; initializeDistance ( other , all , otherDistance ) ; cumulatedDistance . retainAll ( otherDistance ) ; for ( Multiset . Entry < JvmType > typeToDistance : otherDistance . entrySet ( ) ) { if ( cumulatedDistance . contains ( typeToDistance . getElement ( ) ) ) cumulatedDistance . add ( typeToDistance . getElement ( ) , typeToDistance . getCount ( ) ) ; } } }
|
Keeps the cumulated distance for all the common raw super types of the given references . Interfaces that are more directly implemented will get a lower total count than more general interfaces .
|
1,327
|
public void configureFormatterPreferences ( Binder binder ) { binder . bind ( IPreferenceValuesProvider . class ) . annotatedWith ( FormatterPreferences . class ) . to ( FormatterPreferenceValuesProvider . class ) ; }
|
contributed by org . eclipse . xtext . xtext . generator . formatting . Formatter2Fragment2
|
1,328
|
public void resolveLazyCrossReferences ( CancelIndicator monitor ) { IParseResult parseResult = getParseResult ( ) ; if ( parseResult != null ) { batchLinkingService . resolveBatched ( parseResult . getRootASTElement ( ) , monitor ) ; } operationCanceledManager . checkCanceled ( monitor ) ; super . resolveLazyCrossReferences ( monitor ) ; }
|
Delegates to the BatchLinkingService to resolve all references . The linking service is responsible to lock the resource or resource set .
|
1,329
|
private void markPendingInitialization ( JvmDeclaredTypeImplCustom type ) { type . setPendingInitialization ( true ) ; for ( JvmMember member : type . basicGetMembers ( ) ) { if ( member instanceof JvmDeclaredTypeImplCustom ) { markPendingInitialization ( ( JvmDeclaredTypeImplCustom ) member ) ; } } }
|
Recursively traverse the types in this resource to mark them as lazy initialized types .
|
1,330
|
protected Map < JvmIdentifiableElement , ResolvedTypes > prepare ( ResolvedTypes resolvedTypes , IFeatureScopeSession featureScopeSession ) { Map < JvmIdentifiableElement , ResolvedTypes > resolvedTypesByContext = Maps . newHashMapWithExpectedSize ( 3 ) ; JvmType root = getRootJvmType ( ) ; rootedInstances . add ( root ) ; recordExpressions ( root ) ; doPrepare ( resolvedTypes , featureScopeSession , root , resolvedTypesByContext ) ; return resolvedTypesByContext ; }
|
Assign computed type references to the identifiable structural elements in the processed type .
|
1,331
|
protected XExpression getInferredFrom ( JvmTypeReference typeReference ) { if ( InferredTypeIndicator . isInferred ( typeReference ) ) { XComputedTypeReference computed = ( XComputedTypeReference ) typeReference ; if ( computed . getEquivalent ( ) instanceof XComputedTypeReference ) { XComputedTypeReference inferred = ( XComputedTypeReference ) computed . getEquivalent ( ) ; IJvmTypeReferenceProvider typeProvider = inferred . getTypeProvider ( ) ; if ( typeProvider instanceof DemandTypeReferenceProvider ) { return ( ( DemandTypeReferenceProvider ) typeProvider ) . expression ; } } } return null ; }
|
Returns the expression that will be used to infer the given type from . If the type is already resolved the result will be null . If no expression can be determined null is also returned .
|
1,332
|
private boolean isRawType ( JvmTypeParameter current , RecursionGuard < JvmTypeParameter > guard ) { if ( guard . tryNext ( current ) ) { List < JvmTypeConstraint > constraints = current . getConstraints ( ) ; for ( int i = 0 , size = constraints . size ( ) ; i < size ; i ++ ) { JvmTypeConstraint constraint = constraints . get ( i ) ; if ( constraint . eClass ( ) == TypesPackage . Literals . JVM_UPPER_BOUND && constraint . getTypeReference ( ) != null ) { JvmTypeReference superType = constraint . getTypeReference ( ) ; JvmType rawSuperType = superType . getType ( ) ; if ( rawSuperType != null ) { if ( rawSuperType . eClass ( ) == TypesPackage . Literals . JVM_TYPE_PARAMETER ) { if ( isRawType ( ( JvmTypeParameter ) rawSuperType , guard ) ) { return true ; } } if ( rawSuperType . eClass ( ) == TypesPackage . Literals . JVM_GENERIC_TYPE ) { if ( ! ( ( JvmGenericType ) rawSuperType ) . getTypeParameters ( ) . isEmpty ( ) ) { if ( superType . eClass ( ) == TypesPackage . Literals . JVM_PARAMETERIZED_TYPE_REFERENCE ) { JvmParameterizedTypeReference casted = ( JvmParameterizedTypeReference ) superType ; if ( casted . getArguments ( ) . isEmpty ( ) ) { return true ; } } } } } } } } return false ; }
|
Here we already know that we don t have type arguments
|
1,333
|
public ParameterizedTypeReference toInstanceTypeReference ( ) { ParameterizedTypeReference result = getOwner ( ) . newParameterizedTypeReference ( getType ( ) ) ; for ( LightweightTypeReference typeArgument : getTypeArguments ( ) ) { result . addTypeArgument ( typeArgument . getInvariantBoundSubstitute ( ) ) ; } return result ; }
|
Returns a projection of this type to the instance level . That is type arguments will be replaced by their invariant bounds .
|
1,334
|
public void visit ( final String name , final Object value ) { JvmAnnotationValue annotationValue = proxies . createAnnotationValue ( value ) ; annotationValue . setOperation ( proxies . createMethodProxy ( annotationType , name ) ) ; values . addUnique ( annotationValue ) ; }
|
Visits a primitive value of the annotation .
|
1,335
|
public IResourceDescriptions getResourceDescriptions ( ResourceSet resourceSet ) { IResourceDescriptions result = super . getResourceDescriptions ( resourceSet ) ; if ( compilerPhases . isIndexing ( resourceSet ) ) { String projectName = getProjectName ( resourceSet ) ; if ( projectName != null ) { final String encodedProjectName = URI . encodeSegment ( projectName , true ) ; Predicate < URI > predicate = new Predicate < URI > ( ) { public boolean apply ( URI uri ) { return isProjectLocal ( uri , encodedProjectName ) ; } } ; if ( result instanceof IShadowedResourceDescriptions ) { return new ShadowedFilteringResourceDescriptions ( result , predicate ) ; } else { return new FilteringResourceDescriptions ( result , predicate ) ; } } } return result ; }
|
And if we are in the indexing phase we don t want to see the local resources .
|
1,336
|
public void clearResourceSet ( final ResourceSet resourceSet ) { final boolean wasDeliver = resourceSet . eDeliver ( ) ; try { resourceSet . eSetDeliver ( false ) ; resourceSet . getResources ( ) . clear ( ) ; } finally { resourceSet . eSetDeliver ( wasDeliver ) ; } }
|
Clears the content of the resource set without sending notifications . This avoids unnecessary explicit unloads .
|
1,337
|
protected final boolean announceSynonym ( LightweightTypeReference synonym , ConformanceHint hint , Acceptor acceptor ) { if ( synonym . isUnknown ( ) ) { return true ; } return acceptor . accept ( synonym , hint ) ; }
|
Announce a synonym type with the given conformance hint .
|
1,338
|
protected final boolean announceSynonym ( LightweightTypeReference synonym , EnumSet < ConformanceHint > hints , Acceptor acceptor ) { if ( synonym . isUnknown ( ) ) { return true ; } return acceptor . accept ( synonym , hints ) ; }
|
Announce a synonym type with the given conformance hints .
|
1,339
|
protected final boolean announceSynonym ( LightweightTypeReference synonym , int flags , Acceptor acceptor ) { if ( synonym . isUnknown ( ) ) { return true ; } return acceptor . accept ( synonym , flags | ConformanceFlags . CHECKED_SUCCESS ) ; }
|
Announce a synonym type with the given conformance flags .
|
1,340
|
protected File getTmpFolder ( ) { final ArrayList < ? > _cacheKey = CollectionLiterals . newArrayList ( ) ; final File _result ; synchronized ( _createCache_getTmpFolder ) { if ( _createCache_getTmpFolder . containsKey ( _cacheKey ) ) { return _createCache_getTmpFolder . get ( _cacheKey ) ; } File _createTempDir = Files . createTempDir ( ) ; _result = _createTempDir ; _createCache_getTmpFolder . put ( _cacheKey , _result ) ; } _init_getTmpFolder ( _result ) ; return _result ; }
|
offers a singleton temporary folder
|
1,341
|
protected static void deleteDir ( final File dir ) { try { boolean _exists = dir . exists ( ) ; boolean _not = ( ! _exists ) ; if ( _not ) { return ; } org . eclipse . xtext . util . Files . sweepFolder ( dir ) ; try { dir . delete ( ) ; } finally { } } catch ( Throwable _e ) { throw Exceptions . sneakyThrow ( _e ) ; } }
|
little helper for cleaning up the temporary stuff .
|
1,342
|
public static List < AbstractElement > getFirstSet ( AbstractElement element ) { return org . eclipse . xtext . xtext . generator . parser . antlr . AntlrGrammarGenUtil . getFirstSet ( element ) ; }
|
Returns the first - set of the given abstractElement . That is all keywords with distinct values and all rule calls to distinct terminals .
|
1,343
|
public IScope createSimpleFeatureCallScope ( EObject context , IFeatureScopeSession session , IResolvedTypes resolvedTypes ) { IScope root = IScope . NULLSCOPE ; if ( context instanceof XFeatureCall ) { XFeatureCall featureCall = ( XFeatureCall ) context ; if ( ! featureCall . isExplicitOperationCallOrBuilderSyntax ( ) ) { root = createTypeLiteralScope ( context , QualifiedName . EMPTY , root , session , resolvedTypes ) ; if ( isDefiniteTypeLiteral ( featureCall ) ) { return root ; } } } IScope staticImports = createStaticFeaturesScope ( context , root , session ) ; IScope staticMembers = createStaticScope ( asAbstractFeatureCall ( context ) , null , null , staticImports , session , resolvedTypes ) ; IScope staticExtensions = createStaticExtensionsScope ( null , null , context , staticMembers , session , resolvedTypes ) ; IScope dynamicExtensions = createDynamicExtensionsScope ( null , null , context , staticExtensions , session , resolvedTypes ) ; IScope localVariables = createImplicitFeatureCallAndLocalVariableScope ( context , dynamicExtensions , session , resolvedTypes ) ; return localVariables ; }
|
This method serves as an entry point for the content assist scoping for simple feature calls .
|
1,344
|
public IScope createFeatureCallScopeForReceiver ( final XExpression featureCall , final XExpression receiver , IFeatureScopeSession session , IResolvedTypes resolvedTypes ) { if ( receiver == null || receiver . eIsProxy ( ) ) return IScope . NULLSCOPE ; LightweightTypeReference receiverType = resolvedTypes . getActualType ( receiver ) ; if ( receiverType != null && ! isUnknownReceiverType ( receiverType ) ) { JvmIdentifiableElement linkedReceiver = resolvedTypes . getLinkedFeature ( asAbstractFeatureCall ( receiver ) ) ; boolean typeLiteral = false ; IScope root = createTypeLiteralScope ( featureCall , receiver , session , resolvedTypes , receiverType , linkedReceiver ) ; if ( root != null ) { if ( featureCall instanceof XMemberFeatureCall && ( ( XMemberFeatureCall ) featureCall ) . isExplicitStatic ( ) ) { return root ; } typeLiteral = true ; } else { root = IScope . NULLSCOPE ; } if ( typeLiteral || isValidFeatureCallArgument ( receiver , linkedReceiver , session ) ) { IScope staticScope = createStaticScope ( asAbstractFeatureCall ( featureCall ) , receiver , receiverType , root , session , resolvedTypes ) ; IScope staticExtensionScope = createStaticExtensionsScope ( receiver , receiverType , featureCall , staticScope , session , resolvedTypes ) ; IScope extensionScope = createDynamicExtensionsScope ( receiver , receiverType , featureCall , staticExtensionScope , session , resolvedTypes ) ; return createFeatureScopeForTypeRef ( receiver , receiverType , false , featureCall , session , linkedReceiver , extensionScope , true ) ; } else { return createFeatureScopeForTypeRef ( receiver , receiverType , false , featureCall , session , linkedReceiver , IScope . NULLSCOPE , true ) ; } } else if ( typeLiteralHelper . isPotentialTypeLiteral ( featureCall , resolvedTypes ) ) { IScope errorScope = createFollowUpErrorScope ( receiverType ) ; List < String > prefix = typeLiteralHelper . getTypeNameSegmentsFromConcreteSyntax ( ( XMemberFeatureCall ) featureCall ) ; if ( prefix == null ) { return errorScope ; } return createTypeLiteralScope ( featureCall , QualifiedName . create ( prefix ) , errorScope , session , resolvedTypes ) ; } else { return createFollowUpErrorScope ( receiverType ) ; } }
|
This method serves as an entry point for the content assist scoping for features .
|
1,345
|
protected IScope createDynamicExtensionsScope ( EObject featureCall , XExpression firstArgument , LightweightTypeReference firstArgumentType , boolean implicitArgument , IScope parent , IFeatureScopeSession session ) { return new DynamicExtensionsScope ( parent , session , firstArgument , firstArgumentType , implicitArgument , asAbstractFeatureCall ( featureCall ) , operatorMapping ) ; }
|
Create a scope that contains dynamic extension features which are features that are contributed by an instance of a type .
|
1,346
|
protected IScope createStaticExtensionsScope ( EObject featureCall , XExpression firstArgument , LightweightTypeReference firstArgumentType , boolean implicitArgument , IScope parent , IFeatureScopeSession session ) { return new StaticExtensionImportsScope ( parent , session , firstArgument , firstArgumentType , implicitArgument , asAbstractFeatureCall ( featureCall ) , operatorMapping ) ; }
|
Create a scope that contains static extension features which are features that are contributed statically via an import .
|
1,347
|
protected IScope createNestedTypeLiteralScope ( EObject featureCall , LightweightTypeReference enclosingType , JvmDeclaredType rawEnclosingType , IScope parent , IFeatureScopeSession session ) { return new NestedTypeLiteralScope ( parent , session , asAbstractFeatureCall ( featureCall ) , enclosingType , rawEnclosingType ) ; }
|
Create a scope that returns nested types .
|
1,348
|
protected IScope createStaticFeaturesScope ( EObject featureCall , IScope parent , IFeatureScopeSession session ) { return new StaticImportsScope ( parent , session , asAbstractFeatureCall ( featureCall ) ) ; }
|
Creates a scope for the statically imported features .
|
1,349
|
protected IScope createLocalVariableScope ( EObject featureCall , IScope parent , IFeatureScopeSession session , IResolvedTypes resolvedTypes ) { return new LocalVariableScope ( parent , session , asAbstractFeatureCall ( featureCall ) ) ; }
|
Creates a scope for the local variables that have been registered in the given session .
|
1,350
|
protected CompositeScope createCompositeScope ( EObject featureCall , IScope parent , IFeatureScopeSession session ) { return new CompositeScope ( parent , session , asAbstractFeatureCall ( featureCall ) ) ; }
|
Create a composite scope that returns description from multiple other scopes without applying shadowing semantics to then .
|
1,351
|
protected IScope createReceiverFeatureScope ( EObject featureCall , XExpression receiver , LightweightTypeReference receiverType , JvmIdentifiableElement receiverFeature , boolean implicitReceiver , boolean validStatic , TypeBucket receiverBucket , IScope parent , IFeatureScopeSession session ) { return new ReceiverFeatureScope ( parent , session , receiver , receiverType , implicitReceiver , asAbstractFeatureCall ( featureCall ) , receiverBucket , receiverFeature , operatorMapping , validStatic ) ; }
|
Creates a scope that returns the features of a given receiver type .
|
1,352
|
protected void addIssue ( final JvmDeclaredType type , final String fileName ) { StringConcatenation _builder = new StringConcatenation ( ) ; _builder . append ( "The type " ) ; String _simpleName = type . getSimpleName ( ) ; _builder . append ( _simpleName ) ; _builder . append ( " is already defined" ) ; { if ( ( fileName != null ) ) { _builder . append ( " in " ) ; _builder . append ( fileName ) ; } } _builder . append ( "." ) ; final String message = _builder . toString ( ) ; final EObject sourceElement = this . associations . getPrimarySourceElement ( type ) ; if ( ( sourceElement == null ) ) { this . addIssue ( message , type , IssueCodes . DUPLICATE_TYPE ) ; } else { final EStructuralFeature feature = sourceElement . eClass ( ) . getEStructuralFeature ( "name" ) ; this . addIssue ( message , sourceElement , feature , IssueCodes . DUPLICATE_TYPE ) ; } }
|
Marks a type as already defined .
|
1,353
|
protected void handleCollectionTypeNotAvailable ( XCollectionLiteral literal , ITypeComputationState state , Class < ? > clazz ) { for ( XExpression element : literal . getElements ( ) ) { state . withNonVoidExpectation ( ) . computeTypes ( element ) ; } state . acceptActualType ( state . getReferenceOwner ( ) . newUnknownTypeReference ( clazz . getName ( ) ) ) ; }
|
Process all children and assign an unknown type to the literal .
|
1,354
|
protected boolean matchesExpectation ( LightweightTypeReference elementType , LightweightTypeReference expectation ) { return expectation != null && expectation . isResolved ( ) && ! expectation . isWildcard ( ) && expectation . isAssignableFrom ( elementType ) ; }
|
Implements fall - back strategy . If the expected type of a collection literal does not match the actual type but the expected element types would match the actual element type the collection literal will be successfully typed according to the expectation .
|
1,355
|
protected LightweightTypeReference doNormalizeElementType ( LightweightTypeReference actual , LightweightTypeReference expected ) { if ( matchesExpectation ( actual , expected ) ) { return expected ; } return normalizeFunctionTypeReference ( actual ) ; }
|
If the expected type is not a wildcard it may supersede the actual element type .
|
1,356
|
protected List < LightweightTypeReference > computeCollectionTypeCandidates ( XCollectionLiteral literal , JvmGenericType collectionType , LightweightTypeReference elementTypeExpectation , ITypeComputationState state ) { List < XExpression > elements = literal . getElements ( ) ; if ( ! elements . isEmpty ( ) ) { List < LightweightTypeReference > elementTypes = Lists . newArrayListWithCapacity ( elements . size ( ) ) ; for ( XExpression element : elements ) { ITypeComputationResult elementType = computeTypes ( element , elementTypeExpectation , state ) ; LightweightTypeReference actualType = elementType . getActualExpressionType ( ) ; if ( actualType != null && ! actualType . isAny ( ) ) { ParameterizedTypeReference collectionTypeCandidate = state . getReferenceOwner ( ) . newParameterizedTypeReference ( collectionType ) ; collectionTypeCandidate . addTypeArgument ( actualType . getWrapperTypeIfPrimitive ( ) ) ; elementTypes . add ( collectionTypeCandidate ) ; } } return elementTypes ; } return Collections . emptyList ( ) ; }
|
Creates a list of collection type references from the element types of a collection literal .
|
1,357
|
protected List < XExpression > getArguments ( ) { List < XExpression > syntacticArguments = getSyntacticArguments ( ) ; XExpression firstArgument = getFirstArgument ( ) ; if ( firstArgument != null ) { return createArgumentList ( firstArgument , syntacticArguments ) ; } return syntacticArguments ; }
|
Returns the actual arguments of the expression . These do not include the receiver .
|
1,358
|
protected IScope createAnonymousClassConstructorScope ( final JvmGenericType anonymousType , EObject context , final IFeatureScopeSession session ) { IVisibilityHelper protectedIsVisible = new IVisibilityHelper ( ) { public boolean isVisible ( JvmMember member ) { return member . getVisibility ( ) != JvmVisibility . PRIVATE ; } } ; return new ConstructorTypeScopeWrapper ( context , protectedIsVisible , IScope . NULLSCOPE ) { public Iterable < IEObjectDescription > getElements ( EObject object ) { throw new UnsupportedOperationException ( "TODO implement as necessary" ) ; } public Iterable < IEObjectDescription > getElements ( QualifiedName name ) { JvmTypeReference superType = Iterables . getLast ( anonymousType . getSuperTypes ( ) , null ) ; if ( superType == null ) return Collections . emptyList ( ) ; JvmType type = superType . getType ( ) ; if ( type == null ) return Collections . emptyList ( ) ; QualifiedName typeName = qualifiedNameConverter . toQualifiedName ( type . getQualifiedName ( '.' ) ) ; if ( typeName . getSegmentCount ( ) > name . getSegmentCount ( ) ) { typeName = typeName . skipFirst ( typeName . getSegmentCount ( ) - name . getSegmentCount ( ) ) ; } if ( ! typeName . equals ( name ) ) { if ( name . getSegmentCount ( ) == 1 && name . getFirstSegment ( ) . indexOf ( '$' ) > 0 ) { QualifiedName splitted = QualifiedName . create ( Strings . split ( name . getFirstSegment ( ) , '$' ) ) ; typeName = qualifiedNameConverter . toQualifiedName ( type . getQualifiedName ( '.' ) ) ; if ( typeName . getSegmentCount ( ) > splitted . getSegmentCount ( ) ) { typeName = typeName . skipFirst ( typeName . getSegmentCount ( ) - splitted . getSegmentCount ( ) ) ; } if ( ! typeName . equals ( splitted ) ) { return Collections . emptyList ( ) ; } } else { return Collections . emptyList ( ) ; } } IEObjectDescription typeDescription = EObjectDescription . create ( name , anonymousType ) ; return createFeatureDescriptions ( Collections . singletonList ( typeDescription ) ) ; } protected ConstructorDescription createConstructorDescription ( IEObjectDescription typeDescription , JvmConstructor constructor , boolean visible ) { return createAnonmousClassConstructorDescription ( typeDescription . getName ( ) , constructor , visible ) ; } } ; }
|
Custom languages that allow to infer anonymous classes may want to use this helper to access the constructors of those classes .
|
1,359
|
public String toJavaIdentifier ( final String text , final boolean uppercaseFirst ) { return GrammarAccessUtil . toJavaIdentifier ( text , Boolean . valueOf ( uppercaseFirst ) ) ; }
|
Converts an arbitary string to a valid Java identifier . The string is split up along the the characters that are not valid as Java identifier . The first character of each segments is made upper case which leads to a camel - case style .
|
1,360
|
public String gaRuleIdentifyer ( final AbstractRule rule ) { final String plainName = RuleNames . getRuleNames ( rule ) . getUniqueRuleName ( rule ) ; return this . toJavaIdentifier ( plainName , true ) ; }
|
Creates an identifier for a Rule which is a valid Java idetifier and unique within the Rule s grammar .
|
1,361
|
public String gaRuleAccessMethodName ( final AbstractRule rule ) { String _gaRuleIdentifyer = this . gaRuleIdentifyer ( rule ) ; String _plus = ( "get" + _gaRuleIdentifyer ) ; return ( _plus + "Rule" ) ; }
|
Returns the method name for accessing a rule via a GrammarAccess implementation .
|
1,362
|
public String gaRuleElementsMethodName ( final AbstractRule rule ) { String _gaRuleIdentifyer = this . gaRuleIdentifyer ( rule ) ; String _plus = ( "get" + _gaRuleIdentifyer ) ; return ( _plus + "Access" ) ; }
|
Returns the method name for accessing a rule s content via a ParseRuleAccess implementation .
|
1,363
|
public IScope createFeatureCallSerializationScope ( EObject context ) { if ( ! ( context instanceof XAbstractFeatureCall ) ) { return IScope . NULLSCOPE ; } XAbstractFeatureCall call = ( XAbstractFeatureCall ) context ; JvmIdentifiableElement feature = call . getFeature ( ) ; if ( feature instanceof JvmType ) { return getTypeScope ( call , ( JvmType ) feature ) ; } if ( feature instanceof JvmConstructor ) { return getThisOrSuperScope ( call , ( JvmConstructor ) feature ) ; } if ( feature instanceof JvmExecutable ) { return getExecutableScope ( call , feature ) ; } if ( feature instanceof JvmFormalParameter || feature instanceof JvmField || feature instanceof XVariableDeclaration || feature instanceof XSwitchExpression ) { return new SingletonScope ( EObjectDescription . create ( feature . getSimpleName ( ) , feature ) , IScope . NULLSCOPE ) ; } return IScope . NULLSCOPE ; }
|
which is quite hard anyway ...
|
1,364
|
public void optimizeLineSection ( ) { int i = 0 ; while ( i < lineData . size ( ) - 1 ) { LineInfo li = lineData . get ( i ) ; LineInfo liNext = lineData . get ( i + 1 ) ; if ( ! liNext . lineFileIDSet && liNext . inputStartLine == li . inputStartLine && liNext . inputLineCount == 1 && li . inputLineCount == 1 && liNext . outputStartLine == li . outputStartLine + li . inputLineCount * li . outputLineIncrement ) { li . setOutputLineIncrement ( liNext . outputStartLine - li . outputStartLine + liNext . outputLineIncrement ) ; lineData . remove ( i + 1 ) ; } else { i ++ ; } } i = 0 ; while ( i < lineData . size ( ) - 1 ) { LineInfo li = lineData . get ( i ) ; LineInfo liNext = lineData . get ( i + 1 ) ; if ( ! liNext . lineFileIDSet && liNext . inputStartLine == li . inputStartLine + li . inputLineCount && liNext . outputLineIncrement == li . outputLineIncrement && liNext . outputStartLine == li . outputStartLine + li . inputLineCount * li . outputLineIncrement ) { li . setInputLineCount ( li . inputLineCount + liNext . inputLineCount ) ; lineData . remove ( i + 1 ) ; } else { i ++ ; } } }
|
Combines consecutive LineInfos wherever possible
|
1,365
|
public GeneratorConfig copy ( final GeneratorConfig other ) { this . generateExpressions = other . generateExpressions ; this . generateSyntheticSuppressWarnings = other . generateSyntheticSuppressWarnings ; this . generateGeneratedAnnotation = other . generateGeneratedAnnotation ; this . includeDateInGeneratedAnnotation = other . includeDateInGeneratedAnnotation ; this . generatedAnnotationComment = other . generatedAnnotationComment ; this . javaSourceVersion = other . javaSourceVersion ; return this ; }
|
Copy the values of the given generator configuration .
|
1,366
|
public static int compareFlags ( int left , int right ) { if ( left == right ) { return 0 ; } int leftSuccess = left & SUCCESS_OR_LAMBDA ; int rightSuccess = right & SUCCESS_OR_LAMBDA ; if ( leftSuccess != rightSuccess ) { if ( leftSuccess == 0 ) return 1 ; if ( rightSuccess == 0 ) return - 1 ; if ( leftSuccess < rightSuccess ) return - 1 ; return 1 ; } if ( ( left & SYNONYM ) != ( right & SYNONYM ) ) { if ( ( left & SYNONYM ) != 0 ) return 1 ; return - 1 ; } return 0 ; }
|
Simple comparison of two flags . If both indicate compatibility the one with the better compatibility level wins .
|
1,367
|
public static boolean sanityCheck ( int flags ) { doCheck ( flags , ConformanceFlags . CHECKED | ConformanceFlags . UNCHECKED ) ; if ( ( flags & ConformanceFlags . UNCHECKED ) == 0 ) { doCheck ( flags , ConformanceFlags . CHECK_RESULTS ) ; } else if ( ( flags & ( ConformanceFlags . SEALED | ConformanceFlags . CHECK_RESULTS ) ) != 0 ) { throw new IllegalArgumentException ( "Invalid flags: " + toString ( flags ) ) ; } return true ; }
|
Simple sanity check for the given flags .
|
1,368
|
protected Map < JvmTypeParameter , LightweightMergedBoundTypeArgument > getTypeParameterMapping ( ) { if ( typeParameterMapping == null ) { typeParameterMapping = initializeTypeParameterMapping ( ) ; } return typeParameterMapping ; }
|
Returns the mapping of type parameters to their bound arguments .
|
1,369
|
protected String getArgumentTypesAsString ( ) { if ( ! getArguments ( ) . isEmpty ( ) ) { StringBuilder b = new StringBuilder ( ) ; b . append ( "(" ) ; for ( int i = 0 ; i < getArguments ( ) . size ( ) ; ++ i ) { LightweightTypeReference actualType = getActualType ( getArguments ( ) . get ( i ) ) ; if ( actualType != null ) b . append ( actualType . getHumanReadableName ( ) ) ; else b . append ( "null" ) ; if ( i < getArguments ( ) . size ( ) - 1 ) b . append ( "," ) ; } b . append ( ")" ) ; return b . toString ( ) ; } return "" ; }
|
Returns the resolved string representation of the argument types . The simple names of the types are used . The string representation includes the parenthesis .
|
1,370
|
protected String getFeatureTypeParametersAsString ( boolean showBounds ) { List < JvmTypeParameter > typeParameters = getDeclaredTypeParameters ( ) ; if ( ! typeParameters . isEmpty ( ) ) { StringBuilder b = new StringBuilder ( ) ; b . append ( "<" ) ; for ( int i = 0 ; i < typeParameters . size ( ) ; ++ i ) { JvmTypeParameter typeParameter = typeParameters . get ( i ) ; if ( showBounds ) b . append ( getTypeParameterAsString ( typeParameter ) ) ; else b . append ( typeParameter . getSimpleName ( ) ) ; if ( i < typeParameters . size ( ) - 1 ) b . append ( ", " ) ; } b . append ( ">" ) ; return b . toString ( ) ; } return "" ; }
|
Returns the unresolved string representation of the unresolved type parameters of the feature . The simple names of the type bounds are used . The string representation includes the angle brackets .
|
1,371
|
protected String getTypeArgumentsAsString ( List < ? extends LightweightTypeReference > typeArguments ) { if ( ! typeArguments . isEmpty ( ) ) { StringBuilder b = new StringBuilder ( ) ; b . append ( "<" ) ; for ( int i = 0 ; i < typeArguments . size ( ) ; ++ i ) { b . append ( typeArguments . get ( i ) . getHumanReadableName ( ) ) ; if ( i < typeArguments . size ( ) - 1 ) b . append ( ", " ) ; } b . append ( ">" ) ; return b . toString ( ) ; } return "" ; }
|
Returns the resolved string representation of the type arguments . The simple names of the types are used . The string representation includes the angle brackets .
|
1,372
|
public ILinkingCandidate getPreferredCandidate ( ILinkingCandidate other ) { if ( other instanceof AbstractPendingLinkingCandidate ) { AbstractPendingLinkingCandidate < ? > right = ( AbstractPendingLinkingCandidate < ? > ) other ; CandidateCompareResult candidateCompareResult = compareTo ( right ) ; switch ( candidateCompareResult ) { case AMBIGUOUS : return createAmbiguousLinkingCandidate ( right ) ; case SUSPICIOUS_OTHER : return createSuspiciousLinkingCandidate ( right ) ; case EQUALLY_INVALID : case THIS : return this ; case OTHER : return other ; } } throw new IllegalArgumentException ( "other was " + other ) ; }
|
Returns the best candidate considering the this and the given other candidate .
|
1,373
|
public int getArityMismatch ( ) { JvmIdentifiableElement identifiable = getFeature ( ) ; if ( identifiable instanceof JvmExecutable ) { return getArityMismatch ( ( JvmExecutable ) identifiable , getArguments ( ) ) ; } else if ( getExpression ( ) instanceof XAssignment ) { return getArguments ( ) . size ( ) - 1 ; } else { return getArguments ( ) . size ( ) ; } }
|
Returns the mismatch of actually given arguments and declared parameters . Receivers and staticness of the feature is taken into account too . The mismatch may either be negative or positive .
|
1,374
|
public < T extends Object > void forEach ( final ITreeAppendable appendable , final Iterable < T > elements , final Procedure1 < ? super LoopParams > loopInitializer , final Procedure1 < ? super T > procedure ) { boolean _isEmpty = IterableExtensions . isEmpty ( elements ) ; if ( _isEmpty ) { return ; } LoopParams _loopParams = new LoopParams ( ) ; final LoopParams params = ObjectExtensions . < LoopParams > operator_doubleArrow ( _loopParams , loopInitializer ) ; params . appendPrefix ( appendable ) ; T _head = IterableExtensions . < T > head ( elements ) ; ObjectExtensions . < T > operator_doubleArrow ( _head , procedure ) ; final Consumer < T > _function = ( T it ) -> { params . appendSeparator ( appendable ) ; ObjectExtensions . < T > operator_doubleArrow ( it , procedure ) ; } ; IterableExtensions . < T > tail ( elements ) . forEach ( _function ) ; params . appendSuffix ( appendable ) ; }
|
Iterates elements and execute the procedure . A prefix a separator and a suffix can be initialized with the loopInitializer lambda .
|
1,375
|
public < T extends Object > void forEachWithShortcut ( final ITreeAppendable appendable , final Iterable < T > elements , final Procedure1 < ? super T > procedure ) { int _size = IterableExtensions . size ( elements ) ; boolean _equals = ( _size == 1 ) ; if ( _equals ) { T _head = IterableExtensions . < T > head ( elements ) ; ObjectExtensions . < T > operator_doubleArrow ( _head , procedure ) ; } else { appendable . append ( "{" ) ; final Procedure1 < LoopParams > _function = ( LoopParams it ) -> { it . setPrefix ( " " ) ; it . setSeparator ( ", " ) ; it . setSuffix ( " " ) ; } ; this . < T > forEach ( appendable , elements , _function , procedure ) ; appendable . append ( "}" ) ; } }
|
Uses curly braces and comma as delimiters . Doesn t use them for single valued iterables .
|
1,376
|
protected void processAsPropertyNames ( QualifiedName name , NameAcceptor acceptor ) { String nameAsPropertyName = tryGetAsPropertyName ( name . toString ( ) ) ; if ( nameAsPropertyName != null ) { if ( featureCall == null || featureCall instanceof XAssignment ) { String aliasedSetter = "set" + nameAsPropertyName ; acceptor . accept ( aliasedSetter , 2 ) ; } if ( ! ( featureCall instanceof XAssignment ) ) { if ( featureCall == null || ! getFeatureCall ( ) . isExplicitOperationCallOrBuilderSyntax ( ) ) { String aliasedGetter = "get" + nameAsPropertyName ; acceptor . accept ( aliasedGetter , 2 ) ; String aliasedBooleanGetter = "is" + nameAsPropertyName ; acceptor . accept ( aliasedBooleanGetter , 2 ) ; } } } }
|
Considers the given name to be a property name . If the concrete syntax of the processed feature matches a feature call or assignment a prefix is added to the name and that one is used as a variant that should be processed .
|
1,377
|
private boolean handleOverridesAndConflicts ( JvmOperation operation , Multimap < String , AbstractResolvedOperation > processedOperations ) { String simpleName = operation . getSimpleName ( ) ; if ( ! processedOperations . containsKey ( simpleName ) ) { return true ; } List < AbstractResolvedOperation > conflictingOperations = null ; for ( AbstractResolvedOperation candidate : processedOperations . get ( simpleName ) ) { OverrideTester overrideTester = candidate . getOverrideTester ( ) ; IOverrideCheckResult checkResult = overrideTester . isSubsignature ( candidate , operation , false ) ; if ( checkResult . getDetails ( ) . contains ( OverrideCheckDetails . DEFAULT_IMPL_CONFLICT ) ) { if ( conflictingOperations == null ) conflictingOperations = Lists . newLinkedList ( ) ; conflictingOperations . add ( candidate ) ; } else if ( checkResult . isOverridingOrImplementing ( ) ) { return false ; } } if ( conflictingOperations != null ) { if ( conflictingOperations . size ( ) == 1 && conflictingOperations . get ( 0 ) instanceof ConflictingDefaultOperation ) { ConflictingDefaultOperation conflictingDefaultOperation = ( ConflictingDefaultOperation ) conflictingOperations . get ( 0 ) ; boolean isOverridden = false ; for ( IResolvedOperation conflictingOp : conflictingDefaultOperation . getConflictingOperations ( ) ) { if ( conflictingOp . getResolvedDeclarator ( ) . isSubtypeOf ( operation . getDeclaringType ( ) ) ) { isOverridden = true ; break ; } } if ( ! isOverridden ) conflictingDefaultOperation . getConflictingOperations ( ) . add ( createResolvedOperation ( operation ) ) ; return false ; } if ( operation . isAbstract ( ) ) { ConflictingDefaultOperation resolvedOperation = createConflictingOperation ( conflictingOperations . get ( 0 ) . getDeclaration ( ) ) ; resolvedOperation . getConflictingOperations ( ) . add ( createResolvedOperation ( operation ) ) ; for ( AbstractResolvedOperation conflictingOp : conflictingOperations ) { processedOperations . remove ( simpleName , conflictingOp ) ; if ( conflictingOp . getDeclaration ( ) != resolvedOperation . getDeclaration ( ) ) { resolvedOperation . getConflictingOperations ( ) . add ( conflictingOp ) ; } } processedOperations . put ( simpleName , resolvedOperation ) ; } else { ConflictingDefaultOperation resolvedOperation = createConflictingOperation ( operation ) ; for ( AbstractResolvedOperation conflictingOp : conflictingOperations ) { processedOperations . remove ( simpleName , conflictingOp ) ; resolvedOperation . getConflictingOperations ( ) . add ( conflictingOp ) ; } processedOperations . put ( simpleName , resolvedOperation ) ; } return false ; } return true ; }
|
When the inherited operations are computed for Java 8 we have to check for conflicting default interface method implementations .
|
1,378
|
public static UnboundTypeReference create ( ITypeExpectation expectation , XExpression expression , JvmTypeParameter typeParameter ) { return expectation . createUnboundTypeReference ( expression , typeParameter ) ; }
|
Create a new managed unbound type reference for the given type parameter which was first encountered for the given expression .
|
1,379
|
public void tryResolve ( boolean constraintsAreSignificant ) { if ( internalIsResolved ( ) ) return ; List < LightweightBoundTypeArgument > hints = getAllHints ( ) ; if ( ! hints . isEmpty ( ) && hasSignificantHints ( hints , constraintsAreSignificant ) ) { resolveWithHints ( hints ) ; } }
|
Try to resolve this reference iff there are hints available . May be invoked multiple times since it will simply returns if the reference is already resolved . The caller can decide whether type constraints are considered to be significant hints or not .
|
1,380
|
public boolean canResolveTo ( LightweightTypeReference reference ) { if ( internalIsResolved ( ) ) return reference . isAssignableFrom ( resolvedTo , new TypeConformanceComputationArgument ( false , true , true , true , false , false ) ) ; List < LightweightBoundTypeArgument > hints = getAllHints ( ) ; if ( ! hints . isEmpty ( ) && hasSignificantHints ( hints ) ) { return canResolveTo ( reference , hints ) ; } return false ; }
|
Returns true if the existing hints would allow to resolve to the given reference .
|
1,381
|
public LightweightTypeReference resolve ( ) { if ( internalIsResolved ( ) ) return resolvedTo ; List < LightweightBoundTypeArgument > allHints = getAllHints ( ) ; if ( ! allHints . isEmpty ( ) && resolveWithHints ( allHints ) ) { LightweightTypeReference result = internalGetResolvedTo ( ) ; if ( result != null ) { return result ; } } resolveAgainstConstraints ( ) ; return resolvedTo ; }
|
Force this reference to be resolved . If not hints are available the reference is resolved to the constraints of the type parameters .
|
1,382
|
public ITreeAppendable compile ( XBlockExpression expr , ITreeAppendable b , LightweightTypeReference expectedReturnType ) { final boolean isPrimitiveVoidExpected = expectedReturnType . isPrimitiveVoid ( ) ; final boolean isPrimitiveVoid = isPrimitiveVoid ( expr ) ; final boolean earlyExit = isEarlyExit ( expr ) ; final boolean isImplicitReturn = ! isPrimitiveVoidExpected && ! isPrimitiveVoid && ! earlyExit ; final EList < XExpression > expressions = expr . getExpressions ( ) ; for ( int i = 0 ; i < expressions . size ( ) ; i ++ ) { XExpression ex = expressions . get ( i ) ; if ( i < expressions . size ( ) - 1 ) { internalToJavaStatement ( ex , b . trace ( ex , true ) , false ) ; } else { internalToJavaStatement ( ex , b . trace ( ex , true ) , isImplicitReturn ) ; if ( isImplicitReturn ) { b . newLine ( ) . append ( "return (" ) ; internalToConvertedExpression ( ex , b , expectedReturnType ) ; b . append ( ");" ) ; } } } return b ; }
|
this one trims the outer block
|
1,383
|
protected final boolean isVariableDeclarationRequired ( XExpression expr , ITreeAppendable b ) { return isVariableDeclarationRequired ( expr , b , true ) ; }
|
whether an expression needs to be declared in a statement If an expression has side effects this method must return true for it .
|
1,384
|
public int parseArgument ( Options opt , String [ ] args , int start ) throws BadCommandLineException , IOException { int consumed = 0 ; final String optionPrefix = "-" + getOptionName ( ) + "-" ; final int optionPrefixLength = optionPrefix . length ( ) ; final String arg = args [ start ] ; final int equalsPosition = arg . indexOf ( '=' ) ; if ( arg . startsWith ( optionPrefix ) && equalsPosition > optionPrefixLength ) { final String propertyName = arg . substring ( optionPrefixLength , equalsPosition ) ; final String value = arg . substring ( equalsPosition + 1 ) ; consumed ++ ; try { BeanUtils . setProperty ( this , propertyName , value ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; throw new BadCommandLineException ( "Error setting property [" + propertyName + "], value [" + value + "]." ) ; } } return consumed ; }
|
Parses the arguments and injects values into the beans via properties .
|
1,385
|
public static List < GrantedAuthority > buildAuthorities ( final List < CommonProfile > profiles ) { final List < GrantedAuthority > authorities = new ArrayList < > ( ) ; for ( final CommonProfile profile : profiles ) { final Set < String > roles = profile . getRoles ( ) ; for ( final String role : roles ) { authorities . add ( new SimpleGrantedAuthority ( role ) ) ; } } return authorities ; }
|
Build a list of authorities from a list of profiles .
|
1,386
|
public static void populateAuthentication ( final LinkedHashMap < String , CommonProfile > profiles ) { if ( profiles != null && profiles . size ( ) > 0 ) { final List < CommonProfile > listProfiles = ProfileHelper . flatIntoAProfileList ( profiles ) ; try { if ( IS_FULLY_AUTHENTICATED_AUTHORIZER . isAuthorized ( null , listProfiles ) ) { SecurityContextHolder . getContext ( ) . setAuthentication ( new Pac4jAuthenticationToken ( listProfiles ) ) ; } else if ( IS_REMEMBERED_AUTHORIZER . isAuthorized ( null , listProfiles ) ) { SecurityContextHolder . getContext ( ) . setAuthentication ( new Pac4jRememberMeAuthenticationToken ( listProfiles ) ) ; } } catch ( final HttpAction e ) { throw new TechnicalException ( e ) ; } } }
|
Populate the authenticated user profiles in the Spring Security context .
|
1,387
|
public CMAEditorInterface update ( CMAEditorInterface editor ) { final String spaceId = getSpaceIdOrThrow ( editor , "editor" ) ; if ( editor . getSystem ( ) . getContentType ( ) == null ) { throw new IllegalArgumentException ( "ContentType of editor interface may not be null!" ) ; } if ( editor . getSystem ( ) . getContentType ( ) . getId ( ) == null ) { throw new IllegalArgumentException ( "Id of ContentType of editor interface may not be null!" ) ; } final String contentTypeId = editor . getSystem ( ) . getContentType ( ) . getId ( ) ; final String environmentId = editor . getEnvironmentId ( ) ; final Integer version = getVersionOrThrow ( editor , "update" ) ; CMASystem old = editor . getSystem ( ) ; editor . setSystem ( null ) ; try { return service . update ( spaceId , environmentId , contentTypeId , editor , version ) . blockingFirst ( ) ; } finally { editor . setSystem ( old ) ; } }
|
Update an editor interface .
|
1,388
|
public Integer delete ( CMAWebhook webhook ) { final String webhookId = getResourceIdOrThrow ( webhook , "webhook" ) ; final String spaceId = getSpaceIdOrThrow ( webhook , "webhook" ) ; return service . delete ( spaceId , webhookId ) . blockingFirst ( ) . code ( ) ; }
|
Delete a given Webhook .
|
1,389
|
public CMAArray < CMAWebhook > fetchAll ( Map < String , String > query ) { throwIfEnvironmentIdIsSet ( ) ; return fetchAll ( spaceId , query ) ; }
|
Retrieve specific webhooks matching a query for this space .
|
1,390
|
public CMAArray < CMAWebhookCall > calls ( CMAWebhook webhook ) { final String spaceId = getSpaceIdOrThrow ( webhook , "webhook" ) ; final String webhookId = getResourceIdOrThrow ( webhook , "webhook" ) ; return service . calls ( spaceId , webhookId ) . blockingFirst ( ) ; }
|
Get more information about a specific webhook .
|
1,391
|
public CMAWebhookCallDetail callDetails ( CMAWebhookCall call ) { final String spaceId = getSpaceIdOrThrow ( call , "call" ) ; final String callId = getResourceIdOrThrow ( call , "call" ) ; assertNotNull ( call . getSystem ( ) . getCreatedBy ( ) . getId ( ) , "webhook.sys.createdBy" ) ; final String webhookId = call . getSystem ( ) . getCreatedBy ( ) . getId ( ) ; return service . callDetails ( spaceId , webhookId , callId ) . blockingFirst ( ) ; }
|
Get more information about one specific call to one specific webhook hosted by one specific space .
|
1,392
|
public CMAWebhookHealth health ( CMAWebhook webhook ) { final String spaceId = getSpaceIdOrThrow ( webhook , "webhook" ) ; final String webhookId = getResourceIdOrThrow ( webhook , "webhook" ) ; return service . health ( spaceId , webhookId ) . blockingFirst ( ) ; }
|
Return a general understanding of the health of the webhook .
|
1,393
|
public CMAEnvironmentStatus getStatus ( ) { final CMALink link = system . getEnvironmentalStatus ( ) ; if ( link == null ) { return null ; } final String id = link . getId ( ) . toLowerCase ( ) ; for ( final CMAEnvironmentStatus status : CMAEnvironmentStatus . values ( ) ) { final String statusName = status . name ( ) . toLowerCase ( ) ; if ( statusName . equals ( id ) ) { return status ; } } return null ; }
|
Return the state of this environment
|
1,394
|
public Integer delete ( CMAEnvironment environment ) { assertNotNull ( environment . getSpaceId ( ) , "spaceId" ) ; assertNotNull ( environment . getId ( ) , "environmentId" ) ; return service . delete ( getVersionOrThrow ( environment , "version" ) , environment . getSpaceId ( ) , environment . getId ( ) ) . blockingFirst ( ) . code ( ) ; }
|
Delete an environment .
|
1,395
|
@ SuppressWarnings ( "unchecked" ) public < T > T getField ( String key , String locale ) { if ( fields == null ) { return null ; } LinkedHashMap < String , Object > field = fields . get ( key ) ; if ( field == null ) { return null ; } else { return ( T ) field . get ( locale ) ; } }
|
Return a specific localized field .
|
1,396
|
public CMAEntry setFields ( LinkedHashMap < String , LinkedHashMap < String , Object > > fields ) { this . fields = fields ; return this ; }
|
Sets a map of fields for this Entry .
|
1,397
|
public CMARole addPolicy ( CMAPolicy policy ) { if ( policies == null ) { policies = new ArrayList < CMAPolicy > ( ) ; } policies . add ( policy ) ; return this ; }
|
Add a new policy to the existing ones creating a new list if needed .
|
1,398
|
public JsonElement serialize ( CMAEntry src , Type type , JsonSerializationContext context ) { JsonObject fields = new JsonObject ( ) ; for ( Map . Entry < String , LinkedHashMap < String , Object > > field : src . getFields ( ) . entrySet ( ) ) { LinkedHashMap < String , Object > value = field . getValue ( ) ; if ( value == null ) { continue ; } String fieldId = field . getKey ( ) ; JsonObject jsonField = serializeField ( context , field . getValue ( ) ) ; if ( jsonField != null ) { fields . add ( fieldId , jsonField ) ; } } JsonObject result = new JsonObject ( ) ; result . add ( "fields" , fields ) ; final CMASystem sys = src . getSystem ( ) ; if ( sys != null ) { result . add ( "sys" , context . serialize ( sys ) ) ; } return result ; }
|
Make sure all fields are mapped in the locale - value way .
|
1,399
|
public JsonElement serialize ( CMAField field , Type type , JsonSerializationContext context ) { JsonObject json = new JsonObject ( ) ; add ( json , ATTR_ID , field . getId ( ) ) ; add ( json , ATTR_NAME , field . getName ( ) ) ; add ( json , ATTR_TYPE , field . getType ( ) ) ; add ( json , ATTR_LINK_TYPE , field . getLinkType ( ) ) ; add ( json , ATTR_REQUIRED , field . isRequired ( ) ) ; add ( json , ATTR_DISABLED , field . isDisabled ( ) ) ; add ( json , ATTR_OMITTED , field . isOmitted ( ) ) ; add ( json , ATTR_LOCALIZED , field . isLocalized ( ) ) ; List < Map < String , Object > > validations = field . getValidations ( ) ; if ( validations != null ) { json . add ( ATTR_VALIDATIONS , context . serialize ( validations , new TypeToken < List < Map < String , Object > > > ( ) { } . getType ( ) ) ) ; } Map < String , Object > arrayItems = field . getArrayItems ( ) ; if ( arrayItems != null ) { json . add ( ATTR_ARRAY_ITEMS , context . serialize ( arrayItems , Map . class ) ) ; } return json ; }
|
Serialize all fields for content types .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.