From 87b5e14c75dbc02b5bc610dfa33d5789570df5db Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 13:41:30 +0300 Subject: [PATCH] Fix indexing errors --- code/.vscode/launch.json | 2 +- code/src/main.ts | 8 ++++---- src/parser/grammar/expressions.rs | 2 +- src/yellow/syntax.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/.vscode/launch.json b/code/.vscode/launch.json index 5d75a92e86..64f2c36938 100644 --- a/code/.vscode/launch.json +++ b/code/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], + "args": ["--extensionDevelopmentPath=${workspaceRoot}"], "stopOnEntry": false, "sourceMaps": true, "outFiles": [ "${workspaceRoot}/out/src/**/*.js" ], diff --git a/code/src/main.ts b/code/src/main.ts index dfb005c09f..75a824b7be 100644 --- a/code/src/main.ts +++ b/code/src/main.ts @@ -12,7 +12,6 @@ let uris = { export function activate(context: vscode.ExtensionContext) { let textDocumentContentProvider = new TextDocumentContentProvider() - let dispose = (disposable) => { context.subscriptions.push(disposable); } @@ -25,7 +24,6 @@ export function activate(context: vscode.ExtensionContext) { let emitter = textDocumentContentProvider.eventEmitter emitter.fire(uris.syntaxTree) let syntax = activeSyntax() - console.log(syntax.highlight()); setHighlights(vscode.window.activeTextEditor, syntax.highlight()) }) @@ -89,7 +87,10 @@ function documentToFile(disposables: vscode.Disposable[], onChange) { } function createFile(text: String) { - return new backend.RustFile(text) + console.time("parsing") + let res = new backend.RustFile(text); + console.timeEnd("parsing") + return res } vscode.workspace.onDidChangeTextDocument((event: vscode.TextDocumentChangeEvent) => { @@ -159,7 +160,6 @@ function setHighlights( editor: vscode.TextEditor, highlihgs: Array<[number, number, string]> ) { - console.log("setHighlight"); let byTag = {} for (let tag in decorations) { byTag[tag] = [] diff --git a/src/parser/grammar/expressions.rs b/src/parser/grammar/expressions.rs index 4861536f8d..a6456c8d5e 100644 --- a/src/parser/grammar/expressions.rs +++ b/src/parser/grammar/expressions.rs @@ -69,7 +69,7 @@ fn atom_expr(p: &mut Parser) -> Option { match p.current() { L_PAREN => Some(tuple_expr(p)), _ => { - p.error("expected expression"); + p.err_and_bump("expected expression"); None } } diff --git a/src/yellow/syntax.rs b/src/yellow/syntax.rs index 65ce647c7c..58e8ab9b6c 100644 --- a/src/yellow/syntax.rs +++ b/src/yellow/syntax.rs @@ -109,7 +109,7 @@ impl SyntaxNode { let red = self.red(); let parent = self.parent()?; let next_sibling_idx = red.index_in_parent()? + 1; - if next_sibling_idx == red.n_children() { + if next_sibling_idx == parent.red().n_children() { return None; } Some(SyntaxNode {