Skip to content

Commit 3e036dc

Browse files
WangQianliangzfy0701
authored andcommitted
fix(code/frontend): should have no container (#33492)
1 parent 221f9e5 commit 3e036dc

File tree

3 files changed

+125
-2
lines changed

3 files changed

+125
-2
lines changed

x-pack/plugins/code/public/components/symbol_tree/__test__/__snapshots__/symbol_tree.test.tsx.snap

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,106 @@ exports[`render symbol tree correctly 1`] = `
471471
</div>
472472
</div>
473473
</div>
474+
<div
475+
className="euiSideNavItem euiSideNavItem--branch"
476+
>
477+
<div
478+
className="euiFlexGroup euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
479+
>
480+
<div
481+
className="sc-bwzfXH jYpsNE"
482+
>
483+
<div
484+
className="euiFlexItem euiFlexItem--flexGrow1"
485+
>
486+
<a
487+
className="code-link"
488+
href="/github.com/elastic/kibana/blob/master/packages/elastic-datemath/src/index.d.ts!L21:0?tab=structure"
489+
onClick={[Function]}
490+
>
491+
<div
492+
className="euiFlexGroup euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive code-structure-node"
493+
>
494+
<div
495+
className="euiToken euiToken--tokenTint04 euiToken--circle euiToken--small sc-htpNat hDSXcY"
496+
>
497+
<svg
498+
className="euiIcon euiIcon--medium"
499+
focusable="false"
500+
height="16"
501+
style={null}
502+
viewBox="0 0 16 16"
503+
width="16"
504+
xmlns="http://www.w3.org/2000/svg"
505+
>
506+
<path
507+
d="M6.649 4.667l1.326 4.7h.05l1.326-4.7h1.982l-2.134 6.666H6.801L4.667 4.667z"
508+
fillRule="evenodd"
509+
/>
510+
</svg>
511+
</div>
512+
<div
513+
className="euiText euiText--small"
514+
data-test-subj="codeStructureTreeNode-Unit"
515+
>
516+
Unit
517+
</div>
518+
</div>
519+
</a>
520+
</div>
521+
</div>
522+
</div>
523+
</div>
524+
<div
525+
className="euiSideNavItem euiSideNavItem--branch"
526+
>
527+
<div
528+
className="euiFlexGroup euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
529+
>
530+
<div
531+
className="sc-bwzfXH jYpsNE"
532+
>
533+
<div
534+
className="euiFlexItem euiFlexItem--flexGrow1"
535+
>
536+
<a
537+
className="code-link"
538+
href="/github.com/elastic/kibana/blob/master/packages/elastic-datemath/src/index.d.ts!L23:14?tab=structure"
539+
onClick={[Function]}
540+
>
541+
<div
542+
className="euiFlexGroup euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive code-structure-node"
543+
>
544+
<div
545+
className="euiToken euiToken--tokenTint07 euiToken--circle euiToken--small sc-htpNat hDSXcY"
546+
>
547+
<svg
548+
className="euiIcon euiIcon--medium"
549+
focusable="false"
550+
height="16"
551+
style={null}
552+
viewBox="0 0 16 16"
553+
width="16"
554+
xmlns="http://www.w3.org/2000/svg"
555+
>
556+
<path
557+
d="M9.414 3.757l2.829 2.829a2 2 0 0 1 0 2.828l-2.829 2.829a2 2 0 0 1-2.828 0L3.757 9.414a2 2 0 0 1 0-2.828l2.829-2.829a2 2 0 0 1 2.828 0zm-1.747 2.91a1 1 0 0 0-1 1v.666a1 1 0 0 0 1 1h.666a1 1 0 0 0 1-1v-.666a1 1 0 0 0-1-1h-.666z"
558+
fillRule="evenodd"
559+
/>
560+
</svg>
561+
</div>
562+
<div
563+
className="euiText euiText--small"
564+
data-test-subj="codeStructureTreeNode-datemath"
565+
>
566+
datemath
567+
</div>
568+
</div>
569+
</a>
570+
</div>
571+
</div>
572+
</div>
573+
</div>
474574
<div
475575
className="euiSideNavItem euiSideNavItem--branch euiSideNavItem--hasChildItems"
476576
>

x-pack/plugins/code/public/components/symbol_tree/__test__/props.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ export const props: { structureTree: SymbolWithMembers[] } = {
112112
},
113113
],
114114
},
115+
{
116+
name: 'Unit',
117+
kind: SymbolKind.Variable,
118+
location: {
119+
uri:
120+
'git://github.com/elastic/kibana/blob/master/packages/elastic-datemath/src/index.d.ts',
121+
range: { start: { line: 20, character: 0 }, end: { line: 20, character: 66 } },
122+
},
123+
path: 'Unit',
124+
},
125+
{
126+
name: 'datemath',
127+
kind: SymbolKind.Constant,
128+
location: {
129+
uri:
130+
'git://github.com/elastic/kibana/blob/master/packages/elastic-datemath/src/index.d.ts',
131+
range: { start: { line: 22, character: 14 }, end: { line: 47, character: 1 } },
132+
},
133+
path: 'datemath',
134+
},
115135
],
116136
},
117137
],

x-pack/plugins/code/public/reducers/symbol.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ const generateStructureTree: (symbols: SymbolInformation[]) => any = symbols =>
5858

5959
function findContainer(
6060
tree: SymbolWithMembers[],
61-
containerName: string
61+
containerName?: string
6262
): SymbolInformation | undefined {
63+
if (containerName === undefined) {
64+
return undefined;
65+
}
6366
const regex = new RegExp(`^${containerName}[<(]?.*[>)]?$`);
6467
const result = tree.find((s: SymbolInformation) => {
6568
return regex.test(s.name);
@@ -93,7 +96,7 @@ const generateStructureTree: (symbols: SymbolInformation[]) => any = symbols =>
9396
(sy: SymbolInformation) => sy.name === SPECIAL_SYMBOL_NAME
9497
);
9598
} else {
96-
container = findContainer(structureTree, s.containerName || '');
99+
container = findContainer(structureTree, s.containerName);
97100
}
98101
if (container) {
99102
if (!container.path) {

0 commit comments

Comments
 (0)