-
Notifications
You must be signed in to change notification settings - Fork 874
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
Cleanup j2ee.persistence module #5444
Conversation
@pepness I just merged a larger cleanup PR which caused conflicts here. Should be hopefully easy to resolve - bad timing sorry about that. |
You mean replace if -> switch, not SE introduced in jvm14 ))
#5203 ALL CASES, OPENED
#5414 REJECTED, CLOSED
#5328 MOST CASES/ALL, OPENED
In most cases equal lambdas are more slowly
Changing interfaces are dangerous. But i think its a right way for thinking. PS Mixing a lot of different changes in single multicommit PR isnt a good idea. Ty. |
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/editor/ContextUtilities.java
Outdated
Show resolved
Hide resolved
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/editor/ContextUtilities.java
Outdated
Show resolved
Hide resolved
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/editor/DocumentContext.java
Outdated
Show resolved
Hide resolved
@@ -146,7 +146,7 @@ protected void query(CompletionResultSet resultSet, Document doc, int caretOffse | |||
if (anchorOffset > -1) { | |||
resultSet.setAnchorOffset(anchorOffset); | |||
} | |||
} catch (Exception e) { | |||
} catch (MissingResourceException | ParseException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also catch RuntimeException
...2ee.persistence/src/org/netbeans/modules/j2ee/persistence/editor/completion/PUCompletor.java
Outdated
Show resolved
Hide resolved
...2ee.persistence/src/org/netbeans/modules/j2ee/persistence/spi/jpql/support/JPAAttribute.java
Outdated
Show resolved
Hide resolved
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/unit/PUDataObject.java
Outdated
Show resolved
Hide resolved
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/EntityClosure.java
Outdated
Show resolved
Hide resolved
....persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/EntityClassesPanel.java
Outdated
Show resolved
Hide resolved
...j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/SelectedTables.java
Outdated
Show resolved
Hide resolved
@pepness thank you. In general looks good, but I left a few nitpicks inline. |
199970d
to
c00c34d
Compare
@pepness wait, where did the commits go. now its only 3. Was that intended? |
- Add a TODO comment - Fix some formatting
- Use Utilities.toURI method - Use NbBundle.getMessage instead of NbBundle.getBundle - Redundant if expressions and if statements - Remove unnecessary continue and return statements - Use Exception constructor when possible
- Remove unused imports
- Unnecessary boxing - Use diamond inference on declaration-initialization - Use generics
-Unnecessary unboxing
- Remove unused logger - Inefficient Collection.toArray - Use character literal with indexOf - Use String.isEmpty()
c00c34d
to
250fcf9
Compare
@mbien I was working on them. Fixed the suggestions that @matthiasblaesing suggest |
@pepness ah, all good. I was just reviewing it and suddenly most of it was gone :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me. Some comments inline for you to consider.
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/unit/PUDataObject.java
Show resolved
Hide resolved
...stence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/JavaPersistenceGenerator.java
Show resolved
Hide resolved
...e/src/org/netbeans/modules/j2ee/persistence/wizard/jpacontroller/JpaControllerGenerator.java
Outdated
Show resolved
Hide resolved
return metadata.getRoot().getEntity(); | ||
} | ||
}); | ||
entities = ecs.getEntityMappingsModel(false).runReadAction( (EntityMappingsMetadata metadata) -> metadata.getRoot().getEntity() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nitpick. Consider the one-action-per-line formatting when method chaining is used. Makes the lines shorter.
entities = ecs.getEntityMappingsModel(false)
.runReadAction( (EntityMappingsMetadata metadata) -> metadata.getRoot().getEntity() );
there are many comparable occurrences like this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it that way too. Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pepness there are some more invocations of this method in the same style which you converted to lambdas btw. You changed only the one occurrence so far if I see this correctly.
search for getEntityMappingsModel(false).
in
https://patch-diff.githubusercontent.com/raw/apache/netbeans/pull/5444.diff
just a general comment: Converting single char Strings into chars to use a different String method variant is also a stylistic change which has no runtime benefits anymore. Probably something we can skip over in future too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general: Lets get this in. Some nitpicks inline, but I don't think this need another round of reviews. Github somehow thought every file was touched between my reviews, which makes it ugly to follow up.
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/unit/PUDataObject.java
Outdated
Show resolved
Hide resolved
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/EntityClosure.java
Outdated
Show resolved
Hide resolved
Looks sane to me. Thank you. |
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/editor/JPAEditorUtil.java
Show resolved
Hide resolved
.../org/netbeans/modules/j2ee/persistence/editor/completion/db/DBCompletionContextResolver.java
Show resolved
Hide resolved
...tence/src/org/netbeans/modules/j2ee/persistence/editor/completion/db/DBMetaDataProvider.java
Show resolved
Hide resolved
...sistence/src/org/netbeans/modules/j2ee/persistence/entitygenerator/DbSchemaEntityMember.java
Show resolved
Hide resolved
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/provider/ProviderUtil.java
Show resolved
Hide resolved
...2ee.persistence/src/org/netbeans/modules/j2ee/persistence/spi/jpql/support/JPAAttribute.java
Show resolved
Hide resolved
...src/org/netbeans/modules/j2ee/persistence/wizard/PersistenceClientEntitySelectionVisual.java
Show resolved
Hide resolved
...2ee.persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/DBSchemaManager.java
Show resolved
Hide resolved
....persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/EntityClassesPanel.java
Show resolved
Hide resolved
...e/src/org/netbeans/modules/j2ee/persistence/wizard/jpacontroller/JpaControllerGenerator.java
Show resolved
Hide resolved
- Fix some formatting - Use try-with-resources - Use lambdas when possible. Manually check every lambda with the Inspector Tool - if-else and loops statements should use braces - Use URI.toURL() instead of new URL() - Use Utilities.toURI method - Use NbBundle.getMessage instead of NbBundle.getBundle - Remove redundant if expressions and if statements - Remove unnecessary continue and return statements - Use Exception constructor when possible - Remove imports from the same package - Remove unused imports - Add missing Override annotations - Unnecessary boxing or unboxing - Use diamond inference on declaration-initialization - Use generics - Use multi-catch - Use switch statement - Remove unused logger - Inefficient Collection.toArray - Use character literal with indexOf - Use String.isEmpty()
I did some cleaning to the
j2ee.persistence
module with theInspect & Transform
tool. I reviewed each suggestion of the inspection tool with special emphasis on lambdas and try-with-resources and made sure not to break something. After this I plan to improve the JPA support to 2.2 or hopefully 3.1.I did full builds and fix the errors that pop out.
NetBeans Testing:
j2ee.persistence