Skip to content

Commit

Permalink
Avoid calling editor.markBufferRange(...) with custom options
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed Jul 9, 2018
1 parent 1383fff commit 34728a7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions atom-extensions/atom-spring-boot/lib/boot-sts-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import {StsAdapter, HighlightParams} from '@pivotal-tools/atom-languageclient-commons';
import {Convert} from 'atom-languageclient';
import { Range } from 'vscode-languageserver-protocol';
import {TextEditor} from 'atom';
import {TextEditor, DecorationOptions } from 'atom';

const BOOT_DATA_MARKER_TYPE: any = 'BootApp-Hint';
const BOOT_HINT_GUTTER_NAME = 'boot-hint-gutter';

const DECORATION_OPTIONS: DecorationOptions = {
type: 'highlight',
class: 'boot-hint',
gutterName: BOOT_HINT_GUTTER_NAME
};

export class BootStsAdapter extends StsAdapter {

constructor() {
Expand All @@ -17,7 +22,7 @@ export class BootStsAdapter extends StsAdapter {
}

private markHintsForEditor(editor: TextEditor, ranges: Range[]) {
editor.findMarkers(BOOT_DATA_MARKER_TYPE).forEach(m => m.destroy());
editor.getDecorations(DECORATION_OPTIONS).map(decoration => decoration.getMarker()).forEach(m => m.destroy());
if (Array.isArray(ranges)) {
ranges.forEach(range => this.createHintMarker(editor, range));
}
Expand All @@ -33,13 +38,10 @@ export class BootStsAdapter extends StsAdapter {

private createHintMarker(editor: TextEditor, range: Range) {
// Create marker model
const marker = editor.markBufferRange(Convert.lsRangeToAtomRange(range), BOOT_DATA_MARKER_TYPE);
const marker = editor.markBufferRange(Convert.lsRangeToAtomRange(range));

// Marker around the text in the editor
editor.decorateMarker(marker, {
type: 'highlight',
class: 'boot-hint'
});
editor.decorateMarker(marker, DECORATION_OPTIONS);

// Marker in the diagnostic gutter
let gutter = editor.gutterWithName(BOOT_HINT_GUTTER_NAME);
Expand All @@ -53,4 +55,5 @@ export class BootStsAdapter extends StsAdapter {
iconElement.setAttribute('class', 'gutter-boot-hint');
gutter.decorateMarker(marker, {item: iconElement});
}

}

0 comments on commit 34728a7

Please sign in to comment.