Initial support for source code indexing (for semi-modal navigation)
Not yet finished.
--- a/tools/JavaLintService.st Mon Sep 16 14:09:52 2013 +0100
+++ b/tools/JavaLintService.st Tue Sep 17 11:22:20 2013 +0100
@@ -12,7 +12,7 @@
"{ Package: 'stx:libjava/tools' }"
Tools::BackgroundSourceProcessingService subclass:#JavaLintService
- instanceVariableNames:'highlighter problems'
+ instanceVariableNames:'highlighter problems lastClass'
classVariableNames:'Debugging'
poolDictionaries:''
category:'Languages-Java-Tools-Editor-Lint'
@@ -254,6 +254,8 @@
"textView" modified ifFalse:[
Screen currentScreenQuerySignal answer:codeView device
do:[
+ | rehighlight |
+
Error handle:[:ex |
|errMsg|
@@ -269,17 +271,20 @@
"/ self halt.
"/ self showInfo:(errMsg colorizeAllWith:Color red).
] do:[
- | compiler |
+ | compiler newProblems |
compiler := JavaCompiler new.
- problems := compiler check: oldCode.
+ newProblems := compiler check: oldCode.
+ rehighlight := newProblems notEmpty or:[ problems notEmpty ].
highlighter problem: problems ? #()
].
- delayed ifTrue:[
- codeView sensor pushUserEvent:#rehighlight: for:self withArgument: true.
- ] ifFalse:[
- self rehighlight: true.
- ]
+ rehighlight ifTrue:[
+ delayed ifTrue:[
+ codeView sensor pushUserEvent:#rehighlight: for:self withArgument: true.
+ ] ifFalse:[
+ self rehighlight: true.
+ ]
+ ].
]
]
]
@@ -287,7 +292,7 @@
]
"Created: / 24-01-2012 / 12:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 16-09-2013 / 10:37:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 17-09-2013 / 00:40:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
rehighlight: delayed
@@ -347,5 +352,17 @@
"Modified: / 16-09-2013 / 13:36:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!JavaLintService methodsFor:'registering'!
+
+registerIn: aCodeView
+
+ super registerIn: aCodeView.
+ aCodeView languageHolder addDependent: self.
+ aCodeView classHolder addDependent: self.
+ aCodeView methodHolder addDependent: self.
+
+ "Created: / 17-09-2013 / 00:31:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
JavaLintService initialize!
--- a/tools/JavaSourceDocument.st Mon Sep 16 14:09:52 2013 +0100
+++ b/tools/JavaSourceDocument.st Tue Sep 17 11:22:20 2013 +0100
@@ -1,7 +1,8 @@
"{ Package: 'stx:libjava/tools' }"
Object subclass:#JavaSourceDocument
- instanceVariableNames:'javaClass sourceText sourceTree sourceLineEnds sourceTreeLock'
+ instanceVariableNames:'javaClass sourceText sourceTree sourceTreeIndex sourceLineEnds
+ sourceTreeLock'
classVariableNames:'Cache CacheSize Job'
poolDictionaries:''
category:'Languages-Java-Tools-Source'
@@ -187,6 +188,14 @@
"Created: / 13-09-2013 / 11:06:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+sourceTreeIndex
+ ^ sourceTreeIndex
+!
+
+sourceTreeIndex:aParseTreeIndex
+ sourceTreeIndex := aParseTreeIndex.
+!
+
sourceTreeOrNilIfParsing
sourceTree isNil ifTrue:[
sourceTreeLock notNil ifTrue:[
--- 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!
--- a/tools/Make.proto Mon Sep 16 14:09:52 2013 +0100
+++ b/tools/Make.proto Tue Sep 17 11:22:20 2013 +0100
@@ -141,10 +141,9 @@
cd ../../libui && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../../libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../../goodies/petitparser && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd ../ && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../../libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
- cd ../../goodies/sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../../libwidg && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
- cd ../ && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../../libwidg2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd ../../libtool && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
--- a/tools/bc.mak Mon Sep 16 14:09:52 2013 +0100
+++ b/tools/bc.mak Tue Sep 17 11:22:20 2013 +0100
@@ -58,10 +58,9 @@
pushd ..\..\libui & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\goodies\petitparser & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd .. & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
- pushd ..\..\goodies\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\libwidg & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
- pushd .. & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\libwidg2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\libtool & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/ASTNode.st Tue Sep 17 11:22:20 2013 +0100
@@ -0,0 +1,29 @@
+"{ Package: 'stx:libjava/tools' }"
+
+!
+
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.ASTNode') methodsFor:'* instance *'!
+
+endPosition
+ ^ sourceEnd
+! !
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.ASTNode') methodsFor:'* instance *'!
+
+isSelector
+ ^ false
+! !
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.ASTNode') methodsFor:'* instance *'!
+
+isSelf
+ ^ false
+! !
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.ASTNode') methodsFor:'* instance *'!
+
+isVariable
+ ^ false
+! !
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.ASTNode') methodsFor:'* instance *'!
+
+startPosition
+ ^ sourceStart
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/FieldReference.st Tue Sep 17 11:22:20 2013 +0100
@@ -0,0 +1,9 @@
+"{ Package: 'stx:libjava/tools' }"
+
+!
+
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.FieldReference') methodsFor:'* instance *'!
+
+isVariable
+ ^ true
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/MessageSend.st Tue Sep 17 11:22:20 2013 +0100
@@ -0,0 +1,9 @@
+"{ Package: 'stx:libjava/tools' }"
+
+!
+
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.MessageSend') methodsFor:'* instance *'!
+
+isSelector
+ ^ true
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/java/extensions/org/eclipse/jdt/internal/compiler/ast/ThisReference.st Tue Sep 17 11:22:20 2013 +0100
@@ -0,0 +1,9 @@
+"{ Package: 'stx:libjava/tools' }"
+
+!
+
+!(Java classForName:'org.eclipse.jdt.internal.compiler.ast.ThisReference') methodsFor:'* instance *'!
+
+isSelf
+ ^ true
+! !
--- a/tools/java/src/stx/libjava/tools/compiler/CompilerAdapter.java Mon Sep 16 14:09:52 2013 +0100
+++ b/tools/java/src/stx/libjava/tools/compiler/CompilerAdapter.java Tue Sep 17 11:22:20 2013 +0100
@@ -59,14 +59,15 @@
* @return true, if compilation succeeded, false otherwise.
*/
public boolean compile(String source, boolean generate) {
+ CompilerOptions options = getDefaultCompilerOptions();
ICompilerRequestor requestor = this;
IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
Source[] units = new Source[1];
units[0] = new Source(source);
- units[0].setName();
-
- org.eclipse.jdt.internal.compiler.Compiler compiler = new org.eclipse.jdt.internal.compiler.Compiler(environment, policy, getDefaultCompilerOptions(), requestor, problemFactory);
+ units[0].setName();
+ options.generateClassFiles = generate;
+ org.eclipse.jdt.internal.compiler.Compiler compiler = new org.eclipse.jdt.internal.compiler.Compiler(environment, policy, options, requestor, problemFactory);
compiler.compile(units);
return getResult().hasErrors();
}
--- a/tools/tools.rc Mon Sep 16 14:09:52 2013 +0100
+++ b/tools/tools.rc Tue Sep 17 11:22:20 2013 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\0"
VALUE "ProductName", "Smalltalk/X\0"
VALUE "ProductVersion", "6.2.3.0\0"
- VALUE "ProductDate", "Mon, 16 Sep 2013 12:57:36 GMT\0"
+ VALUE "ProductDate", "Tue, 17 Sep 2013 10:11:48 GMT\0"
END
END