diff --git a/src/NECompletion/CompletionEntry.class.st b/src/NECompletion/CompletionEntry.class.st deleted file mode 100644 index 6afbe496548..00000000000 --- a/src/NECompletion/CompletionEntry.class.st +++ /dev/null @@ -1,65 +0,0 @@ -" -One main Entry class instead of NECEntry functionality -" -Class { - #name : #CompletionEntry, - #superclass : #Object, - #instVars : [ - 'contents', - 'node', - 'description' - ], - #category : #'NECompletion-New' -} - -{ #category : #accessing } -CompletionEntry class >> contents: aString [ - ^ self new setContents: aString -] - -{ #category : #accessing } -CompletionEntry class >> contents: aString node: aNode [ - ^ self new setContents: aString node: aNode -] - -{ #category : #ui } -CompletionEntry >> browseWith: aCompletionContext [ - | class | - class := node methodNode compilationContext getClass. - Smalltalk tools browser openOnClass: class. - ^true -] - -{ #category : #accessing } -CompletionEntry >> completion [ - ^ self contents asSymbol -] - -{ #category : #accessing } -CompletionEntry >> contents [ - ^contents -] - -{ #category : #description } -CompletionEntry >> descriptionWith: aCompletionContext [ - ^description ifNil: [ ^ description := node completionDescription]. -] - -{ #category : #initialization } -CompletionEntry >> setContents: aString [ - contents := aString. -] - -{ #category : #initialization } -CompletionEntry >> setContents: aString node: aNode [ - contents := aString. - node := aNode -] - -{ #category : #initialization } -CompletionEntry >> type [ - "Here we should later return the symbol (see the other implementors of type in the old system - this will be easy to get form the node" - ^ node isVariable ifTrue: - [ (Smalltalk globals hasBindingThatBeginsWith: node name) ifTrue: [ ^#globalVar ] ] -] diff --git a/src/NECompletion/CompletionModel.class.st b/src/NECompletion/CompletionModel.class.st index 4578c880b0d..890073b87ed 100644 --- a/src/NECompletion/CompletionModel.class.st +++ b/src/NECompletion/CompletionModel.class.st @@ -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 } diff --git a/src/NECompletion/NECEntry.class.st b/src/NECompletion/NECEntry.class.st index 7454f1f81b2..c9077e83154 100644 --- a/src/NECompletion/NECEntry.class.st +++ b/src/NECompletion/NECEntry.class.st @@ -8,7 +8,7 @@ Class { #superclass : #Object, #instVars : [ 'contents', - 'type', + 'node', 'description' ], #category : #'NECompletion-Model' @@ -19,6 +19,11 @@ 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 @@ -26,12 +31,11 @@ NECEntry >> <= aECEntry [ { #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 } @@ -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: @@ -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 } @@ -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 ] diff --git a/src/NECompletion/NECLocalEntry.class.st b/src/NECompletion/NECLocalEntry.class.st index a2b794f9f91..c7cdff127d9 100644 --- a/src/NECompletion/NECLocalEntry.class.st +++ b/src/NECompletion/NECLocalEntry.class.st @@ -9,11 +9,6 @@ Class { #category : #'NECompletion-Model' } -{ #category : #testing } -NECLocalEntry >> isLocal [ - ^true -] - { #category : #accessing } NECLocalEntry >> label [ ^ 'local variable' diff --git a/src/NECompletion/NECSelectorEntry.class.st b/src/NECompletion/NECSelectorEntry.class.st index edebb192da3..8e5edd5a11c 100644 --- a/src/NECompletion/NECSelectorEntry.class.st +++ b/src/NECompletion/NECSelectorEntry.class.st @@ -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 @@ -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."