Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4060-RBParserparseErrorNode-uses-stop-position-not-start-to-create-ErrorNode #4062

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/AST-Core-Tests/RBParseErrorNodeTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Class {
#name : #RBParseErrorNodeTest,
#superclass : #RBParseTreeTest,
#category : #'AST-Core-Tests-Nodes'
}

{ #category : #tests }
RBParseErrorNodeTest >> testErrorNodeStart [
"check that the start of the error node is correct"
| ast |
ast := RBParser parseFaultyMethod: 'method ( 1 + 3'.
"the start should be much earlier then the end of the method"
self assert: (ast body statements first start < 14).

]
5 changes: 4 additions & 1 deletion src/AST-Core/RBParser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,11 @@ RBParser >> parseErrorNode: aMessageString [
"the error at the end means in some cases that the start of the error is before"
aMessageString = ''')'' expected'
ifTrue: [ errorPosition := source findLastOccurrenceOfString: '(' startingAt: 1 ].
aMessageString = '''|'' expected'
ifTrue: [ errorPosition := source findLastOccurrenceOfString: '|' startingAt: 1 ].
(errorPosition = 0) ifTrue: [ errorPosition := self errorPosition].
sourceString := source copyFrom: errorPosition to: source size.
^ RBParseErrorNode errorMessage: aMessageString value: sourceString at: self errorPosition
^ RBParseErrorNode errorMessage: aMessageString value: sourceString at: errorPosition
]

{ #category : #accessing }
Expand Down
12 changes: 8 additions & 4 deletions src/NECompletion/TestMatchedNodeProducer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ TestMatchedNodeProducer >> visitMessageNode: aRBMessageNode [

{ #category : #visiting }
TestMatchedNodeProducer >> visitMethodNode: aRBMethodNode [
"there is a bug that we end up here when in temp definition, workaround turn it off for now"
"this turns off completion of methods and temp defitions, see issue tracker"
^#().
"(self select: self methodNames beginningWith: aRBMethodNode selector)"

^(self select: self methodNames beginningWith: aRBMethodNode selector)
]

{ #category : #visiting }
Expand All @@ -104,6 +102,12 @@ TestMatchedNodeProducer >> visitPragmaNode: aPragmaNode [
^ self select: Symbol allSymbols beginningWith: aPragmaNode selector
]

{ #category : #visiting }
TestMatchedNodeProducer >> visitReturnNode: aNode [

^ #()
]

{ #category : #visiting }
TestMatchedNodeProducer >> visitSelfNode: aRBSelfNode [
^ self visitVariableNode: aRBSelfNode
Expand Down