org.eclipse.xtext.common.types.JvmField Java Examples
The following examples show how to use
org.eclipse.xtext.common.types.JvmField.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XbaseIdeContentProposalPriorities.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public int getCrossRefPriority(IEObjectDescription objectDesc, ContentAssistEntry entry) { if (entry != null) { if (objectDesc instanceof SimpleIdentifiableElementDescription) { if (!"this".equals(entry.getProposal()) && !"super".equals(entry.getProposal())) { return adjustPriority(entry, getCrossRefPriority() + 70); } } else if (objectDesc instanceof StaticFeatureDescriptionWithTypeLiteralReceiver) { return adjustPriority(entry, getCrossRefPriority() + 60); } else if (objectDesc instanceof IIdentifiableElementDescription) { JvmIdentifiableElement element = ((IIdentifiableElementDescription) objectDesc).getElementOrProxy(); if (element instanceof JvmField) { return adjustPriority(entry, getCrossRefPriority() + 50); } else if (element instanceof JvmExecutable) { return adjustPriority(entry, getCrossRefPriority() + 20); } } } return super.getCrossRefPriority(objectDesc, entry); }
Example #2
Source File: SARLLabelProvider.java From sarl with Apache License 2.0 | 6 votes |
@Override protected StyledString signature(String simpleName, JvmIdentifiableElement element) { final JvmTypeReference returnType; if (element instanceof JvmOperation) { returnType = ((JvmOperation) element).getReturnType(); } else if (element instanceof JvmField) { returnType = ((JvmField) element).getType(); } else { returnType = null; } final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, element); final String returnTypeString = (returnType == null) ? this.keywords.getVoidKeyword() : owner.toLightweightTypeReference(returnType).getHumanReadableName(); String decoratedPart = " : " + returnTypeString; //$NON-NLS-1$ final String typeParam = Strings.nullToEmpty(this.uiStrings.typeParameters(element)); if (!Strings.isNullOrEmpty(typeParam)) { decoratedPart = " " + typeParam + " : " + returnTypeString; //$NON-NLS-1$ //$NON-NLS-2$ } final StyledString str = new StyledString(); str.append(simpleName); str.append(this.uiStrings.styledParameters(element)); str.append(decoratedPart, StyledString.DECORATIONS_STYLER); return str; }
Example #3
Source File: InferredJvmModelTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testInferredFunction_04() throws Exception { XtendFile xtendFile = file("class Foo { def Iterable<CharSequence> create result: newArrayList(s) newList(String s) {} }"); JvmGenericType inferredType = getInferredType(xtendFile); XtendClass xtendClass = (XtendClass) xtendFile.getXtendTypes().get(0); EList<JvmMember> jvmMembers = inferredType.getMembers(); assertEquals(4, jvmMembers.size()); JvmMember jvmMember = jvmMembers.get(1); assertTrue(jvmMember instanceof JvmOperation); XtendFunction xtendFunction = (XtendFunction) xtendClass.getMembers().get(0); assertEquals(xtendFunction.getName(), jvmMember.getSimpleName()); assertEquals(JvmVisibility.PUBLIC, jvmMember.getVisibility()); assertEquals("java.lang.Iterable<java.lang.CharSequence>", ((JvmOperation) jvmMember).getReturnType().getIdentifier()); JvmField cacheVar = (JvmField) jvmMembers.get(2); assertEquals("_createCache_" + xtendFunction.getName(), cacheVar.getSimpleName()); assertEquals(JvmVisibility.PRIVATE, cacheVar.getVisibility()); assertEquals("java.util.HashMap<java.util.ArrayList<? extends java.lang.Object>, java.lang.Iterable<java.lang.CharSequence>>", cacheVar.getType().getIdentifier()); JvmOperation privateInitializer = (JvmOperation) jvmMembers.get(3); assertEquals("_init_"+xtendFunction.getName(), privateInitializer.getSimpleName()); assertEquals(JvmVisibility.PRIVATE, privateInitializer.getVisibility()); // This used to be a bogus assertion since Iterable<CharSequence> is not assignable from ArrayList<String> // assertEquals("java.util.ArrayList<java.lang.String>", privateInitializer.getParameters().get(0).getParameterType().getIdentifier()); assertEquals("java.util.ArrayList<java.lang.CharSequence>", privateInitializer.getParameters().get(0).getParameterType().getIdentifier()); assertEquals("java.lang.String", privateInitializer.getParameters().get(1).getParameterType().getIdentifier()); }
Example #4
Source File: JvmFieldItemProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * This handles model notifications by calling {@link #updateChildren} to update any cached * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void notifyChanged(Notification notification) { updateChildren(notification); switch (notification.getFeatureID(JvmField.class)) { case TypesPackage.JVM_FIELD__STATIC: case TypesPackage.JVM_FIELD__FINAL: case TypesPackage.JVM_FIELD__VOLATILE: case TypesPackage.JVM_FIELD__TRANSIENT: case TypesPackage.JVM_FIELD__CONSTANT: case TypesPackage.JVM_FIELD__CONSTANT_VALUE: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; case TypesPackage.JVM_FIELD__TYPE: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); return; } super.notifyChanged(notification); }
Example #5
Source File: JavaReflectAccessTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testGetField_1() throws Exception { JvmDeclaredType type = getType(Y.class); JvmMember addMethod = Iterables.find(type.getMembers(), new Predicate<JvmMember>() { @Override public boolean apply(JvmMember input) { if (input instanceof JvmField) { return input.getSimpleName().equals("z"); } return false; } }); Field field = Y.class.getDeclaredField("z"); assertEquals(field, getJavaReflectAccess().getField((JvmField) addMethod)); }
Example #6
Source File: InferredJvmModelTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testInferredFunction_05() throws Exception { XtendFile xtendFile = file("class Foo { def Iterable<? extends CharSequence> create result: newArrayList(s) newList(String s) {} }"); JvmGenericType inferredType = getInferredType(xtendFile); XtendClass xtendClass = (XtendClass) xtendFile.getXtendTypes().get(0); EList<JvmMember> jvmMembers = inferredType.getMembers(); assertEquals(4, jvmMembers.size()); JvmMember jvmMember = jvmMembers.get(1); assertTrue(jvmMember instanceof JvmOperation); XtendFunction xtendFunction = (XtendFunction) xtendClass.getMembers().get(0); assertEquals(xtendFunction.getName(), jvmMember.getSimpleName()); assertEquals(JvmVisibility.PUBLIC, jvmMember.getVisibility()); assertEquals("java.lang.Iterable<? extends java.lang.CharSequence>", ((JvmOperation) jvmMember).getReturnType().getIdentifier()); JvmField cacheVar = (JvmField) jvmMembers.get(2); assertEquals("_createCache_" + xtendFunction.getName(), cacheVar.getSimpleName()); assertEquals(JvmVisibility.PRIVATE, cacheVar.getVisibility()); assertEquals("java.util.HashMap<java.util.ArrayList<? extends java.lang.Object>, java.lang.Iterable<? extends java.lang.CharSequence>>", cacheVar.getType().getIdentifier()); JvmOperation privateInitializer = (JvmOperation) jvmMembers.get(3); assertEquals("_init_"+xtendFunction.getName(), privateInitializer.getSimpleName()); assertEquals(JvmVisibility.PRIVATE, privateInitializer.getVisibility()); assertEquals("java.util.ArrayList<java.lang.String>", privateInitializer.getParameters().get(0).getParameterType().getIdentifier()); assertEquals("java.lang.String", privateInitializer.getParameters().get(1).getParameterType().getIdentifier()); }
Example #7
Source File: InferredJvmModelTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testInferredFunction_06() throws Exception { XtendFile xtendFile = file("class Foo { def Iterable<? super CharSequence> create result: newArrayList(s) newList(String s) {} }"); JvmGenericType inferredType = getInferredType(xtendFile); XtendClass xtendClass = (XtendClass) xtendFile.getXtendTypes().get(0); EList<JvmMember> jvmMembers = inferredType.getMembers(); assertEquals(4, jvmMembers.size()); JvmMember jvmMember = jvmMembers.get(1); assertTrue(jvmMember instanceof JvmOperation); XtendFunction xtendFunction = (XtendFunction) xtendClass.getMembers().get(0); assertEquals(xtendFunction.getName(), jvmMember.getSimpleName()); assertEquals(JvmVisibility.PUBLIC, jvmMember.getVisibility()); assertEquals("java.lang.Iterable<? extends java.lang.Object & super java.lang.CharSequence>", ((JvmOperation) jvmMember).getReturnType().getIdentifier()); JvmField cacheVar = (JvmField) jvmMembers.get(2); assertEquals("_createCache_" + xtendFunction.getName(), cacheVar.getSimpleName()); assertEquals(JvmVisibility.PRIVATE, cacheVar.getVisibility()); assertEquals("java.util.HashMap<java.util.ArrayList<? extends java.lang.Object>, java.lang.Iterable<? extends java.lang.Object & super java.lang.CharSequence>>", cacheVar.getType().getIdentifier()); JvmOperation privateInitializer = (JvmOperation) jvmMembers.get(3); assertEquals("_init_"+xtendFunction.getName(), privateInitializer.getSimpleName()); assertEquals(JvmVisibility.PRIVATE, privateInitializer.getVisibility()); assertEquals("java.util.ArrayList<java.lang.CharSequence>", privateInitializer.getParameters().get(0).getParameterType().getIdentifier()); assertEquals("java.lang.String", privateInitializer.getParameters().get(1).getParameterType().getIdentifier()); }
Example #8
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Check public void checkLocalUsageOfDeclaredFields(XtendField field){ if(doCheckValidMemberName(field) && !isIgnored(UNUSED_PRIVATE_MEMBER)) { JvmField jvmField = associations.getJvmField(field); if (jvmField == null || jvmField.getVisibility() != JvmVisibility.PRIVATE || jvmField.eContainer() == null) return; if (isLocallyUsed(jvmField, getOutermostType(field))) return; String message; if(field.isExtension()) { if(field.getName() == null && jvmField.getType() != null) message = "The extension " + jvmField.getType().getIdentifier() + " is not used in " + getDeclaratorName(jvmField); else message = "The extension " + getDeclaratorName(jvmField) + "." + jvmField.getSimpleName() + " is not used"; } else { message = "The value of the field " + getDeclaratorName(jvmField) + "." + jvmField.getSimpleName() + " is not used"; } addIssueToState(UNUSED_PRIVATE_MEMBER, message, XtendPackage.Literals.XTEND_FIELD__NAME); } }
Example #9
Source File: FeatureKinds.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public static String getTypeName(JvmIdentifiableElement feature) { if (feature instanceof JvmFormalParameter) { return "parameter"; } if (feature instanceof XVariableDeclaration) { return "local variable"; } if (feature instanceof JvmEnumerationLiteral) { return "enum literal"; } if (feature instanceof JvmField) { return "field"; } if (feature instanceof JvmOperation) { return "method"; } if (feature instanceof JvmConstructor) { return "constructor"; } if (feature instanceof JvmType) { return "type"; } throw new IllegalStateException(); }
Example #10
Source File: ReferencedInvalidTypeFinder.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected LightweightTypeReference internalFindReferencedInvalidType(final JvmIdentifiableElement operation) { if (operation instanceof JvmOperation) { return _internalFindReferencedInvalidType((JvmOperation)operation); } else if (operation instanceof JvmExecutable) { return _internalFindReferencedInvalidType((JvmExecutable)operation); } else if (operation instanceof JvmField) { return _internalFindReferencedInvalidType((JvmField)operation); } else if (operation != null) { return _internalFindReferencedInvalidType(operation); } else if (operation == null) { return _internalFindReferencedInvalidType((Void)null); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(operation).toString()); } }
Example #11
Source File: Utils.java From sarl with Apache License 2.0 | 6 votes |
/** Analyzing the type hierarchy of the given interface and * extract hierarchy information. * * @param jvmElement - the element to analyze * @param operations - filled with the operations inside and inherited by the element. * @param fields - filled with the fields inside and inherited by the element. * @param sarlSignatureProvider - provider of tools related to action signatures. * @see OverrideHelper */ public static void populateInterfaceElements( JvmDeclaredType jvmElement, Map<ActionPrototype, JvmOperation> operations, Map<String, JvmField> fields, IActionPrototypeProvider sarlSignatureProvider) { for (final JvmFeature feature : jvmElement.getAllFeatures()) { if (!"java.lang.Object".equals(feature.getDeclaringType().getQualifiedName())) { //$NON-NLS-1$ if (operations != null && feature instanceof JvmOperation) { final JvmOperation operation = (JvmOperation) feature; final ActionParameterTypes sig = sarlSignatureProvider.createParameterTypesFromJvmModel( operation.isVarArgs(), operation.getParameters()); final ActionPrototype actionKey = sarlSignatureProvider.createActionPrototype( operation.getSimpleName(), sig); operations.put(actionKey, operation); } else if (fields != null && feature instanceof JvmField) { fields.put(feature.getSimpleName(), (JvmField) feature); } } } }
Example #12
Source File: XtendGenerator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected ArrayList<JvmMember> getAddedDeclarations(final JvmGenericType it, final AnonymousClass anonymousClass) { final ArrayList<JvmMember> result = CollectionLiterals.<JvmMember>newArrayList(); final JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor(); int _size = constructor.getParameters().size(); boolean _greaterEqualsThan = (_size >= 1); if (_greaterEqualsThan) { result.add(0, constructor); } Iterable<JvmField> _declaredFields = it.getDeclaredFields(); Iterables.<JvmMember>addAll(result, _declaredFields); final Function1<JvmOperation, Boolean> _function = (JvmOperation it_1) -> { EObject _head = IterableExtensions.<EObject>head(this.getSourceElements(it_1)); final XtendFunction function = ((XtendFunction) _head); boolean _isOverride = function.isOverride(); return Boolean.valueOf((!_isOverride)); }; Iterable<JvmOperation> _filter = IterableExtensions.<JvmOperation>filter(it.getDeclaredOperations(), _function); Iterables.<JvmMember>addAll(result, _filter); Iterable<JvmDeclaredType> _filter_1 = Iterables.<JvmDeclaredType>filter(it.getMembers(), JvmDeclaredType.class); Iterables.<JvmMember>addAll(result, _filter_1); return result; }
Example #13
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * Initializes the type inference strategy for the cache field for create extensions. */ @Override protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmField field, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { JvmTypeReference knownType = field.getType(); if (InferredTypeIndicator.isInferred(knownType)) { XComputedTypeReference castedKnownType = (XComputedTypeReference) knownType; EObject sourceElement = associations.getPrimarySourceElement(field); if (sourceElement instanceof XtendFunction) { XtendFunction function = (XtendFunction) sourceElement; if (function.getCreateExtensionInfo() != null) { JvmOperation operation = associations.getDirectlyInferredOperation(function); if (operation != null) { declareTypeParameters(resolvedTypes, field, resolvedTypesByContext); XComputedTypeReference fieldType = getServices().getXtypeFactory().createXComputedTypeReference(); fieldType.setTypeProvider(new CreateCacheFieldTypeReferenceProvider(operation, resolvedTypes, featureScopeSession)); castedKnownType.setEquivalent(fieldType); return; } } } } super._doPrepare(resolvedTypes, featureScopeSession, field, resolvedTypesByContext); doPrepareLocalTypes(resolvedTypesByContext.get(field), featureScopeSession, field, resolvedTypesByContext); }
Example #14
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public ITreeAppendable generateMember(final JvmMember it, final ITreeAppendable appendable, final GeneratorConfig config) { if (it instanceof JvmConstructor) { return _generateMember((JvmConstructor)it, appendable, config); } else if (it instanceof JvmOperation) { return _generateMember((JvmOperation)it, appendable, config); } else if (it instanceof JvmField) { return _generateMember((JvmField)it, appendable, config); } else if (it instanceof JvmDeclaredType) { return _generateMember((JvmDeclaredType)it, appendable, config); } else if (it != null) { return _generateMember(it, appendable, config); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, appendable, config).toString()); } }
Example #15
Source File: CompilationUnitImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void setCompilationStrategy(final JvmField field, final CompilationStrategy compilationStrategy) { this.checkCanceled(); final Procedure1<ITreeAppendable> _function = (ITreeAppendable it) -> { final CompilationContextImpl context = new CompilationContextImpl(it, this); it.append(compilationStrategy.compile(context)); }; this.jvmTypesBuilder.setInitializer(field, _function); }
Example #16
Source File: JvmTypesBuilderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testToFieldWithKeywordCollision() { try { final XExpression e = this.expression("\'\'"); final JvmField field = this._jvmTypesBuilder.toField(e, "package", this._jvmTypeReferenceBuilder.typeRef(String.class)); Assert.assertEquals("package", field.getSimpleName()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #17
Source File: InferredJvmModelTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testNameClashWithAnonymousExtension_00() throws Exception { XtendFile xtendFile = file("package foo import com.google.inject.Inject class Foo { @Inject extension String String _string }"); JvmGenericType inferredType = getInferredType(xtendFile); JvmField extension = (JvmField) inferredType.getMembers().get(1); assertEquals("_string_1", extension.getSimpleName()); JvmField field = (JvmField) inferredType.getMembers().get(2); assertEquals("_string", field.getSimpleName()); }
Example #18
Source File: InferredJvmModelTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testNameClashWithCreateExtension_02() throws Exception { XtendFile xtendFile = file("package foo class Foo { def create new String() s(String x) { '' } def create new String() s(Object x) { '' }}"); JvmGenericType inferredType = getInferredType(xtendFile); JvmField cacheVar0 = (JvmField) inferredType.getMembers().get(2); assertEquals("_createCache_s", cacheVar0.getSimpleName()); JvmOperation initializer0 = (JvmOperation) inferredType.getMembers().get(3); assertEquals("_init_s", initializer0.getSimpleName()); JvmField cacheVar1 = (JvmField) inferredType.getMembers().get(5); assertEquals("_createCache_s_1", cacheVar1.getSimpleName()); JvmOperation initializer1 = (JvmOperation) inferredType.getMembers().get(6); assertEquals("_init_s_1", initializer1.getSimpleName()); }
Example #19
Source File: ReferencedInvalidTypeFinder.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference _internalFindReferencedInvalidType(final JvmField field) { final LightweightTypeReference type = this.toLightweightTypeReference(field.getType()); boolean _isPrimitiveVoid = type.isPrimitiveVoid(); if (_isPrimitiveVoid) { return type; } return this.findUnknownType(type); }
Example #20
Source File: XbaseContentProposalPriorities.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void adjustCrossReferencePriority(ICompletionProposal proposal, String prefix) { if (proposal instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal configurableProposal = (ConfigurableCompletionProposal) proposal; Object desc = configurableProposal.getAdditionalData(XbaseProposalProvider.DESCRIPTION_KEY); if (desc instanceof SimpleIdentifiableElementDescription) { if (!"this".equals(configurableProposal.getReplacementString()) && !"super".equals(configurableProposal.getReplacementString())) { adjustPriority(proposal, prefix, 570); return; } } else if (desc instanceof StaticFeatureDescriptionWithTypeLiteralReceiver) { adjustPriority(proposal, prefix, 560); return; } else if (desc instanceof IIdentifiableElementDescription) { JvmIdentifiableElement identifiableElement = ((IIdentifiableElementDescription) desc).getElementOrProxy(); if (identifiableElement instanceof JvmField) { adjustPriority(proposal, prefix, 550); return; } else if (identifiableElement instanceof JvmExecutable) { adjustPriority(proposal, prefix, 520); return; } } } super.adjustCrossReferencePriority(proposal, prefix); }
Example #21
Source File: JvmDeclaredTypeImplCustom.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void processMembers(Map<String, Set<JvmFeature>> result, Collection<? extends JvmMember> members) { for (JvmMember member : members) { if (member instanceof JvmOperation || member instanceof JvmField) { Set<JvmFeature> knownMembers = result.get(member.getSimpleName()); if (knownMembers == null) { // Sets.newLinkedHashSet(capacity) does not exist knownMembers = new LinkedHashSet<JvmFeature>(2); result.put(member.getSimpleName(), knownMembers); } knownMembers.add((JvmFeature) member); } } }
Example #22
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IFeatureScopeSession addExtensionFieldsToMemberSession( ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type, JvmIdentifiableElement thisFeature, Set<String> seenNames, Set<JvmType> seenTypes) { if (seenTypes.add(type)) { Iterable<JvmField> fields = type.getDeclaredFields(); // collect local fields first, to populate the set of names Map<XExpression, LightweightTypeReference> extensionProviders = null; for(JvmField field: fields) { if (featureScopeSession.isVisible(field) && seenNames.add(field.getSimpleName()) && isExtensionProvider(field)) { if (extensionProviders == null) { extensionProviders = Maps2.newLinkedHashMapWithExpectedSize(3); } XAbstractFeatureCall extensionProvider = createExtensionProvider(thisFeature, field); LightweightTypeReference fieldType = resolvedTypes.getActualType(field); extensionProviders.put(extensionProvider, fieldType); } } // traverse the type hierarchy to create the feature scope sessions JvmTypeReference superType = getExtendedClass(type); IFeatureScopeSession result = featureScopeSession; if (superType != null) { result = addExtensionFieldsToMemberSession(resolvedTypes, featureScopeSession, (JvmDeclaredType) superType.getType(), thisFeature, seenNames, seenTypes); } if (extensionProviders != null) { result = result.addToExtensionScope(extensionProviders); } return result; } return featureScopeSession; }
Example #23
Source File: MutableJvmFieldDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void internalGenericSetConstantValue(final Object value) { this.checkMutable(); Preconditions.checkArgument((value != null), "value cannot be null"); JvmField _delegate = this.getDelegate(); _delegate.setConstant(true); JvmField _delegate_1 = this.getDelegate(); _delegate_1.setFinal(true); JvmField _delegate_2 = this.getDelegate(); _delegate_2.setStatic(true); JvmField _delegate_3 = this.getDelegate(); _delegate_3.setConstantValue(value); }
Example #24
Source File: InferredJvmModelTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testNameClashWithCreateExtension_01() throws Exception { XtendFile xtendFile = file("package foo class Foo { def create new String() s(String x) { '' } String _init_s }"); JvmGenericType inferredType = getInferredType(xtendFile); JvmField cacheVar = (JvmField) inferredType.getMembers().get(2); assertEquals("_createCache_s", cacheVar.getSimpleName()); JvmOperation initializer = (JvmOperation) inferredType.getMembers().get(3); assertEquals("_init_s_1", initializer.getSimpleName()); JvmField field = (JvmField) inferredType.getMembers().get(4); assertEquals("_init_s", field.getSimpleName()); }
Example #25
Source File: XbaseDeclarativeHoverSignatureProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected String _signature(JvmField jvmField, boolean typeAtEnd) { JvmTypeReference type = jvmField.getType(); if (type != null) { String signature = jvmField.getSimpleName(); if (typeAtEnd) return signature + " : " + type.getSimpleName(); return type.getSimpleName() + " " + enrichWithDeclarator(signature, jvmField); } return ""; }
Example #26
Source File: ResolvedFeatures.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<IResolvedField> computeDeclaredFields() { JvmType rawType = getRawType(); if (!(rawType instanceof JvmGenericType)) { return Collections.emptyList(); } List<IResolvedField> result = Lists.newArrayList(); for(JvmField field: ((JvmGenericType)rawType).getDeclaredFields()) { result.add(new ResolvedField(field, getType())); } return Collections.unmodifiableList(result); }
Example #27
Source File: SarlCompiler.java From sarl with Apache License 2.0 | 5 votes |
private static void updateReferenceList(List<XAbstractFeatureCall> references, Set<String> identifiers, XAbstractFeatureCall featureCall) { final JvmIdentifiableElement feature = featureCall.getFeature(); if (feature instanceof JvmFormalParameter || feature instanceof XVariableDeclaration || feature instanceof JvmField) { if (identifiers.add(feature.getIdentifier())) { references.add(featureCall); } } else if (!references.contains(featureCall)) { references.add(featureCall); } }
Example #28
Source File: JavaElementFinder.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IJavaElement caseJvmField(JvmField object) { IJavaElement parent = getDeclaringTypeElement(object); if (parent instanceof IType) { IType type = (IType) parent; IField result = type.getField(object.getSimpleName()); if (result != null) return result; } return (isExactMatchOnly) ? null : parent; }
Example #29
Source File: SARLValidator.java From sarl with Apache License 2.0 | 5 votes |
@Override protected boolean isInitialized(JvmField input) { if (super.isInitialized(input)) { return true; } // Check initialization into a static constructor. final XtendField sarlField = (XtendField) this.associations.getPrimarySourceElement(input); if (sarlField == null) { return false; } final XtendTypeDeclaration declaringType = sarlField.getDeclaringType(); if (declaringType == null) { return false; } for (final XtendConstructor staticConstructor : Iterables.filter(Iterables.filter( declaringType.getMembers(), XtendConstructor.class), it -> it.isStatic())) { if (staticConstructor.getExpression() != null) { for (final XAssignment assign : EcoreUtil2.getAllContentsOfType(staticConstructor.getExpression(), XAssignment.class)) { if (assign.isStatic() && Strings.equal(input.getIdentifier(), assign.getFeature().getIdentifier())) { // Mark the field as initialized in order to be faster during the next initialization test. this.readAndWriteTracking.markInitialized(input, null); return true; } } } } return false; }
Example #30
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Check public void checkValidExtension(XtendField field) { if (field.isExtension()) { JvmField jvmField = associations.getJvmField(field); if (jvmField != null) { checkValidExtensionType(jvmField, field, XtendPackage.Literals.XTEND_FIELD__TYPE); } } }