Skip to content

Commit

Permalink
add ref to fileNameReference in case of import from file
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Aug 21, 2023
1 parent 98e0a71 commit 3579f9e
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Famix-Html-Generator/FamixHtmlGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ FamixHtmlGenerator >> defineProperties [
attribute property: #attributeName type: #String.
attribute property: #attributeValue type: #String.
element property: #tagName type: #String.
tHasIndexedReferenceToImmediateSource property: #startPos type: #Number.
tHasIndexedReferenceToImmediateSource
property: #startPos
type: #Number.
tHasIndexedReferenceToImmediateSource property: #endPos type: #Number.
document property: #fileNameReference type: #String
]

{ #category : #definition }
Expand Down
13 changes: 10 additions & 3 deletions src/Famix-Html-Importer/FamixHtmlImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ FamixHtmlImporter >> create: aType for: aNode [
yourself)
]

{ #category : #'as yet unclassified' }
FamixHtmlImporter >> importFromFileReference: aFileReference [
^ (self importString: aFileReference asFileReference contents)
fileNameReference: aFileReference pathString;
yourself
]

{ #category : #'as yet unclassified' }
FamixHtmlImporter >> importString: aHTMLString [

self accept: (HTMLParser parse: aHTMLString).
^ model
^ self accept: (HTMLParser parse: aHTMLString)
]

{ #category : #accessing }
Expand Down Expand Up @@ -92,7 +98,8 @@ FamixHtmlImporter >> visitDocument: aDocument [
parentNode := self model add: FamixHtmlDocument new.
currentDocument := parentNode.
parentNode source: aDocument source.
self clone visitSmaCCParseNode: aDocument
self clone visitSmaCCParseNode: aDocument.
^ currentDocument
]

{ #category : #generated }
Expand Down
17 changes: 17 additions & 0 deletions src/Famix-Html/FamixHtmlDocument.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Class {
#superclass : #FamixHtmlEntity,
#traits : 'FamixHtmlTWithDomElements + FamixTHasImmediateSource',
#classTraits : 'FamixHtmlTWithDomElements classTrait + FamixTHasImmediateSource classTrait',
#instVars : [
'#fileNameReference => FMProperty'
],
#category : #'Famix-Html-Entities'
}

Expand All @@ -18,6 +21,20 @@ FamixHtmlDocument class >> annotation [
^ self
]

{ #category : #accessing }
FamixHtmlDocument >> fileNameReference [

<FMProperty: #fileNameReference type: #String>
<generated>
^ fileNameReference
]

{ #category : #accessing }
FamixHtmlDocument >> fileNameReference: anObject [
<generated>
fileNameReference := anObject
]

{ #category : #testing }
FamixHtmlDocument >> isDocument [

Expand Down
2 changes: 2 additions & 0 deletions src/Famix-Html/FamixHtmlModel.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Class {
#name : #FamixHtmlModel,
#superclass : #MooseModel,
#traits : 'FamixHtmlTEntityCreator',
#classTraits : 'FamixHtmlTEntityCreator classTrait',
#category : #'Famix-Html-Model'
}

Expand Down
52 changes: 52 additions & 0 deletions src/Famix-Html/FamixHtmlTEntityCreator.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"
This trait is used by Famix models.
It provides an API for creating entities and adding them to the model.
"
Trait {
#name : #FamixHtmlTEntityCreator,
#category : #'Famix-Html-Model'
}

{ #category : #meta }
FamixHtmlTEntityCreator classSide >> annotation [

<FMClass: #TEntityCreator super: #Object>
<package: #'Famix-Html'>
<generated>
^ self
]

{ #category : #'entity creation' }
FamixHtmlTEntityCreator >> newAttribute [

<generated>
^ self add: FamixHtmlAttribute new
]

{ #category : #'entity creation' }
FamixHtmlTEntityCreator >> newDocument [

<generated>
^ self add: FamixHtmlDocument new
]

{ #category : #'entity creation' }
FamixHtmlTEntityCreator >> newElement [

<generated>
^ self add: FamixHtmlElement new
]

{ #category : #'entity creation' }
FamixHtmlTEntityCreator >> newScript [

<generated>
^ self add: FamixHtmlScript new
]

{ #category : #'entity creation' }
FamixHtmlTEntityCreator >> newText [

<generated>
^ self add: FamixHtmlText new
]

0 comments on commit 3579f9e

Please sign in to comment.