protected void addException(ITypeBinding exception, AST ast) { exception = Bindings.normalizeForDeclarationUse(exception, ast); if (!fCurrentExceptions.contains(exception)) { fCurrentExceptions.add(exception); } }
protected void addException(ITypeBinding exception, AST ast) { exception= Bindings.normalizeForDeclarationUse(exception, ast); if (!fCurrentExceptions.contains(exception)) fCurrentExceptions.add(exception); }
protected void addException(ITypeBinding exception, AST ast) { exception= Bindings.normalizeForDeclarationUse(exception, ast); if (!fCurrentExceptions.contains(exception)) fCurrentExceptions.add(exception); }
private List<String> guessTempNamesFromExpression(Expression selectedExpression, String[] excluded) { ITypeBinding expressionBinding= Bindings.normalizeForDeclarationUse( selectedExpression.resolveTypeBinding(), selectedExpression.getAST()); String typeName= getQualifiedName(expressionBinding); if (typeName.length() == 0) typeName= expressionBinding.getName(); if (typeName.length() == 0) return Collections.emptyList(); int typeParamStart= typeName.indexOf("<"); //$NON-NLS-1$ if (typeParamStart != -1) typeName= typeName.substring(0, typeParamStart); String[] proposals= StubUtility.getLocalNameSuggestions(fSourceCU.getJavaProject(), typeName, expressionBinding.getDimensions(), excluded); return Arrays.asList(proposals); }
private List<String> guessTempNamesFromExpression(Expression selectedExpression, String[] excluded) { ITypeBinding expressionBinding= Bindings.normalizeForDeclarationUse( selectedExpression.resolveTypeBinding(), selectedExpression.getAST()); String typeName= getQualifiedName(expressionBinding); if (typeName.length() == 0) typeName= expressionBinding.getName(); if (typeName.length() == 0) return Collections.emptyList(); int typeParamStart= typeName.indexOf("<"); //$NON-NLS-1$ if (typeParamStart != -1) typeName= typeName.substring(0, typeParamStart); String[] proposals= StubUtility.getLocalNameSuggestions(fSourceCU.getJavaProject(), typeName, expressionBinding.getDimensions(), excluded); return Arrays.asList(proposals); }
private List/*<String>*/ guessTempNamesFromExpression(Expression selectedExpression, String[] excluded) { ITypeBinding expressionBinding= Bindings.normalizeForDeclarationUse( selectedExpression.resolveTypeBinding(), selectedExpression.getAST()); String typeName= getQualifiedName(expressionBinding); if (typeName.length() == 0) typeName= expressionBinding.getName(); if (typeName.length() == 0) return Collections.EMPTY_LIST; int typeParamStart= typeName.indexOf("<"); //$NON-NLS-1$ if (typeParamStart != -1) typeName= typeName.substring(0, typeParamStart); String[] proposals= StubUtility.getLocalNameSuggestions(fSourceCU.getJavaProject(), typeName, expressionBinding.getDimensions(), excluded); return Arrays.asList(proposals); }
/** * Extracts the type parameter of the variable contained in fCurrentExpression or the elements * type to iterate over an array using <code>foreach</code>. * * @param ast the current {@link AST} instance * @return the {@link ITypeBinding} of the elements to iterate over */ private ITypeBinding extractType(AST ast) { if (fExpressionType.isArray()) { return Bindings.normalizeForDeclarationUse(fExpressionType.getComponentType(), ast); } // extract elements type directly out of the bindings IMethodBinding iteratorMethodBinding= Bindings.findMethodInHierarchy(fExpressionType, "iterator", new ITypeBinding[] {}); //$NON-NLS-1$ IMethodBinding iteratorNextMethodBinding= Bindings.findMethodInHierarchy(iteratorMethodBinding.getReturnType(), "next", new ITypeBinding[] {}); //$NON-NLS-1$ ITypeBinding currentElementBinding= iteratorNextMethodBinding.getReturnType(); return Bindings.normalizeForDeclarationUse(currentElementBinding, ast); }
/** * Extracts the type parameter of the variable contained in fCurrentExpression or the elements * type to iterate over an array using <code>foreach</code>. * * @param ast the current {@link AST} instance * @return the {@link ITypeBinding} of the elements to iterate over */ private ITypeBinding extractType(AST ast) { if (fExpressionType.isArray()) { return Bindings.normalizeForDeclarationUse(fExpressionType.getComponentType(), ast); } // extract elements type directly out of the bindings IMethodBinding iteratorMethodBinding= Bindings.findMethodInHierarchy(fExpressionType, "iterator", new ITypeBinding[] {}); //$NON-NLS-1$ IMethodBinding iteratorNextMethodBinding= Bindings.findMethodInHierarchy(iteratorMethodBinding.getReturnType(), "next", new ITypeBinding[] {}); //$NON-NLS-1$ ITypeBinding currentElementBinding= iteratorNextMethodBinding.getReturnType(); return Bindings.normalizeForDeclarationUse(currentElementBinding, ast); }
private void addParameterInfo(CompilationUnitRewrite cuRewrite) throws JavaModelException { ITypeBinding typeBinding= Bindings.normalizeForDeclarationUse(fSelectedExpression.resolveTypeBinding(), fSelectedExpression.getAST()); String typeName= cuRewrite.getImportRewrite().addImport(typeBinding); String name= fParameterName != null ? fParameterName : guessedParameterName(); String defaultValue= fSourceCU.getBuffer().getText(fSelectedExpression.getStartPosition(), fSelectedExpression.getLength()); fParameter= ParameterInfo.createInfoForAddedParameter(typeBinding, typeName, name, defaultValue); if (fArguments == null) { List parameterInfos= fChangeSignatureRefactoring.getParameterInfos(); int parametersCount= parameterInfos.size(); if (parametersCount > 0 && ((ParameterInfo) parameterInfos.get(parametersCount - 1)).isOldVarargs()) parameterInfos.add(parametersCount - 1, fParameter); else parameterInfos.add(fParameter); } }
public AssignToVariableAssistProposal(ICompilationUnit cu, int variableKind, ExpressionStatement node, ITypeBinding typeBinding, int relevance) { super("", cu, null, relevance, null); //$NON-NLS-1$ fVariableKind= variableKind; fNodesToAssign= new ArrayList<>(); fNodesToAssign.add(node); fTypeBinding= Bindings.normalizeForDeclarationUse(typeBinding, node.getAST()); 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()); }
private Type getConstantType() throws JavaModelException { if (fConstantTypeCache == null) { IExpressionFragment fragment= getSelectedExpression(); ITypeBinding typeBinding= fragment.getAssociatedExpression().resolveTypeBinding(); AST ast= fCuRewrite.getAST(); typeBinding= Bindings.normalizeForDeclarationUse(typeBinding, ast); fConstantTypeCache= fCuRewrite.getImportRewrite().addImport(typeBinding, ast); } return fConstantTypeCache; }
private Type getConstantType() throws JavaModelException { if (fConstantTypeCache == null) { IExpressionFragment fragment = getSelectedExpression(); ITypeBinding typeBinding = guessBindingForReference(fragment.getAssociatedExpression()); AST ast = fCuRewrite.getAST(); typeBinding = Bindings.normalizeForDeclarationUse(typeBinding, ast); ImportRewrite importRewrite = fCuRewrite.getImportRewrite(); ImportRewriteContext context = new ContextSensitiveImportRewriteContext(fCuRewrite.getRoot(), fSelectionStart, importRewrite); fConstantTypeCache = importRewrite.addImport(typeBinding, ast, context, TypeLocation.FIELD); } return fConstantTypeCache; }
private Type getConstantType() throws JavaModelException { if (fConstantTypeCache == null) { IExpressionFragment fragment= getSelectedExpression(); ITypeBinding typeBinding= guessBindingForReference(fragment.getAssociatedExpression()); AST ast= fCuRewrite.getAST(); typeBinding= Bindings.normalizeForDeclarationUse(typeBinding, ast); ImportRewrite importRewrite= fCuRewrite.getImportRewrite(); ImportRewriteContext context= new ContextSensitiveImportRewriteContext(fCuRewrite.getRoot(), fSelectionStart, importRewrite); fConstantTypeCache= importRewrite.addImport(typeBinding, ast, context, TypeLocation.FIELD); } return fConstantTypeCache; }
private Type getConstantType() throws JavaModelException { if (fConstantTypeCache == null) { IExpressionFragment fragment= getSelectedExpression(); ITypeBinding typeBinding= guessBindingForReference(fragment.getAssociatedExpression()); AST ast= fCuRewrite.getAST(); typeBinding= Bindings.normalizeForDeclarationUse(typeBinding, ast); ImportRewrite importRewrite= fCuRewrite.getImportRewrite(); ImportRewriteContext context= new ContextSensitiveImportRewriteContext(fCuRewrite.getRoot(), fSelectionStart, importRewrite); fConstantTypeCache= importRewrite.addImport(typeBinding, ast, context); } return fConstantTypeCache; }
private void addParameterInfo(CompilationUnitRewrite cuRewrite) throws JavaModelException { ITypeBinding typeBinding= Bindings.normalizeForDeclarationUse(fSelectedExpression.resolveTypeBinding(), fSelectedExpression.getAST()); String name= fParameterName != null ? fParameterName : guessedParameterName(); Expression expression= fSelectedExpression instanceof ParenthesizedExpression ? ((ParenthesizedExpression)fSelectedExpression).getExpression() : fSelectedExpression;
private void addParameterInfo(CompilationUnitRewrite cuRewrite) throws JavaModelException { ITypeBinding typeBinding= Bindings.normalizeForDeclarationUse(fSelectedExpression.resolveTypeBinding(), fSelectedExpression.getAST()); String name= fParameterName != null ? fParameterName : guessedParameterName(); Expression expression= fSelectedExpression instanceof ParenthesizedExpression ? ((ParenthesizedExpression)fSelectedExpression).getExpression() : fSelectedExpression;
return binding; if (binding.isArray()) return normalizeForDeclarationUse(binding.getComponentType(), ast).createArrayType(1); if (!binding.isWildcardType()) return binding;
typeBinding= Bindings.normalizeForDeclarationUse(typeBinding, ast); resultingType= fCURewrite.getImportRewrite().addImport(typeBinding, ast); } else {
typeBinding = Bindings.normalizeForDeclarationUse(typeBinding, ast); ImportRewrite importRewrite = fCURewrite.getImportRewrite(); ImportRewriteContext context = new ContextSensitiveImportRewriteContext(expression, importRewrite);
typeBinding= Bindings.normalizeForDeclarationUse(typeBinding, ast); ImportRewrite importRewrite= fCURewrite.getImportRewrite(); ImportRewriteContext context= new ContextSensitiveImportRewriteContext(expression, importRewrite);