From 044f109bfa9ae55430456b1cf21ed56a3902bff2 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 10 Aug 2014 16:58:49 -0400 Subject: fixed recognition of static initializers fixed identifier off-by-one error --- src/cuchaz/enigma/analysis/SourceIndex.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/cuchaz/enigma/analysis/SourceIndex.java') 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 { throw new IllegalArgumentException( "Invalid region: " + region ); } - return new Token( + Token token = new Token( toPos( region.getBeginLine(), region.getBeginColumn() ), toPos( region.getEndLine(), region.getEndColumn() ) ); + + // HACKHACK: sometimes node regions are off by one + // I think this is a bug in Procyon, but it's easy to work around + if( !Character.isJavaIdentifierStart( m_source.charAt( token.start ) ) ) + { + token.start++; + token.end++; + if( !Character.isJavaIdentifierStart( m_source.charAt( token.start ) ) ) + { + throw new IllegalArgumentException( "Region " + region + " does not describe valid token: '" + m_source.substring( token.start, token.end ) + "'" ); + } + } + + return token; } public void add( AstNode node, Entry entry ) -- cgit v1.2.3