Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Bajdzis committed Feb 26, 2021
1 parent b4637a1 commit 0d439e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
26 changes: 2 additions & 24 deletions src/store/dependencies/files/files.ts
Expand Up @@ -90,13 +90,6 @@ export class Files {
const contents = fs.readdirSync(parentDir)
.filter(siblingFile => fs.lstatSync(path.join(parentDir, siblingFile)).isFile() && siblingFile !== fileToSkip);

// .map(siblingFile => {
// const filePath = path.join(parentDir, siblingFile);
// const infoAboutFilePath = getInfoAboutPath(getRelativePath(filePath));
// const lines = splitStringWithSplitter(fs.readFileSync(filePath).toString(), '\n{} ,()');
// return lines.map(line => createVariableTemplate(line, [infoAboutFilePath]));
// });

if (contents.length < 2) {
return '';
}
Expand All @@ -105,7 +98,7 @@ export class Files {
const filePath = path.join(parentDir, siblingFile);
const fileUri = vscode.Uri.file(filePath);
const infoAboutFilePath = getInfoAboutPath(getRelativePath(filePath));
console.log( {fileUri} );

return getFileSymbols(fileUri).then(data => createTemplateInTree([data], [infoAboutFilePath])[0]);
});

Expand All @@ -114,22 +107,7 @@ export class Files {
.then(data => filterTree(data, 0.75))
.then(data => treeSymbolToFlattArray(data));



console.log({ files, filesContent });

const content = joinSymbolToString(filesContent, [infoAboutNewFile]);


// const [baseFile, ...otherFiles] = contents;
// const linesToGenerate: string[] = baseFile
// .filter((line) => this.allFilesIncludeThisLine(otherFiles, line));

// const content = linesToGenerate.map(line =>
// renderVariableTemplate(line, [infoAboutNewFile])
// ).join('');

return content;
return joinSymbolToString(filesContent, [infoAboutNewFile]);
}

createFileContent(templateStringPath:string, directories: DirectoriesInfo, variables: PathInfo[]): string {
Expand Down
4 changes: 2 additions & 2 deletions src/symbolInformation/compareTree.ts
Expand Up @@ -20,7 +20,7 @@ function haveSameValue (elem1:FileSymbol, elem2:FileSymbol) {
if(elem1.children.length > 0 && elem2.children.length > 0) {
return true;
}
return compareVariableTemplate(elem1.value, elem2.value);
return elem1.value === elem2.value || compareVariableTemplate(elem1.text, elem2.text);
}

// function haveSameFirstChildren (elem1:FileSymbol, elem2:FileSymbol) {
Expand Down Expand Up @@ -110,7 +110,7 @@ export function createTemplateInTree(trees: FileSymbol[], infoAboutFile: PathInf

return trees.map(tree => ({
...tree,
value: createVariableTemplate(tree.value, infoAboutFile),
text: createVariableTemplate(tree.text, infoAboutFile),
children: createTemplateInTree(tree.children, infoAboutFile)
}));
}

0 comments on commit 0d439e7

Please sign in to comment.