org.eclipse.xtext.xbase.typesystem.override.IResolvedOperation Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.typesystem.override.IResolvedOperation.
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: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testListToArrayHasTwoOrThreeCandidates() { final IResolvedOperation operation = this.toOperation("(null as java.util.List<String>).toArray(null)"); final List<JvmOperation> candidates = operation.getOverriddenAndImplementedMethodCandidates(); final Function1<JvmOperation, String> _function = (JvmOperation it) -> { return it.getIdentifier(); }; final String message = IterableExtensions.join(ListExtensions.<JvmOperation, String>map(candidates, _function), ", "); try { Assert.assertEquals(message, 2, candidates.size()); } catch (final Throwable _t) { if (_t instanceof AssertionError) { Assert.assertEquals(message, 3, candidates.size()); } else { throw Exceptions.sneakyThrow(_t); } } }
Example #2
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void doCheckFunctionOverrides(IResolvedOperation operation, Set<EObject> flaggedOperations) { EObject sourceElement = findPrimarySourceElement(operation); if (sourceElement != null) { List<IResolvedOperation> allInherited = operation.getOverriddenAndImplementedMethods(); if (allInherited.isEmpty()) { if (sourceElement instanceof XtendFunction && flaggedOperations.add(sourceElement)) { XtendFunction function = (XtendFunction) sourceElement; if (function.isOverride()) { error("The method "+ operation.getSimpleSignature() +" of type "+getDeclaratorName(operation.getDeclaration())+" must override a superclass method.", function, XTEND_MEMBER__MODIFIERS, function.getModifiers().indexOf("override"), OBSOLETE_OVERRIDE); } else { for (XAnnotation anno : function.getAnnotations()) { if (anno != null && anno.getAnnotationType() != null && Override.class.getName().equals(anno.getAnnotationType().getIdentifier())) { error("Superfluous @Override annotation", anno, null, OBSOLETE_ANNOTATION_OVERRIDE); } } } } } else if (flaggedOperations.add(sourceElement)) { doCheckFunctionOverrides(sourceElement, operation, allInherited); } } }
Example #3
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * Determine whether the given type contributes to the conflict caused by the given default interface implementation. */ private boolean contributesToConflict(JvmGenericType rootType, ConflictingDefaultOperation conflictingDefaultOperation) { Set<JvmDeclaredType> involvedInterfaces = Sets.newHashSet(); involvedInterfaces.add(conflictingDefaultOperation.getDeclaration().getDeclaringType()); for (IResolvedOperation conflictingOperation : conflictingDefaultOperation.getConflictingOperations()) { involvedInterfaces.add(conflictingOperation.getDeclaration().getDeclaringType()); } RecursionGuard<JvmDeclaredType> recursionGuard = new RecursionGuard<JvmDeclaredType>(); if (rootType.isInterface()) { int contributingCount = 0; for (JvmTypeReference typeRef : rootType.getExtendedInterfaces()) { JvmType rawType = typeRef.getType(); if (rawType instanceof JvmDeclaredType && contributesToConflict((JvmDeclaredType) rawType, involvedInterfaces, recursionGuard)) { contributingCount++; } } return contributingCount >= 2; } else { return contributesToConflict(rootType, involvedInterfaces, recursionGuard); } }
Example #4
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public IResolvedOperation toOperation(final String expression) { try { XExpression _expression = this.expression(expression); final XMemberFeatureCall featureCall = ((XMemberFeatureCall) _expression); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(featureCall); final LightweightTypeReference receiverType = resolvedTypes.getActualType(featureCall.getMemberCallTarget()); JvmIdentifiableElement _feature = featureCall.getFeature(); final JvmOperation operation = ((JvmOperation) _feature); Assert.assertFalse(operation.eIsProxy()); return new BottomResolvedOperation(operation, receiverType, this.overrideTester); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #5
Source File: JvmMethodDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<? extends MethodDeclaration> getOverriddenOrImplementedMethods() { final ResolvedFeatures resolvedFeatures = this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate().getDeclaringType()); final IResolvedOperation resolvedOperation = resolvedFeatures.getResolvedOperation(this.getDelegate()); final List<IResolvedOperation> overriddenOrImplemented = resolvedOperation.getOverriddenAndImplementedMethods(); final Function1<IResolvedOperation, MemberDeclaration> _function = (IResolvedOperation it) -> { return this.getCompilationUnit().toMemberDeclaration(it.getDeclaration()); }; return Iterables.<MethodDeclaration>filter(ListExtensions.<IResolvedOperation, MemberDeclaration>map(overriddenOrImplemented, _function), MethodDeclaration.class); }
Example #6
Source File: TypeReferenceImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<? extends ResolvedMethod> getDeclaredResolvedMethods() { final Function1<IResolvedOperation, ResolvedMethod> _function = (IResolvedOperation it) -> { return this.getCompilationUnit().toResolvedMethod(it); }; return ListExtensions.<IResolvedOperation, ResolvedMethod>map(this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate()).getDeclaredOperations(), _function); }
Example #7
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverrideMethodResolution_15() { IResolvedOperation _operation = this.toOperation("(null as overrides.ConcreteForCharSequence).method"); final Procedure1<IResolvedOperation> _function = (IResolvedOperation it) -> { final JvmOperation candidate = IterableExtensions.<JvmOperation>head(it.getOverriddenAndImplementedMethodCandidates()); Assert.assertEquals(2, candidate.getTypeParameters().size()); Assert.assertEquals(2, it.getDeclaration().getTypeParameters().size()); this.withDetails(this.candidatesAndOverrides(this.has(it, 1), 1), IOverrideCheckResult.OverrideCheckDetails.IMPLEMENTATION); }; ObjectExtensions.<IResolvedOperation>operator_doubleArrow(_operation, _function); }
Example #8
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverrideMethodResolution_14() { IResolvedOperation _operation = this.toOperation("(null as testdata.MethodOverrides4).m10()"); final Procedure1<IResolvedOperation> _function = (IResolvedOperation it) -> { final JvmOperation candidate = IterableExtensions.<JvmOperation>head(it.getOverriddenAndImplementedMethodCandidates()); Assert.assertEquals(1, candidate.getTypeParameters().size()); Assert.assertEquals(1, it.getDeclaration().getTypeParameters().size()); it.getDeclaration().getTypeParameters().clear(); this.withDetail(this.candidatesAndOverrides(this.has(it, 1), 0), IOverrideCheckResult.OverrideCheckDetails.TYPE_PARAMETER_MISMATCH); }; ObjectExtensions.<IResolvedOperation>operator_doubleArrow(_operation, _function); }
Example #9
Source File: TypeReferenceImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<? extends ResolvedMethod> getAllResolvedMethods() { final Function1<IResolvedOperation, ResolvedMethod> _function = (IResolvedOperation it) -> { return this.getCompilationUnit().toResolvedMethod(it); }; return ListExtensions.<IResolvedOperation, ResolvedMethod>map(this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate()).getAllOperations(), _function); }
Example #10
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void withDetail(final IResolvedOperation operation, final IOverrideCheckResult.OverrideCheckDetails detail) { final Consumer<JvmOperation> _function = (JvmOperation it) -> { final IOverrideCheckResult checkResult = operation.isOverridingOrImplementing(it); final EnumSet<IOverrideCheckResult.OverrideCheckDetails> actual = checkResult.getDetails(); StringConcatenation _builder = new StringConcatenation(); _builder.append("Failed: "); _builder.append(actual); _builder.append(".contains("); _builder.append(detail); _builder.append(")"); Assert.assertTrue(_builder.toString(), actual.contains(detail)); }; operation.getOverriddenAndImplementedMethodCandidates().forEach(_function); }
Example #11
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testListToArrayInheritsOne() { final IResolvedOperation operation = this.toOperation("(null as java.util.List<String>).toArray(null)"); final List<IResolvedOperation> overridden = operation.getOverriddenAndImplementedMethods(); Assert.assertEquals(1, overridden.size()); final JvmTypeParameter typeParameter = IterableExtensions.<JvmTypeParameter>head(IterableExtensions.<IResolvedOperation>head(overridden).getResolvedTypeParameters()); Assert.assertEquals(operation.getDeclaration(), typeParameter.getDeclarator()); }
Example #12
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testVarArgsMismatch_01() { final IResolvedOperation operation = this.toOperation("(null as testdata.MethodOverrides4).withVarArgs(null)"); JvmOperation _declaration = operation.getDeclaration(); _declaration.setVisibility(JvmVisibility.PROTECTED); final Consumer<JvmOperation> _function = (JvmOperation it) -> { it.setVisibility(JvmVisibility.PUBLIC); }; operation.getOverriddenAndImplementedMethodCandidates().forEach(_function); this.withDetails(this.candidatesAndOverrides(this.has(operation, 1), 1), IOverrideCheckResult.OverrideCheckDetails.REDUCED_VISIBILITY, IOverrideCheckResult.OverrideCheckDetails.VAR_ARG_MISMATCH); }
Example #13
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testArrayListIteratorIsBottom() { final IResolvedOperation operation = this.toOperation("newArrayList.iterator"); Assert.assertTrue(operation.isBottomInContext()); Assert.assertEquals("ArrayList<Object>", operation.getContextType().getSimpleName()); Assert.assertEquals("iterator", operation.getDeclaration().getSimpleName()); }
Example #14
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testTypeParameterConstraints() { final IResolvedOperation operation = this.toOperation("(null as overrides.AbstractForCharSequence).method"); Assert.assertTrue(operation.isBottomInContext()); Assert.assertEquals("AbstractForCharSequence", operation.getContextType().getSimpleName()); Assert.assertEquals("method", operation.getDeclaration().getSimpleName()); final List<JvmTypeParameter> typeParameters = operation.getResolvedTypeParameters(); Assert.assertEquals(2, typeParameters.size()); final List<LightweightTypeReference> firstConstraints = operation.getResolvedTypeParameterConstraints(0); Assert.assertEquals(1, firstConstraints.size()); Assert.assertEquals("CharSequence", IterableExtensions.<LightweightTypeReference>head(firstConstraints).getSimpleName()); final List<LightweightTypeReference> secondConstraints = operation.getResolvedTypeParameterConstraints(1); Assert.assertEquals(1, secondConstraints.size()); Assert.assertEquals("V", IterableExtensions.<LightweightTypeReference>head(secondConstraints).getSimpleName()); }
Example #15
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testHashSetInheritsIterator() { final IResolvedOperation operation = this.toOperation("newHashSet(\"\").iterator"); final List<JvmOperation> candidates = operation.getOverriddenAndImplementedMethodCandidates(); Assert.assertEquals(2, candidates.size()); Assert.assertEquals("AbstractCollection", IterableExtensions.<JvmOperation>head(candidates).getDeclaringType().getSimpleName()); Assert.assertEquals("Set", IterableExtensions.<JvmOperation>last(candidates).getDeclaringType().getSimpleName()); }
Example #16
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testInheritedAbstractCollectionIteratorIsNotBottom() { final IResolvedOperation operation = this.toOperation("newHashSet(\"\").iterator"); final List<IResolvedOperation> candidates = operation.getOverriddenAndImplementedMethods(); Assert.assertFalse(IterableExtensions.<IResolvedOperation>head(candidates).isBottomInContext()); Assert.assertEquals("AbstractCollection<String>", IterableExtensions.<IResolvedOperation>head(candidates).getAsBottom().getContextType().getSimpleName()); }
Example #17
Source File: ResolvedFeaturesTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testIterableIterator() { final ResolvedFeatures resolvedOperations = this.toResolvedOperations(Iterable.class); final List<IResolvedOperation> all = resolvedOperations.getAllOperations(); Assert.assertFalse(all.isEmpty()); final Function1<IResolvedOperation, Boolean> _function = (IResolvedOperation it) -> { return Boolean.valueOf(it.getDeclaration().isAbstract()); }; final IResolvedOperation iterator = Iterables.<IResolvedOperation>getOnlyElement(IterableExtensions.<IResolvedOperation>filter(all, _function)); Assert.assertEquals("java.lang.Iterable.iterator()", iterator.getDeclaration().getIdentifier()); }
Example #18
Source File: ResolvedFeaturesTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testAllOperationsIncludeDeclaredOperations() { final ResolvedFeatures resolvedOperations = this.toResolvedOperations(ResolvedFeaturesTest.DerivedClass.class); final List<IResolvedOperation> declared = resolvedOperations.getDeclaredOperations(); final List<IResolvedOperation> all = resolvedOperations.getAllOperations(); Assert.assertFalse(all.isEmpty()); Assert.assertEquals(1, declared.size()); Assert.assertSame(IterableExtensions.<IResolvedOperation>head(declared), IterableExtensions.<IResolvedOperation>head(all)); }
Example #19
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testVarArgsMismatch_02() { final IResolvedOperation operation = this.toOperation("(null as testdata.MethodOverrides4).withArray(null)"); JvmOperation _declaration = operation.getDeclaration(); _declaration.setVisibility(JvmVisibility.PROTECTED); final Consumer<JvmOperation> _function = (JvmOperation it) -> { it.setVisibility(JvmVisibility.DEFAULT); }; operation.getOverriddenAndImplementedMethodCandidates().forEach(_function); this.withDetails(this.candidatesAndOverrides(this.has(operation, 1), 1), IOverrideCheckResult.OverrideCheckDetails.VAR_ARG_MISMATCH); }
Example #20
Source File: EntitiesJvmModelHelper.java From xtext-web with Eclipse Public License 2.0 | 5 votes |
/** * Detects duplicated {@link JvmOperation}s in the passed {@link JvmDeclaredType} taking into consideration overloading and type * erasure; each collection of duplicates is passed to the consumer. */ public void handleDuplicateJvmOperations(JvmDeclaredType jvmDeclaredType, Consumer<Collection<JvmOperation>> consumer) { // takes into consideration overloading and type erasure List<IResolvedOperation> methods = overrideHelper.getResolvedFeatures(jvmDeclaredType).getDeclaredOperations(); Multimap<String, JvmOperation> signature2Declarations = HashMultimap.create(); methods.forEach(method -> signature2Declarations.put(method.getResolvedErasureSignature(), method.getDeclaration())); signature2Declarations.asMap().values().forEach(jvmOperations -> { if (jvmOperations.size() > 1) { consumer.accept(jvmOperations); } }); }
Example #21
Source File: DomainmodelJvmModelHelper.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Detects duplicated {@link JvmOperation}s in the passed {@link JvmDeclaredType} taking into consideration overloading and type * erasure; each collection of duplicates is passed to the consumer. */ public void handleDuplicateJvmOperations(JvmDeclaredType jvmDeclaredType, Consumer<Collection<JvmOperation>> consumer) { // takes into consideration overloading and type erasure List<IResolvedOperation> methods = overrideHelper.getResolvedFeatures(jvmDeclaredType).getDeclaredOperations(); Multimap<String, JvmOperation> signature2Declarations = HashMultimap.create(); methods.forEach(method -> signature2Declarations.put(method.getResolvedErasureSignature(), method.getDeclaration())); signature2Declarations.asMap().values().forEach(jvmOperations -> { if (jvmOperations.size() > 1) { consumer.accept(jvmOperations); } }); }
Example #22
Source File: XbaseLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @return the {@code ImageDescriptor} for a given {@code obj} * @throws NullPointerException * if the passed {@code obj} is null */ protected ImageDescriptor imageDescriptor(Object obj) { Preconditions.checkNotNull(obj); if (obj instanceof JvmConstructor) { return _imageDescriptor((JvmConstructor) obj); } else if (obj instanceof JvmOperation) { return _imageDescriptor((JvmOperation) obj); } else if (obj instanceof JvmAnnotationType) { return _imageDescriptor((JvmAnnotationType) obj); } else if (obj instanceof JvmEnumerationType) { return _imageDescriptor((JvmEnumerationType) obj); } else if (obj instanceof JvmField) { return _imageDescriptor((JvmField) obj); } else if (obj instanceof JvmGenericType) { return _imageDescriptor((JvmGenericType) obj); } else if (obj instanceof JvmTypeParameter) { return _imageDescriptor((JvmTypeParameter) obj); } else if (obj instanceof JvmFormalParameter) { return _imageDescriptor((JvmFormalParameter) obj); } else if (obj instanceof XVariableDeclaration) { return _imageDescriptor((XVariableDeclaration) obj); } else if (obj instanceof IResolvedConstructor) { return _imageDescriptor((IResolvedConstructor) obj); } else if (obj instanceof IResolvedOperation) { return _imageDescriptor((IResolvedOperation) obj); } else if (obj instanceof XImportDeclaration) { return _imageDescriptor((XImportDeclaration) obj); } else if (obj instanceof XImportSection) { return _imageDescriptor((XImportSection) obj); } else if (obj instanceof IResolvedField) { return _imageDescriptor((IResolvedField) obj); } return _imageDescriptor(obj); }
Example #23
Source File: XbaseLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected Object text(IResolvedOperation element) { String returnTypeString = element.getResolvedReturnType().getSimpleName(); String decoratedPart = " : " + returnTypeString; if (!element.getTypeParameters().isEmpty()) { decoratedPart = " <" + uiStrings.toString(element.getTypeParameters()) + "> : " + returnTypeString; } String styledString = element.getDeclaration().getSimpleName() // + element.getResolvedParameterTypes().stream().map(type -> type.getHumanReadableName()) .collect(Collectors.joining(", ", "(", ")")); return new StyledString(styledString).append(new StyledString(decoratedPart, StyledString.DECORATIONS_STYLER)); }
Example #24
Source File: XbaseCopyQualifiedNameService.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected IResolvedExecutable _resolveExecutable(JvmOperation operation, XAbstractFeatureCall featureCall, IResolvedTypes resolvedTypes) { XExpression actualReceiver = featureCall.getActualReceiver(); if (actualReceiver != null) { LightweightTypeReference actualType = resolvedTypes.getActualType(actualReceiver); ResolvedFeatures resolvedFeatures = overrideHelper.getResolvedFeatures(actualType); for (IResolvedOperation resolvedOperation : resolvedFeatures.getAllOperations()) { if (resolvedOperation.getDeclaration().equals(operation)) { return resolvedOperation; } } } return null; }
Example #25
Source File: SuperMemberImplementorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void checkOverrideMethodCode(String operationName, String overrideCode) { StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable(); LightweightTypeReference contextType = getContextType(); IResolvedOperation resolvedOperation = new BottomResolvedOperation((JvmOperation) findExecutable(implementedInterface, operationName), contextType, new OverrideTester()); implementor.appendOverrideFunction(xtendClass, resolvedOperation, appendable); String code = appendable.toString(); if (!equalsIgnoreWhitespace(overrideCode, code)) assertEquals(overrideCode, code); }
Example #26
Source File: ImplementMemberFromSuperAssist.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected StyledString getLabel(IResolvedExecutable executable) { if (executable instanceof IResolvedOperation) { IResolvedOperation resolvedOperation = (IResolvedOperation) executable; return new StyledString(resolvedOperation.getSimpleSignature()).append( " - Override method from " + resolvedOperation.getResolvedDeclarator().getHumanReadableName(), StyledString.QUALIFIER_STYLER); } else { return new StyledString("Add constructor 'new " + executable.getSimpleSignature() + "'"); } }
Example #27
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void reportMissingImplementations(XtendTypeDeclaration xtendClass, JvmGenericType inferredType, List<IResolvedOperation> operationsMissingImplementation) { StringBuilder errorMsg = new StringBuilder(); String name = xtendClass.getName(); boolean needsNewLine = operationsMissingImplementation.size() > 1; if (xtendClass.isAnonymous()) { JvmTypeReference superType = Iterables.getLast(inferredType.getSuperTypes()); errorMsg.append("The anonymous subclass of ").append(superType.getSimpleName()); errorMsg.append(" does not implement "); } else { errorMsg.append("The class ").append(name); errorMsg.append(" must be defined abstract because it does not implement "); } if (needsNewLine) { errorMsg.append("its inherited abstract methods "); } IResolvedOperation operation; for(int i=0; i<operationsMissingImplementation.size() && i<3; ++i) { operation = operationsMissingImplementation.get(i); if(needsNewLine) errorMsg.append("\n- "); errorMsg.append(operation.getSimpleSignature()); } int numUnshownOperations = operationsMissingImplementation.size() - 3; if(numUnshownOperations >0) errorMsg.append("\nand " + numUnshownOperations + " more."); List<String> uris = transform(operationsMissingImplementation, new Function<IResolvedOperation, String>() { @Override public String apply(IResolvedOperation from) { return EcoreUtil.getURI(from.getDeclaration()).toString(); } }); if (xtendClass.isAnonymous()) { error(errorMsg.toString(), xtendClass, ANONYMOUS_CLASS__CONSTRUCTOR_CALL, ANONYMOUS_CLASS_MISSING_MEMBERS, toArray(uris, String.class)); } else { error(errorMsg.toString(), xtendClass, XTEND_TYPE_DECLARATION__NAME, CLASS_MUST_BE_ABSTRACT, toArray(uris, String.class)); } }
Example #28
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void createExceptionMismatchError(IResolvedOperation operation, EObject sourceElement, List<IResolvedOperation> exceptionMismatch) { List<LightweightTypeReference> exceptions = operation.getIllegallyDeclaredExceptions(); StringBuilder message = new StringBuilder(100); message.append("The declared exception"); if (exceptions.size() > 1) { message.append('s'); } message.append(' '); for(int i = 0; i < exceptions.size(); i++) { if (i != 0) { if (i != exceptions.size() - 1) message.append(", "); else message.append(" and "); } message.append(exceptions.get(i).getHumanReadableName()); } if (exceptions.size() > 1) { message.append(" are"); } else { message.append(" is"); } message.append(" not compatible with throws clause in "); for(int i = 0; i < exceptionMismatch.size(); i++) { if (i != 0) { if (i != exceptionMismatch.size() - 1) message.append(", "); else message.append(" and "); } IResolvedOperation resolvedOperation = exceptionMismatch.get(i); message.append(getDeclaratorName(resolvedOperation)); message.append('.'); message.append(exceptionMismatch.get(i).getSimpleSignature()); } error(message.toString(), sourceElement, exceptionsFeature(sourceElement), INCOMPATIBLE_THROWS_CLAUSE); }
Example #29
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected LightweightTypeReference getReturnTypeOfOverriddenOperation(JvmOperation operation, ResolvedTypes resolvedTypes, IFeatureScopeSession session) { if (operation.getVisibility() == JvmVisibility.PRIVATE) return null; if (InferredTypeIndicator.isInferred(operation.getReturnType())) { LightweightTypeReference declaringType = resolvedTypes.getActualType(operation.getDeclaringType()); if (declaringType == null) { throw new IllegalStateException("Cannot determine declaring type of operation: " + operation); } BottomResolvedOperation resolvedOperation = new BottomResolvedOperation(operation, declaringType, overrideTester); List<IResolvedOperation> overriddenMethods = resolvedOperation.getOverriddenAndImplementedMethods(); if (overriddenMethods.isEmpty()) return null; IResolvedOperation overriddenMethod = overriddenMethods.get(0); JvmOperation declaration = overriddenMethod.getDeclaration(); XExpression inferredFrom = getInferredFrom(declaration.getReturnType()); // guard against active annotations that put an expression into a second method // namely in a synthesized super type - in that case, the expression should not be // inferred in the context of the super type but the subtype thus the return type // of a super method has to be ignored // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=439535 if (inferredFrom != null && (inferredFrom == getInferredFrom(operation.getReturnType()) || isHandled(inferredFrom))) { return null; } LightweightTypeReference result = overriddenMethod.getResolvedReturnType(); return result; } return null; }
Example #30
Source File: CompilationUnitImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public ResolvedMethod toResolvedMethod(final IResolvedOperation delegate) { final Function1<IResolvedOperation, ResolvedMethodImpl> _function = (IResolvedOperation it) -> { ResolvedMethodImpl _resolvedMethodImpl = new ResolvedMethodImpl(); final Procedure1<ResolvedMethodImpl> _function_1 = (ResolvedMethodImpl it_1) -> { it_1.setDelegate(delegate); it_1.setCompilationUnit(this); }; return ObjectExtensions.<ResolvedMethodImpl>operator_doubleArrow(_resolvedMethodImpl, _function_1); }; return this.<IResolvedOperation, ResolvedMethodImpl>getOrCreate(delegate, _function); }