Skip to content

Find a replacement for php-parser #46

@StyleShit

Description

@StyleShit

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency fileenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions