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


Java ASTResolving.guessBindingForReference方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.text.correction.ASTResolving.guessBindingForReference方法的典型用法代码示例。如果您正苦于以下问题:Java ASTResolving.guessBindingForReference方法的具体用法?Java ASTResolving.guessBindingForReference怎么用?Java ASTResolving.guessBindingForReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.ui.text.correction.ASTResolving的用法示例。


在下文中一共展示了ASTResolving.guessBindingForReference方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkExpressionIsRValue

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
/**
 * @param e
 * @return int Checks.IS_RVALUE if e is an rvalue Checks.IS_RVALUE_GUESSED if e is guessed as an
 *     rvalue Checks.NOT_RVALUE_VOID if e is not an rvalue because its type is void
 *     Checks.NOT_RVALUE_MISC if e is not an rvalue for some other reason
 */
public static int checkExpressionIsRValue(Expression e) {
  if (e instanceof Name) {
    if (!(((Name) e).resolveBinding() instanceof IVariableBinding)) {
      return NOT_RVALUE_MISC;
    }
  }
  if (e instanceof Annotation) return NOT_RVALUE_MISC;

  ITypeBinding tb = e.resolveTypeBinding();
  boolean guessingRequired = false;
  if (tb == null) {
    guessingRequired = true;
    tb = ASTResolving.guessBindingForReference(e);
  }
  if (tb == null) return NOT_RVALUE_MISC;
  else if (tb.getName().equals("void")) // $NON-NLS-1$
  return NOT_RVALUE_VOID;

  return guessingRequired ? IS_RVALUE_GUESSED : IS_RVALUE;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:Checks.java

示例2: checkExpressionIsRValue

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
/**
 * @param e
 * @return int
 *          Checks.IS_RVALUE			if e is an rvalue
 *          Checks.IS_RVALUE_GUESSED	if e is guessed as an rvalue
 *          Checks.NOT_RVALUE_VOID  	if e is not an rvalue because its type is void
 *          Checks.NOT_RVALUE_MISC  	if e is not an rvalue for some other reason
 */
public static int checkExpressionIsRValue(Expression e) {
	if (e instanceof Name) {
		if(!(((Name) e).resolveBinding() instanceof IVariableBinding)) {
			return NOT_RVALUE_MISC;
		}
	}
	if (e instanceof Annotation)
		return NOT_RVALUE_MISC;
		

	ITypeBinding tb= e.resolveTypeBinding();
	boolean guessingRequired= false;
	if (tb == null) {
		guessingRequired= true;
		tb= ASTResolving.guessBindingForReference(e);
	}
	if (tb == null)
		return NOT_RVALUE_MISC;
	else if (tb.getName().equals("void")) //$NON-NLS-1$
		return NOT_RVALUE_VOID;

	return guessingRequired ? IS_RVALUE_GUESSED : IS_RVALUE;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:Checks.java

示例3: guessBindingForReference

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private ITypeBinding guessBindingForReference(Expression expression) {
  ITypeBinding binding = expression.resolveTypeBinding();
  if (binding == null) {
    binding = ASTResolving.guessBindingForReference(expression);
  }
  return binding;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:ExtractTempRefactoring.java

示例4: evaluateVariableType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private Type evaluateVariableType(
    AST ast,
    ImportRewrite imports,
    ImportRewriteContext importRewriteContext,
    IBinding targetContext) {
  if (fOriginalNode.getParent() instanceof MethodInvocation) {
    MethodInvocation parent = (MethodInvocation) fOriginalNode.getParent();
    if (parent.getExpression() == fOriginalNode) {
      // _x_.foo() -> guess qualifier type by looking for a type with method 'foo'
      ITypeBinding[] bindings =
          ASTResolving.getQualifierGuess(
              fOriginalNode.getRoot(),
              parent.getName().getIdentifier(),
              parent.arguments(),
              targetContext);
      if (bindings.length > 0) {
        for (int i = 0; i < bindings.length; i++) {
          addLinkedPositionProposal(KEY_TYPE, bindings[i]);
        }
        return imports.addImport(bindings[0], ast, importRewriteContext);
      }
    }
  }

  ITypeBinding binding = ASTResolving.guessBindingForReference(fOriginalNode);
  if (binding != null) {
    if (binding.isWildcardType()) {
      binding = ASTResolving.normalizeWildcardType(binding, isVariableAssigned(), ast);
      if (binding == null) {
        // only null binding applies
        binding = ast.resolveWellKnownType("java.lang.Object"); // $NON-NLS-1$
      }
    }

    if (isVariableAssigned()) {
      ITypeBinding[] typeProposals = ASTResolving.getRelaxingTypes(ast, binding);
      for (int i = 0; i < typeProposals.length; i++) {
        addLinkedPositionProposal(KEY_TYPE, typeProposals[i]);
      }
    }
    return imports.addImport(binding, ast, importRewriteContext);
  }
  // no binding, find type AST node instead -> ABC a= x-> use 'ABC' as is
  Type type = ASTResolving.guessTypeForReference(ast, fOriginalNode);
  if (type != null) {
    return type;
  }
  if (fVariableKind == CONST_FIELD) {
    return ast.newSimpleType(ast.newSimpleName("String")); // $NON-NLS-1$
  }
  return ast.newSimpleType(ast.newSimpleName("Object")); // $NON-NLS-1$
}
 
开发者ID:eclipse,项目名称:che,代码行数:53,代码来源:NewVariableCorrectionProposal.java

示例5: guessBindingForReference

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private ITypeBinding guessBindingForReference(Expression expression) {
	ITypeBinding binding= expression.resolveTypeBinding();
	if (binding == null) {
		binding= ASTResolving.guessBindingForReference(expression);
	}
	return binding;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:ExtractTempRefactoring.java

示例6: createTempType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private Type createTempType() throws CoreException {
	Expression expression= getSelectedExpression().getAssociatedExpression();

	Type resultingType= null;
	ITypeBinding typeBinding= expression.resolveTypeBinding();

	ASTRewrite rewrite= fCURewrite.getASTRewrite();
	AST ast= rewrite.getAST();

	if (expression instanceof ClassInstanceCreation && (typeBinding == null || typeBinding.getTypeArguments().length == 0)) {
		resultingType= (Type) rewrite.createCopyTarget(((ClassInstanceCreation) expression).getType());
	} else if (expression instanceof CastExpression) {
		resultingType= (Type) rewrite.createCopyTarget(((CastExpression) expression).getType());
	} else {
		if (typeBinding == null) {
			typeBinding= ASTResolving.guessBindingForReference(expression);
		}
		if (typeBinding != null) {
			typeBinding= Bindings.normalizeForDeclarationUse(typeBinding, ast);
			ImportRewrite importRewrite= fCURewrite.getImportRewrite();
			ImportRewriteContext context= new ContextSensitiveImportRewriteContext(expression, importRewrite);
			resultingType= importRewrite.addImport(typeBinding, ast, context);
		} else {
			resultingType= ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
		}
	}
	if (fLinkedProposalModel != null) {
		LinkedProposalPositionGroup typeGroup= fLinkedProposalModel.getPositionGroup(KEY_TYPE, true);
		typeGroup.addPosition(rewrite.track(resultingType), false);
		if (typeBinding != null) {
			ITypeBinding[] relaxingTypes= ASTResolving.getNarrowingTypes(ast, typeBinding);
			for (int i= 0; i < relaxingTypes.length; i++) {
				typeGroup.addProposal(relaxingTypes[i], fCURewrite.getCu(), relaxingTypes.length - i);
			}
		}
	}
	return resultingType;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:ExtractTempRefactoring.java

示例7: evaluateVariableType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private Type evaluateVariableType(AST ast, ImportRewrite imports, ImportRewriteContext importRewriteContext, IBinding targetContext) {
	if (fOriginalNode.getParent() instanceof MethodInvocation) {
		MethodInvocation parent= (MethodInvocation) fOriginalNode.getParent();
		if (parent.getExpression() == fOriginalNode) {
			// _x_.foo() -> guess qualifier type by looking for a type with method 'foo'
			ITypeBinding[] bindings= ASTResolving.getQualifierGuess(fOriginalNode.getRoot(), parent.getName().getIdentifier(), parent.arguments(), targetContext);
			if (bindings.length > 0) {
				for (int i= 0; i < bindings.length; i++) {
					addLinkedPositionProposal(KEY_TYPE, bindings[i]);
				}
				return imports.addImport(bindings[0], ast, importRewriteContext);
			}
		}
	}

	ITypeBinding binding= ASTResolving.guessBindingForReference(fOriginalNode);
	if (binding != null) {
		if (binding.isWildcardType()) {
			binding= ASTResolving.normalizeWildcardType(binding, isVariableAssigned(), ast);
			if (binding == null) {
				// only null binding applies
				binding= ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
			}
		}

		if (isVariableAssigned()) {
			ITypeBinding[] typeProposals= ASTResolving.getRelaxingTypes(ast, binding);
			for (int i= 0; i < typeProposals.length; i++) {
				addLinkedPositionProposal(KEY_TYPE, typeProposals[i]);
			}
		}
		return imports.addImport(binding, ast, importRewriteContext);
	}
	// no binding, find type AST node instead -> ABC a= x-> use 'ABC' as is
	Type type= ASTResolving.guessTypeForReference(ast, fOriginalNode);
	if (type != null) {
		return type;
	}
	if (fVariableKind == CONST_FIELD) {
		return ast.newSimpleType(ast.newSimpleName("String")); //$NON-NLS-1$
	}
	return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:NewVariableCorrectionProposal.java


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