Skip to content

Commit

Permalink
- use NECEntry instad of CompletionEntry
Browse files Browse the repository at this point in the history
- cleanup NECEntry a bit
    - remove #type ivar
    - add node ivar
    - remove #isLocal and #isSelector (not used)
    - use #lookupSelector, remove lookupSelector: class:
  • Loading branch information
MarcusDenker committed Oct 29, 2019
1 parent 16ce77b commit cc33825
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 108 deletions.
65 changes: 0 additions & 65 deletions src/NECompletion/CompletionEntry.class.st

This file was deleted.

2 changes: 1 addition & 1 deletion src/NECompletion/CompletionModel.class.st
Expand Up @@ -83,7 +83,7 @@ CompletionModel >> initEntries [
producer := CompletionProducerVisitor new.
self sorter: self class sorter.
suggestionsList := self sortList: (producer completionListForNode: node).
^ suggestionsList collect: [ :each | CompletionEntry contents: each node: node ]
^ suggestionsList collect: [ :each | NECEntry contents: each node: node ]
]

{ #category : #initialization }
Expand Down
44 changes: 25 additions & 19 deletions src/NECompletion/NECEntry.class.st
Expand Up @@ -8,7 +8,7 @@ Class {
#superclass : #Object,
#instVars : [
'contents',
'type',
'node',
'description'
],
#category : #'NECompletion-Model'
Expand All @@ -19,19 +19,23 @@ NECEntry class >> contents: aString [
^ self new setContents: aString
]

{ #category : #'instance creation' }
NECEntry class >> contents: aString node: aNode [
^ self new setContents: aString node: aNode
]

{ #category : #operations }
NECEntry >> <= aECEntry [
^ contents <= aECEntry contents
]

{ #category : #'ui related' }
NECEntry >> browseWith: anECContext [
| guessType |
guessType := self guessTypeWith: anECContext.
guessType ifNil: [^ false].
self flag: #SmalltalkReference. "Reference to Smalltalk tools"
Smalltalk tools browser openOnClass: guessType.
^ true
| class |
"no really correct, we need the class of the node..."
class := node methodNode compilationContext getClass.
Smalltalk tools browser openOnClass: class.
^true
]

{ #category : #accessing }
Expand All @@ -47,7 +51,8 @@ NECEntry >> contents [
{ #category : #'detail information' }
NECEntry >> createDescriptionWith: anECContext [
| clazz |
clazz := self guessTypeWith: anECContext.
"no really correct, we need the class of the node..."
clazz := node methodNode compilationContext getClass.
^ clazz
ifNil: [ NECEntryDescription label: self label ]
ifNotNil:
Expand All @@ -59,18 +64,13 @@ NECEntry >> createDescriptionWith: anECContext [

{ #category : #operations }
NECEntry >> descriptionWith: anECContext [
description ifNotNil: [ ^ description ].
^ description := self createDescriptionWith: anECContext
]

{ #category : #testing }
NECEntry >> isLocal [
^ false
^description ifNotNil: [ description := self createDescriptionWith: anECContext ]
]

{ #category : #testing }
NECEntry >> isSelector [
^ false
{ #category : #operations }
NECEntry >> guessTypeWith: aContext [
"senders of this need to get the type from the AST"
^nil
]

{ #category : #accessing }
Expand All @@ -94,7 +94,13 @@ NECEntry >> setContents: aString [
contents := aString.
]

{ #category : #accessing }
NECEntry >> setContents: aString node: aNode [
contents := aString.
node := aNode
]

{ #category : #accessing }
NECEntry >> type [
^type
^nil
]
5 changes: 0 additions & 5 deletions src/NECompletion/NECLocalEntry.class.st
Expand Up @@ -9,11 +9,6 @@ Class {
#category : #'NECompletion-Model'
}

{ #category : #testing }
NECLocalEntry >> isLocal [
^true
]

{ #category : #accessing }
NECLocalEntry >> label [
^ 'local variable'
Expand Down
19 changes: 1 addition & 18 deletions src/NECompletion/NECSelectorEntry.class.st
Expand Up @@ -60,7 +60,7 @@ NECSelectorEntry >> findMethodWith: anECContext do: foundBlock ifAbsent: notfoun
implementors size == 1
ifTrue: [| ref |
ref := implementors first.
self lookupSelector: ref selector class: ref realClass]
ref realClass lookupSelector: ref selector]
ifFalse: [^ notfoundBlock value: contents]]
ifNotNil: [self lookupSelector: contents class: theClass].
^ foundBlock value: result first value: result second
Expand Down Expand Up @@ -92,23 +92,6 @@ NECSelectorEntry >> label [
^ (self guessTypeWith: nil) ifNil:[ 'method' ] ifNotNil: [ 'class' ].
]

{ #category : #private }
NECSelectorEntry >> lookupSelector: aSymbol class: aClass [
"Look up the given selector in my methodDictionary.
Return the corresponding method if found.
Otherwise chase the superclass chain and try again.
Return nil if no method is found."
| lookupClass |
lookupClass := aClass.
[lookupClass isNil]
whileFalse: [(lookupClass includesSelector: aSymbol)
ifTrue: [^ Array
with: lookupClass
with: (lookupClass compiledMethodAt: aSymbol)].
lookupClass := lookupClass superclass].
^ nil
]

{ #category : #private }
NECSelectorEntry >> methodSourceDescription: aClass method: aCompiledMethod [
"I return if it's a class or a method, its class name, and the implementation."
Expand Down

0 comments on commit cc33825

Please sign in to comment.