类org.eclipse.jdt.core.dom.TypeLiteral源码实例Demo

下面列出了怎么用org.eclipse.jdt.core.dom.TypeLiteral的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: JDeodorant   文件: ASTNodeMatcher.java
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;
}
 
源代码2 项目: SimFix   文件: CodeBlock.java
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;
}
 
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;
}
 
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;
}
 
源代码5 项目: eclipse.jdt.ls   文件: FlowAnalyzer.java
@Override
public void endVisit(TypeLiteral node) {
	if (skipNode(node)) {
		return;
	}
	assignFlowInfo(node, node.getType());
}
 
源代码6 项目: xtext-xtend   文件: JavaASTFlattener.java
@Override
public boolean visit(final TypeLiteral node) {
  if (this.fallBackStrategy) {
    this.appendToBuffer("typeof(");
  }
  node.getType().accept(this);
  if (this.fallBackStrategy) {
    this.appendToBuffer(")");
  }
  return false;
}
 
源代码7 项目: api-mining   文件: TypenameScopeExtractor.java
@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);
}
 
源代码8 项目: RefactoringMiner   文件: Visitor.java
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);
}
 
源代码9 项目: txtUML   文件: SharedUtils.java
public static ITypeBinding obtainTypeBindingFromExpression(Expression expr) {
	if(expr instanceof TypeLiteral) {
		return ((TypeLiteral) expr).getType().resolveBinding();
	}
	
	return null;
}
 
源代码10 项目: tassal   文件: TypenameScopeExtractor.java
@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);
}
 
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;
}
 
源代码12 项目: JDeodorant   文件: InstanceOfLiteral.java
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;
}
 
源代码13 项目: JDeodorant   文件: BindingSignatureVisitor.java
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;
}
 
源代码14 项目: JDeodorant   文件: StyledStringVisitor.java
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;
}
 
源代码15 项目: codemining-core   文件: TypenameScopeExtractor.java
@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);
}
 
源代码16 项目: junion   文件: BaseTranslator.java
public Entry typeLiteral(Object o) {
	TypeLiteral typeLit = (TypeLiteral)o;
	Type type = typeLit.getType();
	return entry(type);
}
 
源代码17 项目: api-mining   文件: IdentifierPerType.java
@Override
public boolean visit(final TypeLiteral node) {
	addToMap(identifiers, node, node.getType().toString());
	return super.visit(node);
}
 
源代码18 项目: tassal   文件: IdentifierPerType.java
@Override
public boolean visit(final TypeLiteral node) {
	addToMap(identifiers, node, node.getType().toString());
	return super.visit(node);
}
 
@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));
}
 
@Override
public void endVisit(TypeLiteral node) {
	ITypeBinding typeBinding= node.resolveTypeBinding();
	ImmutableTypeVariable2 cv= fTCModel.makeImmutableTypeVariable(typeBinding, /*no boxing*/null);
	setConstraintVariable(node, cv);
}
 
@Override
public void endVisit(TypeLiteral node) {
	if (skipNode(node))
		return;
	assignFlowInfo(node, node.getType());
}
 
@Override
public boolean visit(TypeLiteral node) {
	if (node.subtreeMatch(fMatcher, fNodeToMatch))
		return matches(node);
	return super.visit(node);
}
 
@Override
public boolean visit(TypeLiteral node) {
	add(fCreator.create(node));
	return true;
}
 
@Override
public void endVisit(TypeLiteral node) {
	endVisitNode(node);
}
 
@Override
public boolean visit(TypeLiteral node) {
	return visitNode(node);
}
 
源代码26 项目: JDeodorant   文件: LiteralObject.java
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);
}
 
源代码27 项目: JDeodorant   文件: InstanceOfTypeLiteral.java
public boolean instanceOf(Expression expression) {
	if(expression instanceof TypeLiteral)
		return true;
	else
		return false;
}
 
源代码28 项目: JDeodorant   文件: BindingSignatureVisitor.java
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);
	}
}
 
源代码29 项目: JDeodorant   文件: StyledStringVisitor.java
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);
	}
}
 
源代码30 项目: codemining-core   文件: IdentifierPerType.java
@Override
public boolean visit(final TypeLiteral node) {
	addToMap(identifiers, node, node.getType().toString());
	return super.visit(node);
}
 
 类所在包
 同包方法