Skip to content

Commit

Permalink
Add JSDoc, VariableStatement, Accessor is[GS]etter:
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhrmanator committed Aug 23, 2023
1 parent 64d1393 commit 84c30f4
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ FamixTypeScriptImportingContext >> importInvocation [
^ self importAssociation: (self class fm3ClassNamed: #Invocation)
]

{ #category : #importing }
FamixTypeScriptImportingContext >> importJSDoc [

<generated>
^ self importConcreteEntity: (self class fm3ClassNamed: #JSDoc)
]

{ #category : #importing }
FamixTypeScriptImportingContext >> importMethod [

Expand Down Expand Up @@ -281,6 +288,13 @@ FamixTypeScriptImportingContext >> importVariable [
^ self importConcreteEntity: (self class fm3ClassNamed: #Variable)
]

{ #category : #importing }
FamixTypeScriptImportingContext >> importVariableStatement [

<generated>
^ self importConcreteEntity: (self class fm3ClassNamed: #VariableStatement)
]

{ #category : #importing }
FamixTypeScriptImportingContext >> importimplicitVariable [

Expand Down Expand Up @@ -428,6 +442,13 @@ FamixTypeScriptImportingContext >> shouldImportInvocation [
^ self shouldImport: #Invocation
]

{ #category : #testing }
FamixTypeScriptImportingContext >> shouldImportJSDoc [

<generated>
^ self shouldImport: #JSDoc
]

{ #category : #testing }
FamixTypeScriptImportingContext >> shouldImportMethod [

Expand Down Expand Up @@ -554,6 +575,13 @@ FamixTypeScriptImportingContext >> shouldImportVariable [
^ self shouldImport: #Variable
]

{ #category : #testing }
FamixTypeScriptImportingContext >> shouldImportVariableStatement [

<generated>
^ self shouldImport: #VariableStatement
]

{ #category : #testing }
FamixTypeScriptImportingContext >> shouldImportimplicitVariable [

Expand Down
17 changes: 17 additions & 0 deletions src/Famix-TypeScript-Entities/FamixTypeScriptJSDoc.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"
I represent a TypeScript (JavaScript) Doc element.
"
Class {
#name : #FamixTypeScriptJSDoc,
#superclass : #FamixTypeScriptSourcedEntity,
#category : #'Famix-TypeScript-Entities-Entities'
}

{ #category : #meta }
FamixTypeScriptJSDoc class >> annotation [

<FMClass: #JSDoc super: #FamixTypeScriptSourcedEntity>
<package: #FamixTypeScript>
<generated>
^ self
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"
I represent a TypeScript variable statement.
"
Class {
#name : #FamixTypeScriptVariableStatement,
#superclass : #FamixTypeScriptType,
#category : #'Famix-TypeScript-Entities-Entities'
}

{ #category : #meta }
FamixTypeScriptVariableStatement class >> annotation [

<FMClass: #VariableStatement super: #FamixTypeScriptType>
<package: #FamixTypeScript>
<generated>
^ self
]
17 changes: 17 additions & 0 deletions src/Famix-TypeScript-Extensions/FamixTHasKind.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Extension { #name : #FamixTHasKind }

{ #category : #'*Famix-TypeScript-Extensions' }
FamixTHasKind >> isGetter: aBoolean [

aBoolean
ifTrue: [ self beGetter ]
ifFalse: [ self isGetter ifTrue: [ self kind: nil ] ]
]

{ #category : #'*Famix-TypeScript-Extensions' }
FamixTHasKind >> isSetter: aBoolean [

aBoolean
ifTrue: [ self beSetter ]
ifFalse: [ self isSetter ifTrue: [ self kind: nil ] ]
]
14 changes: 10 additions & 4 deletions src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Class {
'importClause',
'reference',
'accessor',
'property'
'property',
'variableStatement',
'jsDoc'
],
#category : #'Famix-TypeScript-Generator'
}
Expand Down Expand Up @@ -97,7 +99,7 @@ FamixTypeScriptGenerator >> defineClasses [
super defineClasses.

access := builder newClassNamed: #Access.
accessor:= builder newClassNamed: #Accessor comment:'I represent a TypeScript Accessor (getter or setter)'.
accessor := builder newClassNamed: #Accessor comment: 'I represent a TypeScript Accessor (getter or setter)'.
alias := builder newClassNamed: #Alias.
association:= builder newClassNamed: #Association.
behaviouralEntity := builder newClassNamed: #BehaviouralEntity.
Expand All @@ -123,6 +125,7 @@ FamixTypeScriptGenerator >> defineClasses [
interface := builder newClassNamed: #Interface comment: 'I represent a TypeScript interface.'.
interface withTesting.
invocation := builder newClassNamed: #Invocation.
jsDoc := builder newClassNamed: #JSDoc comment: 'I represent a TypeScript (JavaScript) Doc element.'.
method := builder newClassNamed: #Method comment: 'I represent a TypeScript method.'.
module := builder newClassNamed: #Module.
namespace := builder newClassNamed: #Namespace.
Expand All @@ -137,7 +140,7 @@ FamixTypeScriptGenerator >> defineClasses [
structuralEntity := builder newClassNamed: #StructuralEntity.
type := builder newClassNamed: #Type comment: 'I represent a TypeScript type.'.
variable := builder newClassNamed: #Variable comment: 'I represent a TypeScript variable.'.

variableStatement := builder newClassNamed: #VariableStatement comment: 'I represent a TypeScript variable statement.'.

primitiveType withTesting.
"self defineComments."
Expand All @@ -151,7 +154,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
access--|>association.
access --|> #TAccess.

accessor --|> method.
accessor --|> method.

alias--|> namedEntity.

Expand Down Expand Up @@ -239,6 +242,8 @@ FamixTypeScriptGenerator >> defineHierarchy [


implementation --|> #TImplementation.

jsDoc --|> sourcedEntity.

method --|> behaviouralEntity.
method --|> #TMethod.
Expand Down Expand Up @@ -305,6 +310,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
variable --|> structuralEntity.
variable --|> #TLocalVariable.

variableStatement --|> type. "Maël added"
]

{ #category : #definition }
Expand Down
31 changes: 31 additions & 0 deletions src/Famix-TypeScript-Tests/FamixTypeScriptAccessorTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Class {
#name : #FamixTypeScriptAccessorTest,
#superclass : #TestCase,
#instVars : [
'setterAccessor',
'getterAccessor'
],
#category : #'Famix-TypeScript-Tests'
}

{ #category : #initialization }
FamixTypeScriptAccessorTest >> setUp [
super setUp.
setterAccessor := FamixTypeScriptMethod new.
setterAccessor beSetter.
getterAccessor := FamixTypeScriptMethod new.
getterAccessor beGetter.

]

{ #category : #tests }
FamixTypeScriptAccessorTest >> testIsGetter [
self assert: getterAccessor isGetter.
self deny: setterAccessor isGetter.
]

{ #category : #tests }
FamixTypeScriptAccessorTest >> testIsSetter [
self assert: setterAccessor isSetter.
self deny: getterAccessor isSetter.
]

0 comments on commit 84c30f4

Please sign in to comment.