-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
526200a
commit b49ec38
Showing
21 changed files
with
280 additions
and
257 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/camelcase": ["error", { | ||
"properties": "never" | ||
}], | ||
"@typescript-eslint/interface-name-prefix": ["off"], | ||
"@typescript-eslint/no-empty-function": ["off"], | ||
"@typescript-eslint/no-explicit-any": ["off"], | ||
"@typescript-eslint/no-unused-vars": ["error", { | ||
"argsIgnorePattern": "^_" | ||
}], | ||
"@typescript-eslint/no-use-before-define": ["off"], | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"windows" | ||
], | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
], | ||
"sort-imports": ["error", { | ||
"ignoreCase": true | ||
}] | ||
} | ||
} |
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
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,35 +1,34 @@ | ||
import { env, Range, TextEditor, window, TextEditorOptions, TextEditorEdit } from 'vscode'; | ||
import { ConversionErrorMessage, DefaultIndentSize } from "../constants"; | ||
import { env, TextEditor, TextEditorOptions, window } from "vscode"; | ||
import { IParser } from "../parser"; | ||
import { ConversionErrorMessage, DefaultIndentSize } from '../constants'; | ||
|
||
export async function pasteMonitor(editor: TextEditor, parser: IParser): Promise<void> { | ||
if (editor.document.languageId !== 'yaml') { | ||
return; | ||
} | ||
if (editor.document.languageId !== "yaml") { | ||
return; | ||
} | ||
|
||
configureIndentSize(parser, editor.options); | ||
configureIndentSize(parser, editor.options); | ||
|
||
try { | ||
const clipboardContent = await env.clipboard.readText(); | ||
const converted = parser.parse(clipboardContent); | ||
try { | ||
const clipboardContent = await env.clipboard.readText(); | ||
const converted = parser.parse(clipboardContent); | ||
|
||
if (converted) { | ||
editor.edit(editBuilder => { | ||
if (editor.selection.isEmpty) { | ||
editBuilder.insert(editor.selection.start, converted); | ||
} else { | ||
//editBuilder.replace(new Range(editor.selection.start, editor.selection.end), converted); | ||
editBuilder.replace(editor.selection, converted); | ||
} | ||
}); | ||
} | ||
if (converted) { | ||
editor.edit(editBuilder => { | ||
if (editor.selection.isEmpty) { | ||
editBuilder.insert(editor.selection.start, converted); | ||
} else { | ||
editBuilder.replace(editor.selection, converted); | ||
} | ||
}); | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
console.error(e); | ||
window.showErrorMessage(ConversionErrorMessage); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
function configureIndentSize(parser: IParser, options: TextEditorOptions) { | ||
const indentSize = options.insertSpaces ? options.tabSize as number : DefaultIndentSize; | ||
parser.setIndentSize(indentSize); | ||
}; | ||
function configureIndentSize(parser: IParser, options: TextEditorOptions): void { | ||
const indentSize = options.insertSpaces ? options.tabSize as number : DefaultIndentSize; | ||
parser.setIndentSize(indentSize); | ||
} |
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,51 +1,20 @@ | ||
import { commands, env, ExtensionContext, Range, TextEditor, window, TextEditorOptions, TextEditorEdit } from 'vscode'; | ||
import { IParser, Parser } from "../parser"; | ||
import { MonitorValidator } from '../monitorValidator'; | ||
import { ValidationErrorMessage, ConversionErrorMessage, DefaultIndentSize } from '../constants'; | ||
import { pasteMonitor } from './command'; | ||
import { commands, ExtensionContext, TextEditor, window } from "vscode"; | ||
import { MonitorValidator } from "../monitorValidator"; | ||
import { Parser } from "../parser"; | ||
import { pasteMonitor } from "./command"; | ||
import { ValidationErrorMessage } from "../constants"; | ||
|
||
export function activate(context: ExtensionContext): void { | ||
const parser = new Parser(new MonitorValidator()); | ||
parser.setOnValidationErrors((errors: string[]) => { | ||
errors.forEach(err => console.error(err)); | ||
window.showErrorMessage(ValidationErrorMessage); | ||
}); | ||
const parser = new Parser(new MonitorValidator()); | ||
parser.setOnValidationErrors((errors: string[]) => { | ||
errors.forEach(err => console.error(err)); | ||
window.showErrorMessage(ValidationErrorMessage); | ||
}); | ||
|
||
const pasteCommand = commands.registerTextEditorCommand(pasteMonitor.name, (editor: TextEditor) => pasteMonitor(editor, parser)); | ||
context.subscriptions.push(pasteCommand); | ||
}; | ||
const pasteCommand = commands.registerTextEditorCommand(pasteMonitor.name, (editor: TextEditor) => pasteMonitor(editor, parser)); | ||
context.subscriptions.push(pasteCommand); | ||
} | ||
|
||
export function deactivate(context: ExtensionContext): void { | ||
context.subscriptions.forEach(subscription => subscription.dispose()); | ||
}; | ||
|
||
// export async function pasteDatadogAsYAML(editor: TextEditor, parser: IParser): Promise<void> { | ||
// if (editor.document.languageId !== 'yaml') { | ||
// return; | ||
// } | ||
|
||
// configureIndentSize(parser, editor.options); | ||
|
||
// try { | ||
// const clipboardContent = await env.clipboard.readText(); | ||
// const converted = parser.parse(clipboardContent); | ||
|
||
// if (converted) { | ||
// editor.edit(editBuilder => { | ||
// if (editor.selection.isEmpty) { | ||
// editBuilder.insert(editor.selection.start, converted); | ||
// } else { | ||
// editBuilder.replace(new Range(editor.selection.start, editor.selection.end), converted); | ||
// } | ||
// }); | ||
// } | ||
// } catch (e) { | ||
// console.error(e); | ||
// window.showErrorMessage(ConversionErrorMessage); | ||
// } | ||
// }; | ||
|
||
// function configureIndentSize(parser: IParser, options: TextEditorOptions) { | ||
// const indentSize = options.insertSpaces ? options.tabSize as number : DefaultIndentSize; | ||
// parser.setIndentSize(indentSize); | ||
// }; | ||
context.subscriptions.forEach(subscription => subscription.dispose()); | ||
} |
Oops, something went wrong.