myroslavarm / Experimental-Completion

My internship project: improving code completion for Pharo
6 stars 3 forks source link

DNU on #completionToken in RBReturnNode #62

Closed myroslavarm closed 5 years ago

myroslavarm commented 5 years ago

Cyril got it in

needToAdaptTo: aRGClass
    1halt.
    ^ (self generatedTraits as (aRGClass traitComposition traits select: #isMetamodelEntity) and: [ (self generatedSlots collect: #name) = (aRGClass slots collect: #name) ]) not

trying to write self generatedTraits asSet

maybe can be fixed by creating

RBReturnNode >> completionToken
    ^ Symbol selectorTable

because i don't think returning an empty string makes sense at this point because we do want a completion

MarcusDenker commented 5 years ago

My Theory is that what is wrong is the method that we call on the AST that gives us the node at the cursor offset.

this means that maybe #bestNodeFor: in this case returns the return node and not the message node inside of the return node as it should.

What we could do is to write a test just for #bestNodeFor: to test exactly this scenario

myroslavarm commented 5 years ago

The DNU on visitReturnNode should be fixed here : https://github.com/pharo-project/pharo/pull/4062. In the same PR we also fix a more serious problem, the actual cause of the error in the code provided above. In the case of incorrect syntax, ParseErrorNode should be the one triggered and there should be no completion. Because of the incorrect implementation of the start of the error node, it didn't discover it. We have now fixed that. TL;DR : the error in this particular case was fixed by updating the AST implementation, and then we added a fallback visitReturnNode just in case (for other situations).