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

Fix style of pragmas #13012

Merged
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
23 changes: 22 additions & 1 deletion src/Shout-Tests/SHRBStyleAttributionTest.class.st
Expand Up @@ -539,11 +539,32 @@ SHRBStyleAttributionTest >> testPragmaStyle [

self
assertStyleOf: aText
between: 4
between: 3
and: 8
shouldBe: #pragma
]

{ #category : #tests }
SHRBStyleAttributionTest >> testPragmaStyleWithCrazyPragma [

| aText |
aText := 'm < test: #toto test2: 2 > ^ a' asText.
self style: aText.

self assertStyleOf: aText at: 4 shouldBe: #pragma.
self
assertStyleOf: aText
between: 7
and: 11
shouldBe: #pragma.
self
assertStyleOf: aText
between: 19
and: 24
shouldBe: #pragma.
self assertStyleOf: aText at: 28 shouldBe: #pragma
]

{ #category : #tests }
SHRBStyleAttributionTest >> testReturnStyle [

Expand Down
7 changes: 6 additions & 1 deletion src/Shout/SHRBTextStyler.class.st
Expand Up @@ -1072,8 +1072,13 @@ SHRBTextStyler >> visitParseErrorNode: anErrorNode [

{ #category : #visiting }
SHRBTextStyler >> visitPragmaNode: aPragmaNode [
"Lets imagin this pragma: `< test: #toto test2: 2 >`

aPragmaNode selectorParts with: aPragmaNode keywordsPositions do: [ :keyword :position | self addStyle: #pragma from: position to: position + keyword size ].
We want to highlight the `<`, the `test:`, the `test2:` and the `>` but we do not want to highlight the arguments."

self addStyle: #pragma from: aPragmaNode left to: aPragmaNode left.
aPragmaNode keywordsIntervals do: [ :i | self addStyle: #pragma from: i first to: i last ].
self addStyle: #pragma from: aPragmaNode right to: aPragmaNode right.

aPragmaNode arguments do: [ :each | self visitNode: each ]
]
Expand Down