Skip to content

Commit

Permalink
feat(semantic): initial support for python annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
LuqueDaniel committed Apr 9, 2022
1 parent 5945557 commit 495383c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{
"language": "renpy",
"scopeName": "source.renpy",
"path": "./syntaxes/renpy.tmLanguage.json"
"path": "./syntaxes/renpy.tmLanguage_2.json"
}
],
"snippets": [
Expand Down
7 changes: 1 addition & 6 deletions src/semantics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { stripWorkspaceFromFile } from "./workspace";
export function getSemanticTokens(document: TextDocument, legend: SemanticTokensLegend): SemanticTokens {
const tokensBuilder = new SemanticTokensBuilder(legend);
const rxKeywordList = /\s*(screen|label|transform|def|class)\s+/;
const rxParameterList = /\s*(screen|label|transform|def|class)\s+([a-zA-Z_]\w+)\s*\((.*)\)\s*:|\s*(label)\s+([a-zA-Z0-9_.]+)\s*:|^(init)\s+([-\d]+\s+)*python\s+in\s+(\w+):|^(python)\s+early\s+in\s+(\w+):|\s*(class)\s+([a-zA-Z0-9_]+)\s*/s;
const rxParameterList = /\s*(screen|label|transform|class)\s+([a-zA-Z_]\w*)\s*\((.*)\)\s*:|\s*(label)\s+([a-zA-Z_]\w*)\s*:|^(init)\s+([-\d]+\s+)*python\s+in\s+(\w+):|^(python)\s+early\s+in\s+(\w+):|\s*(class)\s+([a-zA-Z_]\w*)\s*:|\s*(def)\s+([a-zA-Z_]\w*)\s*\((.*)\)\s*(->\s*[a-zA-Z_]\w*\s*)?:/s;
const rxVariableDefines = /^\s*(default|define)\s+([a-zA-Z]+[a-zA-Z0-9_]*)\s*=\s*(.*)/;
const rxPersistentDefines = /^\s*(default|define)\s+persistent\.([a-zA-Z]+[a-zA-Z0-9_]*)\s*=\s*(.*)/;
const filename = stripWorkspaceFromFile(document.uri.path);
Expand Down Expand Up @@ -87,11 +87,6 @@ export function getSemanticTokens(document: TextDocument, legend: SemanticTokens
length = m.split('=')[0].trimRight().length;
}
const range = new Range(i, start + offset, i, start + length);
if (m.substring(offset, length) === 'self' || m.substring(offset, length) === 'cls') {
tokensBuilder.push(range, 'keyword');
} else {
tokensBuilder.push(range, 'parameter', ['declaration']);
}
parent_args.push(line.substring(start + offset, length - offset));
parent_defaults[m.substring(offset, length)] = new Navigation("parameter", m.substring(offset, length), filename, i + 1, "", m.trim(), "", start + offset);
// create a Navigation dictionary entry for this token range
Expand Down

0 comments on commit 495383c

Please sign in to comment.