Skip to content

Validate mainClass and projectName configs - #205

Merged
Jinbo Wang (testforstephen) merged 13 commits into
masterfrom
jinbo_validate
Aug 28, 2018
Merged

Jinbo Wang (testforstephen) merged 13 commits into
masterfrom
jinbo_validate

Conversation

@testforstephen

@testforstephen Jinbo Wang (testforstephen) commented Aug 15, 2018 •

Copy link
Copy Markdown
Contributor

Signed-off-by: Jinbo Wang jinbwan@microsoft.com

The requirement is from issue microsoft/vscode-java-debug#355

Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>

public class ResolveMainClassHandler {
private static final Logger logger = Logger.getLogger(Configuration.LOGGER_NAME);
private static final String CLASSNAME_REGX = "([$\\w]+\\.)*[$\\w]+";

@andxu Andy Xu(devdiv) (andxu) Aug 17, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a better way is to validate the main Class in js side, the java side only exposure ways of querying java projects and main classes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't want to separate the validation logic to two parts, that's hard for reading. JS side is responsible for UI related logic, and JAVA side is for computing the result.

} else if (UPDATE_DEBUG_SETTINGS.equals(commandId)) {
return DebugSettingUtils.configDebugSettings(arguments);
} else if (VALIDATE_LAUNCHCONFIG.equals(commandId)) {
return new ResolveMainClassHandler().validateLaunchConfig(arguments);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about make class ResolveMainClassHandler a utility class(with a changed name) and not new ResolveMainClassHandler every time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i guess the original habit is inherited from jdt.ls handler implementation. If we just refactor this one, it will be a little weird, because ResolveClasspathsHandler has similar issue. So i prefer to keep the current convention.

List<ResolutionItem> proposals = resolveMainClassCore(arguments);

Collections.sort(proposals, new ProposalItemComparator((ResolutionItem item) -> {
if (item.mainClass.equals(mainClass)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Objects.equals

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice suggestions.

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.

2 participants