@angular/language-server 22.1.2 → 22.1.4
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.
- package/index.js +59 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -310402,7 +310402,18 @@ var require_session = __commonJS({
|
|
|
310402
310402
|
false
|
|
310403
310403
|
);
|
|
310404
310404
|
if (!project || project.projectKind !== ts.server.ProjectKind.Configured) {
|
|
310405
|
-
|
|
310405
|
+
let { configFileName } = this.projectService.openClientFile(scriptInfo.fileName);
|
|
310406
|
+
if (configFileName === void 0 && isExternalTemplate(scriptInfo.fileName)) {
|
|
310407
|
+
if (this.loadProjectForExternalTemplate(scriptInfo.fileName)) {
|
|
310408
|
+
({ configFileName } = this.projectService.openClientFile(scriptInfo.fileName));
|
|
310409
|
+
}
|
|
310410
|
+
if (configFileName === void 0) {
|
|
310411
|
+
const componentProject = this.attachToComponentProject(scriptInfo);
|
|
310412
|
+
if (componentProject) {
|
|
310413
|
+
return componentProject;
|
|
310414
|
+
}
|
|
310415
|
+
}
|
|
310416
|
+
}
|
|
310406
310417
|
if (!configFileName) {
|
|
310407
310418
|
this.error(`No config file for ${scriptInfo.fileName}`);
|
|
310408
310419
|
return null;
|
|
@@ -310416,6 +310427,43 @@ var require_session = __commonJS({
|
|
|
310416
310427
|
}
|
|
310417
310428
|
return project;
|
|
310418
310429
|
}
|
|
310430
|
+
/**
|
|
310431
|
+
* In a composite/solution-style project with references, TypeScript will _not_ open a project
|
|
310432
|
+
* for an HTML file unless the file is explicitly included in the files/includes list. This is
|
|
310433
|
+
* quite unlikely to be the case for HTML files. As a best-effort to fix this, we attempt to open
|
|
310434
|
+
* a TS file with the same name so that its project is loaded. Most of the time, this is going to
|
|
310435
|
+
* be the component file for the external template.
|
|
310436
|
+
* https://github.com/angular/vscode-ng-language-service/issues/2149
|
|
310437
|
+
*
|
|
310438
|
+
* Returns whether the component file was opened, i.e. whether the config lookup for the template
|
|
310439
|
+
* is worth retrying.
|
|
310440
|
+
*/
|
|
310441
|
+
loadProjectForExternalTemplate(templatePath) {
|
|
310442
|
+
const maybeComponentTsPath = componentPathForTemplate(templatePath);
|
|
310443
|
+
if (this.projectService.openFiles.has(this.projectService.toPath(maybeComponentTsPath)) || // Non-component HTML files (e.g. `src/index.html`) have no sibling `.ts`; skip the
|
|
310444
|
+
// open/close so we don't walk directory trees looking for a config that can't exist.
|
|
310445
|
+
!this.host.fileExists(maybeComponentTsPath)) {
|
|
310446
|
+
return false;
|
|
310447
|
+
}
|
|
310448
|
+
this.projectService.openClientFile(maybeComponentTsPath);
|
|
310449
|
+
this.projectService.closeClientFile(maybeComponentTsPath);
|
|
310450
|
+
return true;
|
|
310451
|
+
}
|
|
310452
|
+
/**
|
|
310453
|
+
* Attaches an external template to the configured project of its component. Needed because
|
|
310454
|
+
* `openClientFile` does not repeat the config lookup for a file that is already open, so it can
|
|
310455
|
+
* still report no config file even though the component's project has since been loaded.
|
|
310456
|
+
*/
|
|
310457
|
+
attachToComponentProject(scriptInfo) {
|
|
310458
|
+
var _a3;
|
|
310459
|
+
const componentProject = (_a3 = this.projectService.getScriptInfo(componentPathForTemplate(scriptInfo.fileName))) === null || _a3 === void 0 ? void 0 : _a3.containingProjects.find(utils_1.isConfiguredProject);
|
|
310460
|
+
if (!componentProject) {
|
|
310461
|
+
return null;
|
|
310462
|
+
}
|
|
310463
|
+
scriptInfo.detachAllProjects();
|
|
310464
|
+
scriptInfo.attachToProject(componentProject);
|
|
310465
|
+
return componentProject;
|
|
310466
|
+
}
|
|
310419
310467
|
onDidOpenTextDocument(params) {
|
|
310420
310468
|
var _a3;
|
|
310421
310469
|
const { uri, languageId, text } = params.textDocument;
|
|
@@ -310428,12 +310476,15 @@ var require_session = __commonJS({
|
|
|
310428
310476
|
try {
|
|
310429
310477
|
let result = this.projectService.openClientFile(filePath, text, scriptKind);
|
|
310430
310478
|
if (result.configFileName === void 0 && languageId === LanguageId.HTML) {
|
|
310431
|
-
|
|
310432
|
-
if (!this.projectService.openFiles.has(this.projectService.toPath(maybeComponentTsPath))) {
|
|
310433
|
-
this.projectService.openClientFile(maybeComponentTsPath);
|
|
310434
|
-
this.projectService.closeClientFile(maybeComponentTsPath);
|
|
310479
|
+
if (this.loadProjectForExternalTemplate(filePath)) {
|
|
310435
310480
|
result = this.projectService.openClientFile(filePath, text, scriptKind);
|
|
310436
310481
|
}
|
|
310482
|
+
if (result.configFileName === void 0) {
|
|
310483
|
+
const scriptInfo = this.projectService.getScriptInfo(filePath);
|
|
310484
|
+
if (scriptInfo) {
|
|
310485
|
+
this.attachToComponentProject(scriptInfo);
|
|
310486
|
+
}
|
|
310487
|
+
}
|
|
310437
310488
|
}
|
|
310438
310489
|
const { configFileName, configFileErrors } = result;
|
|
310439
310490
|
if (configFileErrors && configFileErrors.length) {
|
|
@@ -310602,6 +310653,9 @@ var require_session = __commonJS({
|
|
|
310602
310653
|
function isExternalTemplate(path) {
|
|
310603
310654
|
return !isTypeScriptFile(path);
|
|
310604
310655
|
}
|
|
310656
|
+
function componentPathForTemplate(templatePath) {
|
|
310657
|
+
return templatePath.replace(/\.html$/, ".ts");
|
|
310658
|
+
}
|
|
310605
310659
|
}
|
|
310606
310660
|
});
|
|
310607
310661
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/language-server",
|
|
3
3
|
"description": "LSP server for Angular Language Service",
|
|
4
|
-
"version": "22.1.
|
|
4
|
+
"version": "22.1.4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/angular/angular.git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"ngserver": "./bin/ngserver"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@angular/language-service": "22.1.
|
|
20
|
+
"@angular/language-service": "22.1.4",
|
|
21
21
|
"typescript": "6.0.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|