brighterscript 1.0.0-alpha.44 → 1.0.0-alpha.46

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.
Files changed (229) hide show
  1. package/bsconfig.schema.json +6 -1
  2. package/dist/AstValidationSegmenter.js +6 -1
  3. package/dist/AstValidationSegmenter.js.map +1 -1
  4. package/dist/BsConfig.d.ts +4 -0
  5. package/dist/BusyStatusTracker.d.ts +37 -7
  6. package/dist/BusyStatusTracker.js +73 -8
  7. package/dist/BusyStatusTracker.js.map +1 -1
  8. package/dist/Cache.d.ts +0 -4
  9. package/dist/Cache.js +0 -6
  10. package/dist/Cache.js.map +1 -1
  11. package/dist/CodeActionUtil.d.ts +6 -1
  12. package/dist/CodeActionUtil.js +3 -0
  13. package/dist/CodeActionUtil.js.map +1 -1
  14. package/dist/CrossScopeValidator.d.ts +1 -1
  15. package/dist/CrossScopeValidator.js +8 -7
  16. package/dist/CrossScopeValidator.js.map +1 -1
  17. package/dist/DiagnosticCollection.d.ts +19 -5
  18. package/dist/DiagnosticCollection.js +71 -23
  19. package/dist/DiagnosticCollection.js.map +1 -1
  20. package/dist/DiagnosticFilterer.d.ts +14 -1
  21. package/dist/DiagnosticFilterer.js +130 -12
  22. package/dist/DiagnosticFilterer.js.map +1 -1
  23. package/dist/DiagnosticManager.d.ts +11 -1
  24. package/dist/DiagnosticManager.js +192 -35
  25. package/dist/DiagnosticManager.js.map +1 -1
  26. package/dist/DiagnosticMessages.d.ts +19 -7
  27. package/dist/DiagnosticMessages.js +21 -9
  28. package/dist/DiagnosticMessages.js.map +1 -1
  29. package/dist/LanguageServer.d.ts +82 -139
  30. package/dist/LanguageServer.js +402 -980
  31. package/dist/LanguageServer.js.map +1 -1
  32. package/dist/Logger.d.ts +9 -4
  33. package/dist/Logger.js +30 -6
  34. package/dist/Logger.js.map +1 -1
  35. package/dist/PluginInterface.d.ts +8 -8
  36. package/dist/PluginInterface.js.map +1 -1
  37. package/dist/Program.d.ts +23 -4
  38. package/dist/Program.js +294 -194
  39. package/dist/Program.js.map +1 -1
  40. package/dist/ProgramBuilder.d.ts +22 -7
  41. package/dist/ProgramBuilder.js +44 -21
  42. package/dist/ProgramBuilder.js.map +1 -1
  43. package/dist/Scope.d.ts +11 -6
  44. package/dist/Scope.js +60 -36
  45. package/dist/Scope.js.map +1 -1
  46. package/dist/SemanticTokenUtils.js +1 -1
  47. package/dist/SemanticTokenUtils.js.map +1 -1
  48. package/dist/astUtils/CachedLookups.js +0 -1
  49. package/dist/astUtils/CachedLookups.js.map +1 -1
  50. package/dist/astUtils/reflection.d.ts +4 -4
  51. package/dist/astUtils/reflection.js +12 -10
  52. package/dist/astUtils/reflection.js.map +1 -1
  53. package/dist/bscPlugin/BscPlugin.d.ts +3 -3
  54. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  55. package/dist/bscPlugin/CallExpressionInfo.js +4 -2
  56. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  57. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +2 -0
  58. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +147 -0
  59. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  60. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +44 -0
  61. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  62. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -1
  63. package/dist/bscPlugin/completions/CompletionsProcessor.js +15 -15
  64. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  65. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +82 -5
  66. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
  67. package/dist/bscPlugin/hover/HoverProcessor.js +3 -0
  68. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  69. package/dist/bscPlugin/hover/HoverProcessor.spec.js +44 -0
  70. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  71. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +4 -0
  72. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  73. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +17 -0
  74. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  75. package/dist/bscPlugin/validation/BrsFileValidator.js +21 -0
  76. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  77. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +161 -7
  78. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  79. package/dist/bscPlugin/validation/ScopeValidator.d.ts +4 -1
  80. package/dist/bscPlugin/validation/ScopeValidator.js +166 -63
  81. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  82. package/dist/bscPlugin/validation/ScopeValidator.spec.js +21 -9
  83. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
  84. package/dist/common/Sequencer.d.ts +53 -0
  85. package/dist/common/Sequencer.js +233 -0
  86. package/dist/common/Sequencer.js.map +1 -0
  87. package/dist/common/Sequencer.spec.d.ts +1 -0
  88. package/dist/common/Sequencer.spec.js +75 -0
  89. package/dist/common/Sequencer.spec.js.map +1 -0
  90. package/dist/deferred.d.ts +2 -0
  91. package/dist/deferred.js +10 -0
  92. package/dist/deferred.js.map +1 -1
  93. package/dist/examples/plugins/removePrint.d.ts +2 -2
  94. package/dist/examples/plugins/removePrint.js.map +1 -1
  95. package/dist/files/BrsFile.d.ts +1 -1
  96. package/dist/files/BrsFile.js +22 -42
  97. package/dist/files/BrsFile.js.map +1 -1
  98. package/dist/files/BrsFile.spec.js +155 -4
  99. package/dist/files/BrsFile.spec.js.map +1 -1
  100. package/dist/files/BscFile.d.ts +1 -0
  101. package/dist/files/LazyFileData.d.ts +1 -0
  102. package/dist/files/XmlFile.spec.js +1 -1
  103. package/dist/files/XmlFile.spec.js.map +1 -1
  104. package/dist/globalCallables.js +189 -189
  105. package/dist/globalCallables.js.map +1 -1
  106. package/dist/interfaces.d.ts +56 -13
  107. package/dist/interfaces.js.map +1 -1
  108. package/dist/lexer/Lexer.js +1 -1
  109. package/dist/lexer/Lexer.js.map +1 -1
  110. package/dist/logging.d.ts +6 -1
  111. package/dist/logging.js +14 -1
  112. package/dist/logging.js.map +1 -1
  113. package/dist/lsp/ActionQueue.d.ts +35 -0
  114. package/dist/lsp/ActionQueue.js +115 -0
  115. package/dist/lsp/ActionQueue.js.map +1 -0
  116. package/dist/lsp/ActionQueue.spec.d.ts +1 -0
  117. package/dist/lsp/ActionQueue.spec.js +80 -0
  118. package/dist/lsp/ActionQueue.spec.js.map +1 -0
  119. package/dist/lsp/DocumentManager.d.ts +63 -0
  120. package/dist/lsp/DocumentManager.js +122 -0
  121. package/dist/lsp/DocumentManager.js.map +1 -0
  122. package/dist/lsp/DocumentManager.spec.d.ts +1 -0
  123. package/dist/lsp/DocumentManager.spec.js +103 -0
  124. package/dist/lsp/DocumentManager.spec.js.map +1 -0
  125. package/dist/lsp/LspProject.d.ts +231 -0
  126. package/dist/lsp/LspProject.js +3 -0
  127. package/dist/lsp/LspProject.js.map +1 -0
  128. package/dist/lsp/PathFilterer.d.ts +75 -0
  129. package/dist/lsp/PathFilterer.js +196 -0
  130. package/dist/lsp/PathFilterer.js.map +1 -0
  131. package/dist/lsp/PathFilterer.spec.d.ts +1 -0
  132. package/dist/lsp/PathFilterer.spec.js +182 -0
  133. package/dist/lsp/PathFilterer.spec.js.map +1 -0
  134. package/dist/lsp/Project.d.ts +167 -0
  135. package/dist/lsp/Project.js +432 -0
  136. package/dist/lsp/Project.js.map +1 -0
  137. package/dist/lsp/Project.spec.d.ts +1 -0
  138. package/dist/lsp/Project.spec.js +220 -0
  139. package/dist/lsp/Project.spec.js.map +1 -0
  140. package/dist/lsp/ProjectManager.d.ts +221 -0
  141. package/dist/lsp/ProjectManager.js +754 -0
  142. package/dist/lsp/ProjectManager.js.map +1 -0
  143. package/dist/lsp/ProjectManager.spec.d.ts +1 -0
  144. package/dist/lsp/ProjectManager.spec.js +783 -0
  145. package/dist/lsp/ProjectManager.spec.js.map +1 -0
  146. package/dist/lsp/ReaderWriterManager.d.ts +21 -0
  147. package/dist/lsp/ReaderWriterManager.js +60 -0
  148. package/dist/lsp/ReaderWriterManager.js.map +1 -0
  149. package/dist/lsp/worker/MessageHandler.d.ts +99 -0
  150. package/dist/lsp/worker/MessageHandler.js +138 -0
  151. package/dist/lsp/worker/MessageHandler.js.map +1 -0
  152. package/dist/lsp/worker/MessageHandler.spec.d.ts +1 -0
  153. package/dist/lsp/worker/MessageHandler.spec.js +64 -0
  154. package/dist/lsp/worker/MessageHandler.spec.js.map +1 -0
  155. package/dist/lsp/worker/WorkerPool.d.ts +38 -0
  156. package/dist/lsp/worker/WorkerPool.js +78 -0
  157. package/dist/lsp/worker/WorkerPool.js.map +1 -0
  158. package/dist/lsp/worker/WorkerPool.spec.d.ts +1 -0
  159. package/dist/lsp/worker/WorkerPool.spec.js +59 -0
  160. package/dist/lsp/worker/WorkerPool.spec.js.map +1 -0
  161. package/dist/lsp/worker/WorkerThreadProject.d.ts +144 -0
  162. package/dist/lsp/worker/WorkerThreadProject.js +183 -0
  163. package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
  164. package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +2 -0
  165. package/dist/lsp/worker/WorkerThreadProject.spec.js +68 -0
  166. package/dist/lsp/worker/WorkerThreadProject.spec.js.map +1 -0
  167. package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
  168. package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
  169. package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
  170. package/dist/parser/Expression.d.ts +1 -0
  171. package/dist/parser/Expression.js +65 -3
  172. package/dist/parser/Expression.js.map +1 -1
  173. package/dist/parser/Parser.spec.js +12 -0
  174. package/dist/parser/Parser.spec.js.map +1 -1
  175. package/dist/parser/Statement.js +2 -2
  176. package/dist/parser/Statement.js.map +1 -1
  177. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +47 -0
  178. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  179. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +51 -5
  180. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  181. package/dist/parser/tests/expression/TernaryExpression.spec.js +44 -0
  182. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  183. package/dist/roku-types/data.json +880 -756
  184. package/dist/roku-types/index.d.ts +17 -0
  185. package/dist/types/BooleanType.d.ts +0 -2
  186. package/dist/types/BooleanType.js +4 -6
  187. package/dist/types/BooleanType.js.map +1 -1
  188. package/dist/types/BscType.js +5 -0
  189. package/dist/types/BscType.js.map +1 -1
  190. package/dist/types/BuiltInInterfaceAdder.d.ts +1 -0
  191. package/dist/types/BuiltInInterfaceAdder.js +24 -17
  192. package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
  193. package/dist/types/DoubleType.d.ts +0 -2
  194. package/dist/types/DoubleType.js +4 -6
  195. package/dist/types/DoubleType.js.map +1 -1
  196. package/dist/types/DynamicType.d.ts +0 -2
  197. package/dist/types/DynamicType.js +3 -5
  198. package/dist/types/DynamicType.js.map +1 -1
  199. package/dist/types/FloatType.d.ts +0 -2
  200. package/dist/types/FloatType.js +4 -6
  201. package/dist/types/FloatType.js.map +1 -1
  202. package/dist/types/FunctionType.d.ts +0 -2
  203. package/dist/types/FunctionType.js +5 -7
  204. package/dist/types/FunctionType.js.map +1 -1
  205. package/dist/types/IntegerType.d.ts +0 -2
  206. package/dist/types/IntegerType.js +4 -6
  207. package/dist/types/IntegerType.js.map +1 -1
  208. package/dist/types/LongIntegerType.d.ts +0 -2
  209. package/dist/types/LongIntegerType.js +4 -6
  210. package/dist/types/LongIntegerType.js.map +1 -1
  211. package/dist/types/ObjectType.d.ts +3 -3
  212. package/dist/types/ObjectType.js +6 -8
  213. package/dist/types/ObjectType.js.map +1 -1
  214. package/dist/types/StringType.d.ts +0 -2
  215. package/dist/types/StringType.js +4 -6
  216. package/dist/types/StringType.js.map +1 -1
  217. package/dist/types/VoidType.d.ts +0 -2
  218. package/dist/types/VoidType.js +4 -6
  219. package/dist/types/VoidType.js.map +1 -1
  220. package/dist/types/helpers.d.ts +4 -0
  221. package/dist/types/helpers.js +5 -1
  222. package/dist/types/helpers.js.map +1 -1
  223. package/dist/util.d.ts +48 -16
  224. package/dist/util.js +203 -70
  225. package/dist/util.js.map +1 -1
  226. package/dist/validators/ClassValidator.js +2 -2
  227. package/dist/validators/ClassValidator.js.map +1 -1
  228. package/package.json +15 -5
  229. package/CHANGELOG.md +0 -2352
@@ -0,0 +1,75 @@
1
+ import type { Logger } from '../logging';
2
+ /**
3
+ * Manage collections of glob patterns used to filter paths.
4
+ *
5
+ * excludeLists are evaluated first to see if a path should be excluded. If the path is excluded, we then test it against the includeLists.
6
+ * If the path matches an includeList, it will be included. If not, it will remain excluded.
7
+ */
8
+ export declare class PathFilterer {
9
+ constructor(options?: {
10
+ logger?: Logger;
11
+ });
12
+ private logger;
13
+ private includeCollections;
14
+ private excludeCollections;
15
+ /**
16
+ * Filter the given list of entries based on the registered include and exclude lists.
17
+ * @param entries the list of paths (or objects having paths) to filter
18
+ * @param fetcher a function that can extract the path from the entry if it's not a string
19
+ * @returns the filtered list of entries
20
+ */
21
+ filter<T = string>(entries: T[], fetcher?: (path: T) => string): T[];
22
+ /**
23
+ * Does the path match at least one of the exclusions lists
24
+ */
25
+ private isExclusionsMatch;
26
+ /**
27
+ * Does the path match at least one of the inclusions lists
28
+ */
29
+ private isInclusionsMatch;
30
+ /**
31
+ * Register a list of inclusive globs that should be evaluated together
32
+ * These should be things like the `files` array from a bsconfig.json
33
+ */
34
+ registerIncludeList(rootDir: string, globs: string[]): () => void;
35
+ /**
36
+ * Register glob patterns for files that should be _excluded_. positive patterns mean a file is excluded,
37
+ * and negative patterns mean a file that was previously matched (excluded) should be unmatched (included)
38
+ * These should be things like .gitignore or vscode's `files.exclude`.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * [
43
+ * '.git',
44
+ * 'node_modules'
45
+ * '!node_modules/@rokucommunity/bslib'
46
+ * ]
47
+ * ```
48
+ * would exclude all files in the `.git` and `node_modules` directories, but would include the `node_modules/@rokucommunity/bslib` directory
49
+ */
50
+ registerExcludeList(rootDir: string, globs: string[]): () => void;
51
+ registerExcludeMatcher(matcher: (path: string) => boolean): () => void;
52
+ private removeCollection;
53
+ /**
54
+ * Remove all registered collections
55
+ */
56
+ clear(): void;
57
+ }
58
+ export declare class PathCollection {
59
+ options: {
60
+ rootDir: string;
61
+ globs: string[];
62
+ } | {
63
+ matcher: (path: string) => boolean;
64
+ isExcludePattern: boolean;
65
+ };
66
+ constructor(options: {
67
+ rootDir: string;
68
+ globs: string[];
69
+ } | {
70
+ matcher: (path: string) => boolean;
71
+ isExcludePattern: boolean;
72
+ });
73
+ private matchers;
74
+ isMatch(path: string): boolean;
75
+ }
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathCollection = exports.PathFilterer = void 0;
4
+ const micromatch = require("micromatch");
5
+ const path = require("path");
6
+ const logging_1 = require("../logging");
7
+ const util_1 = require("../util");
8
+ /**
9
+ * Manage collections of glob patterns used to filter paths.
10
+ *
11
+ * excludeLists are evaluated first to see if a path should be excluded. If the path is excluded, we then test it against the includeLists.
12
+ * If the path matches an includeList, it will be included. If not, it will remain excluded.
13
+ */
14
+ class PathFilterer {
15
+ constructor(options) {
16
+ var _a;
17
+ this.includeCollections = [];
18
+ this.excludeCollections = [];
19
+ this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : (0, logging_1.createLogger)();
20
+ }
21
+ /**
22
+ * Filter the given list of entries based on the registered include and exclude lists.
23
+ * @param entries the list of paths (or objects having paths) to filter
24
+ * @param fetcher a function that can extract the path from the entry if it's not a string
25
+ * @returns the filtered list of entries
26
+ */
27
+ filter(entries, fetcher) {
28
+ var _a;
29
+ //if there are no exclude lists, then all files should be included
30
+ if (this.excludeCollections.length === 0) {
31
+ return entries;
32
+ }
33
+ let results = [];
34
+ //process each path
35
+ for (let entry of entries) {
36
+ let srcPath = (_a = fetcher === null || fetcher === void 0 ? void 0 : fetcher(entry)) !== null && _a !== void 0 ? _a : entry;
37
+ //if this path is excluded
38
+ if (this.isExclusionsMatch(srcPath)) {
39
+ //if this path is re-included, keep it
40
+ if (this.isInclusionsMatch(srcPath)) {
41
+ results.push(entry);
42
+ }
43
+ else {
44
+ //this path should be excluded
45
+ }
46
+ //this path is not excluded, so keep it
47
+ }
48
+ else {
49
+ results.push(entry);
50
+ }
51
+ }
52
+ return results;
53
+ }
54
+ /**
55
+ * Does the path match at least one of the exclusions lists
56
+ */
57
+ isExclusionsMatch(path) {
58
+ //does this path match an exclusion list?
59
+ for (const collection of this.excludeCollections) {
60
+ if (collection.isMatch(path)) {
61
+ return true;
62
+ }
63
+ }
64
+ return false;
65
+ }
66
+ /**
67
+ * Does the path match at least one of the inclusions lists
68
+ */
69
+ isInclusionsMatch(path) {
70
+ //does this path match an exclusion list?
71
+ for (const collection of this.includeCollections) {
72
+ if (collection.isMatch(path)) {
73
+ return true;
74
+ }
75
+ }
76
+ return false;
77
+ }
78
+ /**
79
+ * Register a list of inclusive globs that should be evaluated together
80
+ * These should be things like the `files` array from a bsconfig.json
81
+ */
82
+ registerIncludeList(rootDir, globs) {
83
+ this.logger.debug('registerIncludeList', { rootDir: rootDir, globs: globs });
84
+ let collection = new PathCollection({
85
+ rootDir: rootDir,
86
+ globs: globs
87
+ });
88
+ this.includeCollections.push(collection);
89
+ return () => {
90
+ this.removeCollection(collection);
91
+ };
92
+ }
93
+ /**
94
+ * Register glob patterns for files that should be _excluded_. positive patterns mean a file is excluded,
95
+ * and negative patterns mean a file that was previously matched (excluded) should be unmatched (included)
96
+ * These should be things like .gitignore or vscode's `files.exclude`.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * [
101
+ * '.git',
102
+ * 'node_modules'
103
+ * '!node_modules/@rokucommunity/bslib'
104
+ * ]
105
+ * ```
106
+ * would exclude all files in the `.git` and `node_modules` directories, but would include the `node_modules/@rokucommunity/bslib` directory
107
+ */
108
+ registerExcludeList(rootDir, globs) {
109
+ this.logger.debug('registerExcludeList', { rootDir: rootDir, globs: globs });
110
+ let collection = new PathCollection({
111
+ rootDir: rootDir,
112
+ globs: globs
113
+ });
114
+ this.excludeCollections.push(collection);
115
+ return () => {
116
+ this.removeCollection(collection);
117
+ };
118
+ }
119
+ registerExcludeMatcher(matcher) {
120
+ this.logger.debug('registerExcludeMatcher', matcher);
121
+ const collection = new PathCollection({
122
+ matcher: matcher,
123
+ isExcludePattern: false
124
+ });
125
+ this.excludeCollections.push(collection);
126
+ return () => {
127
+ this.removeCollection(collection);
128
+ };
129
+ }
130
+ removeCollection(collection) {
131
+ let idx = this.includeCollections.indexOf(collection);
132
+ if (idx > -1) {
133
+ this.includeCollections.splice(idx, 1);
134
+ }
135
+ idx = this.excludeCollections.indexOf(collection);
136
+ if (idx > -1) {
137
+ this.excludeCollections.splice(idx, 1);
138
+ }
139
+ }
140
+ /**
141
+ * Remove all registered collections
142
+ */
143
+ clear() {
144
+ this.includeCollections = [];
145
+ this.excludeCollections = [];
146
+ }
147
+ }
148
+ exports.PathFilterer = PathFilterer;
149
+ class PathCollection {
150
+ constructor(options) {
151
+ var _a;
152
+ this.options = options;
153
+ this.matchers = [];
154
+ if ('globs' in options) {
155
+ //build matcher patterns from the globs
156
+ for (let glob of (_a = options.globs) !== null && _a !== void 0 ? _a : []) {
157
+ let isExcludePattern = glob.startsWith('!');
158
+ if (isExcludePattern) {
159
+ glob = glob.substring(1);
160
+ }
161
+ const pattern = path.resolve(options.rootDir, glob).replace(/\\+/g, '/');
162
+ this.matchers.push({
163
+ pattern: pattern,
164
+ isMatch: micromatch.matcher(pattern),
165
+ isExcludePattern: isExcludePattern
166
+ });
167
+ }
168
+ }
169
+ else {
170
+ this.matchers.push({
171
+ isMatch: options.matcher,
172
+ isExcludePattern: options.isExcludePattern
173
+ });
174
+ }
175
+ }
176
+ isMatch(path) {
177
+ let keep = false;
178
+ //coerce the path into a normalized form and unix slashes
179
+ path = util_1.default.standardizePath(path).replace(/\\+/g, '/');
180
+ for (let matcher of this.matchers) {
181
+ //exclusion pattern: do not keep the path if it matches
182
+ if (matcher.isExcludePattern) {
183
+ if (matcher.isMatch(path)) {
184
+ keep = false;
185
+ }
186
+ //inclusion pattern: keep the path if it matches
187
+ }
188
+ else {
189
+ keep = keep || matcher.isMatch(path);
190
+ }
191
+ }
192
+ return keep;
193
+ }
194
+ }
195
+ exports.PathCollection = PathCollection;
196
+ //# sourceMappingURL=PathFilterer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathFilterer.js","sourceRoot":"","sources":["../../src/lsp/PathFilterer.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,6BAA6B;AAE7B,wCAA0C;AAC1C,kCAA2B;AAE3B;;;;;GAKG;AACH,MAAa,YAAY;IACrB,YACI,OAEC;;QAOG,uBAAkB,GAAqB,EAAE,CAAC;QAE1C,uBAAkB,GAAqB,EAAE,CAAC;QAP9C,IAAI,CAAC,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,IAAA,sBAAY,GAAE,CAAC;IACpD,CAAC;IAQD;;;;;OAKG;IACI,MAAM,CAAa,OAAY,EAAE,OAA6B;;QACjE,kEAAkE;QAClE,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE;YACtC,OAAO,OAAO,CAAC;SAClB;QAED,IAAI,OAAO,GAAQ,EAAE,CAAC;QAEtB,mBAAmB;QACnB,KAAK,IAAI,KAAK,IAAI,OAAO,EAAE;YACvB,IAAI,OAAO,GAAG,MAA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jB,yDAAyD;QACzD,IAAI,GAAG,cAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACvD,KAAK,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC/B,uDAAuD;YACvD,IAAI,OAAO,CAAC,gBAAgB,EAAE;gBAC1B,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBACvB,IAAI,GAAG,KAAK,CAAC;iBAChB;gBACD,gDAAgD;aACnD;iBAAM;gBACH,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACxC;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA1DD,wCA0DC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const PathFilterer_1 = require("./PathFilterer");
4
+ const testHelpers_spec_1 = require("../testHelpers.spec");
5
+ const chai_1 = require("chai");
6
+ const util_1 = require("../util");
7
+ const sinon_1 = require("sinon");
8
+ const sinon = (0, sinon_1.createSandbox)();
9
+ describe('PathFilterer', () => {
10
+ let filterer;
11
+ beforeEach(() => {
12
+ filterer = new PathFilterer_1.PathFilterer();
13
+ sinon.restore();
14
+ });
15
+ afterEach(() => {
16
+ sinon.restore();
17
+ });
18
+ it('allows all files through when no filters exist', () => {
19
+ (0, chai_1.expect)(filterer.filter([
20
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
21
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a/b/c/d.xml`,
22
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/e.txt`
23
+ ])).to.eql([
24
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
25
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a/b/c/d.xml`,
26
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/e.txt`
27
+ ]);
28
+ });
29
+ it('supports standalone workspace style', () => {
30
+ const filterer = new PathFilterer_1.PathCollection({
31
+ rootDir: (0, util_1.standardizePath) `${testHelpers_spec_1.cwd}/src/lsp/standalone-project-1`,
32
+ globs: [(0, util_1.standardizePath) `${testHelpers_spec_1.cwd}/.tmp/rootDir/source/main.bs`]
33
+ });
34
+ (0, chai_1.expect)(filterer.isMatch(`${testHelpers_spec_1.cwd}/.tmp/rootDir/source/main.bs`)).to.be.true;
35
+ });
36
+ it('filters files', () => {
37
+ filterer.registerExcludeList(testHelpers_spec_1.rootDir, ['**/*.brs']);
38
+ (0, chai_1.expect)(filterer.filter([
39
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
40
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
41
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
42
+ ])).to.eql([
43
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`
44
+ ]);
45
+ });
46
+ it('filters files but re-includes them if part of an include list', () => {
47
+ filterer.registerExcludeList(testHelpers_spec_1.rootDir, ['**/*.brs']);
48
+ filterer.registerIncludeList(testHelpers_spec_1.rootDir, ['**/a*.brs']);
49
+ (0, chai_1.expect)(filterer.filter([
50
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
51
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
52
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
53
+ ])).to.eql([
54
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
55
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`
56
+ ]);
57
+ });
58
+ it('supports removing lists', () => {
59
+ const removeExclude = filterer.registerExcludeList(testHelpers_spec_1.rootDir, ['**/*.brs']);
60
+ const removeInclude = filterer.registerIncludeList(testHelpers_spec_1.rootDir, ['**/a*.brs']);
61
+ (0, chai_1.expect)(filterer.filter([
62
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
63
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
64
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
65
+ ])).to.eql([
66
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
67
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`
68
+ ]);
69
+ removeInclude();
70
+ (0, chai_1.expect)(filterer.filter([
71
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
72
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
73
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
74
+ ])).to.eql([
75
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`
76
+ ]);
77
+ removeExclude();
78
+ (0, chai_1.expect)(filterer.filter([
79
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
80
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
81
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
82
+ ])).to.eql([
83
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
84
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
85
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
86
+ ]);
87
+ });
88
+ it('clear removes all exclude and include lists', () => {
89
+ filterer.registerExcludeList(testHelpers_spec_1.rootDir, ['**/components/**/*.brs']);
90
+ (0, chai_1.expect)(filterer.filter([
91
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/a.brs`,
92
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/b.brs`,
93
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/c.brs`
94
+ ])).to.eql([]);
95
+ filterer.clear();
96
+ (0, chai_1.expect)(filterer.filter([
97
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/a.brs`,
98
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/b.brs`,
99
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/c.brs`
100
+ ])).to.eql([
101
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/a.brs`,
102
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/b.brs`,
103
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/c.brs`
104
+ ]);
105
+ });
106
+ it('works with null exclude list', () => {
107
+ filterer.registerExcludeList(testHelpers_spec_1.rootDir, null);
108
+ (0, chai_1.expect)(filterer.filter([
109
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/a.brs`,
110
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/b.brs`,
111
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/c.brs`
112
+ ])).to.eql([
113
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/a.brs`,
114
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/b.brs`,
115
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/c.brs`
116
+ ]);
117
+ });
118
+ it('works with null include list', () => {
119
+ filterer.registerExcludeList(testHelpers_spec_1.rootDir, ['**/*']);
120
+ filterer.registerIncludeList(testHelpers_spec_1.rootDir, null);
121
+ (0, chai_1.expect)(filterer.filter([
122
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/a.brs`,
123
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/b.brs`,
124
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/c.brs`
125
+ ])).to.eql([]);
126
+ });
127
+ describe('registerExcludeMatcher', () => {
128
+ it('calls the callback function on every path', () => {
129
+ const spy = sinon.spy();
130
+ filterer.registerExcludeMatcher(spy);
131
+ filterer.filter([
132
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
133
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
134
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
135
+ ]);
136
+ (0, chai_1.expect)(spy.getCalls().map(x => (0, util_1.standardizePath) `${x.args[0]}`)).to.eql([
137
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/a.brs`,
138
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/b.txt`,
139
+ (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/c.brs`
140
+ ]);
141
+ });
142
+ });
143
+ });
144
+ describe('PathCollection', () => {
145
+ function doTest(globs, filePath, expected) {
146
+ const collection = new PathFilterer_1.PathCollection({
147
+ rootDir: testHelpers_spec_1.rootDir,
148
+ globs: globs
149
+ });
150
+ (0, chai_1.expect)(collection.isMatch(filePath)).to.equal(expected);
151
+ }
152
+ it('includes a file that matches a single pattern', () => {
153
+ doTest([
154
+ '**/*.brs'
155
+ ], (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/alpha.brs`, true);
156
+ });
157
+ it('includes a file that matches the 2nd pattern', () => {
158
+ doTest([
159
+ '**/*beta*.brs',
160
+ '**/*alpha*.brs'
161
+ ], (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/alpha.brs`, true);
162
+ });
163
+ it('includes a file that is included then excluded then included again', () => {
164
+ doTest([
165
+ '**/*.brs',
166
+ '!**/a*.brs',
167
+ '**/alpha.brs'
168
+ ], (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/alpha.brs`, true);
169
+ });
170
+ it('excludes a file that does not match the pattern', () => {
171
+ doTest([
172
+ '**/beta.brs'
173
+ ], (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/alpha.brs`, false);
174
+ });
175
+ it('excludes a file that matches first pattern but is excluded from the second pattern', () => {
176
+ doTest([
177
+ '**/*.brs',
178
+ '!**/alpha.brs'
179
+ ], (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/alpha.brs`, false);
180
+ });
181
+ });
182
+ //# sourceMappingURL=PathFilterer.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathFilterer.spec.js","sourceRoot":"","sources":["../../src/lsp/PathFilterer.spec.ts"],"names":[],"mappings":";;AAAA,iDAA8D;AAC9D,0DAAmD;AACnD,+BAA8B;AAC9B,kCAA+C;AAC/C,iCAAsC;AACtC,MAAM,KAAK,GAAG,IAAA,qBAAa,GAAE,CAAC;AAE9B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,IAAI,QAAsB,CAAC;IAE3B,UAAU,CAAC,GAAG,EAAE;QACZ,QAAQ,GAAG,IAAI,2BAAY,EAAE,CAAC;QAC9B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACtD,IAAA,aAAM,EACF,QAAQ,CAAC,MAAM,CAAC;YACZ,IAAA,sBAAC,EAAA,GAAG,0BAAO,QAAQ;YACnB,IAAA,sBAAC,EAAA,GAAG,0BAAO,cAAc;YACzB,IAAA,sBAAC,EAAA,GAAG,0BAAO,QAAQ;SACtB,CAAC,CACL,CAAC,EAAE,CAAC,GAAG,CAAC;YACL,IAAA,sBAAC,EAAA,GAAG,0BAAO,QAAQ;YACnB,IAAA,sBAAC,EAAA,GAAG,0BAAO,cAAc;YACzB,IAAA,sBAAC,EAAA,GAAG,0BAAO,QAAQ;SACtB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,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AAA,sBAAC,EAAA,GAAG,0BAAO,YAAY,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC;YACH,aAAa;SAChB,EAAE,IAAA,sBAAC,EAAA,GAAG,0BAAO,YAAY,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oFAAoF,EAAE,GAAG,EAAE;QAC1F,MAAM,CAAC;YACH,UAAU;YACV,eAAe;SAClB,EAAE,IAAA,sBAAC,EAAA,GAAG,0BAAO,YAAY,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,167 @@
1
+ import type { ProjectConfig, ActivateResponse, LspDiagnostic, LspProject } from './LspProject';
2
+ import type { Hover, MaybePromise } from '../interfaces';
3
+ import type { DocumentSymbol, Position, Range, Location, WorkspaceSymbol } from 'vscode-languageserver-protocol';
4
+ import { CompletionList } from 'vscode-languageserver-protocol';
5
+ import type { DocumentAction, DocumentActionWithStatus } from './DocumentManager';
6
+ import type { SignatureInfoObj } from '../Program';
7
+ import type { BsConfig } from '../BsConfig';
8
+ import type { Logger } from '../logging';
9
+ export declare class Project implements LspProject {
10
+ constructor(options?: {
11
+ logger?: Logger;
12
+ projectIdentifier?: string;
13
+ });
14
+ /**
15
+ * Activates this project. Every call to `activate` should completely reset the project, clear all used ram and start from scratch.
16
+ */
17
+ activate(options: ProjectConfig): Promise<ActivateResponse>;
18
+ isStandaloneProject: boolean;
19
+ logger: Logger;
20
+ /**
21
+ * Options used to activate this project
22
+ */
23
+ activateOptions: ProjectConfig;
24
+ get rootDir(): string;
25
+ /**
26
+ * The file patterns from bsconfig.json that were used to find all files for this project
27
+ */
28
+ get filePatterns(): string[];
29
+ /**
30
+ * Gets resolved when the project has finished activating
31
+ */
32
+ private activationDeferred;
33
+ /**
34
+ * Promise that resolves when the project finishes activating
35
+ * @returns a promise that resolves when the project finishes activating
36
+ */
37
+ whenActivated(): Promise<void>;
38
+ private validationCancelToken;
39
+ /**
40
+ * Validate the project. This will trigger a full validation on any scopes that were changed since the last validation,
41
+ * and will also eventually emit a new 'diagnostics' event that includes all diagnostics for the project.
42
+ *
43
+ * This will cancel any currently running validation and then run a new one.
44
+ */
45
+ validate(): Promise<void>;
46
+ /**
47
+ * Cancel any active running validation
48
+ */
49
+ cancelValidate(): void;
50
+ getDiagnostics(): LspDiagnostic[];
51
+ /**
52
+ * Promise that resolves the next time the system is idle. If the system is already idle, it will resolve immediately
53
+ */
54
+ private onIdle;
55
+ /**
56
+ * Add or replace the in-memory contents of the file at the specified path. This is typically called as the user is typing.
57
+ * This will cancel any pending validation cycles and queue a future validation cycle instead.
58
+ */
59
+ applyFileChanges(documentActions: DocumentAction[]): Promise<DocumentActionWithStatus[]>;
60
+ /**
61
+ * Determine if this project will accept the file at the specified path (i.e. does it match a pattern in the project's files array)
62
+ */
63
+ static willAcceptFile(srcPath: string, files: BsConfig['files'], rootDir: string): boolean;
64
+ /**
65
+ * Set new contents for a file. This is safe to call any time. Changes will be queued and flushed at the correct times
66
+ * during the program's lifecycle flow
67
+ * @param srcPath absolute source path of the file
68
+ * @param fileContents the text contents of the file
69
+ * @returns true if this program accepted and added the file. false if the program didn't want the file, or if the contents didn't change
70
+ */
71
+ private setFile;
72
+ /**
73
+ * Remove the in-memory file at the specified path. This is typically called when the user (or file system watcher) triggers a file delete
74
+ * @param srcPath absolute path to the File
75
+ * @returns true if we found and removed at least one file, or false if no files were removed
76
+ */
77
+ private removeFileOrDirectory;
78
+ /**
79
+ * Get the full list of semantic tokens for the given file path
80
+ * @param options options for getting semantic tokens
81
+ * @param options.srcPath absolute path to the source file
82
+ */
83
+ getSemanticTokens(options: {
84
+ srcPath: string;
85
+ }): Promise<import("../interfaces").SemanticToken[]>;
86
+ transpileFile(options: {
87
+ srcPath: string;
88
+ }): Promise<import("../Program").FileTranspileResult>;
89
+ getHover(options: {
90
+ srcPath: string;
91
+ position: Position;
92
+ }): Promise<Hover[]>;
93
+ getDefinition(options: {
94
+ srcPath: string;
95
+ position: Position;
96
+ }): Promise<Location[]>;
97
+ getSignatureHelp(options: {
98
+ srcPath: string;
99
+ position: Position;
100
+ }): Promise<SignatureInfoObj[]>;
101
+ getDocumentSymbol(options: {
102
+ srcPath: string;
103
+ }): Promise<DocumentSymbol[]>;
104
+ getWorkspaceSymbol(): Promise<WorkspaceSymbol[]>;
105
+ getReferences(options: {
106
+ srcPath: string;
107
+ position: Position;
108
+ }): Promise<Location[]>;
109
+ getCodeActions(options: {
110
+ srcPath: string;
111
+ range: Range;
112
+ }): Promise<import("vscode-languageserver-types").CodeAction[]>;
113
+ getCompletions(options: {
114
+ srcPath: string;
115
+ position: Position;
116
+ }): Promise<CompletionList>;
117
+ /**
118
+ * Manages the BrighterScript program. The main interface into the compiler/validator
119
+ */
120
+ private builder;
121
+ /**
122
+ * The path to where the project resides
123
+ */
124
+ projectPath: string;
125
+ /**
126
+ * A unique number for this project, generated during this current language server session. Mostly used so we can identify which project is doing logging
127
+ */
128
+ projectNumber: number;
129
+ /**
130
+ * A unique name for this project used in logs to help keep track of everything
131
+ */
132
+ projectIdentifier: string;
133
+ /**
134
+ * The path to the workspace where this project resides. A workspace can have multiple projects (by adding a bsconfig.json to each folder).
135
+ * Defaults to `.projectPath` if not set
136
+ */
137
+ workspaceFolder: string;
138
+ /**
139
+ * Path to a bsconfig.json file that will be used for this project
140
+ */
141
+ bsconfigPath?: string;
142
+ /**
143
+ * The contents of the bsconfig.json file. This is used to detect when the bsconfig file has not actually been changed (even if the fs says it did).
144
+ *
145
+ * Only available after `.activate()` has completed.
146
+ * @deprecated do not depend on this property. This will certainly be removed in a future release
147
+ */
148
+ bsconfigFileContents?: string;
149
+ /**
150
+ * Find the path to the bsconfig.json file for this project
151
+ * @returns path to bsconfig.json, or undefined if unable to find it
152
+ */
153
+ private getConfigFilePath;
154
+ on(eventName: 'validate-begin', handler: (data: any) => MaybePromise<void>): any;
155
+ on(eventName: 'validate-end', handler: (data: any) => MaybePromise<void>): any;
156
+ on(eventName: 'critical-failure', handler: (data: {
157
+ message: string;
158
+ }) => MaybePromise<void>): any;
159
+ on(eventName: 'diagnostics', handler: (data: {
160
+ diagnostics: LspDiagnostic[];
161
+ }) => MaybePromise<void>): any;
162
+ on(eventName: 'all', handler: (eventName: string, data: any) => MaybePromise<void>): any;
163
+ private emit;
164
+ private emitter;
165
+ disposables: LspProject['disposables'];
166
+ dispose(): void;
167
+ }