You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/TreeSitter/String.extension.st
+29-80Lines changed: 29 additions & 80 deletions
Original file line number
Diff line number
Diff line change
@@ -2,89 +2,38 @@ Extension { #name : 'String' }
2
2
3
3
{ #category : '*TreeSitter' }
4
4
String>>positionFromTSPoint: aTSPoint [
5
-
"Use me to convert a TSPoint to the position in the original string"
6
-
7
-
"Ideally this method (and #ts* methods on String) should be removed because it does not manage the encoding. On top of that, they are too slow because they do too much things while we could directly manipulate a ByteArray or BinaryStream and use #startByte and #endByte to read or get the positions."
8
-
9
-
| sumcurrentLinelines |
10
-
sum := aTSPoint column.
11
-
currentLine :=0.
12
-
lines :=self tsLines.
13
-
[ currentLine < aTSPoint row ] whileTrue: [
14
-
sum := sum + (lines at: currentLine +1) size.
15
-
currentLine := currentLine +1 ].
16
-
^ sum
17
-
]
18
-
19
-
{ #category : '*TreeSitter' }
20
-
String>>tsLineIndicesDo: aBlock [
21
-
"execute aBlock with 3 arguments for each line:
22
-
- start index of line
23
-
- end index of line without line delimiter
24
-
- end index of line including line delimiter(s) CR, LF or CRLF"
25
-
26
-
27
-
"Ideally this method (and #ts* methods on String) should be removed because it does not manage the encoding. On top of that, they are too slow because they do too much things while we could directly manipulate a ByteArray or BinaryStream and use #startByte and #endByte to read or get the positions."
28
-
29
-
| crlfstartsznextLFnextCR |
30
-
start :=1.
31
-
sz :=self size.
32
-
cr :=Character cr.
33
-
nextCR :=selfindexOf: cr startingAt:1.
34
-
lf :=Character lf.
35
-
nextLF :=selfindexOf: lf startingAt:1.
36
-
sz =0
37
-
ifTrue: [ aBlock value: sz value: sz value: sz.
38
-
^self ].
39
-
[ start <= sz ]
40
-
whileTrue: [ (nextLF =0and: [ nextCR =0 ])
41
-
ifTrue: [ "No more CR, nor LF, the string is over"
"This method is used to convert a TSPoint to the position in the original string"
13
+
"It is specifically used in the TSHighliter to make it compatible with inspectionFASTSourceCode: of FASTEntity"
66
14
67
-
"Ideally this method (and #ts* methods on String) should be removed because it does not manage the encoding. On top of that, they are too slow because they do too much things while we could directly manipulate a ByteArray or BinaryStream and use #startByte and #endByte to read or get the positions."
"Ideally this method (and #ts* methods on String) should be removed because it does not manage the encoding. On top of that, they are too slow because they do too much things while we could directly manipulate a ByteArray or BinaryStream and use #startByte and #endByte to read or get the positions."
0 commit comments