diff options
Diffstat (limited to 'src/cuchaz/enigma/analysis/SourceIndex.java')
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndex.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cuchaz/enigma/analysis/SourceIndex.java b/src/cuchaz/enigma/analysis/SourceIndex.java index 7981f87..ad94cf0 100644 --- a/src/cuchaz/enigma/analysis/SourceIndex.java +++ b/src/cuchaz/enigma/analysis/SourceIndex.java | |||
| @@ -25,12 +25,14 @@ public class SourceIndex | |||
| 25 | { | 25 | { |
| 26 | private String m_source; | 26 | private String m_source; |
| 27 | private TreeMap<Token,Entry> m_tokens; | 27 | private TreeMap<Token,Entry> m_tokens; |
| 28 | private Map<Entry,Token> m_declarations; | ||
| 28 | private List<Integer> m_lineOffsets; | 29 | private List<Integer> m_lineOffsets; |
| 29 | 30 | ||
| 30 | public SourceIndex( String source ) | 31 | public SourceIndex( String source ) |
| 31 | { | 32 | { |
| 32 | m_source = source; | 33 | m_source = source; |
| 33 | m_tokens = Maps.newTreeMap(); | 34 | m_tokens = Maps.newTreeMap(); |
| 35 | m_declarations = Maps.newHashMap(); | ||
| 34 | m_lineOffsets = Lists.newArrayList(); | 36 | m_lineOffsets = Lists.newArrayList(); |
| 35 | 37 | ||
| 36 | // count the lines | 38 | // count the lines |
| @@ -82,9 +84,11 @@ public class SourceIndex | |||
| 82 | m_tokens.put( getToken( node ), entry ); | 84 | m_tokens.put( getToken( node ), entry ); |
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | public void add( Token token, Entry entry ) | 87 | public void addDeclaration( AstNode node, Entry entry ) |
| 86 | { | 88 | { |
| 89 | Token token = getToken( node ); | ||
| 87 | m_tokens.put( token, entry ); | 90 | m_tokens.put( token, entry ); |
| 91 | m_declarations.put( entry, token ); | ||
| 88 | } | 92 | } |
| 89 | 93 | ||
| 90 | public Token getToken( int pos ) | 94 | public Token getToken( int pos ) |
| @@ -116,6 +120,11 @@ public class SourceIndex | |||
| 116 | return m_tokens.keySet(); | 120 | return m_tokens.keySet(); |
| 117 | } | 121 | } |
| 118 | 122 | ||
| 123 | public Token getDeclarationToken( Entry entry ) | ||
| 124 | { | ||
| 125 | return m_declarations.get( entry ); | ||
| 126 | } | ||
| 127 | |||
| 119 | private int toPos( int line, int col ) | 128 | private int toPos( int line, int col ) |
| 120 | { | 129 | { |
| 121 | // line and col are 1-based | 130 | // line and col are 1-based |