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

Commit

Permalink
Make SourceRecord fields Read-Only (#5703)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnshulMalik authored and jasonLaster committed Mar 21, 2018
1 parent c05f410 commit 8df97cc
Show file tree
Hide file tree
Showing 26 changed files with 46 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/actions/sources/loadSourceText.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isLoaded } from "../../utils/source";

import defer from "../../utils/defer";
import type { ThunkArgs } from "../types";
import type { SourceRecord } from "../../reducers/types";
import type { SourceRecord } from "../../types";

const requests = new Map();
import { Services } from "devtools-modules";
Expand Down
3 changes: 2 additions & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
getOrientation
} from "../selectors";

import type { SourceRecord, OrientationType } from "../reducers/types";
import type { OrientationType } from "../reducers/types";
import type { SourceRecord } from "../types";

import { KeyShortcuts, Services } from "devtools-modules";
const shortcuts = new KeyShortcuts({ window });
Expand Down
3 changes: 2 additions & 1 deletion src/components/Editor/Breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { getSelectedSource, getVisibleBreakpoints } from "../../selectors";
import { makeLocationId } from "../../utils/breakpoint";
import { isLoaded } from "../../utils/source";

import type { SourceRecord, BreakpointsMap } from "../../reducers/types";
import type { BreakpointsMap } from "../../reducers/types";
import type { SourceRecord } from "../../types";

type Props = {
selectedSource: SourceRecord,
Expand Down
3 changes: 1 addition & 2 deletions src/components/Editor/DebugLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
getSelectedSource
} from "../../selectors";

import type { Frame, Why } from "../../types";
import type { SourceRecord } from "../../reducers/types";
import type { Frame, Why, SourceRecord } from "../../types";

type Props = {
selectedFrame: Frame,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/EmptyLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { connect } from "react-redux";
import { Component } from "react";
import { getSelectedSource, getEmptyLines } from "../../selectors";
import type { SourceRecord } from "../../reducers/types";
import type { SourceRecord } from "../../types";
import { toEditorLine } from "../../utils/editor";

import "./EmptyLines.css";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { shouldShowFooter, shouldShowPrettyPrint } from "../../utils/editor";

import PaneToggleButton from "../shared/Button/PaneToggle";

import type { SourceRecord } from "../../reducers/sources";
import type { SourceRecord } from "../../types";

import "./Footer.css";

Expand Down
3 changes: 1 addition & 2 deletions src/components/Editor/HighlightLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
getSelectedSource
} from "../../selectors";

import type { SourceRecord } from "../../reducers/types";
import type { Frame, Location } from "../../types";
import type { Frame, Location, SourceRecord } from "../../types";

type Props = {
selectedFrame: Frame,
Expand Down
4 changes: 3 additions & 1 deletion src/components/Editor/Preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import {
import actions from "../../../actions";
import { toEditorRange } from "../../../utils/editor";

import type { SelectedLocation, SourceRecord } from "../../../reducers/types";
import type { SelectedLocation } from "../../../reducers/types";
import type { SourceRecord } from "../../../types";

import type { Preview as PreviewType } from "../../../reducers/ast";

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { removeOverlay } from "../../utils/editor";
import { scrollList } from "../../utils/result-list";
import classnames from "classnames";

import type { SourceRecord } from "../../reducers/sources";
import type { SourceRecord } from "../../types";
import type { ActiveSearchType } from "../../reducers/ui";
import type { Modifiers, SearchResults } from "../../reducers/file-search";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { showMenu, buildMenu } from "devtools-contextmenu";
import CloseButton from "../shared/Button/Close";

import type { List } from "immutable";
import type { SourceRecord } from "../../reducers/sources";
import type { SourceRecord } from "../../types";
import type { SourceMetaDataType } from "../../reducers/ast";

import actions from "../../actions";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import PaneToggleButton from "../shared/Button/PaneToggle";
import Dropdown from "../shared/Dropdown";

import type { List } from "immutable";
import type { SourceRecord } from "../../reducers/sources";
import type { SourceRecord } from "../../types";

type SourcesList = List<SourceRecord>;

Expand Down
2 changes: 1 addition & 1 deletion src/components/PrimaryPanes/Outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
SymbolDeclaration,
AstLocation
} from "../../workers/parser";
import type { SourceRecord } from "../../reducers/sources";
import type { SourceRecord } from "../../types";

type Props = {
symbols: SymbolDeclarations,
Expand Down
3 changes: 2 additions & 1 deletion src/components/PrimaryPanes/SourcesTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import { getRawSourceURL } from "../../utils/source";
import { copyToTheClipboard } from "../../utils/clipboard";
import { features } from "../../utils/prefs";

import type { SourcesMap, SourceRecord } from "../../reducers/types";
import type { SourcesMap } from "../../reducers/types";
import type { SourceRecord } from "../../types";

type Props = {
selectLocation: Object => void,
Expand Down
3 changes: 1 addition & 2 deletions src/components/QuickOpenModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import type {
QuickOpenResult
} from "../utils/quick-open";

import type { Location } from "../types";
import type { SourceRecord } from "../reducers/sources";
import type { Location, SourceRecord } from "../types";
import type { QuickOpenType } from "../reducers/quick-open";

import "./QuickOpenModal.css";
Expand Down
3 changes: 2 additions & 1 deletion src/components/SecondaryPanes/CommandBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import "./CommandBar.css";
import { Services } from "devtools-modules";
const { appinfo } = Services;

import type { SourceRecord, SourcesMap } from "../../reducers/sources";
import type { SourcesMap } from "../../reducers/sources";
import type { SourceRecord } from "../../types";

const isMacOS = appinfo.OS === "Darwin";

Expand Down
3 changes: 1 addition & 2 deletions src/reducers/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import { originalToGeneratedId, isOriginalId } from "devtools-source-map";
import { prefs } from "../utils/prefs";

import type { Map, List } from "immutable";
import type { Source, Location } from "../types";
import type { Source, Location, SourceRecord } from "../types";
import type { SelectedLocation, PendingSelectedLocation } from "./types";
import type { Action } from "../actions/types";
import type { Record } from "../utils/makeRecord";

type Tab = string;
export type SourceRecord = Record<Source>;
export type SourcesMap = Map<string, SourceRecord>;
type TabList = List<Tab>;

Expand Down
2 changes: 1 addition & 1 deletion src/reducers/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type PendingSelectedLocation = {
column?: number
};

export type { SourceRecord, SourcesMap } from "./sources";
export type { SourcesMap } from "./sources";
export type { ActiveSearchType, OrientationType } from "./ui";
export type { BreakpointsMap } from "./breakpoints";
export type { WorkersList } from "./debuggee";
25 changes: 15 additions & 10 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

// @flow

import { RecordOf } from "immutable";

export type SearchModifiers = {
caseSensitive: boolean,
wholeWord: boolean,
Expand Down Expand Up @@ -262,17 +264,20 @@ export type Grip = {
* @memberof types
* @static
*/

export type SourceRecord = RecordOf<Source>;

export type Source = {
id: SourceId,
url: string,
sourceMapURL?: string,
isBlackBoxed: boolean,
isPrettyPrinted: boolean,
isWasm: boolean,
text?: string,
contentType?: string,
error?: string,
loadedState: "unloaded" | "loading" | "loaded"
+id: SourceId,
+url: string,
+sourceMapURL?: string,
+isBlackBoxed: boolean,
+isPrettyPrinted: boolean,
+isWasm: boolean,
+text?: string,
+contentType?: string,
+error?: string,
+loadedState: "unloaded" | "loading" | "loaded"
};

/**
Expand Down
3 changes: 1 addition & 2 deletions src/utils/editor/source-documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import { getMode } from "../source";

import type { Source } from "../../types";
import type { Source, SourceRecord } from "../../types";
import { isWasm, getWasmLineNumberFormatter, renderWasmText } from "../wasm";
import { resizeBreakpointGutter, resizeToggleButton } from "../ui";
import type { SymbolDeclarations } from "../../workers/parser";
import type { SourceRecord } from "../../reducers/types";
import SourceEditor from "./source-editor";

let sourceDocs = {};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/isMinified.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// @flow

import type { SourceRecord } from "../reducers/types";
import type { SourceRecord } from "../types";

// Used to detect minification for automatic pretty printing
const SAMPLE_SIZE = 50;
Expand Down
3 changes: 1 addition & 2 deletions src/utils/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { basename } from "./path";
import { parse as parseURL } from "url";
export { isMinified } from "./isMinified";

import type { Source } from "../types";
import type { SourceRecord } from "../reducers/types";
import type { Source, SourceRecord } from "../types";
import type { SymbolDeclarations } from "../workers/parser/types";

type transformUrlCallback = string => string;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sources-tree/addToTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { getURL } from "./getURL";

import type { ParsedURL } from "./getURL";
import type { Node } from "./types";
import type { SourceRecord } from "../../reducers/types";
import type { SourceRecord } from "../../types";

function isUnderRoot(url, projectRoot) {
if (!projectRoot) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sources-tree/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// @flow

import type { SourceRecord } from "../../reducers/types";
import type { SourceRecord } from "../../types";

/**
* TODO: createNode is exported so this type could be useful to other modules
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sources-tree/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { parse } from "url";

import type { Node } from "./types";
import type { SourceRecord } from "../../reducers/types";
import type { SourceRecord } from "../../types";
import { isPretty } from "../source";
const IGNORED_URLS = ["debugger eval code", "XStringBundle"];

Expand Down
2 changes: 1 addition & 1 deletion src/utils/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from "react";

import type { List } from "immutable";
import type { SourceRecord } from "../reducers/sources";
import type { SourceRecord } from "../types";
import type { SourceMetaDataType } from "../reducers/ast";
import { isPretty } from "./source";

Expand Down
2 changes: 1 addition & 1 deletion src/workers/pretty-print/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { WorkerDispatcher } = workerUtils;
import { isJavaScript } from "../../utils/source";
import assert from "../../utils/assert";

import type { SourceRecord } from "../../reducers/types";
import type { SourceRecord } from "../../types";

const dispatcher = new WorkerDispatcher();
export const startPrettyPrintWorker = dispatcher.start.bind(dispatcher);
Expand Down

0 comments on commit 8df97cc

Please sign in to comment.