Java Code Examples for org.eclipse.jdt.core.dom.Type#setProperty()

The following examples show how to use org.eclipse.jdt.core.dom.Type#setProperty() . 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: SuperTypeConstraintsCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final void endVisit(final ArrayType node) {
	Type elementType= node.getElementType();
	final ConstraintVariable2 variable= fModel.createTypeVariable(elementType);
	if (variable != null) {
		elementType.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable);
		node.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable);
	}
}
 
Example 2
Source File: InferTypeArgumentsRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static ParameterizedType rewriteTypeVariable(TypeVariable2 typeCv, CompilationUnitRewrite rewrite, InferTypeArgumentsTCModel tCModel, boolean leaveUnconstraindRaw, SimpleType[] types) {
	ASTNode node= typeCv.getRange().getNode(rewrite.getRoot());
	if (node instanceof Name && node.getParent() instanceof Type) {
		Type originalType= (Type) node.getParent();

		if (types != null && !has(types, originalType))
			return null;

		// Must rewrite all type arguments in one batch. Do the rewrite when the first one is encountered; skip the others.
		Object rewritten= originalType.getProperty(REWRITTEN);
		if (rewritten == REWRITTEN)
			return null;
		originalType.setProperty(REWRITTEN, REWRITTEN);

		ArrayList<CollectionElementVariable2> typeArgumentCvs= getTypeArgumentCvs(typeCv, tCModel);
		Type[] typeArguments= getTypeArguments(originalType, typeArgumentCvs, rewrite, tCModel, leaveUnconstraindRaw);
		if (typeArguments == null)
			return null;

		Type movingType= (Type) rewrite.getASTRewrite().createMoveTarget(originalType);
		ParameterizedType newType= rewrite.getAST().newParameterizedType(movingType);

		for (int i= 0; i < typeArguments.length; i++) {
			newType.typeArguments().add(typeArguments[i]);
		}

		rewrite.getASTRewrite().replace(originalType, newType, rewrite.createGroupDescription(RefactoringCoreMessages.InferTypeArgumentsRefactoring_addTypeArguments));
		return newType;
	}  else {//TODO: other node types?
		return null;
	}
}
 
Example 3
Source File: SuperTypeConstraintsCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public final void endVisit(final Type node) {
	final ASTNode parent= node.getParent();
	if (!(parent instanceof AbstractTypeDeclaration) && !(parent instanceof ClassInstanceCreation) && !(parent instanceof TypeLiteral) && (!(parent instanceof InstanceofExpression) || fInstanceOf))
		node.setProperty(PROPERTY_CONSTRAINT_VARIABLE, fModel.createTypeVariable(node));
}