Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit bb78cd2

Browse files
nyrosmithjasonLaster
authored andcommitted
[Outline] clicking class selects source in editor (#5356)
1 parent c04fdf1 commit bb78cd2

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/components/PrimaryPanes/Outline.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
color: var(--blue-55);
4545
}
4646

47+
.outline-list h2:hover {
48+
background: var(--theme-toolbar-background-hover);
49+
}
50+
4751
.theme-dark .outline-list h2 {
4852
color: var(--theme-highlight-blue);
4953
}

src/components/PrimaryPanes/Outline.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ export class Outline extends Component<Props> {
6767

6868
const classFunc = functions.find(func => func.name === klass);
6969
const classFunctions = functions.filter(func => func.klass === klass);
70+
const classInfo = this.props.symbols.classes.find(c => c.name === klass);
7071

7172
const heading = classFunc ? (
7273
<h2>{this.renderFunction(classFunc)}</h2>
7374
) : (
74-
<h2>
75+
<h2
76+
onClick={classInfo ? () => this.selectItem(classInfo.location) : null}
77+
>
7578
<span className="keyword">class</span> {klass}
7679
</h2>
7780
);

src/workers/parser/getSymbols.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ import type { NodePath, Node, Location as BabelLocation } from "babel-traverse";
1616

1717
let symbolDeclarations = new Map();
1818

19+
export type ClassDeclaration = {|
20+
name: string,
21+
location: BabelLocation,
22+
parent?: ClassDeclaration
23+
|};
24+
1925
export type SymbolDeclaration = {|
2026
name: string,
2127
expression?: string,
@@ -33,6 +39,7 @@ export type FunctionDeclaration = SymbolDeclaration & {|
3339
|};
3440

3541
export type SymbolDeclarations = {
42+
classes: Array<ClassDeclaration>,
3643
functions: Array<SymbolDeclaration>,
3744
variables: Array<SymbolDeclaration>,
3845
memberExpressions: Array<SymbolDeclaration>,

0 commit comments

Comments
 (0)