307435b02c6b524874f608868ef7e84cde1c0b9a29051b03270a2ab8fce51cd2e5691385cc315aa2bf502a8682e5dc4bc2374023eec434beb18ba40879dc68 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. export class HoverRangeAnchor {
  6. constructor(priority, range) {
  7. this.priority = priority;
  8. this.range = range;
  9. this.type = 1 /* HoverAnchorType.Range */;
  10. }
  11. equals(other) {
  12. return (other.type === 1 /* HoverAnchorType.Range */ && this.range.equalsRange(other.range));
  13. }
  14. canAdoptVisibleHover(lastAnchor, showAtPosition) {
  15. return (lastAnchor.type === 1 /* HoverAnchorType.Range */ && showAtPosition.lineNumber === this.range.startLineNumber);
  16. }
  17. }
  18. export class HoverForeignElementAnchor {
  19. constructor(priority, owner, range) {
  20. this.priority = priority;
  21. this.owner = owner;
  22. this.range = range;
  23. this.type = 2 /* HoverAnchorType.ForeignElement */;
  24. }
  25. equals(other) {
  26. return (other.type === 2 /* HoverAnchorType.ForeignElement */ && this.owner === other.owner);
  27. }
  28. canAdoptVisibleHover(lastAnchor, showAtPosition) {
  29. return (lastAnchor.type === 2 /* HoverAnchorType.ForeignElement */ && this.owner === lastAnchor.owner);
  30. }
  31. }
  32. export const HoverParticipantRegistry = (new class HoverParticipantRegistry {
  33. constructor() {
  34. this._participants = [];
  35. }
  36. register(ctor) {
  37. this._participants.push(ctor);
  38. }
  39. getAll() {
  40. return this._participants;
  41. }
  42. }());