本文整理汇总了Java中org.eclipse.jdt.internal.ui.text.correction.ASTResolving.getRelaxingTypes方法的典型用法代码示例。如果您正苦于以下问题:Java ASTResolving.getRelaxingTypes方法的具体用法?Java ASTResolving.getRelaxingTypes怎么用?Java ASTResolving.getRelaxingTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.ui.text.correction.ASTResolving
的用法示例。
在下文中一共展示了ASTResolving.getRelaxingTypes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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$
}
示例2: evaluateType
import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private Type evaluateType(AST ast) {
ITypeBinding[] proposals = ASTResolving.getRelaxingTypes(ast, fTypeBinding);
for (int i = 0; i < proposals.length; i++) {
addLinkedPositionProposal(KEY_TYPE, proposals[i]);
}
ImportRewrite importRewrite = getImportRewrite();
CompilationUnit cuNode = (CompilationUnit) fNodeToAssign.getRoot();
ImportRewriteContext context =
new ContextSensitiveImportRewriteContext(
cuNode, fNodeToAssign.getStartPosition(), importRewrite);
return importRewrite.addImport(fTypeBinding, ast, context);
}
示例3: evaluateParameterType
import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private Type evaluateParameterType(
AST ast, Expression elem, String key, ImportRewriteContext context) {
ITypeBinding binding = Bindings.normalizeTypeBinding(elem.resolveTypeBinding());
if (binding != null && binding.isWildcardType()) {
binding = ASTResolving.normalizeWildcardType(binding, true, ast);
}
if (binding != null) {
ITypeBinding[] typeProposals = ASTResolving.getRelaxingTypes(ast, binding);
for (int i = 0; i < typeProposals.length; i++) {
addLinkedPositionProposal(key, typeProposals[i]);
}
return getImportRewrite().addImport(binding, ast, context);
}
return ast.newSimpleType(ast.newSimpleName("Object")); // $NON-NLS-1$
}
示例4: evaluateType
import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private Type evaluateType(AST ast) {
ITypeBinding[] proposals= ASTResolving.getRelaxingTypes(ast, fTypeBinding);
for (int i= 0; i < proposals.length; i++) {
addLinkedPositionProposal(KEY_TYPE, proposals[i]);
}
ImportRewrite importRewrite= getImportRewrite();
CompilationUnit cuNode= (CompilationUnit) fNodeToAssign.getRoot();
ImportRewriteContext context= new ContextSensitiveImportRewriteContext(cuNode, fNodeToAssign.getStartPosition(), importRewrite);
return importRewrite.addImport(fTypeBinding, ast, context);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:AssignToVariableAssistProposal.java
示例5: evaluateParameterType
import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private Type evaluateParameterType(AST ast, Expression elem, String key, ImportRewriteContext context) {
ITypeBinding binding= Bindings.normalizeTypeBinding(elem.resolveTypeBinding());
if (binding != null && binding.isWildcardType()) {
binding= ASTResolving.normalizeWildcardType(binding, true, ast);
}
if (binding != null) {
ITypeBinding[] typeProposals= ASTResolving.getRelaxingTypes(ast, binding);
for (int i= 0; i < typeProposals.length; i++) {
addLinkedPositionProposal(key, typeProposals[i]);
}
return getImportRewrite().addImport(binding, ast, context);
}
return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
}
示例6: fixupNames
import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private void fixupNames(ASTRewrite rewrite, ArrayList<String> usedNames) {
AST ast = rewrite.getAST();
// set names for new parameters
for (int i = 0; i < fParameterChanges.length; i++) {
ChangeDescription curr = fParameterChanges[i];
if (curr instanceof ModifyDescription) {
ModifyDescription desc = (ModifyDescription) curr;
String typeKey = getParamTypeGroupId(i);
String nameKey = getParamNameGroupId(i);
// collect name suggestions
String favourite = null;
String[] excludedNames = usedNames.toArray(new String[usedNames.size()]);
String suggestedName = desc.name;
if (suggestedName != null) {
favourite =
StubUtility.suggestArgumentName(
getCompilationUnit().getJavaProject(), suggestedName, excludedNames);
addLinkedPositionProposal(nameKey, favourite, null);
}
if (desc instanceof EditDescription) {
addLinkedPositionProposal(nameKey, ((EditDescription) desc).orginalName, null);
}
Type type = desc.resultingParamType;
String[] suggestedNames =
StubUtility.getArgumentNameSuggestions(
getCompilationUnit().getJavaProject(), type, excludedNames);
for (int k = 0; k < suggestedNames.length; k++) {
addLinkedPositionProposal(nameKey, suggestedNames[k], null);
}
if (favourite == null) {
favourite = suggestedNames[0];
}
usedNames.add(favourite);
SimpleName[] names = desc.resultingParamName;
for (int j = 0; j < names.length; j++) {
names[j].setIdentifier(favourite);
addLinkedPosition(rewrite.track(names[j]), false, nameKey);
}
addLinkedPosition(rewrite.track(desc.resultingParamType), true, typeKey);
// collect type suggestions
ITypeBinding[] bindings = ASTResolving.getRelaxingTypes(ast, desc.type);
for (int k = 0; k < bindings.length; k++) {
addLinkedPositionProposal(typeKey, bindings[k]);
}
SimpleName tagArg = desc.resultingTagArg;
if (tagArg != null) {
tagArg.setIdentifier(favourite);
addLinkedPosition(rewrite.track(tagArg), false, nameKey);
}
}
}
}
示例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
示例8: fixupNames
import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private void fixupNames(ASTRewrite rewrite, ArrayList<String> usedNames) {
AST ast= rewrite.getAST();
// set names for new parameters
for (int i= 0; i < fParameterChanges.length; i++) {
ChangeDescription curr= fParameterChanges[i];
if (curr instanceof ModifyDescription) {
ModifyDescription desc= (ModifyDescription) curr;
String typeKey= getParamTypeGroupId(i);
String nameKey= getParamNameGroupId(i);
// collect name suggestions
String favourite= null;
String[] excludedNames= usedNames.toArray(new String[usedNames.size()]);
String suggestedName= desc.name;
if (suggestedName != null) {
favourite= StubUtility.suggestArgumentName(getCompilationUnit().getJavaProject(), suggestedName, excludedNames);
addLinkedPositionProposal(nameKey, favourite, null);
}
if (desc instanceof EditDescription) {
addLinkedPositionProposal(nameKey, ((EditDescription)desc).orginalName, null);
}
Type type= desc.resultingParamType;
String[] suggestedNames= StubUtility.getArgumentNameSuggestions(getCompilationUnit().getJavaProject(), type, excludedNames);
for (int k= 0; k < suggestedNames.length; k++) {
addLinkedPositionProposal(nameKey, suggestedNames[k], null);
}
if (favourite == null) {
favourite= suggestedNames[0];
}
usedNames.add(favourite);
SimpleName[] names= desc.resultingParamName;
for (int j= 0; j < names.length; j++) {
names[j].setIdentifier(favourite);
addLinkedPosition(rewrite.track(names[j]), false, nameKey);
}
addLinkedPosition(rewrite.track(desc.resultingParamType), true, typeKey);
// collect type suggestions
ITypeBinding[] bindings= ASTResolving.getRelaxingTypes(ast, desc.type);
for (int k= 0; k < bindings.length; k++) {
addLinkedPositionProposal(typeKey, bindings[k]);
}
SimpleName tagArg= desc.resultingTagArg;
if (tagArg != null) {
tagArg.setIdentifier(favourite);
addLinkedPosition(rewrite.track(tagArg), false, nameKey);
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:58,代码来源:ChangeMethodSignatureProposal.java