org.eclipse.jdt.core.dom.TypeLiteral Java Examples

The following examples show how to use org.eclipse.jdt.core.dom.TypeLiteral. 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: ASTNodeMatcher.java    From JDeodorant with MIT License 6 votes vote down vote up
protected boolean isTypeHolder(Object o) {
	if(o.getClass().equals(MethodInvocation.class) || o.getClass().equals(SuperMethodInvocation.class)			
			|| o.getClass().equals(NumberLiteral.class) || o.getClass().equals(StringLiteral.class)
			|| o.getClass().equals(CharacterLiteral.class) || o.getClass().equals(BooleanLiteral.class)
			|| o.getClass().equals(TypeLiteral.class) || o.getClass().equals(NullLiteral.class)
			|| o.getClass().equals(ArrayCreation.class)
			|| o.getClass().equals(ClassInstanceCreation.class)
			|| o.getClass().equals(ArrayAccess.class) || o.getClass().equals(FieldAccess.class)
			|| o.getClass().equals(SuperFieldAccess.class) || o.getClass().equals(ParenthesizedExpression.class)
			|| o.getClass().equals(SimpleName.class) || o.getClass().equals(QualifiedName.class)
			|| o.getClass().equals(CastExpression.class) || o.getClass().equals(InfixExpression.class)
			|| o.getClass().equals(PrefixExpression.class) || o.getClass().equals(InstanceofExpression.class)
			|| o.getClass().equals(ThisExpression.class) || o.getClass().equals(ConditionalExpression.class))
		return true;
	return false;
}
 
Example #2
Source File: CodeBlock.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
private TyLiteral visit(TypeLiteral node) {
	int startLine = _cunit.getLineNumber(node.getStartPosition());
	int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength());
	TyLiteral tyLiteral = new TyLiteral(startLine, endLine, node);
	tyLiteral.setValue(node.getType());
	tyLiteral.setType(node.getType());
	
	return tyLiteral;
}
 
Example #3
Source File: InstanceOfLiteral.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean instanceOf(Expression expression) {
	if(expression instanceof BooleanLiteral || expression instanceof CharacterLiteral || expression instanceof StringLiteral ||
			expression instanceof NullLiteral || expression instanceof NumberLiteral || expression instanceof TypeLiteral)
		return true;
	else
		return false;
}
 
Example #4
Source File: BindingSignatureVisitor.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean visit(TypeLiteral expr) {
	String key;
	if(expr.getType().resolveBinding() != null)
		key = expr.getType().resolveBinding().getKey() + ".class";
	else
		key = expr.toString();
	bindingKeys.add(key);
	return false;
}
 
Example #5
Source File: StyledStringVisitor.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean visit(TypeLiteral expr) {
	/*
	 * ( Type | void ) . class
	 */
	activateDiffStyle(expr);
	handleType(expr.getType());
	appendPeriod();
	styledString.append("class", determineDiffStyle(expr, new StyledStringStyler(keywordStyle)));
	deactivateDiffStyle(expr);
	return false;
}
 
Example #6
Source File: InferTypeArgumentsRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean unboundedWildcardAllowed(Type originalType) {
	ASTNode parent= originalType.getParent();
	while (parent instanceof Type)
		parent= parent.getParent();

	if (parent instanceof ClassInstanceCreation) {
		return false;
	} else if (parent instanceof AbstractTypeDeclaration) {
		return false;
	} else if (parent instanceof TypeLiteral) {
		return false;
	}
	return true;
}
 
Example #7
Source File: TypenameScopeExtractor.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean visit(TypeLiteral node) {
	final String type = node.getType().toString();
	if (topMethod != null && methodsAsRoot) {
		types.put(topMethod, type);
	} else if (topClass != null) {
		types.put(topClass, type);
	}
	return super.visit(node);
}
 
Example #8
Source File: TypenameScopeExtractor.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean visit(TypeLiteral node) {
	final String type = node.getType().toString();
	if (topMethod != null && methodsAsRoot) {
		types.put(topMethod, type);
	} else if (topClass != null) {
		types.put(topClass, type);
	}
	return super.visit(node);
}
 
Example #9
Source File: SharedUtils.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
public static ITypeBinding obtainTypeBindingFromExpression(Expression expr) {
	if(expr instanceof TypeLiteral) {
		return ((TypeLiteral) expr).getType().resolveBinding();
	}
	
	return null;
}
 
Example #10
Source File: Visitor.java    From RefactoringMiner with MIT License 5 votes vote down vote up
public boolean visit(TypeLiteral node) {
	typeLiterals.add(node.toString());
	if(current.getUserObject() != null) {
		AnonymousClassDeclarationObject anonymous = (AnonymousClassDeclarationObject)current.getUserObject();
		anonymous.getTypeLiterals().add(node.toString());
	}
	return super.visit(node);
}
 
Example #11
Source File: TypenameScopeExtractor.java    From api-mining with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean visit(TypeLiteral node) {
	final String type = node.getType().toString();
	if (topMethod != null && methodsAsRoot) {
		types.put(topMethod, type);
	} else if (topClass != null) {
		types.put(topClass, type);
	}
	return super.visit(node);
}
 
Example #12
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final TypeLiteral node) {
  if (this.fallBackStrategy) {
    this.appendToBuffer("typeof(");
  }
  node.getType().accept(this);
  if (this.fallBackStrategy) {
    this.appendToBuffer(")");
  }
  return false;
}
 
Example #13
Source File: FlowAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void endVisit(TypeLiteral node) {
	if (skipNode(node)) {
		return;
	}
	assignFlowInfo(node, node.getType());
}
 
Example #14
Source File: JsonDeserializeAdder.java    From SparkBuilderGenerator with MIT License 5 votes vote down vote up
private TypeLiteral createBuilderClassReferenceLiteral(AST ast, CompilationUnitModificationDomain compilationUnitModificationDomain, TypeDeclaration builderType) {
    String originalClassName = compilationUnitModificationDomain.getOriginalType().getName().toString();
    String builderClassName = builderType.getName().toString();

    QualifiedType qualifiedType = ast.newQualifiedType(ast.newSimpleType(ast.newSimpleName(originalClassName)), ast.newSimpleName(builderClassName));

    TypeLiteral typeLiteral = ast.newTypeLiteral();
    typeLiteral.setType(qualifiedType);
    return typeLiteral;
}
 
Example #15
Source File: JsonDeserializeAdder.java    From SparkBuilderGenerator with MIT License 5 votes vote down vote up
private NormalAnnotation createAnnotation(AST ast, CompilationUnitModificationDomain compilationUnitModificationDomain, TypeDeclaration builderType) {
    TypeLiteral typeLiteral = createBuilderClassReferenceLiteral(ast, compilationUnitModificationDomain, builderType);

    NormalAnnotation jsonDeserializeAnnotation = ast.newNormalAnnotation();
    jsonDeserializeAnnotation.setTypeName(ast.newSimpleName(JSON_DESERIALIZE_CLASS_NAME));

    MemberValuePair builderAttribute = ast.newMemberValuePair();
    builderAttribute.setName(ast.newSimpleName("builder"));
    builderAttribute.setValue(typeLiteral);

    jsonDeserializeAnnotation.values().add(builderAttribute);

    return jsonDeserializeAnnotation;
}
 
Example #16
Source File: BaseTranslator.java    From junion with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public Entry typeLiteral(Object o) {
	TypeLiteral typeLit = (TypeLiteral)o;
	Type type = typeLit.getType();
	return entry(type);
}
 
Example #17
Source File: StyledStringVisitor.java    From JDeodorant with MIT License 4 votes vote down vote up
private void handleExpression(Expression expression) {
	if (expression instanceof ArrayAccess) {
		visit((ArrayAccess) expression);
	} else if (expression instanceof ArrayCreation) {
		visit((ArrayCreation) expression);
	} else if (expression instanceof ArrayInitializer) {
		visit((ArrayInitializer) expression);
	} else if (expression instanceof Assignment) {
		visit((Assignment) expression);
	} else if (expression instanceof BooleanLiteral) {
		visit((BooleanLiteral) expression);
	} else if (expression instanceof CastExpression) {
		visit((CastExpression) expression);
	} else if (expression instanceof CharacterLiteral) {
		visit((CharacterLiteral) expression);
	} else if (expression instanceof ClassInstanceCreation) {
		visit((ClassInstanceCreation) expression);
	} else if (expression instanceof ConditionalExpression) {
		visit((ConditionalExpression) expression);
	} else if (expression instanceof FieldAccess) {
		visit((FieldAccess) expression);
	} else if (expression instanceof InfixExpression) {
		visit((InfixExpression) expression);
	} else if (expression instanceof InstanceofExpression) {
		visit((InstanceofExpression) expression);
	} else if (expression instanceof MethodInvocation) {
		visit((MethodInvocation) expression);
	} else if (expression instanceof NullLiteral) {
		visit((NullLiteral) expression);
	} else if (expression instanceof NumberLiteral) {
		visit((NumberLiteral) expression);
	} else if (expression instanceof ParenthesizedExpression) {
		visit((ParenthesizedExpression) expression);
	} else if (expression instanceof PostfixExpression) {
		visit((PostfixExpression) expression);
	} else if (expression instanceof PrefixExpression) {
		visit((PrefixExpression) expression);
	} else if ((expression instanceof QualifiedName)) {
		visit((QualifiedName) expression);
	} else if (expression instanceof SimpleName) {
		visit((SimpleName) expression);
	} else if (expression instanceof StringLiteral) {
		visit((StringLiteral) expression);
	} else if (expression instanceof SuperFieldAccess) {
		visit((SuperFieldAccess) expression);
	} else if (expression instanceof SuperMethodInvocation) {
		visit((SuperMethodInvocation) expression);
	} else if (expression instanceof ThisExpression) {
		visit((ThisExpression) expression);
	} else if (expression instanceof TypeLiteral) {
		visit((TypeLiteral) expression);
	} else if (expression instanceof VariableDeclarationExpression) {
		visit((VariableDeclarationExpression) expression);
	}
}
 
Example #18
Source File: BindingSignatureVisitor.java    From JDeodorant with MIT License 4 votes vote down vote up
private void handleExpression(Expression expression) {
	if (expression instanceof ArrayAccess) {
		visit((ArrayAccess) expression);
	} else if (expression instanceof ArrayCreation) {
		visit((ArrayCreation) expression);
	} else if (expression instanceof ArrayInitializer) {
		visit((ArrayInitializer) expression);
	} else if (expression instanceof Assignment) {
		visit((Assignment) expression);
	} else if (expression instanceof BooleanLiteral) {
		visit((BooleanLiteral) expression);
	} else if (expression instanceof CastExpression) {
		visit((CastExpression) expression);
	} else if (expression instanceof CharacterLiteral) {
		visit((CharacterLiteral) expression);
	} else if (expression instanceof ClassInstanceCreation) {
		visit((ClassInstanceCreation) expression);
	} else if (expression instanceof ConditionalExpression) {
		visit((ConditionalExpression) expression);
	} else if (expression instanceof FieldAccess) {
		visit((FieldAccess) expression);
	} else if (expression instanceof InfixExpression) {
		visit((InfixExpression) expression);
	} else if (expression instanceof InstanceofExpression) {
		visit((InstanceofExpression) expression);
	} else if (expression instanceof MethodInvocation) {
		visit((MethodInvocation) expression);
	} else if (expression instanceof NullLiteral) {
		visit((NullLiteral) expression);
	} else if (expression instanceof NumberLiteral) {
		visit((NumberLiteral) expression);
	} else if (expression instanceof ParenthesizedExpression) {
		visit((ParenthesizedExpression) expression);
	} else if (expression instanceof PostfixExpression) {
		visit((PostfixExpression) expression);
	} else if (expression instanceof PrefixExpression) {
		visit((PrefixExpression) expression);
	} else if ((expression instanceof QualifiedName)) {
		visit((QualifiedName) expression);
	} else if (expression instanceof SimpleName) {
		visit((SimpleName) expression);
	} else if (expression instanceof StringLiteral) {
		visit((StringLiteral) expression);
	} else if (expression instanceof SuperFieldAccess) {
		visit((SuperFieldAccess) expression);
	} else if (expression instanceof SuperMethodInvocation) {
		visit((SuperMethodInvocation) expression);
	} else if (expression instanceof ThisExpression) {
		visit((ThisExpression) expression);
	} else if (expression instanceof TypeLiteral) {
		visit((TypeLiteral) expression);
	} else if (expression instanceof VariableDeclarationExpression) {
		visit((VariableDeclarationExpression) expression);
	}
}
 
Example #19
Source File: IdentifierPerType.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean visit(final TypeLiteral node) {
	addToMap(identifiers, node, node.getType().toString());
	return super.visit(node);
}
 
Example #20
Source File: InstanceOfTypeLiteral.java    From JDeodorant with MIT License 4 votes vote down vote up
public boolean instanceOf(Expression expression) {
	if(expression instanceof TypeLiteral)
		return true;
	else
		return false;
}
 
Example #21
Source File: LiteralObject.java    From JDeodorant with MIT License 4 votes vote down vote up
public LiteralObject(Expression expression) {
	if(expression instanceof StringLiteral) {
		StringLiteral stringLiteral = (StringLiteral)expression;
		literalType = LiteralType.STRING;
		value = stringLiteral.getLiteralValue();
		type = TypeObject.extractTypeObject(stringLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof NullLiteral) {
		NullLiteral nullLiteral = (NullLiteral)expression;
		literalType = LiteralType.NULL;
		value = "null";
		if(nullLiteral.resolveTypeBinding() != null) {
			type = TypeObject.extractTypeObject(nullLiteral.resolveTypeBinding().getQualifiedName());
		}
	}
	else if(expression instanceof NumberLiteral) {
		NumberLiteral numberLiteral = (NumberLiteral)expression;
		literalType = LiteralType.NUMBER;
		value = numberLiteral.getToken();
		type = TypeObject.extractTypeObject(numberLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof BooleanLiteral) {
		BooleanLiteral booleanLiteral = (BooleanLiteral)expression;
		literalType = LiteralType.BOOLEAN;
		value = Boolean.toString(booleanLiteral.booleanValue());
		type = TypeObject.extractTypeObject(booleanLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof CharacterLiteral) {
		CharacterLiteral characterLiteral = (CharacterLiteral)expression;
		literalType = LiteralType.CHARACTER;
		value = Character.toString(characterLiteral.charValue());
		type = TypeObject.extractTypeObject(characterLiteral.resolveTypeBinding().getQualifiedName());
	}
	else if(expression instanceof TypeLiteral) {
		TypeLiteral typeLiteral = (TypeLiteral)expression;
		literalType = LiteralType.TYPE;
		value = typeLiteral.getType().toString();
		type = TypeObject.extractTypeObject(typeLiteral.resolveTypeBinding().getQualifiedName());
	}
	this.literal = ASTInformationGenerator.generateASTInformation(expression);
}
 
Example #22
Source File: GenericVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(TypeLiteral node) {
	return visitNode(node);
}
 
Example #23
Source File: GenericVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void endVisit(TypeLiteral node) {
	endVisitNode(node);
}
 
Example #24
Source File: ConstraintCollector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(TypeLiteral node) {
	add(fCreator.create(node));
	return true;
}
 
Example #25
Source File: AstMatchingNodeFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(TypeLiteral node) {
	if (node.subtreeMatch(fMatcher, fNodeToMatch))
		return matches(node);
	return super.visit(node);
}
 
Example #26
Source File: FlowAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void endVisit(TypeLiteral node) {
	if (skipNode(node))
		return;
	assignFlowInfo(node, node.getType());
}
 
Example #27
Source File: InferTypeArgumentsConstraintCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void endVisit(TypeLiteral node) {
	ITypeBinding typeBinding= node.resolveTypeBinding();
	ImmutableTypeVariable2 cv= fTCModel.makeImmutableTypeVariable(typeBinding, /*no boxing*/null);
	setConstraintVariable(node, cv);
}
 
Example #28
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));
}
 
Example #29
Source File: IdentifierPerType.java    From tassal with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean visit(final TypeLiteral node) {
	addToMap(identifiers, node, node.getType().toString());
	return super.visit(node);
}
 
Example #30
Source File: IdentifierPerType.java    From api-mining with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean visit(final TypeLiteral node) {
	addToMap(identifiers, node, node.getType().toString());
	return super.visit(node);
}