|
Lines 123-129
Link Here
|
| 123 |
|| getReplaceIfElseWithConditionalProposals(context, coveringNode, null) || getReplaceConditionalWithIfElseProposals(context, coveringNode, null) |
123 |
|| getReplaceIfElseWithConditionalProposals(context, coveringNode, null) || getReplaceConditionalWithIfElseProposals(context, coveringNode, null) |
| 124 |
|| getInverseLocalVariableProposals(context, coveringNode, null) || getPushNegationDownProposals(context, coveringNode, null) |
124 |
|| getInverseLocalVariableProposals(context, coveringNode, null) || getPushNegationDownProposals(context, coveringNode, null) |
| 125 |
|| getPullNegationUpProposals(context, coveredNodes, null) || getJoinIfListInIfElseIfProposals(context, coveringNode, coveredNodes, null) |
125 |
|| getPullNegationUpProposals(context, coveredNodes, null) || getJoinIfListInIfElseIfProposals(context, coveringNode, coveredNodes, null) |
| 126 |
|| getConvertSwitchToIfProposals(context, coveringNode, null) || GetterSetterCorrectionSubProcessor.addGetterSetterProposal(context, coveringNode, null, null); |
126 |
|| getConvertSwitchToIfProposals(context, coveringNode, null) || GetterSetterCorrectionSubProcessor.addGetterSetterProposal(context, coveringNode, null, null) |
|
|
127 |
|| getQualifyTypenameProposals(context, coveringNode, null); |
| 127 |
} |
128 |
} |
| 128 |
return false; |
129 |
return false; |
| 129 |
} |
130 |
} |
|
Lines 161-166
Link Here
|
| 161 |
getJoinIfListInIfElseIfProposals(context, coveringNode, coveredNodes, resultingCollections); |
162 |
getJoinIfListInIfElseIfProposals(context, coveringNode, coveredNodes, resultingCollections); |
| 162 |
getConvertSwitchToIfProposals(context, coveringNode, resultingCollections); |
163 |
getConvertSwitchToIfProposals(context, coveringNode, resultingCollections); |
| 163 |
GetterSetterCorrectionSubProcessor.addGetterSetterProposal(context, coveringNode, locations, resultingCollections); |
164 |
GetterSetterCorrectionSubProcessor.addGetterSetterProposal(context, coveringNode, locations, resultingCollections); |
|
|
165 |
getQualifyTypenameProposals(context, coveringNode, resultingCollections); |
| 164 |
} |
166 |
} |
| 165 |
|
167 |
|
| 166 |
return (IJavaCompletionProposal[]) resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]); |
168 |
return (IJavaCompletionProposal[]) resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]); |
|
Lines 785-790
Link Here
|
| 785 |
return parenthesizedExpression; |
787 |
return parenthesizedExpression; |
| 786 |
} |
788 |
} |
| 787 |
|
789 |
|
|
|
790 |
private static boolean getQualifyTypenameProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) { |
| 791 |
if (!(node instanceof SimpleName)) |
| 792 |
return false; |
| 793 |
SimpleName simpleName = (SimpleName) node; |
| 794 |
IBinding binding= simpleName.resolveBinding(); |
| 795 |
if (!(binding instanceof ITypeBinding)) |
| 796 |
return false; |
| 797 |
ITypeBinding typeBinding= (ITypeBinding) binding; |
| 798 |
if (typeBinding.isPrimitive() || typeBinding.isNullType() |
| 799 |
|| typeBinding.isAnonymous()) |
| 800 |
return false; |
| 801 |
if (typeBinding.getPackage() == null) |
| 802 |
return false; |
| 803 |
String[] split= typeBinding.getPackage().getName().split("[.]"); //$NON-NLS-1$ |
| 804 |
if (split.length < 1) |
| 805 |
return false; |
| 806 |
if (resultingCollections == null) { |
| 807 |
return true; |
| 808 |
} |
| 809 |
AST ast = simpleName.getAST(); |
| 810 |
ASTRewrite rewrite= ASTRewrite.create(ast); |
| 811 |
SimpleName nsn= ast.newSimpleName(simpleName.getFullyQualifiedName()); |
| 812 |
QualifiedName qn = null; |
| 813 |
SimpleName base= ast.newSimpleName(split[0]); |
| 814 |
for (int i = 1; i < split.length; i++) { |
| 815 |
SimpleName tmp= ast.newSimpleName(split[i]); |
| 816 |
qn= ast.newQualifiedName(base, tmp); |
| 817 |
} |
| 818 |
qn= ast.newQualifiedName(qn, nsn); |
| 819 |
rewrite.replace(simpleName, qn, null); |
| 820 |
// add correction proposal |
| 821 |
String label= CorrectionMessages.AdvancedQuickAssistProcessor_qualifyTypename_description; |
| 822 |
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); |
| 823 |
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image); |
| 824 |
resultingCollections.add(proposal); |
| 825 |
return true; |
| 826 |
} |
| 827 |
|
| 788 |
private static boolean getSplitAndConditionProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) { |
828 |
private static boolean getSplitAndConditionProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) { |
| 789 |
Operator andOperator= InfixExpression.Operator.CONDITIONAL_AND; |
829 |
Operator andOperator= InfixExpression.Operator.CONDITIONAL_AND; |
| 790 |
// check that user invokes quick assist on infix expression |
830 |
// check that user invokes quick assist on infix expression |