Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafaeweda committed Apr 17, 2018
2 parents c30f58e + e33e9df commit 709287d
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 33 deletions.
19 changes: 10 additions & 9 deletions flow-libs/nuclide.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ type nuclide$TerminalCommand = {
type TerminalInfoUntrustedFields = {
title?: string,
key?: string,
remainOnCleanExit: boolean,
defaultLocation: string,
icon: string,
remainOnCleanExit?: boolean,
defaultLocation?: atom$PaneLocation | 'pane',
icon?: string,
trustToken?: string,
};

Expand All @@ -44,13 +44,14 @@ type TerminalInfoTrustedFields = {
declare type nuclide$TerminalInfo = TerminalInfoUntrustedFields &
TerminalInfoTrustedFields;

declare interface nuclide$TerminalInstance {
setProcessExitCallback(callback: () => mixed): void;
terminateProcess(): void;
}

declare interface nuclide$TerminalApi {
uriFromCwd(cwd: ?string): string;
uriFromInfo(info: nuclide$TerminalInfo): string;
infoFromUri(
paneUri: string,
uriFromTrustedSource?: boolean,
): nuclide$TerminalInfo;
open(info: nuclide$TerminalInfo): Promise<nuclide$TerminalInstance>;
close(key: string): void;
}

declare interface nuclide$RpcService {
Expand Down
19 changes: 2 additions & 17 deletions modules/atom-ide-ui/pkg/atom-ide-debugger/lib/vsp/DebugService.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ import * as DebugProtocol from 'vscode-debugprotocol';
import * as React from 'react';

import invariant from 'assert';
import {destroyItemWhere} from 'nuclide-commons-atom/destroyItemWhere';
import {goToLocation} from 'nuclide-commons-atom/go-to-location';
import {Icon} from 'nuclide-commons-ui/Icon';
import nuclideUri from 'nuclide-commons/nuclideUri';
import {splitStream} from 'nuclide-commons/observable';
Expand Down Expand Up @@ -1307,19 +1305,7 @@ export default class DebugService implements IDebugService {
// Ensure any previous instances of this same target are closed before
// opening a new terminal tab. We don't want them to pile up if the
// user keeps running the same app over and over.
destroyItemWhere(item => {
if (item.getURI == null || item.getURI() == null) {
return false;
}

const uri = nullthrows(item.getURI());
try {
// Only close terminal tabs with the same title and target binary.
const otherInfo = terminalService.infoFromUri(uri);
return otherInfo.key === key;
} catch (e) {}
return false;
});
terminalService.close(key);

const title =
args.title != null ? args.title : getDebuggerName(adapterType);
Expand Down Expand Up @@ -1351,8 +1337,7 @@ export default class DebugService implements IDebugService {
icon: 'nuclicon-debugger',
defaultLocation: 'bottom',
};
// TODO(pelmers): flow-type this?
const terminal: any = await goToLocation(terminalService.uriFromInfo(info));
const terminal = await terminalService.open(info);
terminal.setProcessExitCallback(() => {
// This callback is invoked if the target process dies first, ensuring
// we tear down the debugger.
Expand Down
44 changes: 44 additions & 0 deletions modules/nuclide-commons-atom/getElementFilePath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/

import type {NuclideUri} from 'nuclide-commons/nuclideUri';

import {isValidTextEditor} from './text-editor';

export default function getElementFilePath(
element: ?HTMLElement,
fallbackToActiveTextEditor: boolean = false,
): ?NuclideUri {
let el = element;
while (el != null) {
if (el.dataset != null && el.dataset.path != null) {
return (el.dataset: any).path;
}
if (typeof el.getModel === 'function') {
const model = el.getModel();
if (isValidTextEditor(model)) {
const path = ((model: any): atom$TextEditor).getPath();
if (path != null) {
return path;
}
}
}
el = el.parentElement;
}
if (fallbackToActiveTextEditor) {
const editor = atom.workspace.getActiveTextEditor();
if (editor != null && isValidTextEditor(editor)) {
return editor.getPath();
}
}
return null;
}
9 changes: 9 additions & 0 deletions modules/nuclide-commons-atom/go-to-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import type {Observable} from 'rxjs';

import {getLogger} from 'log4js';
import {Subject} from 'rxjs';
import invariant from 'assert';
import idx from 'idx';
Expand Down Expand Up @@ -95,6 +96,14 @@ export async function goToLocation(
activateItem,
pending,
});
// TODO(T28305560) Investigate offenders for this error
if (editor == null) {
const tmp = {};
Error.captureStackTrace(tmp);
const error = Error(`atom.workspace.open returned null on ${file}`);
getLogger('goToLocation').error(error);
throw error;
}

if (center && line != null) {
editor.scrollToBufferPosition([line, column], {center: true});
Expand Down
2 changes: 1 addition & 1 deletion modules/nuclide-commons-ui/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Props = {
/** Icon name, without the `icon-` prefix. E.g. `'arrow-up'` */
icon?: IconName,
/** Optional specifier for special buttons, e.g. primary, info, success or error buttons. */
buttonType?: ButtonType,
buttonType?: ?ButtonType,
selected?: boolean,
/** */
size?: ButtonSize,
Expand Down
10 changes: 7 additions & 3 deletions modules/nuclide-debugger-common/debugger-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

import nuclideUri from 'nuclide-commons/nuclideUri';
import fs from 'fs';

import type {VSAdapterExecutableInfo, VsAdapterType} from './types';

Expand All @@ -22,13 +23,16 @@ type AdapterInfo = {
const modulesPath = nuclideUri.dirname(__dirname);

function resolvePackagePath(packageName: string): string {
if (typeof atom !== 'undefined') {
const bundledPath = nuclideUri.join(modulesPath, packageName);
if (fs.existsSync(bundledPath)) {
return bundledPath;
} else if (typeof atom !== 'undefined') {
const pkg = atom.packages.getActivePackage(packageName);
if (pkg != null) {
return pkg.path;
return nuclideUri.join(pkg.path, 'node_modules', packageName);
}
}
return nuclideUri.join(modulesPath, packageName);
return 'DEBUGGER_RUNTIME_NOT_FOUND';
}

const _adapters: Map<VsAdapterType, AdapterInfo> = new Map([
Expand Down
1 change: 0 additions & 1 deletion modules/nuclide-node-transpiler/bin/release-transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function runParent() {
const jsFiles = pathRules.getIncludedFiles(directory);

// Sanity checks
assert(jsFiles.length > 0);
jsFiles.forEach(filename => {
assert(path.isAbsolute(filename));
});
Expand Down
3 changes: 1 addition & 2 deletions modules/nuclide-node-transpiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@
"dedent": "0.6.0",
"jasmine-node": "1.14.5",
"yargs": "3.32.0"
},
"private": true
}
}

0 comments on commit 709287d

Please sign in to comment.