1 | import { tsUtils } from '@neo-one/ts-utils';
|
2 | import ts from 'typescript';
|
3 | import { compileForDiagnostics } from './compile';
|
4 | import { createContextForLanguageService } from './createContext';
|
5 |
|
6 | export const getSemanticDiagnostics = ({
|
7 | filePath,
|
8 | smartContractDir,
|
9 | languageService,
|
10 | }: {
|
11 | readonly filePath: string;
|
12 | readonly smartContractDir: string;
|
13 | readonly languageService: ts.LanguageService;
|
14 | }): ReadonlyArray<ts.Diagnostic> => {
|
15 | const context = createContextForLanguageService(languageService, smartContractDir);
|
16 | try {
|
17 | compileForDiagnostics({
|
18 | sourceFile: tsUtils.file.getSourceFileOrThrow(context.program, filePath),
|
19 | context,
|
20 | sourceMaps: {},
|
21 | });
|
22 | } catch {
|
23 |
|
24 | }
|
25 |
|
26 | return context.diagnostics;
|
27 | };
|