Finished JavaCompiler::ClassSourceAnalyzer refactoring. development
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 15 Dec 2012 22:51:30 +0100
branchdevelopment
changeset 1882 0178ded13292
parent 1881 80d037e8a596
child 1883 b36e52129040
Finished JavaCompiler::ClassSourceAnalyzer refactoring. Analyzer now returns package, imports and first class name occured in a given compilation unit.
experiments/JavaCompiler.st
experiments/JavaCompilerTests.st
experiments/experiments.rc
--- a/experiments/JavaCompiler.st	Sat Dec 15 22:49:41 2012 +0100
+++ b/experiments/JavaCompiler.st	Sat Dec 15 22:51:30 2012 +0100
@@ -287,17 +287,12 @@
     "Created: / 15-12-2012 / 17:28:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-qualifiedNameForImport
-
-"/    ^qualifiedName , ( (self tokenFor: '.') , (self tokenFor: '*') ) optional
+packageDeclaration 
 
-    ^super qualifiedNameForImport ==> [:nodes|
-        String streamContents:[:s|
-            nodes do:[:e|s nextPutAll:e value].
-        ]
-    ]
+"/        ^ (self  packageKW) , qualifiedName , (self tokenFor:';')
+    ^super packageDeclaration ==> [:nodes| package := nodes second ].
 
-    "Created: / 15-12-2012 / 17:41:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 15-12-2012 / 22:44:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaCompiler::ClassSourceAnalyzer methodsFor:'grammar-classes'!
--- a/experiments/JavaCompilerTests.st	Sat Dec 15 22:49:41 2012 +0100
+++ b/experiments/JavaCompilerTests.st	Sat Dec 15 22:51:30 2012 +0100
@@ -103,10 +103,11 @@
             with: 'stxLibjavaTests'.
     imports := (JavaCompiler newAnalyzer analyze: source) imports.
     self 
-        assert: imports = expectedImports
+        assert: imports asArray = expectedImports asArray   
         message: 'analyzer should return an array containing "java.util.List"'.
 
     "Created: / 08-12-2012 / 20:12:23 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+    "Modified: / 15-12-2012 / 22:42:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testGettingImportWhenNonePresent
@@ -147,14 +148,15 @@
 public class Foo {}
 '.
     expectedImports := Array 
-            with: 'org.junit.Assert'
+            with: 'org.junit.Assert.*'
             with: 'java.util.Collection'
             with: 'stxLibjavaTests'.
     imports := (JavaCompiler newAnalyzer analyze: source) imports.
-    self assert: imports = expectedImports
+    self assert: imports asArray = expectedImports asArray
         message: 'analyzer should return an array containing "java.util.List"'.
 
     "Created: / 08-12-2012 / 20:13:15 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+    "Modified: / 15-12-2012 / 22:43:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaCompilerTests methodsFor:'analyzer - package tests'!
--- a/experiments/experiments.rc	Sat Dec 15 22:49:41 2012 +0100
+++ b/experiments/experiments.rc	Sat Dec 15 22:51:30 2012 +0100
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2012\nCopyright eXept Software AG 1998-2012\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Sat, 15 Dec 2012 16:57:02 GMT\0"
+      VALUE "ProductDate", "Sat, 15 Dec 2012 21:49:53 GMT\0"
     END
 
   END