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

Commit 2b34694

Browse files
Łukasz SobekjasonLaster
authored andcommitted
Removes .get - Part 1 (#5788)
1 parent 5689d80 commit 2b34694

File tree

22 files changed

+62
-75
lines changed

22 files changed

+62
-75
lines changed

docs/dbg.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The actions are bound so you can call them directly!
1919

2020
```js
2121
const source = dbg.store.getState().sources.sources.first();
22-
dbg.actions.selectSource(source.get("id")))
22+
dbg.actions.selectSource(source.id))
2323
```
2424

2525
### selectors
@@ -39,7 +39,7 @@ The commands are the interface for talking to the debugger server.
3939
```js
4040
const source = dbg.selectors.getSelectedSource();
4141
dbg.client
42-
.setBreakpoint({line: 24, sourceId: source.get("id")})
42+
.setBreakpoint({line: 24, sourceId: source.id})
4343
.then(console.log)
4444
```
4545

src/actions/file-search.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Match = Object;
2626
export function doSearch(query: string, editor: Editor) {
2727
return ({ getState, dispatch }: ThunkArgs) => {
2828
const selectedSource = getSelectedSource(getState());
29-
if (!selectedSource || !selectedSource.get("text")) {
29+
if (!selectedSource || !selectedSource.text) {
3030
return;
3131
}
3232

@@ -75,19 +75,15 @@ export function searchContents(query: string, editor: Object) {
7575
!query ||
7676
!editor ||
7777
!selectedSource ||
78-
!selectedSource.get("text") ||
78+
!selectedSource.text ||
7979
!modifiers
8080
) {
8181
return;
8282
}
8383

8484
const ctx = { ed: editor, cm: editor.codeMirror };
8585
const _modifiers = modifiers.toJS();
86-
const matches = await getMatches(
87-
query,
88-
selectedSource.get("text"),
89-
_modifiers
90-
);
86+
const matches = await getMatches(query, selectedSource.text, _modifiers);
9187

9288
const res = find(ctx, query, true, _modifiers);
9389
if (!res) {

src/actions/pause/mapScopes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export function mapScopes(scopes: Promise<Scope>, frame: Frame) {
5252

5353
const shouldMapScopes =
5454
features.mapScopes &&
55-
!generatedSourceRecord.get("isWasm") &&
56-
!sourceRecord.get("isPrettyPrinted") &&
55+
!generatedSourceRecord.isWasm &&
56+
!sourceRecord.isPrettyPrinted &&
5757
!isGeneratedId(frame.location.sourceId);
5858

5959
await dispatch({

src/actions/project-text-search.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ export function searchSources(query: string) {
5151
.valueSeq()
5252
.filter(
5353
source =>
54-
!hasPrettySource(getState(), source.get("id")) &&
55-
!isThirdParty(source)
54+
!hasPrettySource(getState(), source.id) && !isThirdParty(source)
5655
);
5756
for (const source of validSources) {
5857
await dispatch(loadSourceText(source));
59-
await dispatch(searchSource(source.get("id"), query));
58+
await dispatch(searchSource(source.id, query));
6059
}
6160
dispatch(updateSearchStatus(statusType.done));
6261
};

src/actions/sources/prettyPrint.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import type { ThunkArgs } from "../types";
2626
export function createPrettySource(sourceId: string) {
2727
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
2828
const source = getSource(getState(), sourceId);
29-
const url = getPrettySourceURL(source.get("url"));
29+
const url = getPrettySourceURL(source.url);
3030
const id = await sourceMaps.generatedToOriginalId(sourceId, url);
3131

3232
const prettySource = {
@@ -39,7 +39,7 @@ export function createPrettySource(sourceId: string) {
3939
dispatch({ type: "ADD_SOURCE", source: prettySource });
4040

4141
const { code, mappings } = await prettyPrint({ source, url });
42-
await sourceMaps.applySourceMap(source.get("id"), url, code, mappings);
42+
await sourceMaps.applySourceMap(source.id, url, code, mappings);
4343

4444
const loadedPrettySource = {
4545
...prettySource,
@@ -84,7 +84,7 @@ export function togglePrettyPrint(sourceId: string) {
8484
);
8585

8686
const selectedLocation = getSelectedLocation(getState());
87-
const url = getPrettySourceURL(source.get("url"));
87+
const url = getPrettySourceURL(source.url);
8888
const prettySource = getSourceByURL(getState(), url);
8989

9090
const options = {};

src/actions/sources/select.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function selectSourceURL(
5656
return async ({ dispatch, getState }: ThunkArgs) => {
5757
const source = getSourceByURL(getState(), url);
5858
if (source) {
59-
const sourceId = source.get("id");
59+
const sourceId = source.id;
6060
const location = createLocation({ ...options.location, sourceId });
6161
// flow is unable to comprehend that if an options.location object
6262
// exists, that we have a valid Location object, and if it doesnt,
@@ -131,7 +131,7 @@ export function selectLocation(location: Location) {
131131
isMinified(selectedSource)
132132
) {
133133
await dispatch(togglePrettyPrint(sourceId));
134-
dispatch(closeTab(source.get("url")));
134+
dispatch(closeTab(source.url));
135135
}
136136

137137
dispatch(setSymbols(sourceId));

src/actions/sources/tests/loadSource.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ describe("loadSourceText", async () => {
1515
await dispatch(actions.loadSourceText(I.Map({ id: "foo1" })));
1616
const fooSource = selectors.getSource(getState(), "foo1");
1717

18-
expect(fooSource.get("text").indexOf("return foo1")).not.toBe(-1);
18+
expect(fooSource.text.indexOf("return foo1")).not.toBe(-1);
1919

2020
await dispatch(actions.loadSourceText(I.Map({ id: "foo2" })));
2121
const foo2Source = selectors.getSource(getState(), "foo2");
2222

23-
expect(foo2Source.get("text").indexOf("return foo2")).not.toBe(-1);
23+
expect(foo2Source.text.indexOf("return foo2")).not.toBe(-1);
2424
});
2525

2626
it("loads two sources w/ one request", async () => {
@@ -47,7 +47,7 @@ describe("loadSourceText", async () => {
4747
resolve({ source: "yay", contentType: "text/javascript" });
4848
await loading;
4949
expect(count).toEqual(1);
50-
expect(selectors.getSource(getState(), id).get("text")).toEqual("yay");
50+
expect(selectors.getSource(getState(), id).text).toEqual("yay");
5151
});
5252

5353
it("doesn't re-load loaded sources", async () => {
@@ -72,7 +72,7 @@ describe("loadSourceText", async () => {
7272
source = selectors.getSource(getState(), id);
7373
await dispatch(actions.loadSourceText(source));
7474
expect(count).toEqual(1);
75-
expect(selectors.getSource(getState(), id).get("text")).toEqual("yay");
75+
expect(selectors.getSource(getState(), id).text).toEqual("yay");
7676
});
7777

7878
it("should cache subsequent source text loads", async () => {

src/actions/sources/tests/select.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("sources", () => {
4040
expect(selectedSource.get("id")).toEqual("foo1");
4141

4242
const source = getSource(getState(), selectedSource.get("id"));
43-
expect(source.get("id")).toEqual("foo1");
43+
expect(source.id).toEqual("foo1");
4444

4545
await waitForState(
4646
store,
@@ -58,7 +58,7 @@ describe("sources", () => {
5858

5959
expect(getSelectedSource(getState())).toBe(undefined);
6060
await dispatch(actions.newSource(baseSource));
61-
expect(getSelectedSource(getState()).get("url")).toBe(baseSource.url);
61+
expect(getSelectedSource(getState()).url).toBe(baseSource.url);
6262
});
6363

6464
it("should open a tab for the source", async () => {

src/components/Editor/EditorMenu.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function getMenuItems(
7070
const blackboxKey = L10N.getStr("sourceFooter.blackbox.accesskey");
7171
const blackboxLabel = L10N.getStr("sourceFooter.blackbox");
7272
const unblackboxLabel = L10N.getStr("sourceFooter.unblackbox");
73-
const toggleBlackBoxLabel = selectedSource.get("isBlackBoxed")
73+
const toggleBlackBoxLabel = selectedSource.isBlackBoxed
7474
? unblackboxLabel
7575
: blackboxLabel;
7676
const copyFunctionKey = L10N.getStr("copyFunction.accesskey");
@@ -101,7 +101,7 @@ function getMenuItems(
101101
label: copyToClipboardLabel,
102102
accesskey: copyToClipboardKey,
103103
disabled: false,
104-
click: () => copyToTheClipboard(selectedSource.get("text"))
104+
click: () => copyToTheClipboard(selectedSource.text)
105105
};
106106

107107
const copySourceItem = {
@@ -117,7 +117,7 @@ function getMenuItems(
117117
label: copySourceUri2Label,
118118
accesskey: copySourceUri2Key,
119119
disabled: false,
120-
click: () => copyToTheClipboard(getRawSourceURL(selectedSource.get("url")))
120+
click: () => copyToTheClipboard(getRawSourceURL(selectedSource.url))
121121
};
122122

123123
const sourceId = selectedSource.get("id");

src/components/Editor/Footer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class SourceFooter extends PureComponent<Props> {
7474
return;
7575
}
7676

77-
const blackboxed = selectedSource.get("isBlackBoxed");
77+
const blackboxed = selectedSource.isBlackBoxed;
7878

7979
const tooltip = L10N.getStr("sourceFooter.blackbox");
8080
const type = "black-box";
@@ -98,7 +98,7 @@ class SourceFooter extends PureComponent<Props> {
9898
blackBoxSummary() {
9999
const { selectedSource } = this.props;
100100

101-
if (!selectedSource || !selectedSource.get("isBlackBoxed")) {
101+
if (!selectedSource || !selectedSource.isBlackBoxed) {
102102
return;
103103
}
104104

0 commit comments

Comments
 (0)