-
Notifications
You must be signed in to change notification settings - Fork 31
Don't re-trigger Java validation for all opened Java files when a Java file is saved. #546
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,4 +100,5 @@ public interface IConfigSource { | |
| */ | ||
| Set<String> getAllKeys(); | ||
|
|
||
| void reset(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,12 +189,33 @@ public boolean visit(IResourceDelta delta) throws CoreException { | |
| mpProject.getProjectRuntime().clearProjectClassCache(); | ||
| } | ||
| fireAsyncEvent(event); | ||
| } else if (isConfigSource(file) && isFileContentChanged(delta)) { | ||
| MicroProfilePropertiesChangeEvent event = new MicroProfilePropertiesChangeEvent(); | ||
| event.setType(MicroProfilePropertiesScope.ONLY_CONFIG_FILES); | ||
| event.setProjectURIs(new HashSet<String>()); | ||
| event.getProjectURIs().add(JDTMicroProfileUtils.getProjectURI(file.getProject())); | ||
| fireAsyncEvent(event); | ||
| } else if (isConfigSource(file)) { | ||
| // Create, delete, update config source file (ex : | ||
| // microprofile-config.properties) | ||
|
|
||
| JDTMicroProfileProject mpProject = JDTMicroProfileProjectManager.getInstance() | ||
| .getJDTMicroProfileProject(file); | ||
|
|
||
| boolean generateEvent = false; | ||
| if (isFileDeleted(delta) || isFileAdded(delta)) { | ||
| generateEvent = true; | ||
| // Create, delete config source file (ex : microprofile-config.properties) | ||
| if (mpProject != null) { | ||
| // Evict the properties cache | ||
| mpProject.evictConfigSourcesCache(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The evict cache of config source is done now only when a config file is created/deleted which is required to rebuild the config files scope. |
||
| } | ||
| } else if (isFileContentChanged(delta)) { | ||
| // Update config source file (ex : microprofile-config.properties) | ||
| generateEvent = mpProject != null ? mpProject.updateConfigSource(file) : true; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This case comes from when:
The mpProject.updateConfigSource(file) returns true only when src/main/resources/application.properties is updated When application.properties is updated (only for sources), we don't evict the full cache of config sources but just reset the IConfigSource |
||
| } | ||
|
|
||
| if (generateEvent) { | ||
| MicroProfilePropertiesChangeEvent event = new MicroProfilePropertiesChangeEvent(); | ||
| event.setType(MicroProfilePropertiesScope.ONLY_CONFIG_FILES); | ||
| event.setProjectURIs(new HashSet<String>()); | ||
| event.getProjectURIs().add(JDTMicroProfileUtils.getProjectURI(file.getProject())); | ||
| fireAsyncEvent(event); | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
|
|
@@ -277,6 +298,14 @@ private boolean isConfigSource(IFile file) { | |
| return JDTMicroProfileProjectManager.getInstance().isConfigSource(file); | ||
| } | ||
|
|
||
| private boolean isFileDeleted(IResourceDelta delta) { | ||
| return delta.getKind() == IResourceDelta.REMOVED; | ||
| } | ||
|
|
||
| private boolean isFileAdded(IResourceDelta delta) { | ||
| return delta.getKind() == IResourceDelta.ADDED; | ||
| } | ||
|
|
||
| private boolean isFileContentChanged(IResourceDelta delta) { | ||
| return (delta.getKind() == IResourceDelta.CHANGED && (delta.getFlags() & IResourceDelta.CONTENT) != 0); | ||
| } | ||
|
|
||
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.
This code was super annoying because it evicted the config source cache as soon as an application.properties was updated (in other words when a Java file was saved because target/classes/application.properties was updated) or when src/main/resources/application.properties was updated.