mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
handle one other type of PSI change (part of KTIJ-27988 K2 IDE: used/unused declaration highlighting is not updated in Kotlin source on editing Java source)
GitOrigin-RevId: d2e7d4c9801d50df41cffa33eedb22a1db1ac7cf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e31cbdfc41
commit
12fe9dde02
@@ -0,0 +1,7 @@
|
||||
package p1;
|
||||
|
||||
public class A1111 {
|
||||
void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package p2;
|
||||
|
||||
public class A2222 {
|
||||
void foo(p1.A1111 a) {
|
||||
a.hashCode();
|
||||
// a.foo();
|
||||
a.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -2214,4 +2214,22 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
// now A2222 is no longer unused
|
||||
assertEmpty(doHighlighting(HighlightSeverity.WARNING));
|
||||
}
|
||||
|
||||
// test the other type of PSI change: child remove/child add
|
||||
public void testTypingInsideCodeBlockCanAffectUnusedDeclarationInTheOtherClass2() {
|
||||
enableInspectionTool(new UnusedSymbolLocalInspection());
|
||||
enableDeadCodeInspection();
|
||||
configureByFiles(null, BASE_PATH+getTestName(true)+"/p1/A1111.java", BASE_PATH+getTestName(true)+"/p2/A2222.java");
|
||||
assertEquals("A1111.java", getFile().getName());
|
||||
makeEditorWindowVisible(new Point(0, 1000), myEditor);
|
||||
HighlightInfo info = assertOneElement(doHighlighting(HighlightSeverity.WARNING));
|
||||
assertEquals("Method 'foo()' is never used", info.getDescription());
|
||||
|
||||
Document document2222 = getFile().getParent().findFile("A2222.java").getFileDocument();
|
||||
// uncomment (inside codeblock) the reference to A1111
|
||||
WriteCommandAction.writeCommandAction(myProject).run(()->document2222.deleteString(document2222.getText().indexOf("//"), document2222.getText().indexOf("//")+2));
|
||||
|
||||
// now foo() is no longer unused
|
||||
assertEmpty(doHighlighting(HighlightSeverity.WARNING));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,11 @@ final class PsiChangeHandler extends PsiTreeChangeAdapter {
|
||||
return true;
|
||||
}
|
||||
PsiElement newChild = event.getNewChild();
|
||||
return newChild != null && newChild != oldChild && hasReferenceInside(newChild);
|
||||
if (newChild != null && newChild != oldChild && hasReferenceInside(newChild)) {
|
||||
return true;
|
||||
}
|
||||
PsiElement child = event.getChild();
|
||||
return child != null && child != oldChild && child != newChild && hasReferenceInside(child);
|
||||
}
|
||||
|
||||
private void queueElement(@NotNull PsiElement child, boolean whitespaceOptimizationAllowed, @NotNull PsiTreeChangeEvent event) {
|
||||
|
||||
Reference in New Issue
Block a user