-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smart imports + Decorate type expressions + Refactors
- Avoid importing types with same name, refer to them with fully qualified name. - Export arrays correctly, even though Famix does not represent them. - WIP stub export
- Loading branch information
1 parent
796f89d
commit 35b5d56
Showing
20 changed files
with
345 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Class { | ||
#name : #FASTBuilder, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'model' | ||
], | ||
#classVars : [ | ||
'Current' | ||
], | ||
#category : #'Famix-Value-Exporter' | ||
} | ||
|
||
{ #category : #accessing } | ||
FASTBuilder class >> current [ | ||
|
||
^ Current ifNil: [ Current := self new ] | ||
] | ||
|
||
{ #category : #accessing } | ||
FASTBuilder >> beCurrent [ | ||
|
||
Current := self | ||
] | ||
|
||
{ #category : #accessing } | ||
FASTBuilder >> model [ | ||
|
||
^ model ifNil: [ model := FASTJavaModel new ] | ||
] | ||
|
||
{ #category : #accessing } | ||
FASTBuilder >> model: aFASTModel [ | ||
|
||
model := aFASTModel | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
Class { | ||
#name : #FASTJavaBuilder, | ||
#superclass : #FASTBuilder, | ||
#instVars : [ | ||
'imports', | ||
'typeNameDictionary', | ||
'registeredTypes' | ||
], | ||
#category : #'Famix-Value-Exporter' | ||
} | ||
|
||
{ #category : #temp } | ||
FASTJavaBuilder >> fullyQualifiedPackageNameFor: aFamixJavaPackage [ | ||
|
||
^ aFamixJavaPackage parentPackage | ||
ifNil: [ self model newTypeName name: aFamixJavaPackage name ] | ||
ifNotNil: [ :parentPackage | | ||
self model newQualifiedTypeName | ||
name: aFamixJavaPackage name; | ||
namespace: (self fullyQualifiedPackageNameFor: parentPackage) ] | ||
] | ||
|
||
{ #category : #temp } | ||
FASTJavaBuilder >> fullyQualifiedTypeNameFor: aFamixJavaType [ | ||
|
||
^ self model newQualifiedTypeName | ||
name: aFamixJavaType baseName; | ||
namespace: | ||
(self fullyQualifiedPackageNameFor: aFamixJavaType typeContainer) | ||
] | ||
|
||
{ #category : #initialization } | ||
FASTJavaBuilder >> initialize [ | ||
|
||
self reset | ||
] | ||
|
||
{ #category : #temp } | ||
FASTJavaBuilder >> makeImportDeclaration: aFamixType [ | ||
|
||
^ self model newImportDeclaration qualifiedName: | ||
(model newQualifiedName name: aFamixType mooseNameWithDots) | ||
] | ||
|
||
{ #category : #temp } | ||
FASTJavaBuilder >> makeImportDeclarations [ | ||
|
||
^ typeNameDictionary values collect: [ :type | | ||
self makeImportDeclaration: type ] | ||
] | ||
|
||
{ #category : #temp } | ||
FASTJavaBuilder >> processType: aFamixType [ | ||
|
||
| type | | ||
type := aFamixType isParameterizedType | ||
ifTrue: [ | ||
aFamixType arguments do: [ :argument | | ||
self processType: argument ]. | ||
aFamixType parameterizableClass ] | ||
ifFalse: [ aFamixType ]. | ||
type needsJavaImport ifTrue: [ self registerType: type ] | ||
] | ||
|
||
{ #category : #temp } | ||
FASTJavaBuilder >> referType: aFamixType [ | ||
|
||
| registeredType | | ||
self processType: aFamixType. | ||
registeredType := typeNameDictionary | ||
at: aFamixType name | ||
ifAbsent: nil. | ||
^ self model newClassTypeExpression typeName: | ||
((registeredType == aFamixType or: [ | ||
aFamixType needsJavaImport not or: [ | ||
aFamixType isParameterizedType and: [ | ||
registeredType == aFamixType parameterizableClass ] ] ]) | ||
ifTrue: [ "has import" | ||
model newTypeName name: aFamixType baseName ] | ||
ifFalse: [ "no import" | ||
self fullyQualifiedTypeNameFor: aFamixType ]) | ||
] | ||
|
||
{ #category : #temp } | ||
FASTJavaBuilder >> registerType: aFamixType [ | ||
"If the type is in the typeNameDict, it will be imported." | ||
|
||
registeredTypes add: aFamixType. | ||
typeNameDictionary at: aFamixType name ifAbsentPut: aFamixType | ||
] | ||
|
||
{ #category : #initialization } | ||
FASTJavaBuilder >> reset [ | ||
|
||
typeNameDictionary := Dictionary new. | ||
registeredTypes := IdentitySet new | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.