Browse Source

Remove decoration

pull/99/head
cweijan 5 years ago
parent
commit
d132740d28
  1. 4
      src/model/es/provider/ElasticCodeLensProvider.ts
  2. 96
      src/model/es/provider/ElasticDecoration.ts
  3. 2
      src/model/es/provider/ElasticMatch.ts
  4. 4
      syntaxes/es.tmLanguage.json

4
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 = [];

96
src/model/es/provider/ElasticDecoration.ts

@ -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));
}
}

2
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

4
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"
}

Loading…
Cancel
Save