Skip to content

Commit 46bc9a5

Browse files
committed
refact: use new instanceof syntax
1 parent 50718a7 commit 46bc9a5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/main/java/org/antlr/intellij/plugin/preview/HierarchyViewer.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ public void selectNodeAtOffset(int offset) {
112112
private DefaultMutableTreeNode getNodeAtOffset(DefaultMutableTreeNode node, int offset) {
113113
Tree tree = (Tree) node.getUserObject();
114114

115-
if ( tree instanceof ParserRuleContext ) {
116-
ParserRuleContext ctx = (ParserRuleContext) tree;
115+
if ( tree instanceof ParserRuleContext ctx ) {
117116
if ( inBounds(ctx, offset) ) {
118117
for ( int i = 0; i<node.getChildCount(); i++ ) {
119118
DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i);
@@ -127,9 +126,7 @@ private DefaultMutableTreeNode getNodeAtOffset(DefaultMutableTreeNode node, int
127126
return node;
128127
}
129128
}
130-
else if ( tree instanceof TerminalNode ) {
131-
TerminalNode terminal = (TerminalNode) tree;
132-
129+
else if ( tree instanceof TerminalNode terminal ) {
133130
if ( terminal.getSymbol().getStartIndex()<=offset && terminal.getSymbol().getStopIndex()>=offset ) {
134131
return node;
135132
}

0 commit comments

Comments
 (0)