mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
move checking if a file contains a create table statement to utils (#20512)
This commit is contained in:
@@ -10,7 +10,6 @@ import * as utils from '../common/utils';
|
||||
import * as xmlFormat from 'xml-formatter';
|
||||
import * as os from 'os';
|
||||
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
|
||||
import * as mssql from 'mssql';
|
||||
|
||||
import { Uri, window } from 'vscode';
|
||||
import { EntryType, IDatabaseReferenceProjectEntry, IProjectEntry, ISqlProject, ItemType, SqlTargetPlatform } from 'sqldbproj';
|
||||
@@ -328,20 +327,10 @@ export class Project implements ISqlProject {
|
||||
const fileEntries: FileProjectEntry[] = [];
|
||||
for (let f of Array.from(filesSet.values())) {
|
||||
const typeEntry = entriesWithType.find(e => e.relativePath === f);
|
||||
let containsCreateTableStatement = false;
|
||||
|
||||
// read file to check if it has a "Create Table" statement
|
||||
const fullPath = path.join(utils.getPlatformSafeFileEntryPath(this.projectFolderPath), utils.getPlatformSafeFileEntryPath(f));
|
||||
|
||||
if (utils.getAzdataApi() && await utils.exists(fullPath)) {
|
||||
const dacFxService = await utils.getDacFxService() as mssql.IDacFxService;
|
||||
try {
|
||||
const result = await dacFxService.parseTSqlScript(fullPath, this.getProjectTargetVersion());
|
||||
containsCreateTableStatement = result.containsCreateTableStatement;
|
||||
} catch (e) {
|
||||
console.error(utils.getErrorMessage(e));
|
||||
}
|
||||
}
|
||||
const containsCreateTableStatement = await utils.fileContainsCreateTableStatement(fullPath, this.getProjectTargetVersion());
|
||||
|
||||
fileEntries.push(this.createFileProjectEntry(f, EntryType.File, typeEntry ? typeEntry.typeAttribute : undefined, containsCreateTableStatement));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user