本文整理汇总了Java中org.eclipse.jdt.core.dom.QualifiedType类的典型用法代码示例。如果您正苦于以下问题:Java QualifiedType类的具体用法?Java QualifiedType怎么用?Java QualifiedType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QualifiedType类属于org.eclipse.jdt.core.dom包,在下文中一共展示了QualifiedType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNormalizedNode
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
/**
* For {@link Name} or {@link Type} nodes, returns the topmost {@link Type} node
* that shares the same type binding as the given node.
*
* @param node an ASTNode
* @return the normalized {@link Type} node or the original node
*/
public static ASTNode getNormalizedNode(ASTNode node) {
ASTNode current= node;
// normalize name
if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
// normalize type
if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())
|| SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())
|| NameQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
// normalize parameterized types
if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
return current;
}
示例2: getNormalizedNode
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
/**
* For {@link Name} or {@link org.eclipse.jdt.core.dom.Type} nodes, returns the topmost {@link
* org.eclipse.jdt.core.dom.Type} node that shares the same type binding as the given node.
*
* @param node an ASTNode
* @return the normalized {@link org.eclipse.jdt.core.dom.Type} node or the original node
*/
public static ASTNode getNormalizedNode(ASTNode node) {
ASTNode current = node;
// normalize name
if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
current = current.getParent();
}
// normalize type
if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())
|| SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())
|| NameQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) {
current = current.getParent();
}
// normalize parameterized types
if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
current = current.getParent();
}
return current;
}
示例3: getNormalizedNode
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
/**
* For {@link Name} or {@link Type} nodes, returns the topmost {@link Type} node
* that shares the same type binding as the given node.
*
* @param node an ASTNode
* @return the normalized {@link Type} node or the original node
*/
public static ASTNode getNormalizedNode(ASTNode node) {
ASTNode current= node;
// normalize name
if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
// normalize type
if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())
|| SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())
|| NameQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
// normalize parameterized types
if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
return current;
}
示例4: getNormalizedNode
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
public static ASTNode getNormalizedNode(ASTNode node) {
ASTNode current= node;
// normalize name
if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
// normalize type
if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent()) ||
SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
// normalize parameterized types
if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
current= current.getParent();
}
return current;
}
示例5: getLeftMostSimpleType
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
public static SimpleType getLeftMostSimpleType(QualifiedType type) {
final SimpleType[] result= new SimpleType[1];
ASTVisitor visitor= new ASTVisitor() {
@Override
public boolean visit(QualifiedType qualifiedType) {
Type left= qualifiedType.getQualifier();
if (left instanceof SimpleType)
result[0]= (SimpleType)left;
else
left.accept(this);
return false;
}
};
type.accept(visitor);
return result[0];
}
示例6: toClassName
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
public static String toClassName(IProject project, Type type)
{
Name name = null;
if (type instanceof SimpleType)
{
name = ((SimpleType) type).getName();
}
else if (type instanceof QualifiedType)
{
name = ((QualifiedType) type).getName();
}
else if (type instanceof ParameterizedType)
{
return toClassName(project, ((ParameterizedType) type).getType());
}
else
{
// Unsupported type, i.e., primitive types are not supported at the moment
return null;
}
return name.isQualifiedName()
? name.getFullyQualifiedName()
: tryResolveFQNameFromImports(project, type.getRoot(), name.getFullyQualifiedName());
}
示例7: tryToResolve
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
protected boolean tryToResolve(Type type) {
boolean result = false;
if (underResolution.getResolverMap().containsKey(type)) {
result = true;
} else {
if (type.isPrimitiveType()) {
result = tryToResolve((PrimitiveType)type);
} else if (type.isQualifiedType()) {
result = tryToResolve((QualifiedType)type);
} else if (type.isArrayType()) {
result = tryToResolve(((ArrayType)type).getElementType());
} else if (type.isSimpleType()) {
result = tryToResolve((SimpleType)type);
} else if (type.isParameterizedType()) {
result = tryToResolve((ParameterizedType)type);
} else if (type.isWildcardType()) {
result = tryToResolve((WildcardType)type);
} else {
CoreActivator.log(IStatus.INFO, "Type not handled " + type.toString());
}
}
return result;
}
示例8: getName
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
/**
* Return a name instance from a Type instance
*/
public static Name getName(Type t) {
if (t.isArrayType()) {
ArrayType arrayType = (ArrayType) t;
return getName(ASTArrayTypeHelper.getComponentType(arrayType));
} else if (t.isParameterizedType()) {
return getName(((ParameterizedType) t).getType());
} else if (t.isPrimitiveType()) {
return null;
} else if (t.isQualifiedType()) {
return ((QualifiedType) t).getName();
} else if (t.isSimpleType()) {
return ((SimpleType) t).getName();
}
return null;
}
示例9: visit
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
@Override
public boolean visit(QualifiedType node) {
addType(
node.resolveBinding(),
extractClassNameFromQualifiedName(extractTypeNameWithoutGenerics(node)),
node.getStartPosition());
return true;
}
示例10: getNameOfType
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
/**
* @return a String representation of 'type'. Handles qualified, simple and parameterized types.
*/
@Nullable
private String getNameOfType(Type type) {
if (type instanceof QualifiedType) {
return extractTypeNameWithoutGenerics((QualifiedType) type);
}
if (type instanceof SimpleType) {
return ((SimpleType) type).getName().getFullyQualifiedName();
}
if (type instanceof ParameterizedType) {
return getNameOfType(((ParameterizedType) type).getType());
}
return null;
}
示例11: testExtractTypeNameWithoutGenerics
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
@Test
public void testExtractTypeNameWithoutGenerics() {
AST ast = AST.newAST(AST.JLS4);
org.eclipse.jdt.core.dom.SimpleName entry = ast.newSimpleName("Entry");
ParameterizedType map = ast.newParameterizedType(ast.newSimpleType(ast.newSimpleName("Map")));
map.typeArguments().add(ast.newSimpleType(ast.newSimpleName("Foo")));
QualifiedType type = ast.newQualifiedType(map, entry);
assertThat(type.toString()).isEqualTo("Map<Foo>.Entry");
assertThat(ReferencedClassesParser.extractTypeNameWithoutGenerics(type)).isEqualTo("Map.Entry");
}
示例12: endVisit
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
@Override
public void endVisit(QualifiedType node) {
if (skipNode(node)) {
return;
}
processSequential(node, node.getQualifier(), node.getName());
}
示例13: getSelectedName
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
private static SimpleName getSelectedName(CompilationUnit compilationUnit, IProblemLocation problem) {
final ASTNode selection= problem.getCoveredNode(compilationUnit);
if (selection == null)
return null;
Name name= null;
if (selection instanceof SimpleType) {
name= ((SimpleType) selection).getName();
} else if (selection instanceof NameQualifiedType) {
name= ((NameQualifiedType) selection).getName();
} else if (selection instanceof QualifiedType) {
name= ((QualifiedType) selection).getName();
} else if (selection instanceof ParameterizedType) {
final ParameterizedType type= (ParameterizedType) selection;
final Type raw= type.getType();
if (raw instanceof SimpleType)
name= ((SimpleType) raw).getName();
else if (raw instanceof NameQualifiedType)
name= ((NameQualifiedType) raw).getName();
else if (raw instanceof QualifiedType)
name= ((QualifiedType) raw).getName();
} else if (selection instanceof Name) {
name= (Name) selection;
}
if (name == null)
return null;
if (name.isSimpleName()) {
return (SimpleName)name;
} else {
return ((QualifiedName)name).getName();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:PotentialProgrammingProblemsFix.java
示例14: visit
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
@Override
public boolean visit(QualifiedType node) {
node.getQualifier().accept(this);
this.fBuffer.append(".");//$NON-NLS-1$
node.getName().accept(this);
return false;
}
示例15: resolveBinding
import org.eclipse.jdt.core.dom.QualifiedType; //导入依赖的package包/类
private static IBinding resolveBinding(ASTNode node) {
if (node instanceof SimpleName) {
// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
SimpleName simpleName= (SimpleName) node;
StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY|| loc == SimpleType.NAME_PROPERTY || loc == ParameterizedType.TYPE_PROPERTY) {
node= node.getParent();
loc= node.getLocationInParent();
}
if (loc == ClassInstanceCreation.TYPE_PROPERTY) {
ClassInstanceCreation cic= (ClassInstanceCreation) node.getParent();
IMethodBinding constructorBinding= cic.resolveConstructorBinding();
if (constructorBinding == null)
return null;
ITypeBinding declaringClass= constructorBinding.getDeclaringClass();
if (!declaringClass.isAnonymous())
return constructorBinding;
ITypeBinding superTypeDeclaration= declaringClass.getSuperclass().getTypeDeclaration();
return resolveSuperclassConstructor(superTypeDeclaration, constructorBinding);
}
return simpleName.resolveBinding();
} else if (node instanceof SuperConstructorInvocation) {
return ((SuperConstructorInvocation) node).resolveConstructorBinding();
} else if (node instanceof ConstructorInvocation) {
return ((ConstructorInvocation) node).resolveConstructorBinding();
} else {
return null;
}
}