From d132740d285e0cc5b963a4d75ae37d74d6012a01 Mon Sep 17 00:00:00 2001 From: cweijan Date: Fri, 15 Jan 2021 15:12:27 +0800 Subject: [PATCH] Remove decoration --- .../es/provider/ElasticCodeLensProvider.ts | 4 - src/model/es/provider/ElasticDecoration.ts | 96 ------------------- src/model/es/provider/ElasticMatch.ts | 2 +- syntaxes/es.tmLanguage.json | 4 + 4 files changed, 5 insertions(+), 101 deletions(-) delete mode 100644 src/model/es/provider/ElasticDecoration.ts diff --git a/src/model/es/provider/ElasticCodeLensProvider.ts b/src/model/es/provider/ElasticCodeLensProvider.ts index fd26cbe..00d8209 100644 --- a/src/model/es/provider/ElasticCodeLensProvider.ts +++ b/src/model/es/provider/ElasticCodeLensProvider.ts @@ -1,18 +1,14 @@ import * as vscode from 'vscode'; import { DocumentFinder } from './documentFinder'; -import { ElasticDecoration } from './ElasticDecoration' import { ElasticMatches } from './ElasticMatches' export class ElasticCodeLensProvider implements vscode.CodeLensProvider { - private decoration: ElasticDecoration; public constructor(context: vscode.ExtensionContext) { - this.decoration = new ElasticDecoration(context) } public provideCodeLenses(document: vscode.TextDocument, _token: vscode.CancellationToken) { var esMatches = new ElasticMatches(vscode.window.activeTextEditor) - this.decoration.UpdateDecoration(esMatches) var ret = []; diff --git a/src/model/es/provider/ElasticDecoration.ts b/src/model/es/provider/ElasticDecoration.ts deleted file mode 100644 index 4aeb611..0000000 --- a/src/model/es/provider/ElasticDecoration.ts +++ /dev/null @@ -1,96 +0,0 @@ -import * as vscode from 'vscode'; -import { ElasticMatches } from './ElasticMatches'; - -export class ElasticDecoration { - pHighlight: vscode.TextEditorDecorationType; - bHighlight: vscode.TextEditorDecorationType; - bHighlightSelected: vscode.TextEditorDecorationType; - mHighlight: vscode.TextEditorDecorationType; - errHighlight: vscode.TextEditorDecorationType; - - context: vscode.ExtensionContext; - - public constructor(context: vscode.ExtensionContext) { - this.context = context - - this.pHighlight = vscode.window.createTextEditorDecorationType({ - light: { - color: 'rgb(0,191,171)', - // after: { contentText: ' • ' + host, color: 'lightgray' } - }, - dark: { - color: 'rgb(0,191,171)', - // after: { contentText: ' • ' + host, color: 'gray' } - } - }); - - this.bHighlight = vscode.window.createTextEditorDecorationType({ - isWholeLine: true, - light: { - gutterIconSize: 'contain', - backgroundColor: 'rgba(200, 200, 200, 0.2)', - gutterIconPath: this.context.asAbsolutePath("./media/gutter-dis-light.svg"), - }, - dark: { - gutterIconSize: 'contain', - backgroundColor: 'rgba(50, 50, 50, 0.3)', - gutterIconPath: vscode.Uri.parse('data:image/svg+xml;base64,PHN2ZyB4b+'), - } - }); - - this.bHighlightSelected = vscode.window.createTextEditorDecorationType({ - isWholeLine: true, - gutterIconPath: vscode.Uri.parse('data:image/svg+xml;base64,PHN2ZyB4b+'), - gutterIconSize: 'contain', - light: { - backgroundColor: 'rgba(200, 200, 200, 0.2)' - }, - dark: { - backgroundColor: 'rgba(50, 50, 50, 0.3)' - } - }); - - this.mHighlight = vscode.window.createTextEditorDecorationType({ - rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed, - light: { - color: '#EF5098' - }, - dark: { - color: '#EF5098' - }, - overviewRulerColor: '#0271bc', - overviewRulerLane: vscode.OverviewRulerLane.Left - }); - - this.errHighlight = vscode.window.createTextEditorDecorationType({ - borderWidth: '1px', - borderStyle: 'solid', - light: - { - borderColor: 'rgba(255,0,0,0.5)', - backgroundColor: 'rgba(255,0,0,0.25)' - }, - dark: - { - borderColor: 'rgba(255,0,0,0.5)', - backgroundColor: 'rgba(255,0,0,0.25)' - }, - overviewRulerColor: 'rgba(255,0,0,0.5)', - overviewRulerLane: vscode.OverviewRulerLane.Left - }); - } - - public UpdateDecoration(esMatches: ElasticMatches) { - - var editor = esMatches.Editor - var matches = esMatches.Matches - - editor.setDecorations(this.mHighlight, matches.map(m => m.Method.Range).filter(x => !!x)); - editor.setDecorations(this.pHighlight, matches.map(p => p.Path.Range).filter(x => !!x)); - editor.setDecorations(this.bHighlight, matches.filter(x => !x.Selected).map(b => b.Range).filter(x => !!x)); - editor.setDecorations(this.errHighlight, matches.map(e => e.Error.Range).filter(x => !!x)); - editor.setDecorations(this.bHighlightSelected, matches.filter(x => x.Selected).map(b => b.Range)); - - - } -} \ No newline at end of file diff --git a/src/model/es/provider/ElasticMatch.ts b/src/model/es/provider/ElasticMatch.ts index 8f4b22c..43ae00b 100644 --- a/src/model/es/provider/ElasticMatch.ts +++ b/src/model/es/provider/ElasticMatch.ts @@ -9,7 +9,7 @@ export class ElasticItem { export class ElasticMatch { - static RegexMatch: RegExp = /^(GET|POST|DELETE|PUT|HEADER)\s+([A-Za-z0-9\-\._~:\/#\[\]@!$&'"%\(\)\*+,;=`?]+)\s*$/gim; + static RegexMatch: RegExp = /^\s*(GET|POST|DELETE|PUT|HEADER)\s+([A-Za-z0-9\-\._~:\/#\[\]@!$&'"%\(\)\*+,;=`?]+)\s*$/gim; Error: ElasticItem Path: ElasticItem Body: ElasticItem diff --git a/syntaxes/es.tmLanguage.json b/syntaxes/es.tmLanguage.json index abfc2e5..01b2112 100644 --- a/syntaxes/es.tmLanguage.json +++ b/syntaxes/es.tmLanguage.json @@ -2,6 +2,10 @@ "name": "ElasticSearch", "scopeName": "source.es", "patterns": [ + { + "match": "(?i)^\\s*\\b(GET|post|header|put|delete)\\b", + "name": "keyword.es" + }, { "include": "#value" }