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


Java ASTResolving.normalizeWildcardType方法代码示例

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


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

示例1: AssignToVariableAssistProposal

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public AssignToVariableAssistProposal(
    ICompilationUnit cu,
    int variableKind,
    ExpressionStatement node,
    ITypeBinding typeBinding,
    int relevance) {
  super("", cu, null, relevance, null); // $NON-NLS-1$

  fVariableKind = variableKind;
  fNodeToAssign = node;
  if (typeBinding.isWildcardType()) {
    typeBinding = ASTResolving.normalizeWildcardType(typeBinding, true, node.getAST());
  }

  fTypeBinding = typeBinding;
  if (variableKind == LOCAL) {
    setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntolocal_description);
    setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL));
  } else {
    setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntofield_description);
    setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE));
  }
  createImportRewrite((CompilationUnit) node.getRoot());
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:AssignToVariableAssistProposal.java

示例2: AssignToVariableAssistProposal

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public AssignToVariableAssistProposal(ICompilationUnit cu, int variableKind, ExpressionStatement node, ITypeBinding typeBinding, int relevance) {
	super("", cu, null, relevance, null); //$NON-NLS-1$

	fVariableKind= variableKind;
	fNodeToAssign= node;
	if (typeBinding.isWildcardType()) {
		typeBinding= ASTResolving.normalizeWildcardType(typeBinding, true, node.getAST());
	}

	fTypeBinding= typeBinding;
	if (variableKind == LOCAL) {
		setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntolocal_description);
		setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL));
	} else {
		setDisplayName(CorrectionMessages.AssignToVariableAssistProposal_assigntofield_description);
		setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE));
	}
	createImportRewrite((CompilationUnit) node.getRoot());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:AssignToVariableAssistProposal.java

示例3: getElementType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
/**
 * Returns the type of elements returned by the iterator.
 *
 * @param iterator the iterator type binding, or <code>null</code>
 * @return the element type
 */
private ITypeBinding getElementType(final ITypeBinding iterator) {
  if (iterator != null) {
    final ITypeBinding[] bindings = iterator.getTypeArguments();
    if (bindings.length > 0) {
      ITypeBinding arg = bindings[0];
      if (arg.isWildcardType()) {
        arg = ASTResolving.normalizeWildcardType(arg, true, getRoot().getAST());
      }
      return arg;
    }
  }
  return getRoot().getAST().resolveWellKnownType("java.lang.Object"); // $NON-NLS-1$
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ConvertIterableLoopOperation.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: 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$
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:NewMethodCorrectionProposal.java

示例6: getElementType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
/**
 * Returns the type of elements returned by the iterator.
 *
 * @param iterator
 *            the iterator type binding, or <code>null</code>
 * @return the element type
 */
private ITypeBinding getElementType(final ITypeBinding iterator) {
	if (iterator != null) {
		final ITypeBinding[] bindings= iterator.getTypeArguments();
		if (bindings.length > 0) {
			ITypeBinding arg= bindings[0];
			if (arg.isWildcardType()) {
				arg= ASTResolving.normalizeWildcardType(arg, true, getRoot().getAST());
			}
			return arg;
		}
	}
	return getRoot().getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ConvertIterableLoopOperation.java

示例7: 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$
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:NewMethodCorrectionProposal.java

示例8: 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.normalizeWildcardType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。