Skip to content

Commit

Permalink
Fixed [#334]
Browse files Browse the repository at this point in the history
  • Loading branch information
thqby committed Jun 11, 2023
1 parent b01341a commit bec62d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
47 changes: 28 additions & 19 deletions server/src/Lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1615,12 +1615,7 @@ export class Lexer {
}
break;
case 'isset':
tk.definition = ahkvars['ISSET'];
tk.semantic = { type: SemanticTokenTypes.operator };
if (input.charAt(tk.offset + 5) === '(') {
tk.type = 'TK_WORD', tk.ignore = true, next = false;
} else
_this.addDiagnostic(diagnostic.missing('('), tk.offset, 5);
parse_isset(input.charAt(tk.offset + 5));
break;
default:
nk = get_token_ignore_comment();
Expand Down Expand Up @@ -2349,13 +2344,9 @@ export class Lexer {
next = false, tk.type = 'TK_WORD', tk.semantic = { type: SemanticTokenTypes.variable };
break;
}
if (tk.content.match(/^(class|super|isset)$/i)) {
if (tk.content.toLowerCase() === 'isset') {
tk.definition = ahkvars['ISSET'];
tk.ignore = true, tk.semantic = { type: SemanticTokenTypes.operator };
if (c !== '(')
_this.addDiagnostic(diagnostic.missing('('), tk.offset, tk.length);
}
if (/^(class|super|isset)$/i.test(tk.content)) {
if (tk.content.toLowerCase() === 'isset' && parse_isset(c))
break;
next = false, tk.type = 'TK_WORD';
break;
}
Expand Down Expand Up @@ -2980,12 +2971,8 @@ export class Lexer {
continue;
}
if (tk.content.match(/^(class|super|isset)$/i)) {
if (tk.content.toLowerCase() === 'isset') {
tk.definition = ahkvars['ISSET'];
tk.ignore = true, tk.semantic = { type: SemanticTokenTypes.operator };
if (c !== '(')
_this.addDiagnostic(diagnostic.missing('('), tk.offset, tk.length);
}
if (tk.content.toLowerCase() === 'isset' && parse_isset(c))
continue;
next = false, tk.type = 'TK_WORD';
continue;
}
Expand Down Expand Up @@ -3063,6 +3050,27 @@ export class Lexer {
}
}

function parse_isset(c: string) {
let l = result.length;
tk.definition = ahkvars['ISSET'];
tk.ignore = true, tk.type = 'TK_WORD';
tk.semantic = { type: SemanticTokenTypes.operator };
if (c === '(') {
let fc = tk;
nexttoken(), parse_pair('(', ')');
let pc = tokens[tk.previous_pair_pos!]?.paraminfo?.count ?? 0;
if (pc !== 1)
extsettings.Diagnostics.ParamsCheck && _this.addDiagnostic(diagnostic.paramcounterr(1, pc), fc.offset, parser_pos - fc.offset);
else if (result.length > l && lk.type === 'TK_WORD') {
let vr = result[result.length - 1] as Variable;
if (lk.content === vr.name && lk.offset === _this.document.offsetAt(vr.range.start))
vr.returntypes ??= {};
}
return true;
}
_this.addDiagnostic(diagnostic.missing('('), tk.offset, 5);
}

function maybeclassprop(tk: Token, flag: boolean | null = false) {
if (classfullname === '')
return;
Expand Down Expand Up @@ -6258,6 +6266,7 @@ export function checksamenameerr(decs: { [name: string]: DocumentSymbol }, arr:
if (decs[_low].kind === SymbolKind.Variable) {
if ((<Variable>it).def && !(<Variable>decs[_low]).def)
decs[_low] = it;
else (decs[_low] as Variable).returntypes ??= (it as Variable).returntypes;
} else if ((<Variable>it).def)
delete (<Variable>it).def, diags.push({ message: samenameerr(decs[_low], it), range: it.selectionRange, severity: DiagnosticSeverity.Error });
} else {
Expand Down
4 changes: 2 additions & 2 deletions server/src/symbolProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function symbolProvider(params: DocumentSymbolParams, token?: Cancellatio
for (let k in dec) {
if (!(t = gvar[k]) || d || dec[k].kind !== SymbolKind.Variable && (t.kind === SymbolKind.Variable || t.def === false))
gvar[k] = dec[k];
else if (t.kind === SymbolKind.Variable && (dec[k] as Variable).def)
t.def ??= false, t.returntypes ??= dec[k].returntypes;
else if (t.kind === SymbolKind.Variable && (t.returntypes ??= dec[k].returntypes, (dec[k] as Variable).def))
t.def ??= false;
}
}
if (ahkuris.winapi && !list.includes(ahkuris.winapi))
Expand Down

0 comments on commit bec62d5

Please sign in to comment.