-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue-36 : Fix JSON parsing error (#57)
* Issue-36 : Fix JSON parsing error * Issue-36 : Ensure all tests pass * Issue-36 : Update changelog Co-authored-by: Robbie Ostermann <[email protected]>
- Loading branch information
1 parent
4c580b7
commit 99d81fc
Showing
11 changed files
with
81 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,54 @@ | ||
import * as vscode from "vscode"; | ||
|
||
export const activate = async (docUri: vscode.Uri): Promise<vscode.TextDocument | undefined> => { | ||
export const SLEEP_TIME = 10000; | ||
|
||
export const activate = async (documentUri: vscode.Uri): Promise<vscode.TextDocument | undefined> => { | ||
// The extensionId is `publisher.name` from package.json | ||
const ext = vscode.extensions.getExtension("vscode-sqlfluff"); | ||
await ext?.activate(); | ||
const extension = vscode.extensions.getExtension("vscode-sqlfluff"); | ||
await extension?.activate(); | ||
try { | ||
const document = await vscode.workspace.openTextDocument(docUri); | ||
const editor = await vscode.window.showTextDocument(document); | ||
await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); | ||
const document = await vscode.workspace.openTextDocument(documentUri); | ||
await vscode.window.showTextDocument(document); | ||
await document.save(); | ||
|
||
await sleep(2000); // Wait for server activation | ||
await sleep(SLEEP_TIME); // Wait for server activation | ||
|
||
return document; | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; | ||
|
||
export const format = async (document: vscode.TextDocument | undefined) => { | ||
if (document) { | ||
try { | ||
await vscode.commands.executeCommand("editor.action.formatDocument"); | ||
await sleep(2000); | ||
await document.save(); | ||
await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
export const format = async (documentUri: vscode.Uri) => { | ||
try { | ||
await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); | ||
const document = await vscode.workspace.openTextDocument(documentUri); | ||
await vscode.window.showTextDocument(document); | ||
await vscode.commands.executeCommand("editor.action.formatDocument"); | ||
await sleep(SLEEP_TIME); | ||
await document.save(); | ||
|
||
await sleep(SLEEP_TIME); // Wait for server activation | ||
|
||
return document; | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; | ||
|
||
const sleep = async (ms: number): Promise<any> => { | ||
export const sleep = async (ms: number): Promise<any> => { | ||
return new Promise(resolve => { | ||
return setTimeout(resolve, ms); | ||
}); | ||
}; | ||
|
||
export const getDocUri = (p: string) => { | ||
export const getDocumentUri = (p: string) => { | ||
return vscode.Uri.file(__dirname + p); | ||
}; | ||
|
||
export const toRange = (sLine: number, sChar: number, eLine: number, eChar: number) => { | ||
const start = new vscode.Position(sLine, sChar); | ||
const end = new vscode.Position(eLine, eChar); | ||
export const toRange = (startLine: number, StartCharacter: number, endLine: number, endCharacter: number) => { | ||
const start = new vscode.Position(startLine, StartCharacter); | ||
const end = new vscode.Position(endLine, endCharacter); | ||
return new vscode.Range(start, end); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
-- 割引金額 | ||
select a from b; | ||
SELECT a from b; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SELECT a FROM a_table; | ||
SELECT a from a_table; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
select a from a_table; | ||
SELECT a FROM a_table; |