Skip to content

Fix package.json search for JavaScript #2040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2023
Merged

Conversation

rudolf101
Copy link
Member

Description

When the plugin has been reinstalled with IDEA restart and project clean & experimental languages support enabled, the action called for the JS file works properly.

Fixes #1947

How to test

Manual tests

Follow this steps:

  • Install plugin
  • Reinstall plugin with IDEA restart
  • Clean project, make sure that utbot_settings.xml is deleted after deinstallation of previously installed plugin
  • Turn on experimental languages support
  • Find the examples in the folder `/utbot-js/samples' and try to run UTBot.

Self-check list

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@rudolf101 rudolf101 added lang-javascript Issue is related to JavaScript support comp-ide Issue is related to IDE support ctg-bug-fix PR is fixing a bug labels Mar 24, 2023
@rudolf101 rudolf101 requested a review from Markoutte March 24, 2023 13:04
@rudolf101 rudolf101 self-assigned this Mar 24, 2023
val matchingFiles: Array<File> = currDir.listFiles(
FilenameFilter { _, name ->
return@FilenameFilter name == "package.json"
}
) ?: throw IllegalStateException("Error occurred while scanning file system")
if (matchingFiles.isNotEmpty()) return parseConfig(matchingFiles.first())
currDir = currDir.parentFile
} while (currDir.path != projectPath)
} while (currDir.path.replace("\\", "/") != projectPath)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better way to handle this problem is to put projectPath into File object and compare files instead of strings. Try this:

        File file = new File("C:/Windows/Resources");
        File f = new File("C:\\Windows\\Resources");
        System.out.println(Objects.equals(file, f));

Or with newer API (Also, I show prev example with normalization only for example):

        Path file = Paths.get("C:/Windows/Resources/Themes/..").normalize();
        Path f = Paths.get("C:\\Windows\\Resources").normalize();
        System.out.println(Objects.equals(file, f));

@rudolf101 rudolf101 merged commit 80c0e68 into main Mar 27, 2023
@rudolf101 rudolf101 deleted the sergeyl/fix-package-json-search branch March 27, 2023 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-ide Issue is related to IDE support ctg-bug-fix PR is fixing a bug lang-javascript Issue is related to JavaScript support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS. NPE on action when Experimental languages support is enabled after plugin reinstallation
3 participants