Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const stat = await fs.lstat(fileName);
return {
isFile: stat.isFile(),
fileName
};
})
))
.filter(x => x.isFile)
.map(x => this._parseCodeModFile(x.fileName));
// user-workspace code mods
const wsFolders = await connectionService.connection().workspace.getWorkspaceFolders();
if (wsFolders) {
const codemodDir = connectionService.getSettings().codemodDir;
for (let folder of wsFolders) {
const folderUri = Uri.parse(folder.uri);
if (folderUri.scheme !== 'file') {
continue;
}
const dirName = path.join(folderUri.fsPath, codemodDir);
if (!(await fs.pathExists(dirName))) {
continue;
}
const names = await fs.readdir(dirName);
for (let n of names) {
const fn = path.join(dirName, n);
if ((await fs.stat(fn)).isFile) {
codeMods.push(this._parseCodeModFile(fn));
}
}
getFilePath(url: ResolvedUrl): Result {
if (!url.startsWith('file://')) {
return {successful: false, error: 'Not a local file:// url.'};
}
if (!this.canLoad(url)) {
return {
successful: false,
error: `Path is not inside root directory: ${JSON.stringify(this.root)}`
};
}
const path = Uri.parse(url).fsPath;
return {successful: true, value: path};
}
function uriToFile(uri: string): string {
return URI.parse(uri).fsPath;
}
function isValidURI(uri: string) {
try {
Uri.parse(uri);
return true;
} catch (e) {
return false;
}
}
async function loadLibrary(docUri: string) {
trace('loadLibrary for ' + docUri)
let uri = Uri.parse(docUri)
let promise: Thenable
let settings = await settingsCache.get(docUri)
let getGlobalPath = () => getGlobalPackageManagerPath(settings.packageManager)
if (uri.scheme === 'file') {
let file = uri.fsPath
let directory = path.dirname(file)
if (settings && settings.nodePath) {
promise = resolveModule('tslint', settings.nodePath, getGlobalPath())
} else {
promise = resolveModule('tslint', directory, getGlobalPath())
}
} else {
promise = resolveModule('tslint', process.cwd(), getGlobalPath())
}
function collectExpressionSuggestions(valueStart: number): Boolean {
if (valueStart >= 0 && offset < text.length && (text[offset] === '}' || text[offset] === '>')) {
const expressionEnd = offset - 1;
for (let i = expressionEnd; i >= valueStart; i--) {
if (text[i] === '{') {
const templateTag = componentUtil.tagFromFile(URI.parse(document.uri).fsPath, settings.isSfdxProject);
if (templateTag) {
const range = getReplaceRange(i + 1, offset);
tagProviders.forEach(provider => {
provider.collectExpressionValues(templateTag, value => {
result.items.push({
label: value,
kind: CompletionItemKind.Reference,
textEdit: TextEdit.replace(range, value + (text[offset] === '}' ? '' : '}')),
insertTextFormat: InsertTextFormat.PlainText,
});
});
});
return true;
}
}
}
constructor(
projectUri: string,
projectLoader: IProjectLoader,
instantiationService: IInstantiationService
) {
this._projectUri = projectUri;
this._projectName = path.basename(URI.parse(projectUri).fsPath);
this._projectLoader = projectLoader;
this._instantiationService = instantiationService;
this.reloadProject();
}
asUri(uri: PathLike | URI): URI {
if (URI.isUri(uri)) {
return uri;
}
uri = uri as string;
if (this.env.isWin()) {
uri = uri.replace(/\\/g, '/').replace(/^(\w):/i, m => {
return `/${m[0].toLowerCase()}%3A`;
});
}
return URI.parse(uri).with({ scheme: 'file' });
}
this._signature.indexOf('.') > -1
? this._signature.substring(0, this._signature.lastIndexOf('.'))
: this._signature;
if (logContext.getStaticVariablesClassMap().has(className)) {
frame.statics = logContext.getStaticVariablesClassMap().get(className)!;
} else {
logContext.getStaticVariablesClassMap().set(className, frame.statics);
}
logContext
.getFrames()
.push(
new StackFrame(
id,
this._frameName,
sourceUri
? new Source(basename(sourceUri), Uri.parse(sourceUri).fsPath)
: undefined,
undefined
)
);
return false;
}
}
private getcwd(uri: string): string {
let { path } = Uri.parse(uri)
let m = path.match(/\/\/\d+/)
if (!m) return
return path.slice(0, m.index)
}