ace-linters 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20431,6 +20431,15 @@ class MarkerGroup {
20431
20431
  return marker.range.contains(pos.row, pos.column);
20432
20432
  });
20433
20433
  }
20434
+ /**
20435
+ * Finds all markers that contain the given position.
20436
+ * @param {Position} pos - The position to search for.
20437
+ * @returns {Ace.MarkerGroupItem[]} - An array of all markers that contain the given position.
20438
+ */ getMarkersAtPosition(pos) {
20439
+ return this.markers.filter(function(marker) {
20440
+ return marker.range.contains(pos.row, pos.column);
20441
+ });
20442
+ }
20434
20443
  /**
20435
20444
  * Comparator for Array.sort function, which sorts marker definitions by their positions
20436
20445
  *
@@ -21941,37 +21950,39 @@ class LanguageProvider {
21941
21950
  });
21942
21951
  }
21943
21952
  $initHoverTooltip(editor) {
21953
+ const Range = editor.getSelectionRange().constructor;
21944
21954
  this.$hoverTooltip.setDataProvider((e, editor)=>{
21945
- let session = editor.session;
21946
- let docPos = e.getDocumentPosition();
21955
+ const session = editor.session;
21956
+ const docPos = e.getDocumentPosition();
21947
21957
  this.doHover(session, docPos, (hover)=>{
21948
- var _this_$getSessionLanguageProvider_state_diagnosticMarkers, _this_$getSessionLanguageProvider_state, _hover, _hover1, _errorMarker;
21949
- if (!hover) return;
21950
- var errorMarker = (_this_$getSessionLanguageProvider_state = this.$getSessionLanguageProvider(session).state) === null || _this_$getSessionLanguageProvider_state === void 0 ? void 0 : (_this_$getSessionLanguageProvider_state_diagnosticMarkers = _this_$getSessionLanguageProvider_state.diagnosticMarkers) === null || _this_$getSessionLanguageProvider_state_diagnosticMarkers === void 0 ? void 0 : _this_$getSessionLanguageProvider_state_diagnosticMarkers.getMarkerAtPosition(docPos);
21951
- if (!errorMarker && !((_hover = hover) === null || _hover === void 0 ? void 0 : _hover.content)) return;
21952
- var range = ((_hover1 = hover) === null || _hover1 === void 0 ? void 0 : _hover1.range) || ((_errorMarker = errorMarker) === null || _errorMarker === void 0 ? void 0 : _errorMarker.range);
21953
- const Range = editor.getSelectionRange().constructor;
21958
+ var _this_$getSessionLanguageProvider_state_diagnosticMarkers, _this_$getSessionLanguageProvider_state, _hover, _hover1, _errorMarkers_;
21959
+ var _this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition;
21960
+ const errorMarkers = (_this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition = (_this_$getSessionLanguageProvider_state = this.$getSessionLanguageProvider(session).state) === null || _this_$getSessionLanguageProvider_state === void 0 ? void 0 : (_this_$getSessionLanguageProvider_state_diagnosticMarkers = _this_$getSessionLanguageProvider_state.diagnosticMarkers) === null || _this_$getSessionLanguageProvider_state_diagnosticMarkers === void 0 ? void 0 : _this_$getSessionLanguageProvider_state_diagnosticMarkers.getMarkersAtPosition(docPos)) !== null && _this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition !== void 0 ? _this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition : [];
21961
+ const hasHoverContent = (_hover = hover) === null || _hover === void 0 ? void 0 : _hover.content;
21962
+ if (errorMarkers.length === 0 && !hasHoverContent) return;
21963
+ var _hover_range;
21964
+ var range = (_hover_range = (_hover1 = hover) === null || _hover1 === void 0 ? void 0 : _hover1.range) !== null && _hover_range !== void 0 ? _hover_range : (_errorMarkers_ = errorMarkers[0]) === null || _errorMarkers_ === void 0 ? void 0 : _errorMarkers_.range;
21954
21965
  range = range ? Range.fromPoints(range.start, range.end) : session.getWordRange(docPos.row, docPos.column);
21955
- var hoverNode = hover && document.createElement("div");
21956
- if (hoverNode) {
21957
- // todo render markdown using ace markdown mode
21958
- hoverNode.innerHTML = this.getTooltipText(hover);
21959
- }
21960
- var domNode = document.createElement('div');
21961
- if (errorMarker) {
21962
- var errorDiv = document.createElement('div');
21963
- var errorText = document.createTextNode(errorMarker.tooltipText.trim());
21964
- errorDiv.appendChild(errorText);
21965
- domNode.appendChild(errorDiv);
21966
- }
21967
- if (hoverNode) {
21968
- domNode.appendChild(hoverNode);
21969
- }
21966
+ const hoverNode = hasHoverContent ? this.createHoverNode(hover) : null;
21967
+ const errorNode = errorMarkers.length > 0 ? this.createErrorNode(errorMarkers) : null;
21968
+ const domNode = document.createElement('div');
21969
+ if (errorNode) domNode.appendChild(errorNode);
21970
+ if (hoverNode) domNode.appendChild(hoverNode);
21970
21971
  this.$hoverTooltip.showForRange(editor, range, domNode, e);
21971
21972
  });
21972
21973
  });
21973
21974
  this.$hoverTooltip.addToEditor(editor);
21974
21975
  }
21976
+ createHoverNode(hover) {
21977
+ const hoverNode = document.createElement("div");
21978
+ hoverNode.innerHTML = this.getTooltipText(hover);
21979
+ return hoverNode;
21980
+ }
21981
+ createErrorNode(errorMarkers) {
21982
+ const errorDiv = document.createElement('div');
21983
+ errorDiv.textContent = errorMarkers.map((el)=>el.tooltipText.trim()).join("\n");
21984
+ return errorDiv;
21985
+ }
21975
21986
  setStyles(editor) {
21976
21987
  if (!this.stylesEmbedded) {
21977
21988
  setStyles(editor);
@@ -19456,6 +19456,15 @@ class MarkerGroup {
19456
19456
  return marker.range.contains(pos.row, pos.column);
19457
19457
  });
19458
19458
  }
19459
+ /**
19460
+ * Finds all markers that contain the given position.
19461
+ * @param {Position} pos - The position to search for.
19462
+ * @returns {Ace.MarkerGroupItem[]} - An array of all markers that contain the given position.
19463
+ */ getMarkersAtPosition(pos) {
19464
+ return this.markers.filter(function(marker) {
19465
+ return marker.range.contains(pos.row, pos.column);
19466
+ });
19467
+ }
19459
19468
  /**
19460
19469
  * Comparator for Array.sort function, which sorts marker definitions by their positions
19461
19470
  *
@@ -20966,37 +20975,39 @@ class LanguageProvider {
20966
20975
  });
20967
20976
  }
20968
20977
  $initHoverTooltip(editor) {
20978
+ const Range = editor.getSelectionRange().constructor;
20969
20979
  this.$hoverTooltip.setDataProvider((e, editor)=>{
20970
- let session = editor.session;
20971
- let docPos = e.getDocumentPosition();
20980
+ const session = editor.session;
20981
+ const docPos = e.getDocumentPosition();
20972
20982
  this.doHover(session, docPos, (hover)=>{
20973
- var _this_$getSessionLanguageProvider_state_diagnosticMarkers, _this_$getSessionLanguageProvider_state, _hover, _hover1, _errorMarker;
20974
- if (!hover) return;
20975
- var errorMarker = (_this_$getSessionLanguageProvider_state = this.$getSessionLanguageProvider(session).state) === null || _this_$getSessionLanguageProvider_state === void 0 ? void 0 : (_this_$getSessionLanguageProvider_state_diagnosticMarkers = _this_$getSessionLanguageProvider_state.diagnosticMarkers) === null || _this_$getSessionLanguageProvider_state_diagnosticMarkers === void 0 ? void 0 : _this_$getSessionLanguageProvider_state_diagnosticMarkers.getMarkerAtPosition(docPos);
20976
- if (!errorMarker && !((_hover = hover) === null || _hover === void 0 ? void 0 : _hover.content)) return;
20977
- var range = ((_hover1 = hover) === null || _hover1 === void 0 ? void 0 : _hover1.range) || ((_errorMarker = errorMarker) === null || _errorMarker === void 0 ? void 0 : _errorMarker.range);
20978
- const Range = editor.getSelectionRange().constructor;
20983
+ var _this_$getSessionLanguageProvider_state_diagnosticMarkers, _this_$getSessionLanguageProvider_state, _hover, _hover1, _errorMarkers_;
20984
+ var _this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition;
20985
+ const errorMarkers = (_this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition = (_this_$getSessionLanguageProvider_state = this.$getSessionLanguageProvider(session).state) === null || _this_$getSessionLanguageProvider_state === void 0 ? void 0 : (_this_$getSessionLanguageProvider_state_diagnosticMarkers = _this_$getSessionLanguageProvider_state.diagnosticMarkers) === null || _this_$getSessionLanguageProvider_state_diagnosticMarkers === void 0 ? void 0 : _this_$getSessionLanguageProvider_state_diagnosticMarkers.getMarkersAtPosition(docPos)) !== null && _this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition !== void 0 ? _this_$getSessionLanguageProvider_state_diagnosticMarkers_getMarkersAtPosition : [];
20986
+ const hasHoverContent = (_hover = hover) === null || _hover === void 0 ? void 0 : _hover.content;
20987
+ if (errorMarkers.length === 0 && !hasHoverContent) return;
20988
+ var _hover_range;
20989
+ var range = (_hover_range = (_hover1 = hover) === null || _hover1 === void 0 ? void 0 : _hover1.range) !== null && _hover_range !== void 0 ? _hover_range : (_errorMarkers_ = errorMarkers[0]) === null || _errorMarkers_ === void 0 ? void 0 : _errorMarkers_.range;
20979
20990
  range = range ? Range.fromPoints(range.start, range.end) : session.getWordRange(docPos.row, docPos.column);
20980
- var hoverNode = hover && document.createElement("div");
20981
- if (hoverNode) {
20982
- // todo render markdown using ace markdown mode
20983
- hoverNode.innerHTML = this.getTooltipText(hover);
20984
- }
20985
- var domNode = document.createElement('div');
20986
- if (errorMarker) {
20987
- var errorDiv = document.createElement('div');
20988
- var errorText = document.createTextNode(errorMarker.tooltipText.trim());
20989
- errorDiv.appendChild(errorText);
20990
- domNode.appendChild(errorDiv);
20991
- }
20992
- if (hoverNode) {
20993
- domNode.appendChild(hoverNode);
20994
- }
20991
+ const hoverNode = hasHoverContent ? this.createHoverNode(hover) : null;
20992
+ const errorNode = errorMarkers.length > 0 ? this.createErrorNode(errorMarkers) : null;
20993
+ const domNode = document.createElement('div');
20994
+ if (errorNode) domNode.appendChild(errorNode);
20995
+ if (hoverNode) domNode.appendChild(hoverNode);
20995
20996
  this.$hoverTooltip.showForRange(editor, range, domNode, e);
20996
20997
  });
20997
20998
  });
20998
20999
  this.$hoverTooltip.addToEditor(editor);
20999
21000
  }
21001
+ createHoverNode(hover) {
21002
+ const hoverNode = document.createElement("div");
21003
+ hoverNode.innerHTML = this.getTooltipText(hover);
21004
+ return hoverNode;
21005
+ }
21006
+ createErrorNode(errorMarkers) {
21007
+ const errorDiv = document.createElement('div');
21008
+ errorDiv.textContent = errorMarkers.map((el)=>el.tooltipText.trim()).join("\n");
21009
+ return errorDiv;
21010
+ }
21000
21011
  setStyles(editor) {
21001
21012
  if (!this.stylesEmbedded) {
21002
21013
  setStyles(editor);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ace-linters",
3
3
  "author": "Azat Alimov <mkslanc@gmail.com>",
4
- "version": "1.3.0",
4
+ "version": "1.3.1",
5
5
  "scripts": {
6
6
  "clean": "rimraf build",
7
7
  "prebuild": "node prebuild.js",
@@ -9,6 +9,12 @@ export declare class MarkerGroup {
9
9
  * @returns Ace.MarkerGroupItem
10
10
  */
11
11
  getMarkerAtPosition(pos: any): any;
12
+ /**
13
+ * Finds all markers that contain the given position.
14
+ * @param {Position} pos - The position to search for.
15
+ * @returns {Ace.MarkerGroupItem[]} - An array of all markers that contain the given position.
16
+ */
17
+ getMarkersAtPosition(pos: any): any[];
12
18
  /**
13
19
  * Comparator for Array.sort function, which sorts marker definitions by their positions
14
20
  *
@@ -67,6 +67,8 @@ export declare class LanguageProvider {
67
67
  $registerEditor(editor: Ace.Editor): void;
68
68
  private $provideCodeActions;
69
69
  private $initHoverTooltip;
70
+ private createHoverNode;
71
+ private createErrorNode;
70
72
  private setStyles;
71
73
  setGlobalOptions<T extends keyof ServiceOptionsMap>(serviceName: T & string, options: ServiceOptionsMap[T], merge?: boolean): void;
72
74
  /**