#252630 Correct exception when parsing after the update of jython-parser
authorJulien Enselme <jenselme@netbeans.org>
Thu, 09 Jul 2015 11:37:35 +0200
changeset 182950bf82b105206
parent 18294 28142955865a
child 18297 dcf70135c86f
#252630 Correct exception when parsing after the update of jython-parser
python.editor/src/org/netbeans/modules/python/editor/PythonParser.java
     1.1 --- a/python.editor/src/org/netbeans/modules/python/editor/PythonParser.java	Wed Jul 08 17:38:02 2015 +0200
     1.2 +++ b/python.editor/src/org/netbeans/modules/python/editor/PythonParser.java	Thu Jul 09 11:37:35 2015 +0200
     1.3 @@ -299,19 +299,24 @@
     1.4  
     1.5                          errors.add(new DefaultError(null, message, null, file, start, end, Severity.ERROR));
     1.6  
     1.7 +                        // In order to avoid a StackOverflowError, the BaseRecognizer must be recreated.
     1.8 +                        // We must keep the names of the tokens to avoid a NullPointerException.
     1.9 +                        // See bz252630
    1.10 +                        final String[] tokenNames = br.getTokenNames();
    1.11                          br = new BaseRecognizer() {
    1.12  
    1.13                              @Override
    1.14                              public String getSourceName() {
    1.15                                  return file.getName();
    1.16                              }
    1.17 +
    1.18 +                            @Override
    1.19 +                            public String[] getTokenNames() {
    1.20 +                                return tokenNames;
    1.21 +                            }
    1.22                          };
    1.23 -                        try {
    1.24 -                            super.reportError(br, re);
    1.25 -                        } catch (NullPointerException e) {
    1.26 -                            
    1.27 -                        }
    1.28 -                        
    1.29 +
    1.30 +                        super.reportError(br, re);
    1.31                      }
    1.32                  }
    1.33              };