本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding類的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding類的具體用法?Java ITypeBinding怎麽用?Java ITypeBinding使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ITypeBinding類屬於org.eclipse.jdt.core.dom包,在下文中一共展示了ITypeBinding類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNewCastTypeNode
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
private Type getNewCastTypeNode(ASTRewrite rewrite, ImportRewrite importRewrite) {
AST ast= rewrite.getAST();
ImportRewriteContext context= new ContextSensitiveImportRewriteContext((CompilationUnit) fNodeToCast.getRoot(), fNodeToCast.getStartPosition(), importRewrite);
if (fCastType != null) {
return importRewrite.addImport(fCastType, ast,context, TypeLocation.CAST);
}
ASTNode node= fNodeToCast;
ASTNode parent= node.getParent();
if (parent instanceof CastExpression) {
node= parent;
parent= parent.getParent();
}
while (parent instanceof ParenthesizedExpression) {
node= parent;
parent= parent.getParent();
}
if (parent instanceof MethodInvocation) {
MethodInvocation invocation= (MethodInvocation) node.getParent();
if (invocation.getExpression() == node) {
IBinding targetContext= ASTResolving.getParentMethodOrTypeBinding(node);
ITypeBinding[] bindings= ASTResolving.getQualifierGuess(node.getRoot(), invocation.getName().getIdentifier(), invocation.arguments(), targetContext);
if (bindings.length > 0) {
ITypeBinding first= getCastFavorite(bindings, fNodeToCast.resolveTypeBinding());
Type newTypeNode= importRewrite.addImport(first, ast, context, TypeLocation.CAST);
return newTypeNode;
}
}
}
Type newCastType= ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
return newCastType;
}
示例2: isContext
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
private static boolean isContext(ITypeBinding tbinding) {
String executionContextClass = org.graphwalker.core.machine.ExecutionContext.class.getName();
String contextClass = org.graphwalker.core.machine.Context.class.getName();
while (tbinding != null) {
String clazz = tbinding.getQualifiedName();
if (executionContextClass.equals(clazz))
return true;
if (contextClass.equals(clazz))
return true;
ITypeBinding[] interfaces = tbinding.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
ITypeBinding interf = interfaces[i];
if (contextClass.equals(interf.getQualifiedName()))
return true;
}
tbinding = tbinding.getSuperclass();
}
return false;
}
示例3: handleTypeBinding
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
private void handleTypeBinding(ASTNode node, ITypeBinding typeBinding, boolean includeTypeParameters) {
if (typeBinding == null) {
StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
//System.out.println(locationInParent.getId() + " has no type binding");
} else {
List<ITypeBinding> rawTypes = new ArrayList<ITypeBinding>();
Set<String> dejavu = new HashSet<String>();
this.appendRawTypes(rawTypes, dejavu, typeBinding, includeTypeParameters);
for (ITypeBinding rawType : rawTypes) {
if (!this.ignoreType(rawType)) {
this.onTypeAccess(node, rawType);
}
}
}
}
示例4: getKeyFromMethodBinding
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
public static String getKeyFromMethodBinding(IMethodBinding binding) {
StringBuilder sb = new StringBuilder();
String className = binding.getDeclaringClass().getErasure().getQualifiedName();
sb.append(className);
sb.append('.');
String methodName = binding.isConstructor() ? "" : binding.getName();
sb.append(methodName);
//if (methodName.equals("allObjectsSorted")) {
// System.out.println();
//}
sb.append('(');
ITypeBinding[] parameters = binding.getParameterTypes();
for (int i = 0; i < parameters.length; i++) {
if (i > 0) {
sb.append(", ");
}
ITypeBinding type = parameters[i];
sb.append(type.getErasure().getName());
}
sb.append(')');
return sb.toString();
}
示例5: getKeyFromMethodBinding
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
public static String getKeyFromMethodBinding(IMethodBinding binding) {
StringBuilder sb = new StringBuilder();
String className = binding.getDeclaringClass().getErasure().getQualifiedName();
sb.append(className);
sb.append('#');
String methodName = binding.isConstructor() ? "" : binding.getName();
sb.append(methodName);
//if (methodName.equals("allObjectsSorted")) {
// System.out.println();
//}
sb.append('(');
ITypeBinding[] parameters = binding.getParameterTypes();
for (int i = 0; i < parameters.length; i++) {
if (i > 0) {
sb.append(", ");
}
ITypeBinding type = parameters[i];
sb.append(type.getErasure().getName());
}
sb.append(')');
return sb.toString();
}
示例6: visit
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
public boolean visit(CastExpression node) {
if (mtbStack.isEmpty()) // not part of a method
return true;
Expression expression = node.getExpression();
ITypeBinding type = node.getType().resolveBinding();
IMethodBinding mtb = mtbStack.peek();
String exprStr = expression.toString();
String typeStr = getQualifiedName(type);
String methodStr = getQualifiedName(mtb);
exprStr = edit_str(exprStr);
facts.add(Fact.makeCastFact(exprStr, typeStr, methodStr));
return true;
}
示例7: getInvalidQualificationProposals
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
public static void getInvalidQualificationProposals(IInvocationContext context, IProblemLocation problem,
Collection<CUCorrectionProposal> proposals) {
ASTNode node= problem.getCoveringNode(context.getASTRoot());
if (!(node instanceof Name)) {
return;
}
Name name= (Name) node;
IBinding binding= name.resolveBinding();
if (!(binding instanceof ITypeBinding)) {
return;
}
ITypeBinding typeBinding= (ITypeBinding)binding;
AST ast= node.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
rewrite.replace(name, ast.newName(typeBinding.getQualifiedName()), null);
String label= CorrectionMessages.JavadocTagsSubProcessor_qualifylinktoinner_description;
ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(),
rewrite, IProposalRelevance.QUALIFY_INNER_TYPE_NAME);
proposals.add(proposal);
}
示例8: createName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
static void createName(ITypeBinding type, boolean includePackage,
List<String> list) {
ITypeBinding baseType = type;
if (type.isArray()) {
baseType = type.getElementType();
}
if (!baseType.isPrimitive() && !baseType.isNullType()) {
ITypeBinding declaringType = baseType.getDeclaringClass();
if (declaringType != null) {
createName(declaringType, includePackage, list);
} else if (includePackage && !baseType.getPackage().isUnnamed()) {
String[] components = baseType.getPackage().getNameComponents();
for (int i = 0; i < components.length; i++) {
list.add(components[i]);
}
}
}
if (!baseType.isAnonymous()) {
list.add(type.getName());
} else {
list.add("$local$"); //$NON-NLS-1$
}
}
示例9: getUniqueMethodName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
private static String getUniqueMethodName(ASTNode astNode, String suggestedName) throws JavaModelException {
while (astNode != null && !(astNode instanceof TypeDeclaration)) {
astNode = astNode.getParent();
}
if (astNode instanceof TypeDeclaration) {
ITypeBinding typeBinding = ((TypeDeclaration) astNode).resolveBinding();
if (typeBinding == null) {
return suggestedName;
}
IType type = (IType) typeBinding.getJavaElement();
if (type == null) {
return suggestedName;
}
IMethod[] methods = type.getMethods();
int suggestedPostfix = 2;
String resultName = suggestedName;
while (suggestedPostfix < 1000) {
if (!hasMethod(methods, resultName)) {
return resultName;
}
resultName = suggestedName + suggestedPostfix++;
}
}
return suggestedName;
}
示例10: addParameterMissmatchProposals
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
private static void addParameterMissmatchProposals(IInvocationContext context, IProblemLocation problem,
List<IMethodBinding> similarElements, ASTNode invocationNode, List<Expression> arguments,
Collection<CUCorrectionProposal> proposals) throws CoreException {
int nSimilarElements= similarElements.size();
ITypeBinding[] argTypes= getArgumentTypes(arguments);
if (argTypes == null || nSimilarElements == 0) {
return;
}
for (int i= 0; i < nSimilarElements; i++) {
IMethodBinding elem = similarElements.get(i);
int diff= elem.getParameterTypes().length - argTypes.length;
if (diff == 0) {
int nProposals= proposals.size();
doEqualNumberOfParameters(context, invocationNode, problem, arguments, argTypes, elem, proposals);
if (nProposals != proposals.size()) {
return; // only suggest for one method (avoid duplicated proposals)
}
} else if (diff > 0) {
doMoreParameters(context, invocationNode, argTypes, elem, proposals);
} else {
doMoreArguments(context, invocationNode, arguments, argTypes, elem, proposals);
}
}
}
示例11: typeFtoA
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
/**
* Perform generic type substitution...
* Currently, just uses string substitution.
* Could be problematic (e.g., if it constructs invalid types).
*
* @return
*/
public static String typeFtoA(ITypeBinding typeBinding) {
String formalType = "";
if(typeBinding.isParameterizedType()){
ITypeBinding genericTypeBinding = typeBinding.getTypeDeclaration();
ITypeBinding[] typeArguments = typeBinding.getTypeArguments();
ITypeBinding[] typeParameters = genericTypeBinding.getTypeParameters();
formalType = typeBinding.getQualifiedName();
int i =0;
for (ITypeBinding iTypeBinding : typeParameters) {
String typeParameterName = iTypeBinding.getQualifiedName();
String typeArgumentName = typeArguments[i].getQualifiedName();
formalType = formalType.replace(typeArgumentName, typeParameterName);
}
}
else{
formalType = typeBinding.getQualifiedName();
}
return formalType;
}
示例12: isMethodCompatible
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
public static boolean isMethodCompatible(MethodDeclaration methodDeclaration) {
Crystal instance = Crystal.getInstance();
TypeDeclaration enclosingType = methodDeclaration.enclosingType;
if(enclosingType!=null){
ITypeBinding typeBinding = instance
.getTypeBindingFromName(enclosingType
.getFullyQualifiedName());
for(IMethodBinding methodBinding : typeBinding.getDeclaredMethods()){
if(methodDeclaration.methodName.compareTo(methodBinding.getName()) == 0){
if(!isMethodCompatible(methodBinding)){
return false;
}
}
}
}
return true;
}
示例13: asString
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
private static String asString(IMethodBinding method) {
StringBuffer result= new StringBuffer();
result.append(method.getDeclaringClass().getName());
result.append(':');
result.append(method.getName());
result.append('(');
ITypeBinding[] parameters= method.getParameterTypes();
int lastComma= parameters.length - 1;
for (int i= 0; i < parameters.length; i++) {
ITypeBinding parameter= parameters[i];
result.append(parameter.getName());
if (i < lastComma)
{
result.append(", "); //$NON-NLS-1$
}
}
result.append(')');
return result.toString();
}
示例14: createFrom
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
public static ast.TypeDeclaration createFrom(ITypeBinding typeBinding){
ast.TypeDeclaration retNode = null;
Adapter factory = Adapter.getInstance();
AstNode astNode = factory.get(typeBinding);
if(astNode instanceof ast.TypeDeclaration){
retNode = (ast.TypeDeclaration)astNode;
}else{
retNode = ast.TypeDeclaration.create();
retNode.type = TraceabilityFactory.getType(typeBinding);
retNode.fields = TraceabilityFactory.getDeclaredFields(typeBinding);
factory.map(typeBinding, retNode);
// typeBinding.getQualifiedName()
// XXX. Has the name been set yet?
factory.mapTypeDeclaration(retNode);
}
return retNode;
}
示例15: pinDownInner
import org.eclipse.jdt.core.dom.ITypeBinding; //導入依賴的package包/類
/**
* A method to pin down inner of the qualifiers of a generic type
*
*/
private void pinDownInner() {
// TODO Auto-generated method stub
TM tm = currentTM.copyTypeMapping(currentTM.getKey());
for (Variable var : tm.keySet()) {
if(var instanceof TACNewExpr){
TACNewExpr newExprVar = (TACNewExpr)var;
ITypeBinding instantiatedType = newExprVar.resolveType();
if(instantiatedType.isParameterizedType()){
Set<OType> varSet = new HashSet<OType>(tm.getAnalysisResult(var));
if(varSet.size()>1){
RankingStrategy ranking = RankingStrategy.getInstance();
OType highestQualifier = ranking.pickFromSet(varSet, null);
varSet.clear();
varSet.add(highestQualifier);
tm.putTypeMapping(var, varSet);
TM newTM = runTFs(tm);
if(!newTM.isDiscarded){
currentTM = newTM;
}
}
}
}
}
}