Skip to content

Commit

Permalink
Merge pull request Larcheveque#1 from mahugnon/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
mahugnon authored Mar 20, 2020
2 parents d7a6881 + 1530278 commit 290512e
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
#format : #tonel
}
7 changes: 7 additions & 0 deletions .smalltalk.ston
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SmalltalkCISpec {
#loading : [
SCIMetacelloLoadSpec {
#baseline : 'SymbolResolver'
}
]
}
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

language: smalltalk
sudo: false

os:
- linux

smalltalk:
- Pharo64-7.0
- Pharo64-8.0

matrix:
fast_finish: true
allow_failures:
- smalltalk: Pharo64-7.0

after_success:
- wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- bash upload.sh Pharo.image Pharo.changes

branches:
except:
- /^(?i:continuous)$/
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SymbolResolver


You can download the project in your image by doing:

```st
Metacello new
baseline: 'SymbolResolver';
repository: 'github://moosetechnology/SymbolResolver';
onWarningLog;
load.
```
28 changes: 27 additions & 1 deletion src/BaselineOfSymbolResolver/BaselineOfSymbolResolver.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,31 @@ Class {
{ #category : #baselines }
BaselineOfSymbolResolver >> baseline: spec [
<baseline>
spec for: #common do: [ spec package: 'SymbolResolver' ]
spec
for: #common
do: [ spec
package: 'SymbolResolver';
package: 'SRResolvableTest'
with: [ spec requires: #('SymbolResolver') ] ].
spec
for: #WithoutMoose
do: [ self baselineOfFamix: spec.
spec
package: 'SymbolResolver'
with: [ spec requires: #('Famix') ] ]
]

{ #category : #baselines }
BaselineOfSymbolResolver >> baselineOfFamix: spec [
spec
baseline: 'Famix'
with: [ spec repository: 'github://moosetechnology/Moose:development/src' ]
]

{ #category : #accessing }
BaselineOfSymbolResolver >> customProjectAttributes [
self class environment
at: #MooseEntity
ifAbsent: [ ^ #(#WithoutMoose) ].
^ #()
]
20 changes: 0 additions & 20 deletions src/SymbolResolver-Tests/SRReferencesSolverTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ SRReferencesSolverTest >> testCurrentEntity [
self assert: referencesSolver currentEntity equals: currentEntity.
]

{ #category : #tests }
SRReferencesSolverTest >> testDefineAliasInCurrentScopeFor [
self fail
]

{ #category : #tests }
SRReferencesSolverTest >> testEnsureScopesAreCopied [
| firstScope scopesFirstState secondScope scopesSecondState |
Expand Down Expand Up @@ -133,18 +128,3 @@ SRReferencesSolverTest >> testRemoveScope [
self assert: referencesSolver scopes first equals: scope3.
self assert: referencesSolver scopes allButFirst first equals: scope1
]

{ #category : #tests }
SRReferencesSolverTest >> testResolve [
self fail
]

{ #category : #tests }
SRReferencesSolverTest >> testResolveInScope [
self fail
]

{ #category : #tests }
SRReferencesSolverTest >> testTopScopeReachableEntities [
self fail
]
65 changes: 65 additions & 0 deletions src/SymbolResolver-Tests/SRResolvableTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Class {
#name : #SRResolvableTest,
#superclass : #TestCase,
#instVars : [
'scope',
'variable1',
'variable2',
'variable3'
],
#category : #'SymbolResolver-Tests'
}

{ #category : #running }
SRResolvableTest >> setUp [
variable1 := FamixTest2Class new
name: 'aVariable1';
yourself.
variable2 := FamixTest2Class new
name: 'aVariable2';
yourself.
variable3 := FamixTest2Class new
name: 'aVariable3';
yourself.
scope := SRCollectionScope new.
scope
reachableEntitiesOwned:
{variable1.
variable2.
variable3}
]

{ #category : #tests }
SRResolvableTest >> testResolveConsiderCase [
| resolver |
resolver := (SRIdentifierWithNode identifier: 'AVariable1' node: nil)
isCaseSensitive: true;
foundAction: [ :identifier :currentEntity | ];
yourself.
self
should: [ resolver resolveInScope: scope currentEntity: nil ]
raise: NotFound
]

{ #category : #tests }
SRResolvableTest >> testResolveIgnoreCase [
| resolver |
resolver := (SRIdentifierWithNode identifier: 'AVariable1' node: nil)
isCaseSensitive: false ;
foundAction: [ :identifier :currentEntity | ];
yourself.
resolver resolveInScope: scope currentEntity: nil.
self assert: resolver entity equals: variable1
]

{ #category : #tests }
SRResolvableTest >> testResolveSameCase [
| resolver |
resolver := (SRIdentifierWithNode identifier: 'aVariable1' node: nil)
isCaseSensitive: false ;
foundAction: [ :identifier :currentEntity | ];
yourself.

resolver resolveInScope: scope currentEntity: nil.
self assert: resolver entity equals: variable1
]
4 changes: 2 additions & 2 deletions src/SymbolResolver/SRCollectionScope.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ SRCollectionScope >> reachableEntitiesOwned [
]

{ #category : #accessing }
SRCollectionScope >> reachableEntitiesOwned: anObject [
reachableEntitiesOwned := anObject
SRCollectionScope >> reachableEntitiesOwned: aCollection [
reachableEntitiesOwned := aCollection
]
2 changes: 1 addition & 1 deletion src/SymbolResolver/SRFutureReferencesSolver.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"
I am a reference solver that does not directly resolve stuff but store all the resolution it will have to do and then resolve everything when #resolveStoredCases is called
I am a reference solver that does not directly resolve stuff but store all the resolution it will have to do and then resolve everything when #resolveUnresolvedReferences is called
"
Class {
#name : #SRFutureReferencesSolver,
Expand Down
2 changes: 1 addition & 1 deletion src/SymbolResolver/SRIdentifierWithNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SRIdentifierWithNode >> resolveInScope: aScope currentEntity: currentEntity [
entity:
(aScope
detect: [ :anEntity |
anEntity name = self identifier
(self name: anEntity name isSameAs: self identifier)
and: [ self checkKindOfEntity: anEntity ] ]).
self triggerFoundActionWithCurrentEntity: currentEntity.
self isLast
Expand Down
4 changes: 2 additions & 2 deletions src/SymbolResolver/SRInvocationWithNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Class {
}

{ #category : #'instance creation' }
SRInvocationWithNode class >> identifier: anIdentifier node: aNode expectedKind: aKind arguments: aCollectionOfArguments [
SRInvocationWithNode class >> identifier: anIdentifier expectedKind: aKind node: aNode arguments: aCollectionOfArguments [
^ (self identifier: anIdentifier node: aNode)
expectedKind: aKind;
arguments: aCollectionOfArguments;
Expand Down Expand Up @@ -64,7 +64,7 @@ SRInvocationWithNode >> resolveInScope: aScope currentEntity: currentEntity [
ifFalse: [ NotFound signal ].
^ (aScope
select: [ :anEntity |
anEntity name = self identifier
(self name: anEntity name isSameAs: self identifier)
and: [ self checkKindOfEntity: anEntity ] ])
ifEmpty: [ NotFound signal ]
ifNotEmpty: [ :entities |
Expand Down
23 changes: 21 additions & 2 deletions src/SymbolResolver/SRReferencesSolver.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Class {
#name : #SRReferencesSolver,
#superclass : #Object,
#instVars : [
'scopes'
'scopes',
'isCaseSensitive'
],
#category : #'SymbolResolver-Solver'
}
Expand Down Expand Up @@ -41,7 +42,18 @@ SRReferencesSolver >> detect: aBlock [
{ #category : #initialization }
SRReferencesSolver >> initialize [
super initialize.
self scopes: Stack new
self scopes: Stack new.
isCaseSensitive := true
]

{ #category : #accessing }
SRReferencesSolver >> isCaseSensitive [
^ isCaseSensitive
]

{ #category : #accessing }
SRReferencesSolver >> isCaseSensitive: anObject [
isCaseSensitive := anObject
]

{ #category : #accessing }
Expand Down Expand Up @@ -100,6 +112,13 @@ SRReferencesSolver >> removeScope: aPSQLScope [
self copyScopes remove: aPSQLScope
]

{ #category : #factory }
SRReferencesSolver >> resolvable: aResolvable [
^aResolvable
isCaseSensitive: self isCaseSensitive ;
yourself
]

{ #category : #resolution }
SRReferencesSolver >> resolve: aChainOfIdentifiers [
"a collection of identifier will be for example {'myTable' . 'columnA'}"
Expand Down
34 changes: 29 additions & 5 deletions src/SymbolResolver/SRResolvable.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Class {
'next',
'expectedKind',
'foundAction',
'notFoundReplacementEntity'
'notFoundReplacementEntity',
'isCaseSensitive'
],
#category : #'SymbolResolver-Core'
}
Expand All @@ -31,11 +32,11 @@ SRResolvable class >> identifier: aStringIdentifier node: aPSQLASTIdentifier [
]

{ #category : #'instance creation' }
SRResolvable class >> identifier: aStringIdentifier node: aPSQLASTIdentifier next: aNextPSQIdentifierWithNode [
SRResolvable class >> identifier: aString node: anIdentifier next: aNextIdentifierWithNode [
^ self new
identifier: aStringIdentifier;
node: aPSQLASTIdentifier;
next: aNextPSQIdentifierWithNode;
identifier: aString;
node: anIdentifier;
next: aNextIdentifierWithNode;
yourself
]

Expand Down Expand Up @@ -93,11 +94,34 @@ SRResolvable >> identifier: anObject [
identifier := anObject
]

{ #category : #resolution }
SRResolvable >> initialize [
super initialize.
isCaseSensitive := true
]

{ #category : #accessing }
SRResolvable >> isCaseSensitive [
^ isCaseSensitive
]

{ #category : #accessing }
SRResolvable >> isCaseSensitive: aBoolean [
isCaseSensitive := aBoolean
]

{ #category : #testing }
SRResolvable >> isLast [
^ self next isNil
]

{ #category : #resolution }
SRResolvable >> name: aString isSameAs: anotherString [
^ self isCaseSensitive
ifTrue: [ aString = anotherString ]
ifFalse: [ aString asLowercase = anotherString asLowercase ]
]

{ #category : #accessing }
SRResolvable >> next [
^ next
Expand Down
8 changes: 7 additions & 1 deletion src/SymbolResolver/SRSolverUserVisitor.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ SRSolverUserVisitor >> errorReport: anObject [

{ #category : #initialization }
SRSolverUserVisitor >> initialiseFutureSolver [
solver := SRFutureReferencesSolver new
solver := SRFutureReferencesSolver new.
solver isCaseSensitive: false
]

{ #category : #initialization }
Expand Down Expand Up @@ -109,6 +110,11 @@ SRSolverUserVisitor >> pushEntityAsScope: anEntity [
self solver pushEntityAsScope: anEntity
]

{ #category : #factory }
SRSolverUserVisitor >> resolvable: aResolvable [
^ self solver resolvable: aResolvable
]

{ #category : #resolution }
SRSolverUserVisitor >> resolve: identifiers [
self solver resolve: identifiers
Expand Down

0 comments on commit 290512e

Please sign in to comment.