Allow variables from TOPSCOPE to be marked as unused
authorJulien Enselme <jenselme@netbeans.org>
Fri, 11 Sep 2015 15:32:16 +0200
changeset 183054c97c883247c
parent 18304 a075d988c9d5
child 18306 52e4f803a8f8
Allow variables from TOPSCOPE to be marked as unused
python.editor/src/org/netbeans/modules/python/editor/scopes/SymInfo.java
python.editor/src/org/netbeans/modules/python/editor/scopes/SymbolTable.java
     1.1 --- a/python.editor/src/org/netbeans/modules/python/editor/scopes/SymInfo.java	Sat Sep 12 23:03:15 2015 -0700
     1.2 +++ b/python.editor/src/org/netbeans/modules/python/editor/scopes/SymInfo.java	Fri Sep 11 15:32:16 2015 +0200
     1.3 @@ -103,7 +103,9 @@
     1.4      }
     1.5  
     1.6      public boolean isUnused(ScopeInfo info) {
     1.7 -        return (info == null || info.kind == FUNCSCOPE) && (flags & (READ | BOUND | DEF)) == BOUND;
     1.8 +        // Cannot correctly detect usage of variables in CLASSSCOPE
     1.9 +        return (info == null || info.kind == FUNCSCOPE || info.kind == TOPSCOPE) &&
    1.10 +                (flags & (READ | BOUND | DEF)) == BOUND;
    1.11      }
    1.12  
    1.13      public boolean isParameter() {
     2.1 --- a/python.editor/src/org/netbeans/modules/python/editor/scopes/SymbolTable.java	Sat Sep 12 23:03:15 2015 -0700
     2.2 +++ b/python.editor/src/org/netbeans/modules/python/editor/scopes/SymbolTable.java	Fri Sep 11 15:32:16 2015 +0200
     2.3 @@ -1113,7 +1113,7 @@
     2.4          List<PythonTree> unusedNodes = new ArrayList<>();
     2.5  
     2.6          for (ScopeInfo scopeInfo : scopes.values()) {
     2.7 -            if (scopeInfo.kind != FUNCSCOPE) {
     2.8 +            if (scopeInfo.kind != FUNCSCOPE && scopeInfo.kind != TOPSCOPE && scopeInfo.kind != CLASSSCOPE) {
     2.9                  continue;
    2.10              }
    2.11              Set<String> unused = new HashSet<>();