You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by rt...@apache.org on 2018/11/13 13:21:58 UTC
[incubator-netbeans] branch master updated: [NETBEANS-586]: NPE
findUsages (#1016)
This is an automated email from the ASF dual-hosted git repository.
rtaneja pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 8fa7812 [NETBEANS-586]: NPE findUsages (#1016)
8fa7812 is described below
commit 8fa7812c140977cf7962a548c10a65c9bd732d34
Author: Reema Taneja <32...@users.noreply.github.com>
AuthorDate: Tue Nov 13 18:51:52 2018 +0530
[NETBEANS-586]: NPE findUsages (#1016)
* [NETBEANS-586]: NPE findUsages
* Update FindUsagesVisitor.java
* [NETBEANS-586] NPE findUsages
---
.../modules/refactoring/java/plugins/FindUsagesVisitor.java | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
index 051530f..422b560 100644
--- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
+++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
@@ -393,13 +393,10 @@ public class FindUsagesVisitor extends ErrorAwareTreePathScanner<Tree, Element>
Trees trees = workingCopy.getTrees();
ClassTree classTree = ((NewClassTree) node).getClassBody();
if (classTree != null && p.getKind() == ElementKind.CONSTRUCTOR) {
- Element anonClass = workingCopy.getTrees().getElement(TreePath.getPath(workingCopy.getCompilationUnit(), classTree));
- if (anonClass == null) {
- Logger.getLogger("org.netbeans.modules.refactoring.java").log(Level.SEVERE, "FindUsages cannot resolve {0}", classTree); // NOI18N
- } else {
- for (ExecutableElement c : ElementFilter.constructorsIn(anonClass.getEnclosedElements())) {
- MethodTree t = workingCopy.getTrees().getTree(c);
- TreePath superCall = trees.getPath(workingCopy.getCompilationUnit(), ((ExpressionStatementTree) t.getBody().getStatements().get(0)).getExpression());
+ for (Tree t : classTree.getMembers()) {
+ Element elem = workingCopy.getTrees().getElement(TreePath.getPath(workingCopy.getCompilationUnit(), t));
+ if (elem.getKind() == ElementKind.CONSTRUCTOR) {
+ TreePath superCall = trees.getPath(workingCopy.getCompilationUnit(), ((ExpressionStatementTree) ((MethodTree) t).getBody().getStatements().get(0)).getExpression());
Element superCallElement = trees.getElement(superCall);
if (superCallElement != null && superCallElement.equals(p) && !workingCopy.getTreeUtilities().isSynthetic(superCall)) {
addUsage(superCall);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists