Skip to content

Commit

Permalink
simplified a simple process
Browse files Browse the repository at this point in the history
  • Loading branch information
muremwa committed Dec 2, 2020
1 parent 57cc8c7 commit 92fb3ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
7 changes: 5 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ function readAndDisplayUrls (projectPath) {

// create urlConfig children
const appUrlConfigs = appUrlPatterns.map((appUrlPattern) => {
const _appName = appUrlPattern.reverseName.split(':');
const appName = _appName.length === 2? _appName[1]: appUrlPattern.reverseName;

// url config arguments
const urlArgs = appUrlPattern.arguments.map((arg) => new provider.TreeItem(`${arg.name}=${arg.argType}`, provider.trees.ARGUMENT));
return new provider.TreeItem(appUrlPattern.reverseName, provider.trees.URL, urlArgs);
const urlArgs = appUrlPattern.arguments.map((arg) => new provider.TreeItem(`${arg.name}=${arg.argType}`, provider.trees.ARGUMENT, [], appName));
return new provider.TreeItem(appUrlPattern.reverseName, provider.trees.URL, urlArgs, null, appName);
});

// add app
Expand Down
16 changes: 4 additions & 12 deletions treeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TreeDataProvider {

class TreeItem extends vscode.TreeItem {

constructor (label, treeType, children) {
constructor (label, treeType, children, parent, simpleLabel) {
let collapsedTreeOrNot, labelToFeed, contextValue, tooltip;

if (treeType === trees.APP) {
Expand All @@ -46,23 +46,15 @@ class TreeItem extends vscode.TreeItem {
} else if (treeType === trees.URL) {
collapsedTreeOrNot = vscode.TreeItemCollapsibleState.Collapsed;
contextValue = 'urlName';
const _tempLabel = label.split(':');

if (_tempLabel.length === 1) {
labelToFeed = _tempLabel[0];
} else if (_tempLabel.length === 2) {
labelToFeed = _tempLabel[1];
} else {
labelToFeed = label;
};
tooltip = `url config named ${labelToFeed}`;
labelToFeed = simpleLabel;
tooltip = `URL config named ${labelToFeed}`;

} else if (treeType === trees.ARGUMENT) {
contextValue = 'args';
const _tempLabel = label.split('=');
const typeName = _tempLabel[1] === 'NULL'? 'Type undeclared': _tempLabel[1];
labelToFeed = `${_tempLabel[0]} <${typeName}>`;
tooltip = 'url config argument';
tooltip = `URL config argument for ${parent}`;
};


Expand Down

0 comments on commit 92fb3ba

Please sign in to comment.