From a25238d40a8ac58908c637d4a943f55aa7d9d3ca Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Tue, 17 Jul 2018 16:06:48 -0400 Subject: [PATCH] Atom boot-hint marker --- .../atom-spring-boot/lib/boot-sts-adapter.ts | 25 +++++++++++++++++- .../styles/hints.atom-text-editor.less | 26 ++++++++++++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/atom-extensions/atom-spring-boot/lib/boot-sts-adapter.ts b/atom-extensions/atom-spring-boot/lib/boot-sts-adapter.ts index 37f036a5e..2c0bb9532 100644 --- a/atom-extensions/atom-spring-boot/lib/boot-sts-adapter.ts +++ b/atom-extensions/atom-spring-boot/lib/boot-sts-adapter.ts @@ -8,9 +8,10 @@ const BOOT_HINT_GUTTER_NAME = 'boot-hint-gutter'; const DECORATION_OPTIONS: DecorationOptions = { type: 'highlight', class: 'boot-hint', - gutterName: BOOT_HINT_GUTTER_NAME + // gutterName: BOOT_HINT_GUTTER_NAME }; + export class BootStsAdapter extends StsAdapter { constructor() { @@ -23,6 +24,10 @@ export class BootStsAdapter extends StsAdapter { private markHintsForEditor(editor: TextEditor, ranges: Range[]) { editor.getDecorations(DECORATION_OPTIONS).map(decoration => decoration.getMarker()).forEach(m => m.destroy()); + editor.getDecorations({ + type: 'block', + class: 'boot-hint-icon' + }).map(decoration => decoration.getMarker()).forEach(m => m.destroy()); if (Array.isArray(ranges)) { ranges.forEach(range => this.createHintMarker(editor, range)); } @@ -37,12 +42,30 @@ export class BootStsAdapter extends StsAdapter { } private createHintMarker(editor: TextEditor, range: Range) { + // Create marker model const marker = editor.markBufferRange(Convert.lsRangeToAtomRange(range)); // Marker around the text in the editor editor.decorateMarker(marker, DECORATION_OPTIONS); + const element = document.createElement('img'); + // element.textContent = '🐲'; + element.src = 'atom://spring-boot/styles/boot-icon.png'; + + const AUX_DECORATION_OPTIONS: DecorationOptions = { + type: 'block', + position: 'before', + item: element, + class: 'boot-hint-icon' + }; + const auxMarker = editor.markBufferRange(Convert.lsRangeToAtomRange({ + start: range.start, + end: range.start + })); + + editor.decorateMarker(auxMarker, AUX_DECORATION_OPTIONS); + // Marker in the diagnostic gutter let gutter = editor.gutterWithName(BOOT_HINT_GUTTER_NAME); if (!gutter) { diff --git a/atom-extensions/atom-spring-boot/styles/hints.atom-text-editor.less b/atom-extensions/atom-spring-boot/styles/hints.atom-text-editor.less index 2ef68d7c5..1514f6461 100644 --- a/atom-extensions/atom-spring-boot/styles/hints.atom-text-editor.less +++ b/atom-extensions/atom-spring-boot/styles/hints.atom-text-editor.less @@ -1,9 +1,29 @@ .boot-hint .region { - border-color: #32BA56; - border-style: dotted; - border-width: 1px; + background-color: rgba(109,179,63,0.25); + border-color: rgba(109,179,63,0.25); + border-radius: 4px; + border-spacing: 4px; } +.boot-hint-icon { + //background-image: url("atom://spring-boot/styles/boot-icon.png"); + //width: 10px; + //height: 10px; + display: inline; +} + +//.boot-hint .region::before { +// content: url("atom://spring-boot/styles/boot-icon.png"); +// display: block; +//} + +//before: { +// contentIconPath: path.resolve(__dirname, "../icons/boot-12.png"), +// margin: '0px 2px 0px 0px', +// height: '18pt' +//}, + + atom-text-editor.editor { .gutter-boot-hint:before { content: url("atom://spring-boot/styles/boot-icon.png");