Skip to content

support single file debug#7

Open
ansyral wants to merge 4 commits intovscjavaci:masterfrom
ansyral:singlefiledebug
Open

support single file debug#7
ansyral wants to merge 4 commits intovscjavaci:masterfrom
ansyral:singlefiledebug

Conversation

@ansyral
Copy link
Copy Markdown
Collaborator

@ansyral ansyral commented Aug 8, 2017

Signed-off-by: xuzho xuzho@microsoft.com

Signed-off-by: xuzho <xuzho@microsoft.com>
Comment thread src/extension.ts Outdated
config.sourcePath = [cur];
config.cwd = cur;
config.stopOnEntry = true;
await runJavaC(fullpath, cur).then(function () {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use lambda ()=>

Comment thread src/javaServerStarter.ts Outdated
declare let v8debug;
const DEBUG = (typeof v8debug === 'object') || startedInDebugMode();
let electron = require('./electron_j');
let cp = require('child_process');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const cp

Comment thread src/javaServerStarter.ts Outdated
resolve();
}
else {
reject(code);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tested the multiple reject scenario

Copy link
Copy Markdown
Collaborator Author

@ansyral ansyral Aug 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reject handler would send the error to vscode panel, rethink about it, i think it is ok to reject in both of the two event handlers as only on would hit

Comment thread src/extension.ts
const fullpath = editor.document.fileName;
const cur = path.parse(fullpath).dir;
config.startupClass = path.parse(fullpath).base.slice(0, -5);
config.sourcePath = [cur];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the single file defines the package name, and the config.sourcePath option you give will also contain the package path. Not sure if the DebugAdapter can infer the right file path when the breakpoint occurs. Did you test this case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we only support default package for single file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for single file debug, the file is linked to default project under src/[package]. so if we support non-default package, we also need to support user to change package name, i don't think we can do that as we cannot create working copy for .project file

Signed-off-by: xuzho <xuzho@microsoft.com>
Comment thread src/javaServerStarter.ts Outdated
});
// rethrow to disrupt the chain.
throw error;
}).then(requirements => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For convention, then should before catch.

Comment thread src/javaServerStarter.ts Outdated
throw error;
}).then(requirements => {
return new Promise(function(resolve, reject) {
let child = path.resolve(requirements.java_home + '/bin/javac');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using path join

Comment thread src/extension.ts Outdated
import { workspace, ExtensionContext, window, StatusBarAlignment, commands, ViewColumn, Uri, CancellationToken, TextDocumentContentProvider, TextEditor, WorkspaceConfiguration, languages, IndentAction, ProgressLocation, Progress } from 'vscode';
import { LanguageClient, LanguageClientOptions, Position as LSPosition, Location as LSLocation } from 'vscode-languageclient';
import { runServer, awaitServerConnection } from './javaServerStarter';
import { runServer, awaitServerConnection, runJavaC } from './javaServerStarter';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javac is a common execution file. doesn't need upper case the the C

Comment thread src/extension.ts Outdated
if (editor && editor.document.languageId === 'java') {
const fullpath = editor.document.fileName;
const cur = path.parse(fullpath).dir;
config.startupClass = path.parse(fullpath).base.slice(0, -5);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user path.basename(path[, ext]) to get base name of xxx.java.
https://nodejs.org/api/path.html#path_path_basename_path_ext

Comment thread src/extension.ts Outdated
const editor = vscode.window.activeTextEditor;
if (editor && editor.document.languageId === 'java') {
const fullpath = editor.document.fileName;
const cur = path.parse(fullpath).dir;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use path.dirname(path) to get dir name.
https://nodejs.org/api/path.html#path_path_dirname_path

Signed-off-by: xuzho <xuzho@microsoft.com>
ansyral pushed a commit to ansyral/vscode-java that referenced this pull request Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants