Skip to content

Commit

Permalink
Handle arrays
Browse files Browse the repository at this point in the history
moosetechnology/FAST-JAVA#210 is blocking further progress on this front
  • Loading branch information
Gabriel-Darbord committed Jan 9, 2024
1 parent f3eebe5 commit 094b00e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Famix-Value-Entities/FamixValueUnknownType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FamixValueUnknownType class >> annotation [
]

{ #category : #visiting }
FamixValueUnknownType >> acceptValueVisitor: visitor for: object [
FamixValueUnknownType >> acceptValueVisitor: visitor forObject: object [

self error: 'Exporting an unknown type is not (yet?) supported.'
]
Expand Down
8 changes: 7 additions & 1 deletion src/Famix-Value-Exporter/FamixJavaType.extension.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Extension { #name : #FamixJavaType }

{ #category : #'*Famix-Value-Exporter' }
FamixJavaType >> acceptValueVisitor: visitor for: object [
FamixJavaType >> acceptValueVisitor: visitor forCollection: collection [

^ visitor visitCollectionOfRegularType: collection
]

{ #category : #'*Famix-Value-Exporter' }
FamixJavaType >> acceptValueVisitor: visitor forObject: object [

^ visitor visitObjectOfRegularType: object
]
Expand Down
9 changes: 8 additions & 1 deletion src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ FamixValue2FASTJavaVisitor >> statementBlock [

{ #category : #visiting }
FamixValue2FASTJavaVisitor >> visitCollection: collection [
"Dispatch to type to handle special cases"

^ collection type acceptValueVisitor: self forCollection: collection
]

{ #category : #visiting }
FamixValue2FASTJavaVisitor >> visitCollectionOfRegularType: collection [

| varName |
self statementBlock addStatement:
Expand Down Expand Up @@ -278,7 +285,7 @@ FamixValue2FASTJavaVisitor >> visitEnumValue: enumValue [
FamixValue2FASTJavaVisitor >> visitObject: object [
"Dispatch to type to handle special cases"

^ object type acceptValueVisitor: self for: object
^ object type acceptValueVisitor: self forObject: object
]

{ #category : #visiting }
Expand Down
24 changes: 17 additions & 7 deletions src/Famix-Value-Importer/FamixJavaEntityFinder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,24 @@ FamixJavaEntityFinder >> methodNameFromSignature: signature [

{ #category : #enumerating }
FamixJavaEntityFinder >> parseTypeName: name [
"The name may not be fully qualified."
"The name may not be fully qualified.
Even if we want to find a name in java.lang or java.util packages, we want to search using the mooseName if it is parameterized.
Famix does not represent arrays, but we need the information, so we use a wrapper around the type."

(name includes: $.) ifFalse: [ ^ self findTypeWithName: name ].
self flag: #VerveineJ.
^ "(name beginsWithAnyOf: #( 'java.lang.' 'java.util.' ))
ifTrue: [ self findTypeWithName: (name copyAfterLast: $.) ]
ifFalse: ["
self findTypeWithMooseName: (name copyReplaceAll: '.' with: '::') "]"
| typeName dimensions type |
typeName := self translateFieldDescriptor: name.
dimensions := name occurrencesOf: $[.
type := (typeName includes: $.)
ifFalse: [ self findTypeWithName: typeName ]
ifTrue: [
self findTypeWithMooseName:
((typeName allButLast: dimensions * 2)
copyReplaceAll: '.'
with: '::') ].
^ dimensions > 0
ifFalse: [ type ]
ifTrue: [
(FamixValueJavaArray proxying: type) dimensions: dimensions ]
]

{ #category : #matching }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ FamixValueAbstractImporter >> initialize [
FamixValueAbstractImporter >> loadType [
"Return the inferred type if it exists, otherwise the type is unknown."

^ self typeInference ifNil: [ self getUnknownTypeNamed: 'UNKNOWN' ]
^ self typeInference ifNil: [ self getDefaultUnknownType ]
]

{ #category : #enumerating }
Expand Down

0 comments on commit 094b00e

Please sign in to comment.