Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlocklogic committed Nov 17, 2020
2 parents 5419a83 + b7b62b7 commit 3a25eb0
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

package com.github.javaparser.printer.lexicalpreservation;

import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.observer.AstObserver;
import com.github.javaparser.ast.observer.AstObserverAdapter;
import com.github.javaparser.ast.type.UnknownType;
import static java.util.Collections.synchronizedMap;

import java.util.IdentityHashMap;
import java.util.Map;

import static java.util.Collections.synchronizedMap;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.observer.AstObserver;
import com.github.javaparser.ast.observer.AstObserverAdapter;
import com.github.javaparser.ast.type.UnknownType;

/**
* We want to recognize and ignore "phantom" nodes, like the fake type of variable in FieldDeclaration
Expand All @@ -54,8 +54,10 @@ static boolean isPhantomNode(Node node) {
if (node instanceof UnknownType) {
return true;
}
boolean res = (node.getParentNode().isPresent() &&
!node.getParentNode().get().getRange().get().contains(node.getRange().get())
boolean res = (node.getParentNode().isPresent()
&& node.getParentNode().get().hasRange()
&& node.hasRange()
&& !node.getParentNode().get().getRange().get().contains(node.getRange().get())
|| inPhantomNode(node, LEVELS_TO_EXPLORE));
isPhantomNodeCache.put(node, res);
node.register(cacheCleaner);
Expand Down

0 comments on commit 3a25eb0

Please sign in to comment.