Binder now uses reportDuplicateSymbols from Program
This commit is contained in:
Родитель
f093f5c4f8
Коммит
f2da3d1f5a
|
@ -48,7 +48,7 @@ export interface TypeSymbol {
|
|||
}
|
||||
|
||||
export interface Binder {
|
||||
bindSourceFile(program: Program, sourceFile: ADLScriptNode): void;
|
||||
bindSourceFile(sourceFile: ADLScriptNode): void;
|
||||
bindNode(node: Node): void;
|
||||
}
|
||||
|
||||
|
@ -62,10 +62,7 @@ export interface BinderOptions {
|
|||
initialParentNode?: Node;
|
||||
}
|
||||
|
||||
export function createBinder(
|
||||
reportDuplicateSymbols: (symbolTable: SymbolTable) => void,
|
||||
options: BinderOptions = {}
|
||||
): Binder {
|
||||
export function createBinder(program: Program, options: BinderOptions = {}): Binder {
|
||||
let currentFile: ADLScriptNode;
|
||||
let parentNode: Node | undefined = options?.initialParentNode;
|
||||
let globalNamespace: NamespaceStatementNode;
|
||||
|
@ -79,7 +76,7 @@ export function createBinder(
|
|||
bindNode,
|
||||
};
|
||||
|
||||
function bindSourceFile(program: Program, sourceFile: ADLScriptNode) {
|
||||
function bindSourceFile(sourceFile: ADLScriptNode) {
|
||||
globalNamespace = program.globalNamespace;
|
||||
fileNamespace = globalNamespace;
|
||||
currentFile = sourceFile;
|
||||
|
@ -132,7 +129,7 @@ export function createBinder(
|
|||
visitChildren(node, bindNode);
|
||||
|
||||
if (node.kind !== SyntaxKind.NamespaceStatement) {
|
||||
reportDuplicateSymbols(node.locals!);
|
||||
program.reportDuplicateSymbols(node.locals!);
|
||||
}
|
||||
|
||||
scope = prevScope;
|
||||
|
|
|
@ -45,7 +45,7 @@ function addProperty(
|
|||
graftProperty.end = modelNode.end;
|
||||
|
||||
// Create a binder to wire up the grafted property
|
||||
const binder = createBinder((dupe) => {}, {
|
||||
const binder = createBinder(program, {
|
||||
initialParentNode: parentNode,
|
||||
});
|
||||
binder.bindNode(graftProperty);
|
||||
|
@ -176,7 +176,7 @@ export function addOperationResponseType(
|
|||
operation.node.returnType = graftUnion;
|
||||
|
||||
// Create a binder to wire up the grafted property
|
||||
const binder = createBinder((dupe) => {}, {
|
||||
const binder = createBinder(program, {
|
||||
initialParentNode: operation.node,
|
||||
});
|
||||
binder.bindNode(graftUnion);
|
||||
|
|
|
@ -90,7 +90,7 @@ export async function createProgram(
|
|||
};
|
||||
|
||||
let virtualFileCount = 0;
|
||||
const binder = createBinder(program.reportDuplicateSymbols);
|
||||
const binder = createBinder(program);
|
||||
|
||||
if (!options?.nostdlib) {
|
||||
await loadStandardLibrary(program);
|
||||
|
@ -252,7 +252,7 @@ export async function createProgram(
|
|||
|
||||
program.reportDiagnostics(sourceFile.parseDiagnostics);
|
||||
program.sourceFiles.push(sourceFile);
|
||||
binder.bindSourceFile(program, sourceFile);
|
||||
binder.bindSourceFile(sourceFile);
|
||||
await evalImports(sourceFile);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче