org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner.
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: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Check public void checkTypeGuardsOrder(XSwitchExpression expression) { if (isIgnored(IssueCodes.UNREACHABLE_CASE)) { return; } ITypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), expression); List<LightweightTypeReference> previousTypeReferences = new ArrayList<LightweightTypeReference>(); for (XCasePart casePart : expression.getCases()) { JvmTypeReference typeGuard = casePart.getTypeGuard(); if (typeGuard == null) { continue; } LightweightTypeReference actualType = owner.toLightweightTypeReference(typeGuard); if (actualType == null) { continue; } if (isHandled(actualType, previousTypeReferences)) { addIssue("Unreachable code: The case can never match. It is already handled by a previous condition.", typeGuard, IssueCodes.UNREACHABLE_CASE); continue; } if (casePart.getCase() == null) { previousTypeReferences.add(actualType); } } }
Example #2
Source File: Bug661Test.java From sarl with Apache License 2.0 | 6 votes |
@RepeatedTest(5) public void isAssignableFrom_01() throws Exception { ParseHelper<SarlScript> helper = getParseHelper(); SarlScript mas0 = helper.parse(SNIPSET1); ResourceSet resourceSet = mas0.eResource().getResourceSet(); SarlScript mas1 = helper.parse(SNIPSET1, resourceSet); assertSame(mas0.eResource().getResourceSet(), mas1.eResource().getResourceSet()); JvmTypeReference reference0 = this.typeReferences.getTypeForName("boolean", mas0); StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, mas1); LightweightTypeReference reference1 = owner.newParameterizedTypeReference(this.typeReferences.findDeclaredType("boolean", mas1)); assertTrue(reference1.isAssignableFrom(reference0.getType())); }
Example #3
Source File: Bug661Test.java From sarl with Apache License 2.0 | 6 votes |
@RepeatedTest(5) public void isSubtypeOf_01() throws Exception { ParseHelper<SarlScript> helper = getParseHelper(); SarlScript mas0 = helper.parse(SNIPSET1); ResourceSet resourceSet = mas0.eResource().getResourceSet(); SarlScript mas1 = helper.parse(SNIPSET1, resourceSet); assertSame(mas0.eResource().getResourceSet(), mas1.eResource().getResourceSet()); JvmTypeReference reference0 = this.typeReferences.getTypeForName("boolean", mas0); StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, mas1); LightweightTypeReference reference1 = owner.newParameterizedTypeReference(this.typeReferences.findDeclaredType("boolean", mas1)); assertTrue(reference1.isSubtypeOf(reference0.getType())); }
Example #4
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 #5
Source File: CompilationUnitImpl.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public void before(final ActiveAnnotationContexts.AnnotationCallback phase) { this.lastPhase = phase; final StandardTypeReferenceOwner standardTypeReferenceOwner = new StandardTypeReferenceOwner(this.services, this.xtendFile); boolean _equals = Objects.equal(ActiveAnnotationContexts.AnnotationCallback.INDEXING, phase); if (_equals) { IndexingLightweightTypeReferenceFactory _indexingLightweightTypeReferenceFactory = new IndexingLightweightTypeReferenceFactory(standardTypeReferenceOwner); this.typeRefFactory = _indexingLightweightTypeReferenceFactory; } else { LightweightTypeReferenceFactory _lightweightTypeReferenceFactory = new LightweightTypeReferenceFactory(standardTypeReferenceOwner); this.typeRefFactory = _lightweightTypeReferenceFactory; } boolean _equals_1 = Objects.equal(ActiveAnnotationContexts.AnnotationCallback.VALIDATION, phase); if (_equals_1) { this.problemSupport.validationPhaseStarted(); } }
Example #6
Source File: DispatchHelper.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * Computes all the dispatch methods that are declared in the given type or altered * by additional cases in this type. The associated operations are sorted by according their parameter types * from left to right where the most special types occur before more common types. Ambiguous * ordering is resolved alphabetically. * * An exemplary order would look like this * <pre> * method(String) * method(Serializable) * method(CharSequence) * method(Object) * </pre> * * @return a mapping from {@link DispatchSignature signature} to sorted operations. */ public ListMultimap<DispatchSignature, JvmOperation> getDeclaredOrEnhancedDispatchMethods(JvmDeclaredType type) { ListMultimap<DispatchSignature, JvmOperation> result = Multimaps2.newLinkedHashListMultimap(2,4); Iterable<JvmOperation> operations = type.getDeclaredOperations(); ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type); ContextualVisibilityHelper contextualVisibilityHelper = new ContextualVisibilityHelper(visibilityHelper, owner.newParameterizedTypeReference(type)); for(JvmOperation operation: operations) { if (isDispatchFunction(operation)) { DispatchSignature signature = new DispatchSignature(operation.getSimpleName().substring(1), operation.getParameters().size()); if (!result.containsKey(signature)) { List<JvmOperation> allOperations = getAllDispatchMethods(signature, type, contextualVisibilityHelper); result.putAll(signature, allOperations); } } } return result; }
Example #7
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
private void checkExceptions(EObject context, List<JvmTypeReference> exceptions, EReference reference) { Set<String> declaredExceptionNames = Sets.newHashSet(); JvmTypeReference throwableType = getServices().getTypeReferences().getTypeForName(Throwable.class, context); if (throwableType == null) { return; } ITypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), context); LightweightTypeReference throwableReference = owner.toLightweightTypeReference(throwableType); for(int i = 0; i < exceptions.size(); i++) { JvmTypeReference exception = exceptions.get(i); // throwables may not carry generics thus the raw comparison is sufficient if (exception.getType() != null && !exception.getType().eIsProxy()) { if(!throwableReference.isAssignableFrom(exception.getType())) error("No exception of type " + exception.getSimpleName() + " can be thrown; an exception type must be a subclass of Throwable", reference, i, EXCEPTION_NOT_THROWABLE); if(!declaredExceptionNames.add(exception.getQualifiedName())) error("Exception " + exception.getSimpleName() + " is declared twice", reference, i, EXCEPTION_DECLARED_TWICE); } } }
Example #8
Source File: AbstractOverloadedStaticMethodTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void linksTo(final String invocation, final String method) { try { final XtendFile file = this.file(this.inMethodBody(invocation), false); XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()); final XtendClass c = ((XtendClass) _head); XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers()); final XtendFunction m = ((XtendFunction) _head_1); XExpression _expression = m.getExpression(); final XBlockExpression body = ((XBlockExpression) _expression); XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions()); final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last); JvmIdentifiableElement _feature = featureCall.getFeature(); final JvmOperation operation = ((JvmOperation) _feature); final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file); final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType()); final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester); Assert.assertEquals(method, resolved.getSimpleSignature()); Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty()); Assert.assertNull(featureCall.getImplicitReceiver()); Assert.assertNull(featureCall.getImplicitFirstArgument()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #9
Source File: AbstractOverloadedInstanceMethodTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void linksTo(final String invocation, final String method) { try { final XtendFile file = this.file(this.inMethodBody(invocation), false); XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()); final XtendClass c = ((XtendClass) _head); XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers()); final XtendFunction m = ((XtendFunction) _head_1); XExpression _expression = m.getExpression(); final XBlockExpression body = ((XBlockExpression) _expression); XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions()); final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last); JvmIdentifiableElement _feature = featureCall.getFeature(); final JvmOperation operation = ((JvmOperation) _feature); final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file); final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType()); final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester); Assert.assertEquals(method, resolved.getSimpleSignature()); Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty()); Assert.assertNotNull(featureCall.getImplicitReceiver()); Assert.assertNull(featureCall.getImplicitFirstArgument()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #10
Source File: CreateMemberQuickfixes.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected List<LightweightTypeReference> getResolvedArgumentTypes(EObject context, JvmIdentifiableElement logicalContainer, List<XExpression> arguments) { List<LightweightTypeReference> argumentTypes = newArrayList(); IResolvedTypes resolvedTypes = typeResolver.resolveTypes(context); for(XExpression argument: arguments) { LightweightTypeReference resolved = resolvedTypes.getActualType(argument); if(resolved == null) { StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context); argumentTypes.add(owner.newReferenceToObject()); } else { LocalTypeSubstitutor substitutor = new LocalTypeSubstitutor(resolved.getOwner(), logicalContainer); argumentTypes.add(substitutor.withoutLocalTypes(resolved)); } } return argumentTypes; }
Example #11
Source File: CreateMemberQuickfixes.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected LightweightTypeReference getReceiverType(XAbstractFeatureCall featureCall) { XExpression actualReceiver = featureCall.getActualReceiver(); ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, featureCall); if (actualReceiver == null) { JvmDeclaredType callersType = getCallersType(featureCall); if (callersType != null) return owner.newParameterizedTypeReference(callersType); } else if (actualReceiver instanceof XAbstractFeatureCall && ((XAbstractFeatureCall) actualReceiver).isTypeLiteral()) { JvmType type = (JvmType) ((XAbstractFeatureCall) actualReceiver).getFeature(); ParameterizedTypeReference reference = owner.newParameterizedTypeReference(type); return reference; } else { LightweightTypeReference typeRef = typeResolver.resolveTypes(featureCall).getActualType(actualReceiver); if(typeRef != null && typeRef.getType() instanceof JvmDeclaredType) return typeRef; } return null; }
Example #12
Source File: ReplacingAppendableTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected XtextDocument insertListField(final String model, final String fieldName) throws Exception { final int cursorPosition = model.indexOf('|'); String actualModel = model.replace("|", " "); final XtendFile file = testHelper.xtendFile("Foo", actualModel); final XtextDocument document = documentProvider.get(); document.set(actualModel); XtextResource xtextResource = (XtextResource) file.eResource(); document.setInput(xtextResource); final EObject context = eObjectAtOffsetHelper.resolveElementAt(xtextResource, cursorPosition); document.modify(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource state) throws Exception { ReplacingAppendable a = appendableFactory.create(document, state, cursorPosition, 1); ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context); LightweightTypeReference typeRef = owner.toLightweightTypeReference(services.getTypeReferences().getTypeForName(List.class, context, typesFactory.createJvmWildcardTypeReference())); a.append(typeRef); a.append(" ").append(fieldName); a.commitChanges(); } }); return document; }
Example #13
Source File: XbaseLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected StyledString signature(String simpleName, JvmIdentifiableElement element) { JvmTypeReference returnType = null; if (element instanceof JvmOperation) { returnType = ((JvmOperation) element).getReturnType(); } else if (element instanceof JvmField) { returnType = ((JvmField) element).getType(); } StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, element); final String returnTypeString; if (returnType == null) { returnTypeString = "void"; } else { returnTypeString = owner.toLightweightTypeReference(returnType).getHumanReadableName(); } String decoratedPart = " : " + returnTypeString; String typeParam = uiStrings.typeParameters(element) != null ? uiStrings.typeParameters(element) : ""; if (!typeParam.isEmpty()) { decoratedPart = " " + typeParam + " : " + returnTypeString; } return new StyledString(simpleName + uiStrings.parameters(element)) .append(new StyledString(decoratedPart, StyledString.DECORATIONS_STYLER)); }
Example #14
Source File: ConstantInlineExpansionTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected String compileToJavaCode(String xtendCode) { XExpression model = null; ITreeAppendable appendable = new FakeTreeAppendable(); try { model = expression(xtendCode, true); XbaseCompiler compiler = this.compilerProvider.get(); LightweightTypeReference objectRef = new StandardTypeReferenceOwner(this.services, model).newReferenceToObject(); compiler.compile(model, appendable, objectRef); } catch (Exception e) { throw new RuntimeException("Xtend compilation failed", e); } finally { if (model != null) this.cache.clear(model.eResource()); } return appendable.getContent(); }
Example #15
Source File: EvaluationCompilerTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected String compileToJavaCode(String xtendCode) { XExpression model = null; ITreeAppendable appendable = new FakeTreeAppendable(); try { model = expression(xtendCode, true); XbaseCompiler compiler = compilerProvider.get(); LightweightTypeReference objectRef = new StandardTypeReferenceOwner(services, model).newReferenceToObject(); compiler.compile(model, appendable, objectRef); } catch (Exception e) { throw new RuntimeException("Xtend compilation failed", e); } finally { if (model != null) cache.clear(model.eResource()); } return appendable.getContent(); }
Example #16
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.16 */ protected void appendCompilationTemplate(final ITreeAppendable appendable, final JvmIdentifiableElement it) { boolean _matched = false; if (appendable instanceof TreeAppendable) { _matched=true; SharedAppendableState _state = ((TreeAppendable)appendable).getState(); StandardTypeReferenceOwner _standardTypeReferenceOwner = new StandardTypeReferenceOwner(this.commonServices, it); final ImportingStringConcatenation target = this.createImportingStringConcatenation(_state, _standardTypeReferenceOwner); target.append(this._jvmTypeExtensions.getCompilationTemplate(it)); ((TreeAppendable)appendable).append(target); } if (!_matched) { String _name = appendable.getClass().getName(); String _plus = ("unexpected appendable: " + _name); throw new IllegalStateException(_plus); } }
Example #17
Source File: UIStrings.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.4 */ public String referenceToString(JvmTypeReference typeRef, String defaultLabel) { if (typeRef == null) return defaultLabel; if (typeRef.eResource() == null) { if (typeRef instanceof JvmAnyTypeReference) { return "Object"; } return typeRef.getSimpleName(); } StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, typeRef); LightweightTypeReference reference = owner.toLightweightTypeReference(typeRef); return referenceToString(reference); }
Example #18
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Check public void checkTypeGuardsOrderWithGenerics(XSwitchExpression expression) { if (isIgnored(IssueCodes.UNREACHABLE_CASE)) { return; } ITypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), expression); List<LightweightTypeReference> previousTypeReferences = new ArrayList<LightweightTypeReference>(); for (XCasePart casePart : expression.getCases()) { JvmTypeReference typeGuard = casePart.getTypeGuard(); if (typeGuard == null) { continue; } LightweightTypeReference typeReference = owner.toLightweightTypeReference(typeGuard); LightweightTypeReference actualType = typeReference.getRawTypeReference(); if (actualType == null || typeReference == actualType) { continue; } if (isHandled(actualType, previousTypeReferences)) { addIssue("Unreachable code: The case can never match. It is already handled by a previous condition (with the same type erasure).", typeGuard, IssueCodes.UNREACHABLE_CASE); continue; } if (casePart.getCase() == null) { previousTypeReferences.add(actualType); } } }
Example #19
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Check public void checkCatchClausesOrder(XTryCatchFinallyExpression expression) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), expression); List<LightweightTypeReference> previousTypeReferences = new ArrayList<LightweightTypeReference>(); for (XCatchClause catchClause : expression.getCatchClauses()) { LightweightTypeReference actualTypeReference = owner.toLightweightTypeReference(catchClause.getDeclaredParam().getParameterType()); if (actualTypeReference == null) { continue; } if (isHandled(actualTypeReference, previousTypeReferences)) { error("Unreachable code: The catch block can never match. It is already handled by a previous condition.", catchClause.getDeclaredParam().getParameterType(), null, IssueCodes.UNREACHABLE_CATCH_BLOCK); continue; } previousTypeReferences.add(actualTypeReference); } }
Example #20
Source File: AbstractBuilderTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference createTypeRef(final JvmType type) { ParameterizedTypeReference _xblockexpression = null; { final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, type); _xblockexpression = owner.newParameterizedTypeReference(type); } return _xblockexpression; }
Example #21
Source File: AbstractBatchTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public IResolvedTypes resolveTypes(/* @NonNull */ Resource resource, /* @Nullable */ CancelIndicator monitor) { validateResourceState(resource); List<EObject> resourceContents = resource.getContents(); if (resourceContents.isEmpty()) { IFeatureScopeSession session = scopeProvider.newSession(resource); return new EmptyResolvedTypes(session, featureScopes, new StandardTypeReferenceOwner(services, resource)); } else { return resolveTypes(resourceContents.get(0), monitor); } }
Example #22
Source File: DispatchHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * Return all the cases that are associated with the given dispatch operation. */ public List<JvmOperation> getAllDispatchCases(JvmOperation dispatcherOperation) { DispatchSignature dispatchSignature = new DispatchSignature(dispatcherOperation.getSimpleName(), dispatcherOperation.getParameters().size()); JvmDeclaredType type = dispatcherOperation.getDeclaringType(); ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type); ContextualVisibilityHelper contextualVisibilityHelper = new ContextualVisibilityHelper(visibilityHelper, owner.newParameterizedTypeReference(type)); return getAllDispatchMethods(dispatchSignature, type, contextualVisibilityHelper); }
Example #23
Source File: CompilationUnitImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void setXtendFile(final XtendFile xtendFile) { this.xtendFile = xtendFile; StandardTypeReferenceOwner _standardTypeReferenceOwner = new StandardTypeReferenceOwner(this.services, xtendFile); LightweightTypeReferenceFactory _lightweightTypeReferenceFactory = new LightweightTypeReferenceFactory(_standardTypeReferenceOwner); this.typeRefFactory = _lightweightTypeReferenceFactory; this.fileSystemSupport.setContext(xtendFile.eResource().getResourceSet()); this.fileLocations.setContext(xtendFile.eResource()); }
Example #24
Source File: OverrideHelper.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public JvmOperation findOverriddenOperation(JvmOperation operation) { if (operation.getVisibility() == JvmVisibility.PRIVATE) { return null; } ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, operation.eResource().getResourceSet()); LightweightTypeReference declaringType = owner.toLightweightTypeReference(operation.getDeclaringType()); TypeParameterSubstitutor<?> substitutor = createSubstitutor(owner, declaringType); return findOverriddenOperation(operation, declaringType, substitutor, owner, new ContextualVisibilityHelper(visibilityHelper, declaringType)); }
Example #25
Source File: SarlMethodBuilder.java From sarl with Apache License 2.0 | 5 votes |
@Override protected ISourceAppender appendTypeParameters(ISourceAppender appendable, List<JvmTypeParameter> typeParameters) { final Iterator<JvmTypeParameter> iterator = typeParameters.iterator(); if (iterator.hasNext()) { appendable.append(" ").append(this.keywords.getWithKeyword()).append(" "); //$NON-NLS-1$//$NON-NLS-2$ final String objectId = Object.class.getName(); do { final JvmTypeParameter typeParameter = iterator.next(); appendable.append(this.keywords.protectKeyword(typeParameter.getName())); final Iterable<JvmUpperBound> upperBounds = Iterables.filter(Iterables.filter(typeParameter.getConstraints(), JvmUpperBound.class), it -> !it.getTypeReference().getIdentifier().equals(objectId)); final Iterator<JvmUpperBound> iterator2 = upperBounds.iterator(); if (iterator2.hasNext()) { appendable.append(" ").append(this.keywords.getExtendsKeyword()).append(" "); //$NON-NLS-1$ //$NON-NLS-2$ boolean isFirst = true; final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, getContext()); for (final JvmUpperBound upperBound: upperBounds) { if (!isFirst) { appendable.append(" ").append(this.keywords.getAmpersandKeyword()).append(" "); //$NON-NLS-1$ //$NON-NLS-2$ } isFirst = false; appendType(appendable, owner.toLightweightTypeReference(upperBound.getTypeReference()), Object.class.getSimpleName()); } } if (iterator.hasNext()) { appendable.append(this.keywords.getCommaKeyword()).append(" "); //$NON-NLS-1$ } } while (iterator.hasNext()); } return appendable; }
Example #26
Source File: ExtractMethodRefactoring.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference calculateReturnType(IResolvedTypes resolvedTypes) { List<LightweightTypeReference> returnTypes = newArrayList(); for(XExpression expression: expressions) { LightweightTypeReference expressionReturnType = resolvedTypes.getReturnType(expression, expression != lastExpression); if(expressionReturnType != null) returnTypes.add(expressionReturnType); } StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(typeComputationServices, xtendClass); return typeComputationServices.getTypeConformanceComputer().getCommonSuperType(returnTypes, owner); }
Example #27
Source File: XtendHoverSignatureProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected String getTypeName(JvmTypeReference typeReference) { JvmType type = typeReference.getType(); if (type instanceof JvmDeclaredType) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type); return owner.toLightweightTypeReference(typeReference).getHumanReadableName(); } return typeReference.getSimpleName(); }
Example #28
Source File: SARLHoverSignatureProvider.java From sarl with Apache License 2.0 | 5 votes |
/** Replies the type name for the given type. * * @param type the type. * @return the string representation of the given type. */ protected String getTypeName(JvmType type) { if (type != null) { if (type instanceof JvmDeclaredType) { final ITypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, type); return owner.toLightweightTypeReference(type).getHumanReadableName(); } return type.getSimpleName(); } return Messages.SARLHoverSignatureProvider_1; }
Example #29
Source File: AbstractBuilderTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference createTypeRef(final Class<?> clazz, final EObject context) { LightweightTypeReference _xblockexpression = null; { final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, context); _xblockexpression = owner.newReferenceTo(clazz); } return _xblockexpression; }
Example #30
Source File: AbstractBuilder.java From sarl with Apache License 2.0 | 5 votes |
/** Replies if the first parameter is a subtype of the second parameter. * * @param context the context. * @param subType the subtype to test. * @param superType the expected super type. * @return the type reference. */ @Pure protected boolean isSubTypeOf(EObject context, JvmTypeReference subType, JvmTypeReference superType) { if (isTypeReference(superType) && isTypeReference(subType)) { StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context); LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, false); LightweightTypeReference reference = factory.toLightweightReference(subType); return reference.isSubtypeOf(superType.getType()); } return false; }