It causes too many issues and seems incomplete.
See #13, #23, and:
|
findClosestKeyword( |
|
node: Node, |
|
keyword: string, |
|
): Omit<Location, 'source'> | null { |
|
const lines = this.lines; |
|
const nodeLoc = this.getLoc(node); |
|
|
|
for (let line = nodeLoc.start.line; line >= 0; line--) { |
|
const startColumn = |
|
line === nodeLoc.start.line |
|
? nodeLoc.start.column |
|
: lines[line]?.length; |
|
|
|
for (let column = startColumn ?? 0; column >= 0; column--) { |
|
const sliceStart = Math.max(0, column - keyword.length); |
|
const sliceEnd = sliceStart + keyword.length; |
|
|
|
if (lines[line]?.slice(sliceStart, sliceEnd) === keyword) { |
|
const locLine = line + LINE_START; |
|
|
|
return { |
|
start: { |
|
line: locLine, |
|
column: sliceStart, |
|
offset: this.getOffset({ |
|
line: locLine, |
|
column: sliceStart, |
|
}), |
|
}, |
|
end: { |
|
line: locLine, |
|
column: sliceEnd, |
|
offset: this.getOffset({ |
|
line: locLine, |
|
column: sliceEnd, |
|
}), |
|
}, |
|
}; |
|
} |
|
} |
|
} |
|
|
|
return null; |
|
} |
It causes too many issues and seems incomplete.
See #13, #23, and:
eslint-plugin-php/src/language/php-source-code.ts
Lines 49 to 92 in 4230f6f