Java Code Examples for org.eclipse.xtext.common.types.JvmOperation#isFinal()

The following examples show how to use org.eclipse.xtext.common.types.JvmOperation#isFinal() . 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: OverrideTester.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void addAdditionalDetails(AbstractResolvedOperation overriding,
		AbstractResolvedOperation overridden, EnumSet<OverrideCheckDetails> result) {
	addReturnTypeDetails(overriding, overridden, result);
	addExceptionDetails(overriding, overridden, result);
	JvmOperation overridingDecl = overriding.getDeclaration();
	JvmOperation overriddenDecl = overridden.getDeclaration();
	if (isMorePrivateThan(overridingDecl.getVisibility(), overriddenDecl.getVisibility())) {
		result.add(OverrideCheckDetails.REDUCED_VISIBILITY);
	}
	if (overriddenDecl.isFinal()) {
		result.add(OverrideCheckDetails.IS_FINAL);
	}
	if (overridingDecl.isVarArgs() != overriddenDecl.isVarArgs()) {
		result.add(OverrideCheckDetails.VAR_ARG_MISMATCH);
	}
	if (isConflictingDefaultImplementation(overriding, overridden)) {
		result.add(OverrideCheckDetails.DEFAULT_IMPL_CONFLICT);
	}
	if (!overridingDecl.isSynchronized() && overriddenDecl.isSynchronized()) {
		result.add(OverrideCheckDetails.SYNCHRONIZED_MISMATCH);
	}
}
 
Example 2
Source File: OverrideProposalUtil.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean isCandidate(LightweightTypeReference type, IResolvedExecutable executable,
		IVisibilityHelper visibilityHelper) {
	JvmDeclaredType declaringType = executable.getDeclaration().getDeclaringType();
	if (type.getType() != declaringType && isVisible(executable, visibilityHelper)) {
		JvmExecutable rawExecutable = executable.getDeclaration();
		if (rawExecutable instanceof JvmOperation) {
			JvmOperation operation = (JvmOperation) rawExecutable;
			if (operation.isFinal() || operation.isStatic()) {
				return false;
			} else {
				if (type.getType() instanceof JvmGenericType && ((JvmGenericType) type.getType()).isInterface()) {
					return  declaringType instanceof JvmGenericType
							&& ((JvmGenericType) declaringType).isInterface() && !operation.isAbstract();
				} else {
					return true;
				}
			}
		} else {
			return true;
		}
	}
	return false;
}
 
Example 3
Source File: JvmDeclaredTypeSignatureHashProvider.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected SignatureHashBuilder appendSignature(JvmOperation operation) {
	appendVisibility(operation.getVisibility()).append(" ");
	if (operation.isAbstract())
		append("abstract ");
	if (operation.isStatic())
		append("static ");
	if (operation.isFinal())
		append("final ");
	appendType(operation.getReturnType()).appendTypeParameters(operation).append(" ")
			.append(operation.getSimpleName()).append("(");
	for (JvmFormalParameter p : operation.getParameters()) {
		appendType(p.getParameterType());
		append(" ");
	}
	append(") ");
	for (JvmTypeReference ex : operation.getExceptions()) {
		appendType(ex).append(" ");
	}
	return this;
}
 
Example 4
Source File: JvmModelGenerator.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected ITreeAppendable _generateModifier(final JvmOperation it, final ITreeAppendable appendable, final GeneratorConfig config) {
  ITreeAppendable _xblockexpression = null;
  {
    this.generateVisibilityModifier(it, appendable);
    if ((it.isAbstract() && (!this.isDeclaredWithinInterface(it)))) {
      appendable.append("abstract ");
    }
    boolean _isStatic = it.isStatic();
    if (_isStatic) {
      appendable.append("static ");
    }
    if (((((!it.isAbstract()) && (!it.isStatic())) && config.getJavaSourceVersion().isAtLeast(JavaVersion.JAVA8)) && this.isDeclaredWithinInterface(it))) {
      appendable.append("default ");
    }
    boolean _isFinal = it.isFinal();
    if (_isFinal) {
      appendable.append("final ");
    }
    boolean _isSynchronized = it.isSynchronized();
    if (_isSynchronized) {
      appendable.append("synchronized ");
    }
    boolean _isStrictFloatingPoint = it.isStrictFloatingPoint();
    if (_isStrictFloatingPoint) {
      appendable.append("strictfp ");
    }
    ITreeAppendable _xifexpression = null;
    boolean _isNative = it.isNative();
    if (_isNative) {
      _xifexpression = appendable.append("native ");
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
Example 5
Source File: XbaseReferenceProposalCreator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected Image computeImage(JvmFeature feature) {
	int flags = 0;
	int decorator = 0;
	switch(feature.getVisibility()) {
		case PUBLIC: flags = Flags.AccPublic; break;
		case PROTECTED: flags = Flags.AccProtected; break;
		case PRIVATE: flags = Flags.AccPrivate; break;
		case DEFAULT: flags = Flags.AccDefault; break;
	}
	JvmDeclaredType declaringType = feature.getDeclaringType();
	boolean interfaceOrAnnotation = false;
	if (declaringType instanceof JvmGenericType) {
		interfaceOrAnnotation = ((JvmGenericType) declaringType).isInterface();
	} else if (declaringType instanceof JvmAnnotationType) {
		interfaceOrAnnotation = true;
	}
	if (feature instanceof JvmConstructor) {
		decorator = JavaElementImageDescriptor.CONSTRUCTOR;
		if (declaringType.isAbstract()) {
			flags |= Flags.AccAbstract;
			decorator |= JavaElementImageDescriptor.ABSTRACT;
		}
		return computeConstructorImage(declaringType.getDeclaringType() != null, interfaceOrAnnotation, flags, decorator);
	} else if (feature instanceof JvmOperation) {
		JvmOperation operation = (JvmOperation) feature;
		if (operation.isStatic()) {
			flags |= Flags.AccStatic;
			decorator |= JavaElementImageDescriptor.STATIC;
		}
		if (operation.isAbstract()) {
			flags |= Flags.AccAbstract;
			decorator |= JavaElementImageDescriptor.ABSTRACT;
		}
		if (operation.isFinal()) {
			flags |= Flags.AccFinal;
			decorator |= JavaElementImageDescriptor.FINAL;
		}
		return computeMethodImage(interfaceOrAnnotation, flags, decorator);
	} else if (feature instanceof JvmField) {
		JvmField field = (JvmField) feature;
		if (field.isStatic()) {
			flags |= Flags.AccStatic;
			decorator |= JavaElementImageDescriptor.STATIC;
		}
		if (field.isFinal()) {
			flags |= Flags.AccFinal;
			decorator |= JavaElementImageDescriptor.FINAL;
		}
		if (declaringType instanceof JvmEnumerationType)
			flags |= Flags.AccEnum;
		return computeFieldImage(interfaceOrAnnotation, flags, decorator);
	} 
	return null;
}