diff options
| author | 2014-08-10 16:58:49 -0400 | |
|---|---|---|
| committer | 2014-08-10 16:58:49 -0400 | |
| commit | 044f109bfa9ae55430456b1cf21ed56a3902bff2 (patch) | |
| tree | d0cf925cb949b00fda09f37ffe9f8b150e051514 /src/cuchaz/enigma/analysis/SourceIndex.java | |
| parent | completely re-wrote token recognizer to bootstrap from Procyon's AST (diff) | |
| download | enigma-fork-044f109bfa9ae55430456b1cf21ed56a3902bff2.tar.gz enigma-fork-044f109bfa9ae55430456b1cf21ed56a3902bff2.tar.xz enigma-fork-044f109bfa9ae55430456b1cf21ed56a3902bff2.zip | |
fixed recognition of static initializers
fixed identifier off-by-one error
Diffstat (limited to 'src/cuchaz/enigma/analysis/SourceIndex.java')
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndex.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/cuchaz/enigma/analysis/SourceIndex.java b/src/cuchaz/enigma/analysis/SourceIndex.java index 398a50d..7981f87 100644 --- a/src/cuchaz/enigma/analysis/SourceIndex.java +++ b/src/cuchaz/enigma/analysis/SourceIndex.java | |||
| @@ -57,10 +57,24 @@ public class SourceIndex | |||
| 57 | { | 57 | { |
| 58 | throw new IllegalArgumentException( "Invalid region: " + region ); | 58 | throw new IllegalArgumentException( "Invalid region: " + region ); |
| 59 | } | 59 | } |
| 60 | return new Token( | 60 | Token token = new Token( |
| 61 | toPos( region.getBeginLine(), region.getBeginColumn() ), | 61 | toPos( region.getBeginLine(), region.getBeginColumn() ), |
| 62 | toPos( region.getEndLine(), region.getEndColumn() ) | 62 | toPos( region.getEndLine(), region.getEndColumn() ) |
| 63 | ); | 63 | ); |
| 64 | |||
| 65 | // HACKHACK: sometimes node regions are off by one | ||
| 66 | // I think this is a bug in Procyon, but it's easy to work around | ||
| 67 | if( !Character.isJavaIdentifierStart( m_source.charAt( token.start ) ) ) | ||
| 68 | { | ||
| 69 | token.start++; | ||
| 70 | token.end++; | ||
| 71 | if( !Character.isJavaIdentifierStart( m_source.charAt( token.start ) ) ) | ||
| 72 | { | ||
| 73 | throw new IllegalArgumentException( "Region " + region + " does not describe valid token: '" + m_source.substring( token.start, token.end ) + "'" ); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | return token; | ||
| 64 | } | 78 | } |
| 65 | 79 | ||
| 66 | public void add( AstNode node, Entry entry ) | 80 | public void add( AstNode node, Entry entry ) |