Atom boot-hint marker

This commit is contained in:
BoykoAlex
2018-07-17 16:06:48 -04:00
parent e350da8ab7
commit a25238d40a
2 changed files with 47 additions and 4 deletions

View File

@@ -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) {

View File

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