--- a/SmallSense__JavaCompletionEngine.st Thu Aug 07 10:24:03 2014 +0100
+++ b/SmallSense__JavaCompletionEngine.st Thu Aug 07 10:30:23 2014 +0100
@@ -153,22 +153,35 @@
complete
- | position entry node |
+ | position source parser tree finder node scope |
position := context codeView characterPositionOfCursor.
- codeView syntaxElements notEmptyOrNil ifTrue:[
- entry := codeView syntaxElements atCharacterPosition: position - 1.
- entry notNil ifTrue:[
- node := entry node
+
+ source := JAVA stx libjava tools Source new.
+ source setContents: codeView list asStringWithoutEmphasis.
+ parser := JAVA stx libjava tools parser Parser new.
+ tree := parser parse: source diet: true resolve: true.
+
+ "
+ (SmallSense::ParseTreeInspector new node:tree source: codeView list asString) open
+ "
+
+ (tree notNil and:[tree types notEmptyOrNil]) ifTrue:[
+ classTree := tree types detect:[:t | (position - 1) between: t declarationSourceStart and: t declarationSourceEnd ] ifNone:[nil].
+ (classTree notNil and: [ classTree methods notEmptyOrNil ]) ifTrue:[
+ methodTree := classTree methods detect:[:m | (position - 1) between: m declarationSourceStart and: m declarationSourceEnd ] ifNone:[nil].
+ methodTree notNil ifTrue:[
+ methodTree parseStatements: parser in: tree.
+ ].
].
- codeView syntaxElements tree notNil ifTrue:[
- classTree := (codeView syntaxElements tree types ? #()) detect:[:t | (position - 1) between: t declarationSourceStart and: t declarationSourceEnd ] ifNone:[nil].
- classTree notNil ifTrue:[
- methodTree := (classTree methods ? #()) detect:[:m | (position - 1) between: m declarationSourceStart and: m declarationSourceEnd ] ifNone:[nil].
- ]
- ].
+ finder := JAVA stx libjava tools ast ASTNodeFinder new.
+ finder setPosition: position - 1.
+ tree traverse: finder scope: tree scope.
+ node := finder node.
+ scope := finder scope.
].
+
context node: node position: position.
node isNil ifTrue:[
@@ -180,6 +193,6 @@
^ result
"Created: / 02-10-2013 / 13:55:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 13-05-2014 / 17:21:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 07-08-2014 / 10:05:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !