Skip to content

Commit 6ebe6a2

Browse files
committed
fix: fix setup option return alias
1 parent eea0065 commit 6ebe6a2

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/analyze/options.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,26 @@ export function analyze(
171171
traverse(returnNode, {
172172
ObjectProperty(path3) {
173173
if(path3.parent === returnNode) {
174-
if(path3.node.key.type === 'Identifier') {
174+
if(path3.node.key.type === 'Identifier' && path3.node.value.type === 'Identifier') {
175+
const valName = path3.node.value.name;
176+
if(!graph.nodes.has(valName)) {
177+
graph.nodes.add(valName);
178+
nodeCollection.addTypedNode(
179+
valName,
180+
tempNodeCollection.nodes.get(valName)!
181+
);
182+
}
183+
if(!graph.edges.has(valName)) {
184+
graph.edges.set(valName, new Set([...Array.from(
185+
tempEdges.get(valName) || new Set<string>()
186+
)]));
187+
}
188+
175189
const name = path3.node.key.name;
176-
const valName = path3.node.value.type === 'Identifier' ? path3.node.value.name : '';
177-
if(valName && tempNodes.has(valName)) {
190+
if(name !== valName) {
178191
graph.nodes.add(name);
179-
nodeCollection.addTypedNode(name, tempNodeCollection.nodes.get(valName)!);
180-
if(!graph.edges.get(name)) {
181-
graph.edges.set(name, new Set());
182-
tempEdges.get(valName)?.forEach((edge) => {
183-
graph.edges.get(name)?.add(edge);
184-
});
185-
}
192+
nodeCollection.addNode(name, path3.node.key);
193+
graph.edges.set(name, new Set([valName]));
186194
}
187195
}
188196
}

test/options-setup/TestComponent.graph.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ const number: TypedNode = {label: 'number', type: NodeType.var, info: {line: 65,
66
const count: TypedNode = {label: 'count', type: NodeType.var, info: {line: 67, column: 10}};
77
const plus: TypedNode = {label: 'plus', type: NodeType.fun, info: {line: 70, column: 6}};
88
const add: TypedNode = {label: 'add', type: NodeType.fun, info: {line: 74, column: 6}};
9+
const a: TypedNode = {label: 'a', type: NodeType.var, info: {line: 83, column: 6}};
910

1011
edges.set(number, new Set([]));
1112
edges.set(count, new Set([]));
1213
edges.set(plus, new Set([plus]));
13-
edges.set(add, new Set([number, add]));
14+
edges.set(add, new Set([number, add, count]));
15+
edges.set(a, new Set([count]));
1416

1517
export const graph = {
16-
nodes: new Set([number, count, plus, add]),
18+
nodes: new Set([number, count, plus, add, a]),
1719
edges,
1820
};

test/options-setup/TestComponent.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@ export default {
7575
add() {
7676
counterStore.add(Number(data.number));
7777
methods.add();
78+
console.log(count)
7879
}
7980
}
8081
8182
return {
8283
...toRefs(data),
83-
count,
84+
a: count,
8485
...methods,
8586
}
8687
}

0 commit comments

Comments
 (0)