mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
(no message)
This commit is contained in:
@@ -250,7 +250,9 @@ public abstract class JavaElementVisitor {
|
||||
visitElement(reference);
|
||||
}
|
||||
|
||||
public abstract void visitReferenceExpression(PsiReferenceExpression expression);
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
|
||||
public void visitReferenceList(PsiReferenceList list) {
|
||||
visitElement(list);
|
||||
|
||||
@@ -10,8 +10,4 @@ public abstract class PsiRecursiveElementVisitor extends PsiElementVisitor {
|
||||
public void visitElement(PsiElement element) {
|
||||
element.acceptChildren(this);
|
||||
}
|
||||
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -75,10 +75,6 @@ public class ComparingReferencesInspection extends BaseLocalInspectionTool {
|
||||
|
||||
final ArrayList[] problemList = new ArrayList[]{null};
|
||||
where.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
super.visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitMethod(PsiMethod method) {}
|
||||
|
||||
public void visitClass(PsiClass aClass) {}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
public class X {
|
||||
void f(int i) {
|
||||
if (i==0) {
|
||||
return;
|
||||
}
|
||||
int j = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public class X {
|
||||
void f(int i) {
|
||||
if (i==0) {
|
||||
return;
|
||||
}
|
||||
<spot>else</spot> {
|
||||
int j = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<font face="verdana" size="-1">This intention detaches <b>else</b> clause from the <b>if</b> statement,
|
||||
if corresponding <b>then</b> clause never completes normally.
|
||||
</font>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,5 @@
|
||||
public class X {
|
||||
void f(int i) {
|
||||
if (true) return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class X {
|
||||
void f(int i) {
|
||||
if (this == null || <spot>true</spot> || i == 0) return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<font face="verdana" size="-1">This intention simplifies expression with boolean literals.
|
||||
</font>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -119,10 +119,6 @@ public class AnalysisScope {
|
||||
|
||||
private PsiElementVisitor createFileSearcher() {
|
||||
PsiElementVisitor visitor = new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitFile(PsiFile file) {
|
||||
if (myFilter.accept(file)) {
|
||||
myFilesSet.add(file.getVirtualFile());
|
||||
|
||||
@@ -158,10 +158,6 @@ public class CodeInsightUtil {
|
||||
final PsiElementVisitor visitor = new PsiElementVisitor() {
|
||||
int offset = currentOffset;
|
||||
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitElement(PsiElement element) {
|
||||
PsiElement child = element.getFirstChild();
|
||||
if (child == null) {
|
||||
|
||||
@@ -225,10 +225,6 @@ public class ExceptionUtil {
|
||||
public static PsiClassType[] getUnhandledExceptions(PsiElement[] elements) {
|
||||
final List<PsiClassType> array = new ArrayList<PsiClassType>();
|
||||
PsiRecursiveElementVisitor visitor = new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitCallExpression(PsiCallExpression expression) {
|
||||
addExceptions(array, getUnhandledExceptions(expression, null));
|
||||
visitElement(expression);
|
||||
|
||||
@@ -429,10 +429,6 @@ abstract class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
|
||||
protected PsiFile createCopy(final CompletionContext context) {
|
||||
final PsiElementVisitor visitor = new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitClass(PsiClass aClass) {
|
||||
aClass.putCopyableUserData(CompletionUtil.ORIGINAL_KEY, aClass);
|
||||
super.visitClass(aClass);
|
||||
|
||||
@@ -917,6 +917,7 @@ public class HighlightUtil {
|
||||
}
|
||||
else if (type instanceof PsiClassType) {
|
||||
PsiClass psiClass = ((PsiClassType)type).resolve();
|
||||
if (psiClass == null) return false;
|
||||
return psiClass != null && psiClass.isEnum();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -56,9 +56,6 @@ public class XmlHighlightVisitor extends PsiElementVisitor implements Validator.
|
||||
myResult.clear();
|
||||
}
|
||||
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
}
|
||||
|
||||
private static void addElementsForTag(XmlTag tag,
|
||||
String localizedMessage,
|
||||
List<HighlightInfo> result,
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RemoveRedundantElseAction implements IntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.RemoveRedundantElseAction");
|
||||
|
||||
public String getText() {
|
||||
return "Remove Redundant 'else'";
|
||||
return getFamilyName();
|
||||
}
|
||||
|
||||
public String getFamilyName() {
|
||||
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
public class SimplifyBooleanExpressionFix implements IntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.SimplifyBooleanExpression");
|
||||
|
||||
private final PsiExpression mySubExpression;
|
||||
private final boolean mySubExpressionValue;
|
||||
private PsiExpression trueExpression;
|
||||
private PsiExpression falseExpression;
|
||||
|
||||
public SimplifyBooleanExpressionFix(PsiExpression subExpression, boolean subExpressionValue) {
|
||||
mySubExpression = subExpression;
|
||||
mySubExpressionValue = subExpressionValue;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return getFamilyName();
|
||||
}
|
||||
|
||||
public String getFamilyName() {
|
||||
return "Simplify boolean expression";
|
||||
}
|
||||
|
||||
public boolean isAvailable(Project project, Editor editor, PsiFile file) {
|
||||
return mySubExpression.isValid()
|
||||
&& mySubExpression.getManager().isInProject(mySubExpression);
|
||||
}
|
||||
|
||||
public void invoke(Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
PsiExpression constExpression = mySubExpression.getManager().getElementFactory().createExpressionFromText(Boolean.toString(mySubExpressionValue), mySubExpression);
|
||||
PsiExpression expression = (PsiExpression)mySubExpression.replace(constExpression);
|
||||
while (expression.getParent() instanceof PsiExpression) {
|
||||
expression = (PsiExpression)expression.getParent();
|
||||
}
|
||||
final PsiExpression newExpression = simplifyExpression(expression);
|
||||
expression.replace(newExpression);
|
||||
}
|
||||
|
||||
public PsiExpression simplifyExpression(PsiExpression expression) throws IncorrectOperationException {
|
||||
trueExpression = expression.getManager().getElementFactory().createExpressionFromText(Boolean.toString(true), null);
|
||||
falseExpression = expression.getManager().getElementFactory().createExpressionFromText(Boolean.toString(false), null);
|
||||
final PsiExpression[] copy = new PsiExpression[]{(PsiExpression)expression.copy()};
|
||||
copy[0].accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitElement(PsiElement element) {
|
||||
final PsiElement[] children = element.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
PsiElement child = children[i];
|
||||
child.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void visitExpression(PsiExpression expression) {
|
||||
super.visitExpression(expression);
|
||||
final ExpressionVisitor expressionVisitor = new ExpressionVisitor();
|
||||
expression.accept(expressionVisitor);
|
||||
if (expressionVisitor.resultExpression != null) {
|
||||
LOG.assertTrue(expressionVisitor.resultExpression.isValid());
|
||||
try {
|
||||
if (expression != copy[0]) {
|
||||
expression.replace(expressionVisitor.resultExpression);
|
||||
}
|
||||
else {
|
||||
copy[0] = expressionVisitor.resultExpression;
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return copy[0];
|
||||
}
|
||||
|
||||
private class ExpressionVisitor extends PsiElementVisitor {
|
||||
private PsiExpression resultExpression;
|
||||
|
||||
public void visitBinaryExpression(PsiBinaryExpression expression) {
|
||||
final PsiExpression lOperand = expression.getLOperand();
|
||||
final PsiExpression rOperand = expression.getROperand();
|
||||
final PsiJavaToken operationSign = expression.getOperationSign();
|
||||
final IElementType tokenType = operationSign.getTokenType();
|
||||
final Boolean lConstBoolean = getConstBoolean(lOperand);
|
||||
final Boolean rConstBoolean = getConstBoolean(rOperand);
|
||||
|
||||
if (lConstBoolean != null) {
|
||||
if (JavaTokenType.ANDAND == tokenType || JavaTokenType.AND == tokenType) {
|
||||
resultExpression = lConstBoolean.booleanValue() ? rOperand : falseExpression;
|
||||
}
|
||||
else if (JavaTokenType.OROR == tokenType || JavaTokenType.OR == tokenType) {
|
||||
resultExpression = lConstBoolean.booleanValue() ? trueExpression : rOperand;
|
||||
}
|
||||
}
|
||||
else if (rConstBoolean != null) {
|
||||
if (JavaTokenType.ANDAND == tokenType || JavaTokenType.AND == tokenType) {
|
||||
resultExpression = rConstBoolean.booleanValue() ? lOperand : falseExpression;
|
||||
}
|
||||
else if (JavaTokenType.OROR == tokenType || JavaTokenType.OR == tokenType) {
|
||||
resultExpression = rConstBoolean.booleanValue() ? trueExpression : lOperand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void visitPrefixExpression(PsiPrefixExpression expression) {
|
||||
final PsiExpression operand = expression.getOperand();
|
||||
final Boolean constBoolean = getConstBoolean(operand);
|
||||
if (constBoolean == null) return;
|
||||
final PsiJavaToken operationSign = expression.getOperationSign();
|
||||
final IElementType tokenType = operationSign.getTokenType();
|
||||
if (JavaTokenType.EXCL == tokenType) {
|
||||
resultExpression = constBoolean.booleanValue() ? falseExpression : trueExpression;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
|
||||
final PsiExpression subexpr = expression.getExpression();
|
||||
final Boolean constBoolean = getConstBoolean(subexpr);
|
||||
if (constBoolean == null) return;
|
||||
resultExpression = constBoolean.booleanValue() ? trueExpression : falseExpression;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean getConstBoolean(final PsiExpression operand) {
|
||||
if (operand == null) return null;
|
||||
final String text = operand.getText();
|
||||
return "true".equals(text) ? Boolean.TRUE : "false".equals(text) ? Boolean.FALSE : null;
|
||||
}
|
||||
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-4
@@ -43,10 +43,6 @@ public class AfterSemicolonEnterProcessor implements EnterProcessor {
|
||||
private static int getErrorElementOffset(PsiElement elt) {
|
||||
final int[] offset = new int[] { -1 };
|
||||
elt.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
if (offset[0] == -1) visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
if (offset[0] == -1) offset[0] = element.getTextRange().getStartOffset();
|
||||
}
|
||||
|
||||
@@ -84,9 +84,6 @@ class FoldingPolicy {
|
||||
list.add(aClass);
|
||||
}
|
||||
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
};
|
||||
scope.accept(visitor);
|
||||
for (Iterator<PsiClass> iterator = list.iterator(); iterator.hasNext();) {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.SimplifyBooleanExpressionFix;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
public class SimplifyBooleanExpressionAction implements IntentionAction{
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.SimplifyBooleanExpressionAction");
|
||||
|
||||
public String getText() {
|
||||
return getFamilyName();
|
||||
}
|
||||
|
||||
public String getFamilyName() {
|
||||
return new SimplifyBooleanExpressionFix(null,false).getFamilyName();
|
||||
}
|
||||
|
||||
public boolean isAvailable(Project project, Editor editor, PsiFile file) {
|
||||
try {
|
||||
final PsiExpression newExpression = simplifyExpression(editor, file, false);
|
||||
return newExpression != null;
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static PsiExpression simplifyExpression(final Editor editor, final PsiFile file, boolean replace) throws IncorrectOperationException {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiElement element = file.findElementAt(offset);
|
||||
if (element == null) return null;
|
||||
PsiExpression expression = PsiTreeUtil.getParentOfType(element, PsiExpression.class);
|
||||
if (expression == null) return null;
|
||||
final Boolean constBoolean = SimplifyBooleanExpressionFix.getConstBoolean(expression);
|
||||
if (constBoolean == null) return null;
|
||||
PsiExpression topexpression = expression;
|
||||
while (topexpression.getParent() instanceof PsiExpression) {
|
||||
topexpression = (PsiExpression)topexpression.getParent();
|
||||
}
|
||||
if (topexpression == expression) return null;
|
||||
final SimplifyBooleanExpressionFix fix = new SimplifyBooleanExpressionFix(topexpression, constBoolean.booleanValue());
|
||||
final PsiExpression newExpression = fix.simplifyExpression(topexpression);
|
||||
if (Comparing.strEqual(newExpression.getText(), topexpression.getText())) return null;
|
||||
return replace ? (PsiExpression)topexpression.replace(newExpression) : newExpression;
|
||||
}
|
||||
|
||||
public void invoke(Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
simplifyExpression(editor, file, true);
|
||||
}
|
||||
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -30,12 +30,13 @@ public class IntentionManagerImpl extends IntentionManager {
|
||||
|
||||
registerIntentionAndMetaData(new SplitIfAction(), new String[]{"Control Flow"});
|
||||
registerIntentionAndMetaData(new InvertIfConditionAction(), new String[]{"Control Flow"});
|
||||
registerIntentionAndMetaData(new RemoveRedundantElseAction(), new String[]{"Control Flow"});
|
||||
|
||||
registerIntentionAndMetaData(new ImplementAbstractClassAction(), new String[]{"Declaration"});
|
||||
registerIntentionAndMetaData(new ImplementAbstractMethodAction(), new String[]{"Declaration"});
|
||||
registerIntentionAndMetaData(new SplitDeclarationAction(), new String[]{"Declaration"});
|
||||
//TODO:add metadata!
|
||||
addAction(new RemoveRedundantElseAction());
|
||||
|
||||
registerIntentionAndMetaData(new SimplifyBooleanExpressionAction(), new String[]{"Boolean"});
|
||||
|
||||
registerIntentionAndMetaData(new EJBImplementationAction(), new String[]{"EJB"});
|
||||
registerIntentionAndMetaData(new EJBDeclarationAction(), new String[]{"EJB"});
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.SimplifyBooleanExpressionFix;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -67,7 +68,7 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
return null;
|
||||
}
|
||||
|
||||
private LocalQuickFix createAssertNotNullFix(PsiExpression qualifier) {
|
||||
private static LocalQuickFix createAssertNotNullFix(PsiExpression qualifier) {
|
||||
if (qualifier != null && qualifier.getManager().getEffectiveLanguageLevel().hasAssertKeyword() &&
|
||||
!(qualifier instanceof PsiMethodCallExpression)) {
|
||||
try {
|
||||
@@ -179,10 +180,12 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
}
|
||||
else {
|
||||
final LocalQuickFix localQuickFix = createSimplifyBooleanExpressionFix(true);
|
||||
descriptions.add(manager.createProblemDescriptor(psiAnchor,
|
||||
"Condition <code>#ref</code> #loc is always true</code>",
|
||||
null,
|
||||
localQuickFix,
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
|
||||
}
|
||||
}
|
||||
else if (psiAnchor instanceof PsiSwitchLabelStatement) {
|
||||
@@ -193,9 +196,10 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
else if (psiAnchor != null) {
|
||||
if (!reportedAnchors.contains(psiAnchor)) {
|
||||
final LocalQuickFix localQuickFix = createSimplifyBooleanExpressionFix(trueSet.contains(instruction));
|
||||
descriptions.add(manager.createProblemDescriptor(psiAnchor, "Condition <code>#ref</code> #loc is always <code>" +
|
||||
(trueSet.contains(instruction) ? "true" : "false") +
|
||||
"</code>.", null,
|
||||
"</code>.", localQuickFix,
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
reportedAnchors.add(psiAnchor);
|
||||
}
|
||||
@@ -206,6 +210,26 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
return descriptions.toArray(new ProblemDescriptor[descriptions.size()]);
|
||||
}
|
||||
|
||||
private static LocalQuickFix createSimplifyBooleanExpressionFix(final boolean value) {
|
||||
return new LocalQuickFix() {
|
||||
public String getName() {
|
||||
return new SimplifyBooleanExpressionFix(null,false).getText();
|
||||
}
|
||||
|
||||
public void applyFix(Project project, ProblemDescriptor descriptor) {
|
||||
final PsiElement psiElement = descriptor.getPsiElement();
|
||||
try {
|
||||
final SimplifyBooleanExpressionFix action = new SimplifyBooleanExpressionFix((PsiExpression)psiElement, value);
|
||||
LOG.assertTrue(psiElement.isValid());
|
||||
action.invoke(project, null, psiElement.getContainingFile());
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class RedundantInstanceofFix implements LocalQuickFix {
|
||||
public String getName() {
|
||||
return "Replace with != null";
|
||||
|
||||
@@ -115,10 +115,6 @@ public class DefUseInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
|
||||
body.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitClass(PsiClass aClass) {
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,6 @@ public class EqualsAndHashcode extends DescriptorProviderInspection {
|
||||
}
|
||||
}
|
||||
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitElement(PsiElement element) {
|
||||
PsiElement[] children = element.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
|
||||
@@ -123,9 +123,6 @@ public class LocalCanBeFinal extends BaseLocalInspectionTool {
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
PsiElement child = children[i];
|
||||
child.accept(new PsiElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
}
|
||||
|
||||
public void visitDeclarationStatement(PsiDeclarationStatement statement) {
|
||||
PsiElement[] declaredElements = statement.getDeclaredElements();
|
||||
for (int i = 0; i < declaredElements.length; i++) {
|
||||
|
||||
@@ -49,8 +49,6 @@ public class RedundantTypeArgsInspection extends GenericsInspectionToolBase {
|
||||
public ProblemDescriptor[] getDescriptions(PsiElement place, final InspectionManager inspectionManager) {
|
||||
final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
|
||||
place.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {}
|
||||
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
final PsiType[] typeArguments = expression.getTypeArguments();
|
||||
if (typeArguments.length > 0) {
|
||||
|
||||
@@ -75,9 +75,6 @@ public class CyclicDependenciesBuilder{
|
||||
public void analyze() {
|
||||
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(getProject()).getFileIndex();
|
||||
getScope().accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
|
||||
}
|
||||
|
||||
public void visitFile(PsiFile file) {
|
||||
if (file != null && file instanceof PsiJavaFile) {
|
||||
@@ -331,9 +328,6 @@ public class CyclicDependenciesBuilder{
|
||||
if (myPackages.isEmpty()) {
|
||||
final PsiManager psiManager = PsiManager.getInstance(getProject());
|
||||
getScope().accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
}
|
||||
|
||||
public void visitFile(PsiFile file) {
|
||||
if (file != null && file instanceof PsiJavaFile) {
|
||||
PsiJavaFile psiJavaFile = (PsiJavaFile)file;
|
||||
|
||||
@@ -128,10 +128,6 @@ public class PositionManagerImpl implements PositionManager {
|
||||
final PsiMethod[] compiledMethod = new PsiMethod[1];
|
||||
|
||||
PsiRecursiveElementVisitor visitor = new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
expression.acceptChildren(this);
|
||||
}
|
||||
|
||||
public void visitClass(PsiClass aClass) {
|
||||
List<ReferenceType> allClasses = myDebugProcess.getPositionManager().getAllClasses(SourcePosition.createFromElement(aClass));
|
||||
for (Iterator<ReferenceType> iterator = allClasses.iterator(); iterator.hasNext();) {
|
||||
|
||||
@@ -26,9 +26,6 @@ public class ClassTreeNode extends BasePsiNode<PsiClass>{
|
||||
for (Iterator<PsiElement> iterator = result.iterator(); iterator.hasNext();) {
|
||||
PsiElement psiElement = iterator.next();
|
||||
psiElement.accept(new PsiElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
}
|
||||
|
||||
public void visitClass(PsiClass aClass) {
|
||||
treeNodes.add(new ClassTreeNode(getProject(), aClass, getSettings()));
|
||||
}
|
||||
|
||||
@@ -54,9 +54,6 @@ public class BackwardDependenciesBuilder extends DependenciesBuilder {
|
||||
psiManager.startBatchFilesProcessingMode();
|
||||
try {
|
||||
getScope().accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
}
|
||||
|
||||
public void visitFile(final PsiFile file) {
|
||||
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
|
||||
@@ -5,11 +5,13 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.codeStyle.ImportHelper;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ForwardDependenciesBuilder extends DependenciesBuilder {
|
||||
|
||||
@@ -34,9 +36,6 @@ public class ForwardDependenciesBuilder extends DependenciesBuilder {
|
||||
psiManager.startBatchFilesProcessingMode();
|
||||
try {
|
||||
getScope().accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
}
|
||||
|
||||
public void visitFile(final PsiFile file) {
|
||||
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
|
||||
@@ -41,10 +41,6 @@ public class RecordUtil {
|
||||
|
||||
if (psiElement != null && mayContainClassesInside(psiElement)) {
|
||||
psiElement.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitClass(PsiClass aClass) {
|
||||
if (ourList.isNull()) ourList.set(new ArrayList<PsiClass>());
|
||||
ourList.get().add(aClass);
|
||||
|
||||
@@ -27,10 +27,6 @@ public class PsiTypeCodeFragmentImpl extends PsiCodeFragmentImpl implements PsiT
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
throw new SyntaxError();
|
||||
}
|
||||
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(SyntaxError e) {
|
||||
|
||||
@@ -6,15 +6,14 @@ import com.intellij.pom.PomModel;
|
||||
import com.intellij.pom.event.PomModelEvent;
|
||||
import com.intellij.pom.impl.PomTransactionBase;
|
||||
import com.intellij.pom.xml.XmlAspect;
|
||||
import com.intellij.pom.xml.impl.events.XmlDocumentChangedImpl;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor;
|
||||
import com.intellij.psi.PsiReferenceExpression;
|
||||
import com.intellij.psi.impl.meta.MetaRegistry;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.pom.xml.impl.events.XmlDocumentChangedImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
import com.intellij.psi.xml.XmlProlog;
|
||||
@@ -87,10 +86,6 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument {
|
||||
final TObjectIntHashMap map = new TObjectIntHashMap();
|
||||
|
||||
final PsiRecursiveElementVisitor psiRecursiveElementVisitor = new PsiRecursiveElementVisitor(){
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitXmlToken(XmlToken token) {
|
||||
inc("Tokens");
|
||||
}
|
||||
|
||||
@@ -645,7 +645,6 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag/*, Modification
|
||||
}
|
||||
super.visitXmlTag(tag);
|
||||
}
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -254,10 +254,6 @@ public class ConvertToInstanceMethodProcessor extends BaseRefactoringProcessor {
|
||||
additionalReplacements = null;
|
||||
}
|
||||
newMethod.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
PsiTypeParameter typeParameterToBind = reference.getCopyableUserData(BIND_TO_TYPE_PARAMETER);
|
||||
if (typeParameterToBind != null) {
|
||||
|
||||
@@ -1443,10 +1443,6 @@ public class RefactoringUtil {
|
||||
for (Iterator<PsiElement> iterator = scopes.iterator(); iterator.hasNext();) {
|
||||
final PsiElement scope = iterator.next();
|
||||
scope.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
super.visitReferenceElement(reference);
|
||||
final PsiElement resolved = reference.resolve();
|
||||
|
||||
@@ -48,10 +48,6 @@ public class DuplicatesFinder {
|
||||
for (int i = 0; i < myPattern.length; i++) {
|
||||
final PsiElement patternComponent = myPattern[i];
|
||||
patternComponent.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
final PsiElement element = reference.resolve();
|
||||
if (myParameters.contains(element)) {
|
||||
@@ -73,10 +69,6 @@ public class DuplicatesFinder {
|
||||
for (int i = 0; i < myPattern.length; i++) {
|
||||
final PsiElement patternComponent = myPattern[i];
|
||||
patternComponent.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
if (reference.getUserData(PARAMETER) != null) {
|
||||
reference.putUserData(PARAMETER, null);
|
||||
|
||||
Reference in New Issue
Block a user