本文整理汇总了Java中org.eclipse.jdt.ui.text.java.IInvocationContext.getCoveringNode方法的典型用法代码示例。如果您正苦于以下问题:Java IInvocationContext.getCoveringNode方法的具体用法?Java IInvocationContext.getCoveringNode怎么用?Java IInvocationContext.getCoveringNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.ui.text.java.IInvocationContext
的用法示例。
在下文中一共展示了IInvocationContext.getCoveringNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addUnknownSuppressWarningProposals
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入方法依赖的package包/类
/**
* Adds a proposal to correct the name of the SuppressWarning annotation
*
* @param context the context
* @param problem the problem
* @param proposals the resulting proposals
*/
public static void addUnknownSuppressWarningProposals(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ASTNode coveringNode = context.getCoveringNode();
if (!(coveringNode instanceof StringLiteral)) return;
AST ast = coveringNode.getAST();
StringLiteral literal = (StringLiteral) coveringNode;
String literalValue = literal.getLiteralValue();
String[] allWarningTokens = CorrectionEngine.getAllWarningTokens();
for (int i = 0; i < allWarningTokens.length; i++) {
String curr = allWarningTokens[i];
if (NameMatcher.isSimilarName(literalValue, curr)) {
StringLiteral newLiteral = ast.newStringLiteral();
newLiteral.setLiteralValue(curr);
ASTRewrite rewrite = ASTRewrite.create(ast);
rewrite.replace(literal, newLiteral, null);
String label =
Messages.format(
CorrectionMessages.SuppressWarningsSubProcessor_fix_suppress_token_label,
new String[] {curr});
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal =
new ASTRewriteCorrectionProposal(
label,
context.getCompilationUnit(),
rewrite,
IProposalRelevance.FIX_SUPPRESS_TOKEN,
image);
proposals.add(proposal);
}
}
addRemoveUnusedSuppressWarningProposals(context, problem, proposals);
}
示例2: hasAssists
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入方法依赖的package包/类
public boolean hasAssists(IInvocationContext context) throws CoreException {
ASTNode coveringNode = context.getCoveringNode();
if (coveringNode != null) {
ArrayList<ASTNode> coveredNodes = getFullyCoveredNodes(context, coveringNode);
return getConvertToIfReturnProposals(context, coveringNode, null)
|| getInverseIfProposals(context, coveringNode, null)
|| getIfReturnIntoIfElseAtEndOfVoidMethodProposals(context, coveringNode, null)
|| getInverseIfContinueIntoIfThenInLoopsProposals(context, coveringNode, null)
|| getInverseIfIntoContinueInLoopsProposals(context, coveringNode, null)
|| getInverseConditionProposals(context, coveringNode, coveredNodes, null)
|| getRemoveExtraParenthesesProposals(context, coveringNode, coveredNodes, null)
|| getAddParanoidalParenthesesProposals(context, coveredNodes, null)
|| getAddParenthesesForExpressionProposals(context, coveringNode, null)
|| getJoinAndIfStatementsProposals(context, coveringNode, null)
|| getSplitAndConditionProposals(context, coveringNode, null)
|| getJoinOrIfStatementsProposals(context, coveringNode, coveredNodes, null)
|| getSplitOrConditionProposals(context, coveringNode, null)
|| getInverseConditionalExpressionProposals(context, coveringNode, null)
|| getExchangeInnerAndOuterIfConditionsProposals(context, coveringNode, null)
|| getExchangeOperandsProposals(context, coveringNode, null)
|| getCastAndAssignIfStatementProposals(context, coveringNode, null)
|| getCombineStringProposals(context, coveringNode, null)
|| getPickOutStringProposals(context, coveringNode, null)
|| getReplaceIfElseWithConditionalProposals(context, coveringNode, null)
|| getReplaceConditionalWithIfElseProposals(context, coveringNode, null)
|| getInverseLocalVariableProposals(context, coveringNode, null)
|| getPushNegationDownProposals(context, coveringNode, null)
|| getPullNegationUpProposals(context, coveredNodes, null)
|| getJoinIfListInIfElseIfProposals(context, coveringNode, coveredNodes, null)
|| getConvertSwitchToIfProposals(context, coveringNode, null)
|| getConvertIfElseToSwitchProposals(context, coveringNode, null)
|| GetterSetterCorrectionSubProcessor.addGetterSetterProposal(
context, coveringNode, null, null);
}
return false;
}
示例3: hasAssists
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入方法依赖的package包/类
public boolean hasAssists(IInvocationContext context) throws CoreException {
ASTNode coveringNode = context.getCoveringNode();
if (coveringNode != null) {
ArrayList<ASTNode> coveredNodes =
AdvancedQuickAssistProcessor.getFullyCoveredNodes(context, coveringNode);
return getCatchClauseToThrowsProposals(context, coveringNode, null)
|| getPickoutTypeFromMulticatchProposals(context, coveringNode, coveredNodes, null)
|| getConvertToMultiCatchProposals(context, coveringNode, null)
|| getUnrollMultiCatchProposals(context, coveringNode, null)
|| getRenameLocalProposals(context, coveringNode, null, null)
|| getRenameRefactoringProposal(context, coveringNode, null, null)
|| getAssignToVariableProposals(context, coveringNode, null, null)
|| getUnWrapProposals(context, coveringNode, null)
|| getAssignParamToFieldProposals(context, coveringNode, null)
|| getJoinVariableProposals(context, coveringNode, null)
|| getAddFinallyProposals(context, coveringNode, null)
|| getAddElseProposals(context, coveringNode, null)
|| getSplitVariableProposals(context, coveringNode, null)
|| getAddBlockProposals(context, coveringNode, null)
|| getArrayInitializerToArrayCreation(context, coveringNode, null)
|| getCreateInSuperClassProposals(context, coveringNode, null)
|| getInvertEqualsProposal(context, coveringNode, null)
|| getConvertForLoopProposal(context, coveringNode, null)
|| getConvertIterableLoopProposal(context, coveringNode, null)
|| getConvertEnhancedForLoopProposal(context, coveringNode, null)
|| getGenerateForLoopProposals(context, coveringNode, null, null)
|| getExtractVariableProposal(context, false, null)
|| getExtractMethodProposal(context, coveringNode, false, null)
|| getInlineLocalProposal(context, coveringNode, null)
|| getConvertLocalToFieldProposal(context, coveringNode, null)
|| getConvertAnonymousToNestedProposal(context, coveringNode, null)
|| getConvertAnonymousClassCreationsToLambdaProposals(context, coveringNode, null)
|| getConvertLambdaToAnonymousClassCreationsProposals(context, coveringNode, null)
|| getChangeLambdaBodyToBlockProposal(context, coveringNode, null)
|| getChangeLambdaBodyToExpressionProposal(context, coveringNode, null)
|| getRemoveBlockProposals(context, coveringNode, null)
|| getMakeVariableDeclarationFinalProposals(context, null)
|| getMissingCaseStatementProposals(context, coveringNode, null)
|| getConvertStringConcatenationProposals(context, null)
|| getInferDiamondArgumentsProposal(context, coveringNode, null, null);
}
return false;
}
示例4: getAssists
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入方法依赖的package包/类
public IJavaCompletionProposal[] getAssists(
IInvocationContext context, IProblemLocation[] locations) throws CoreException {
ASTNode coveringNode = context.getCoveringNode();
if (coveringNode != null) {
ArrayList<ASTNode> coveredNodes =
AdvancedQuickAssistProcessor.getFullyCoveredNodes(context, coveringNode);
ArrayList<ICommandAccess> resultingCollections = new ArrayList<ICommandAccess>();
boolean noErrorsAtLocation = noErrorsAtLocation(locations);
// quick assists that show up also if there is an error/warning
getRenameLocalProposals(context, coveringNode, locations, resultingCollections);
getRenameRefactoringProposal(context, coveringNode, locations, resultingCollections);
getAssignToVariableProposals(context, coveringNode, locations, resultingCollections);
getAssignParamToFieldProposals(context, coveringNode, resultingCollections);
getInferDiamondArgumentsProposal(context, coveringNode, locations, resultingCollections);
getGenerateForLoopProposals(context, coveringNode, locations, resultingCollections);
if (noErrorsAtLocation) {
boolean problemsAtLocation = locations.length != 0;
getCatchClauseToThrowsProposals(context, coveringNode, resultingCollections);
getPickoutTypeFromMulticatchProposals(
context, coveringNode, coveredNodes, resultingCollections);
getConvertToMultiCatchProposals(context, coveringNode, resultingCollections);
getUnrollMultiCatchProposals(context, coveringNode, resultingCollections);
getUnWrapProposals(context, coveringNode, resultingCollections);
getJoinVariableProposals(context, coveringNode, resultingCollections);
getSplitVariableProposals(context, coveringNode, resultingCollections);
getAddFinallyProposals(context, coveringNode, resultingCollections);
getAddElseProposals(context, coveringNode, resultingCollections);
getAddBlockProposals(context, coveringNode, resultingCollections);
getInvertEqualsProposal(context, coveringNode, resultingCollections);
getArrayInitializerToArrayCreation(context, coveringNode, resultingCollections);
getCreateInSuperClassProposals(context, coveringNode, resultingCollections);
getExtractVariableProposal(context, problemsAtLocation, resultingCollections);
getExtractMethodProposal(context, coveringNode, problemsAtLocation, resultingCollections);
getInlineLocalProposal(context, coveringNode, resultingCollections);
getConvertLocalToFieldProposal(context, coveringNode, resultingCollections);
getConvertAnonymousToNestedProposal(context, coveringNode, resultingCollections);
getConvertAnonymousClassCreationsToLambdaProposals(
context, coveringNode, resultingCollections);
getConvertLambdaToAnonymousClassCreationsProposals(
context, coveringNode, resultingCollections);
getChangeLambdaBodyToBlockProposal(context, coveringNode, resultingCollections);
getChangeLambdaBodyToExpressionProposal(context, coveringNode, resultingCollections);
if (!getConvertForLoopProposal(context, coveringNode, resultingCollections))
getConvertIterableLoopProposal(context, coveringNode, resultingCollections);
getConvertEnhancedForLoopProposal(context, coveringNode, resultingCollections);
getRemoveBlockProposals(context, coveringNode, resultingCollections);
getMakeVariableDeclarationFinalProposals(context, resultingCollections);
getConvertStringConcatenationProposals(context, resultingCollections);
getMissingCaseStatementProposals(context, coveringNode, resultingCollections);
}
return resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
}
return null;
}
示例5: getConvertStringConcatenationProposals
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入方法依赖的package包/类
private static boolean getConvertStringConcatenationProposals(
IInvocationContext context, Collection<ICommandAccess> resultingCollections) {
ASTNode node = context.getCoveringNode();
BodyDeclaration parentDecl = ASTResolving.findParentBodyDeclaration(node);
if (!(parentDecl instanceof MethodDeclaration || parentDecl instanceof Initializer))
return false;
AST ast = node.getAST();
ITypeBinding stringBinding = ast.resolveWellKnownType("java.lang.String"); // $NON-NLS-1$
if (node instanceof Expression && !(node instanceof InfixExpression)) {
node = node.getParent();
}
if (node instanceof VariableDeclarationFragment) {
node = ((VariableDeclarationFragment) node).getInitializer();
} else if (node instanceof Assignment) {
node = ((Assignment) node).getRightHandSide();
}
InfixExpression oldInfixExpression = null;
while (node instanceof InfixExpression) {
InfixExpression curr = (InfixExpression) node;
if (curr.resolveTypeBinding() == stringBinding
&& curr.getOperator() == InfixExpression.Operator.PLUS) {
oldInfixExpression = curr; // is a infix expression we can use
} else {
break;
}
node = node.getParent();
}
if (oldInfixExpression == null) return false;
if (resultingCollections == null) {
return true;
}
LinkedCorrectionProposal stringBufferProposal =
getConvertToStringBufferProposal(context, ast, oldInfixExpression);
resultingCollections.add(stringBufferProposal);
ASTRewriteCorrectionProposal messageFormatProposal =
getConvertToMessageFormatProposal(context, ast, oldInfixExpression);
if (messageFormatProposal != null) resultingCollections.add(messageFormatProposal);
return true;
}
示例6: getAssists
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入方法依赖的package包/类
public IJavaCompletionProposal[] getAssists(
IInvocationContext context, IProblemLocation[] locations) throws CoreException {
ASTNode coveringNode = context.getCoveringNode();
if (coveringNode != null) {
ArrayList<ASTNode> coveredNodes = getFullyCoveredNodes(context, coveringNode);
ArrayList<ICommandAccess> resultingCollections = new ArrayList<ICommandAccess>();
// quick assists that show up also if there is an error/warning
getReplaceConditionalWithIfElseProposals(context, coveringNode, resultingCollections);
if (QuickAssistProcessor.noErrorsAtLocation(locations)) {
getConvertToIfReturnProposals(context, coveringNode, resultingCollections);
getInverseIfProposals(context, coveringNode, resultingCollections);
getIfReturnIntoIfElseAtEndOfVoidMethodProposals(
context, coveringNode, resultingCollections);
getInverseIfContinueIntoIfThenInLoopsProposals(context, coveringNode, resultingCollections);
getInverseIfIntoContinueInLoopsProposals(context, coveringNode, resultingCollections);
getInverseConditionProposals(context, coveringNode, coveredNodes, resultingCollections);
getRemoveExtraParenthesesProposals(
context, coveringNode, coveredNodes, resultingCollections);
getAddParanoidalParenthesesProposals(context, coveredNodes, resultingCollections);
getAddParenthesesForExpressionProposals(context, coveringNode, resultingCollections);
getJoinAndIfStatementsProposals(context, coveringNode, resultingCollections);
getSplitAndConditionProposals(context, coveringNode, resultingCollections);
getJoinOrIfStatementsProposals(context, coveringNode, coveredNodes, resultingCollections);
getSplitOrConditionProposals(context, coveringNode, resultingCollections);
getInverseConditionalExpressionProposals(context, coveringNode, resultingCollections);
getExchangeInnerAndOuterIfConditionsProposals(context, coveringNode, resultingCollections);
getExchangeOperandsProposals(context, coveringNode, resultingCollections);
getCastAndAssignIfStatementProposals(context, coveringNode, resultingCollections);
getCombineStringProposals(context, coveringNode, resultingCollections);
getPickOutStringProposals(context, coveringNode, resultingCollections);
getReplaceIfElseWithConditionalProposals(context, coveringNode, resultingCollections);
getInverseLocalVariableProposals(context, coveringNode, resultingCollections);
getPushNegationDownProposals(context, coveringNode, resultingCollections);
getPullNegationUpProposals(context, coveredNodes, resultingCollections);
getJoinIfListInIfElseIfProposals(context, coveringNode, coveredNodes, resultingCollections);
getConvertSwitchToIfProposals(context, coveringNode, resultingCollections);
getConvertIfElseToSwitchProposals(context, coveringNode, resultingCollections);
GetterSetterCorrectionSubProcessor.addGetterSetterProposal(
context, coveringNode, locations, resultingCollections);
}
return resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
}
return null;
}