Skip to content
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

#25: implement tool commandlet for intellij #297

Open
wants to merge 55 commits into
base: main
Choose a base branch
from

Conversation

ndemirca
Copy link
Contributor

@ndemirca ndemirca commented Apr 17, 2024

Closes #25

@ndemirca ndemirca marked this pull request as draft April 17, 2024 09:41
@ndemirca ndemirca marked this pull request as ready for review April 17, 2024 11:46
@ndemirca ndemirca marked this pull request as draft April 17, 2024 14:38
Copy link
Contributor

@salimbouch salimbouch left a comment

Choose a reason for hiding this comment

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

Looks great to me 👍

@coveralls
Copy link
Collaborator

coveralls commented Apr 23, 2024

Pull Request Test Coverage Report for Build 9497637949

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 19 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.7%) to 60.535%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/intellij/Intellij.java 4 85.71%
com/devonfw/tools/ide/io/FileAccessImpl.java 15 56.19%
Totals Coverage Status
Change from base Build 9496980488: 0.7%
Covered Lines: 4750
Relevant Lines: 7558

💛 - Coveralls

@ndemirca ndemirca marked this pull request as ready for review April 23, 2024 11:55
@ndemirca ndemirca marked this pull request as draft April 23, 2024 15:51
Copy link
Contributor

@salimbouch salimbouch left a comment

Choose a reason for hiding this comment

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

Looks great to me 👍

@hohwille hohwille changed the title Feature/25 implement tool commandlet for intellij #25: implement tool commandlet for intellij May 6, 2024
@ndemirca ndemirca marked this pull request as draft May 7, 2024 08:26
@ndemirca ndemirca marked this pull request as ready for review May 8, 2024 12:27
@ndemirca ndemirca requested a review from hohwille May 17, 2024 08:47
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@ndemirca Thanks for your improvements and all the great work in this PR. 👍
However, we still have some last mile to go to complete this story.
See my review comments for details.

@@ -6,3 +6,6 @@
*.tar binary
*.bz2 binary
*.gz binary

# special handling for test files
cli/src/test/resources/ide-projects/intellij/repository/intellij/intellij/default/windows/bin/studio64.exe text
Copy link
Member

Choose a reason for hiding this comment

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

is this full path really required? Assuming we do some small refactoring and the path changes nobody will remember to also fix this path here?

Suggested change
cli/src/test/resources/ide-projects/intellij/repository/intellij/intellij/default/windows/bin/studio64.exe text
studio64.exe text

} else if (this.context.getSystemInfo().isLinux()) {
return toolBinPath.resolve(IDEA_BASH_SCRIPT).toString();
} else {
return getToolPath().resolve("IntelliJ IDEA CE.app").resolve("Contents").resolve("MacOS").resolve(IDEA).toString();
Copy link
Member

@hohwille hohwille Jun 13, 2024

Choose a reason for hiding this comment

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

IMHO this is still wrong as we discussed in our meeting.
I already merged the PR #359 and resolved the conflicts into this PR.
If we did everything correct there is no such thing anymore than IntelliJ IDEA CA.app inside the software folder.
Also please be aware the different editions of intelliJ will have a different *.app name so your code would never work with the ultimate edition used by many projects (CE stands for Community Edition).
I hope it was already clarified meanwhile why we need the generic MacOS workaround and avoid such ugly OS-switches here and handling of MacOS apps in individual commandlets.
Ideally like in devonfw-ide after installation we can just call idea on any plattform to launch IntelliJ.
This PR therefore still needs some reworking...

Comment on lines +73 to +75
if (this.context.getSystemInfo().isMac()) {
setMacOsFilePermissions(getToolPath().resolve("IntelliJ IDEA CE.app").resolve("Contents").resolve("MacOS").resolve(IDEA));
}
Copy link
Member

Choose a reason for hiding this comment

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

same here...


if (Files.exists(binaryFile)) {
String permissionStr = FileAccessImpl.generatePermissionString(493);
Copy link
Member

Choose a reason for hiding this comment

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

Seems I missed to discuss on this API.
IMHO this is very bad design:

  • numeric file permissions must always be given in octal notation or nobody can understand what 493 actually is. If you write it octal as 0755 at least some bash/unix experienced user will understand what this.
  • We should avoid direct usage of FileAccessImpl in commandlets. That is why we have FileAccess interface.
  • Why do we provide a method in FileAccessImpl that converts a number to a String and then we again convert the String to a Set of PosixFilePermissions in order to then natively set this via Files.setPosixFilePermissions? The idea of FileAccess is to create a higher level API and abstraction to such lower-level Java NIO operations and make our live easier. So if we believe that using numeric (octal) notation is the most readable way why dont we create a method in FileAccess to set file permissions to a given file with a given numeric value? However, it may be even simpler and more readable to simply define constants for the combinations that we need like this:
/** {@link PosixFilePermission}s for "rwxr-xr-x" or 0755. */
public static Set<PosixFilePermission> RWX_RX_RX = Set.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_EXECUTE);
  • My real suggestion would rather be to add a method FileAccess.makeExecutable(Path) that will simply implement what chmod a+x «path» will do and could also be implemented to work on Windows (see also here).

Comment on lines +87 to +88
} finally {
return;
Copy link
Member

Choose a reason for hiding this comment

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

This does not seem to add any value and is IMHO only causing confusion.

Suggested change
} finally {
return;

@Override
public void installPlugin(PluginDescriptor plugin) {

Copy link
Member

Choose a reason for hiding this comment

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

This is not implemented so this PR does not entirely close #25. If you do something like this on purpose, then create a new issue for IntelliJ plugin support and leave a comment here like TODO https://github.com/devonfw/IDEasy/issues/«id». Otherwise we still end up in the same situation that we have currently that some comandlets seem to be present but are incomplete and if we have no issue about the problem, we might forget about it and currently merging this PR would automatically close #25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Implement ToolCommandlet for Intellij
5 participants