--- a/tools/JavaSourceHighlighter.st Mon Sep 16 14:09:52 2013 +0100
+++ b/tools/JavaSourceHighlighter.st Tue Sep 17 11:22:20 2013 +0100
@@ -28,6 +28,13 @@
category:'Languages-Java-Tools-Source'
!
+Object subclass:#Indexer
+ instanceVariableNames:'index'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:JavaSourceHighlighter
+!
+
Object subclass:#Marker
instanceVariableNames:'highlighter'
classVariableNames:'MARK_KEYWORD MARK_NUMBER MARK_STRING MARK_CHARACTER MARK_COMMENT
@@ -313,11 +320,18 @@
document := JavaSourceDocument cachedDocumentFor: class theNonMetaclass.
document notNil ifTrue:[
(document sourceText notNil and:[document sourceText string = source]) ifTrue:[
+ (sourceIndex notNil and:[document sourceTreeIndex notNil]) ifTrue:[
+ sourceIndex addAll: document sourceTreeIndex.
+ ].
^ document sourceText copy.
].
+ ] ifFalse:[
+ document := JavaSourceDocument for: class theNonMetaclass.
+ (sourceIndex isNil and:[SmallSense::ParseTreeIndex notNil]) ifTrue:[
+ sourceIndex := SmallSense::ParseTreeIndex new.
+ ].
+ JavaSourceDocument cachedDocumentFor: class theNonMetaclass put: document.
].
- document := JavaSourceDocument for: class theNonMetaclass.
- JavaSourceDocument cachedDocumentFor: class theNonMetaclass put: document.
].
marker := Marker new.
marker highlighter: self.
@@ -338,6 +352,13 @@
sourceUnit setContents: source string.
parser := (Java classForName:'stx.libjava.tools.text.Highlighter') new.
parser setMarker: marker.
+ (sourceIndex notNil and:[sourceIndex isKindOf: SmallSense::ParseTreeIndex]) ifTrue:[
+ | indexer |
+
+ indexer := Indexer new.
+ indexer index: sourceIndex.
+ parser setIndexer: indexer.
+ ].
parser parse: sourceUnit diet: false resolve: true.
].
@@ -347,13 +368,14 @@
^ cacheIt ifTrue:[
document sourceText: sourceText.
+ document sourceTreeIndex: sourceIndex.
sourceText copy
] ifFalse:[
sourceText
]
"Created: / 17-03-2012 / 14:02:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 12-09-2013 / 01:02:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 17-09-2013 / 01:31:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaSourceHighlighter methodsFor:'queries'!
@@ -697,6 +719,39 @@
"Modified: / 4.3.1999 / 12:56:13 / cg"
! !
+!JavaSourceHighlighter::Indexer class methodsFor:'initialization'!
+
+initialize
+ "Invoked at system start or when the class is dynamically loaded."
+
+ self lookupObject: JavaLookup instance.
+
+
+ "/ please change as required (and remove this comment)
+
+ "Modified: / 17-09-2013 / 01:33:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+
+!JavaSourceHighlighter::Indexer methodsFor:'accessing'!
+
+index
+ ^ index
+!
+
+index:aParseTreeIndex
+ index := aParseTreeIndex.
+! !
+
+!JavaSourceHighlighter::Indexer methodsFor:'indexing'!
+
+index: node from: start to: stop
+
+ index add: (index newElementFor: node)
+
+ "Created: / 17-09-2013 / 01:08:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!JavaSourceHighlighter::Marker class methodsFor:'initialization'!
initialize
@@ -882,4 +937,5 @@
! !
+JavaSourceHighlighter::Indexer initialize!
JavaSourceHighlighter::Marker initialize!