当前位置: 首页>>代码示例>>Java>>正文


Java SimpleType类代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.SimpleType的典型用法代码示例。如果您正苦于以下问题:Java SimpleType类的具体用法?Java SimpleType怎么用?Java SimpleType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleType类属于org.eclipse.jdt.core.dom包,在下文中一共展示了SimpleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPrivilegedActionType

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
private ParameterizedType createPrivilegedActionType(ASTRewrite rewrite, ClassInstanceCreation classLoaderCreation) {
    AST ast = rewrite.getAST();

    Name privilegedActionName;
    if (isUpdateImports()) {
        privilegedActionName = ast.newSimpleName(PrivilegedAction.class.getSimpleName());
    } else {
        privilegedActionName = ast.newName(PrivilegedAction.class.getName());
    }
    SimpleType rawPrivilegedActionType = ast.newSimpleType(privilegedActionName);
    ParameterizedType privilegedActionType = ast.newParameterizedType(rawPrivilegedActionType);
    Type typeArgument = (Type) rewrite.createCopyTarget(classLoaderCreation.getType());
    List<Type> typeArguments = checkedList(privilegedActionType.typeArguments());

    typeArguments.add(typeArgument);

    return privilegedActionType;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:19,代码来源:CreateDoPrivilegedBlockResolution.java

示例2: provideAnswer

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
public static Object provideAnswer(InvocationOnMock inv) {
    Type type = ((BuilderField) inv.getArguments()[0]).getFieldType();
    if (type instanceof ParameterizedType) {
        Type baseType = ((ParameterizedType) type).getType();
        if (baseType instanceof SimpleType) {
            String name = ((SimpleType) baseType).getName().getFullyQualifiedName();

            // if name is fully qualified
            if (recognisedClasses.contains(name)) {
                return Optional.ofNullable(name);
            }

            Optional<String> found = recognisedClasses.stream()
                    .filter(fqn -> fqn.endsWith("." + name))
                    .findFirst();
            if (found.isPresent()) {
                return found;
            }
        }
    }
    return Optional.of("some.other.value");
}
 
开发者ID:helospark,项目名称:SparkBuilderGenerator,代码行数:23,代码来源:FieldDeclarationAnswerProvider.java

示例3: getNormalizedNode

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:ASTNodes.java

示例4: addEnhancedForWithoutTypeProposals

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode,
		Collection<CUCorrectionProposal> proposals) {
	if (selectedNode instanceof SimpleName && (selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY || selectedNode.getLocationInParent() == NameQualifiedType.NAME_PROPERTY)) {
		ASTNode type= selectedNode.getParent();
		if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
			SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent();
			if (svd.getLocationInParent() == EnhancedForStatement.PARAMETER_PROPERTY) {
				if (svd.getName().getLength() == 0) {
					SimpleName simpleName= (SimpleName) selectedNode;
					String name= simpleName.getIdentifier();
					int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7;
					String label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_create_loop_variable_description, BasicElementLabels.getJavaElementName(name));

					proposals.add(new NewVariableCorrectionProposal(label, cu, NewVariableCorrectionProposal.LOCAL,
							simpleName, null, relevance));
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:UnresolvedElementsSubProcessor.java

示例5: getAllSuperTypes

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
public List getAllSuperTypes(TypeDeclaration typeDeclaration) {
	List list = new ArrayList();

	Type superclassType = typeDeclaration.getSuperclassType();
	if (superclassType != null) {
		list.add(superclassType);
	}

	List superInterfaceTypes = typeDeclaration.superInterfaceTypes();

	for (Iterator itSuperInterfacesIterator = superInterfaceTypes.iterator(); itSuperInterfacesIterator.hasNext();) {
		Object next = itSuperInterfacesIterator.next();
		if (next instanceof SimpleType) {
			list.add(next);
		}
	}
	return list;
}
 
开发者ID:aroog,项目名称:code,代码行数:19,代码来源:SaveAnnotations.java

示例6: createRawTypeReferenceFix

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
public static Java50Fix createRawTypeReferenceFix(
    CompilationUnit compilationUnit, IProblemLocation problem) {
  List<CompilationUnitRewriteOperation> operations =
      new ArrayList<CompilationUnitRewriteOperation>();
  SimpleType node =
      createRawTypeReferenceOperations(
          compilationUnit, new IProblemLocation[] {problem}, operations);
  if (operations.size() == 0) return null;

  return new Java50Fix(
      Messages.format(
          FixMessages.Java50Fix_AddTypeArguments_description,
          BasicElementLabels.getJavaElementName(node.getName().getFullyQualifiedName())),
      compilationUnit,
      operations.toArray(new CompilationUnitRewriteOperation[operations.size()]));
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:Java50Fix.java

示例7: rewriteConstraintVariable

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
private static ParameterizedType rewriteConstraintVariable(
    ConstraintVariable2 cv,
    CompilationUnitRewrite rewrite,
    InferTypeArgumentsTCModel tCModel,
    boolean leaveUnconstraindRaw,
    SimpleType[] types) {
  if (cv instanceof CollectionElementVariable2) {
    ConstraintVariable2 parentElement =
        ((CollectionElementVariable2) cv).getParentConstraintVariable();
    if (parentElement instanceof TypeVariable2) {
      TypeVariable2 typeCv = (TypeVariable2) parentElement;
      return rewriteTypeVariable(typeCv, rewrite, tCModel, leaveUnconstraindRaw, types);
    } else {
      // only rewrite type variables
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:InferTypeArgumentsRefactoring.java

示例8: getNormalizedNode

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:ASTNodes.java

示例9: retrieveTypeClass

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
private Class<?> retrieveTypeClass(SimpleType simpleType) {
	ITypeBinding binding = simpleType.resolveBinding();
	if (binding == null) {
		String result = imports.get(simpleType.toString());
		if (result != null) {
			try {
				return Class.forName(result);
			} catch (ClassNotFoundException exc) {
				throw new RuntimeException("Classpath incomplete?", exc);
			}
		}
	}
	assert binding != null : "Could not resolve binding for " + simpleType
	        + ". Missing sources folder?";
	return retrieveTypeClass(binding);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:17,代码来源:TestExtractingVisitor.java

示例10: createAstType

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
private Type createAstType(final String type, final AST ast)
{
	if(type.startsWith("[")) // does type specify an array?
	{
		return this.createAstArrayType(type, ast);
	}
	else
	{
		final String[] fragments = type.split("\\.");
		if(fragments.length == 1)
		{
			return ast.newSimpleType(ast.newSimpleName(fragments[0]));
		}
		
	
		final String[] pkgArray = new String[fragments.length - 1];
		System.arraycopy(fragments, 0, pkgArray, 0, pkgArray.length);
		final SimpleType pkgType = ast.newSimpleType(ast.newName(pkgArray));
		
		return  ast.newQualifiedType( pkgType,  ast.newSimpleName(fragments[fragments.length - 1]));
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:23,代码来源:CodeGenerator.java

示例11: addTypeQualification

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
private void addTypeQualification(final Type type, final CompilationUnitRewrite targetRewrite, final TextEditGroup group) {
	Assert.isNotNull(type);
	Assert.isNotNull(targetRewrite);
	final ITypeBinding binding= type.resolveBinding();
	if (binding != null) {
		final ITypeBinding declaring= binding.getDeclaringClass();
		if (declaring != null) {
			if (type instanceof SimpleType) {
				final SimpleType simpleType= (SimpleType) type;
				addSimpleTypeQualification(targetRewrite, declaring, simpleType, group);
			} else if (type instanceof ParameterizedType) {
				final ParameterizedType parameterizedType= (ParameterizedType) type;
				final Type rawType= parameterizedType.getType();
				if (rawType instanceof SimpleType)
					addSimpleTypeQualification(targetRewrite, declaring, (SimpleType) rawType, group);
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:MoveInnerToTopRefactoring.java

示例12: inferArguments

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
public static ParameterizedType[] inferArguments(SimpleType[] types, InferTypeArgumentsUpdate update, InferTypeArgumentsTCModel model, CompilationUnitRewrite rewrite) {
	for (int i= 0; i < types.length; i++) {
		types[i].setProperty(REWRITTEN, null);
	}
	List<ParameterizedType> result= new ArrayList<ParameterizedType>();
	HashMap<ICompilationUnit, CuUpdate> updates= update.getUpdates();
	Set<Entry<ICompilationUnit, CuUpdate>> entrySet= updates.entrySet();
	for (Iterator<Entry<ICompilationUnit, CuUpdate>> iter= entrySet.iterator(); iter.hasNext();) {

		Entry<ICompilationUnit, CuUpdate> entry= iter.next();

		rewrite.setResolveBindings(false);
		CuUpdate cuUpdate= entry.getValue();

		for (Iterator<CollectionElementVariable2> cvIter= cuUpdate.getDeclarations().iterator(); cvIter.hasNext();) {
			ConstraintVariable2 cv= cvIter.next();
			ParameterizedType newNode= rewriteConstraintVariable(cv, rewrite, model, false, types);
			if (newNode != null)
				result.add(newNode);
		}
	}
	return result.toArray(new ParameterizedType[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:InferTypeArgumentsRefactoring.java

示例13: getNormalizedNode

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ASTNodes.java

示例14: isRawTypeReference

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
private static boolean isRawTypeReference(ASTNode node) {
	if (!(node instanceof SimpleType))
		return false;

	ITypeBinding typeBinding= ((SimpleType) node).resolveBinding();
	if (typeBinding == null)
		return false;

	ITypeBinding binding= typeBinding.getTypeDeclaration();
	if (binding == null)
		return false;

	ITypeBinding[] parameters= binding.getTypeParameters();
	if (parameters.length == 0)
		return false;

	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:Java50Fix.java

示例15: guessBindingForTypeReference

import org.eclipse.jdt.core.dom.SimpleType; //导入依赖的package包/类
public static ITypeBinding guessBindingForTypeReference(ASTNode node) {
  	StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
  	if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) {
  		return null; // can't guess type for X.A
  	}
if (locationInParent == SimpleType.NAME_PROPERTY ||
		locationInParent == NameQualifiedType.NAME_PROPERTY) {
  		node= node.getParent();
  	}
  	ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node));
  	if (binding != null) {
  		if (binding.isWildcardType()) {
  			return normalizeWildcardType(binding, true, node.getAST());
  		}
  	}
  	return binding;
  }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:ASTResolving.java


注:本文中的org.eclipse.jdt.core.dom.SimpleType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。