Skip to content

Commit

Permalink
feat(language-service): diagnostic messages for external files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrius-pra committed Jun 6, 2019
1 parent 4dc7851 commit c39a977
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false

[*.sh]
end_of_line = lf
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
# API guardian patch must always use LF for tests to work
*.patch eol=lf

# sh files must always use LF
*.sh eol=lf

# Must keep Windows line ending to be parsed correctly
scripts/windows/packages.txt eol=crlf
10 changes: 5 additions & 5 deletions packages/language-service/src/ts_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const projectHostMap = new WeakMap<tss.server.Project, TypeScriptServiceHost>();

export function getExternalFiles(project: tss.server.Project): string[]|undefined {
const host = projectHostMap.get(project);
if (host) {
const rootFiles = (project as any).getRootFilesMap();

if (host && rootFiles && Array.from(rootFiles).length) {
const externalFiles = host.getTemplateReferences();
return externalFiles;
}
Expand Down Expand Up @@ -51,7 +53,7 @@ function diagnosticMessageToDiagnosticMessageText(message: string | DiagnosticMe
return diagnosticChainToDiagnosticChain(message);
}

function diagnosticToDiagnostic(d: Diagnostic, file: ts.SourceFile): ts.Diagnostic {
function diagnosticToDiagnostic(d: Diagnostic, file: ts.SourceFile | undefined): ts.Diagnostic {
const result = {
file,
start: d.span.start,
Expand Down Expand Up @@ -147,9 +149,7 @@ export function create(info: tss.server.PluginCreateInfo): ts.LanguageService {
const ours = ls.getDiagnostics(fileName);
if (ours && ours.length) {
const file = oldLS.getProgram() !.getSourceFile(fileName);
if (file) {
base.push.apply(base, ours.map(d => diagnosticToDiagnostic(d, file)));
}
base.push.apply(base, ours.map(d => diagnosticToDiagnostic(d, file)));
}
});

Expand Down

0 comments on commit c39a977

Please sign in to comment.