-
Notifications
You must be signed in to change notification settings - Fork 93
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
Send notification to client when xml.catalogs contains an invalid path #757
Conversation
I would like to avoid doing that because it's a catalog feature, so it should be managed in the catalog extension (see XMLCatalogPlugin which manages is able to return the proper catalog.xsd from urn:oasis:names:tc:entity:xmlns:xml:catalog namespace). I mean if there are some validation to do, it should be done in |
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/XMLTextDocumentService.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/client/PathWarnings.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/XMLTextDocumentService.java
Outdated
Show resolved
Hide resolved
I made an update to this PR with these changes:
In order to do 2., I've implemented a way to access Please let me know if I'm (or not) on the right track with this PR. What this PR is missing:
|
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/client/AbstractXMLNotification.java
Outdated
Show resolved
Hide resolved
import org.eclipse.lemminx.settings.SharedSettings; | ||
import org.eclipse.lsp4j.Command; | ||
|
||
public class PathWarnings extends AbstractXMLNotification { |
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.
It might make more sense to name this class PathWarner
, change cache
to a Set
, and store settingId
as a attribute that is set in the constructor. Then you can make a different PathWarner
for each setting you want to watch. I think this makes sense in this context, since the only time this class is being used, it is only tracking one setting.
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 think it would make more sense to call this class AbstractXMLNotifier, since this generates a notification, but doesn't represent one itself.
It might make more sense to name this class PathWarner
I like this idea. This means LimitExceededWarnings
should change to LimitExceededWarner
too. I will change this soon.
change cache to a Set, and store settingId as a attribute that is set in the constructor.
I realized that for LimitExceededWarnings
, the cache is being shared for all features: https://github.com/eclipse/lemminx/blob/c9fa0cc44faa55c80c5d06a5824039be948eec3c/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/client/LimitExceededWarnings.java#L53
Right now, we only have one, so its not a problem. In my latest push for this PR, I separated the cache for each feature using a map (key is the feature, value is a Set), but perhaps its a bit messy.
If we want one feature = one instance, we must remove this method signature: https://github.com/eclipse/lemminx/blob/c9fa0cc44faa55c80c5d06a5824039be948eec3c/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/client/LimitExceededWarnings.java#L53
and provide the feature in the constructor as you said.
I quickly made a branch (branched off from the branch for this current PR) that implements that change: https://github.com/xorye/lsp4xml/tree/217catalogs_path_cleaner_cache
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.
@xorye I thing your design is very good now. The validation is processed in plugin + AbstractXMLNotification manages cache.
what is the problem with public void onResultLimitExceeded(String uri, LimitFeature feature)
signature?
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.
@angelozerr If we follow this suggestion:
It might make more sense to name this class PathWarner, change cache to a Set, and store settingId as a attribute that is set in the constructor.
Changing the cache type for PathWarnings
would change the cache type for LimitExceededWarnings
too. The cache would only store info for one feature, since the cache would be a Set<String>
instead of Map<String, Set<String>>
.
Therefore, it would make LimitExceededWarnings
work only for one feature, which would change this method signature:
onResultLimitExceeded(String uri, LimitFeature feature)
to
onResultLimitExceeded(String uri)
So, there's no problem with onResultLimitExceeded(String uri, LimitFeature feature)
right now in this PR, its just that if the suggestion is followed, it does not make sense to provide feature
in onResultLimitExceeded(String uri, LimitFeature feature)
This PR has been updated with changes from #794. In the gif above, the first entry is an existing file. The others are not. |
You should use error messages |
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/IXMLNotificationService.java
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/IXMLNotificationService.java
Show resolved
Hide resolved
...pse.lemminx/src/main/java/org/eclipse/lemminx/services/extensions/XMLExtensionsRegistry.java
Show resolved
Hide resolved
...pse.lemminx/src/main/java/org/eclipse/lemminx/services/extensions/XMLExtensionsRegistry.java
Show resolved
Hide resolved
org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/services/AbstractNotifierTest.java
Show resolved
Hide resolved
org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/services/AbstractNotifierTest.java
Show resolved
Hide resolved
org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/services/InvalidPathWarningsTest.java
Outdated
Show resolved
Hide resolved
I have added a Everything has been squashed to one commit. |
Signed-off-by: David Kwon <dakwon@redhat.com>
Great job @xorye ! |
For redhat-developer/vscode-xml#217
My plan is to check for invalid paths from
XMLTextDocumentService
, and send a notification to the client if an invalid path exists here:https://github.com/eclipse/lemminx/blob/977a96757b1f9cd472b81394e4cfd2dd866867b5/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/XMLTextDocumentService.java#L424-L429
The reason why I have this in
XMLTextDocumentService
is that it is easy detect incorrect paths and send notifications here, because there is easy access toXMLLanguageServer#languageClient
.The problem with this approach is that path validation happens twice, once in the code above and once here:
https://github.com/eclipse/lemminx/blob/84d268957060b53aee211bd75a34b4536e9dab1e/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/XMLCatalogResolverExtension.java#L102-L131
Would this be ok?
Signed-off-by: David Kwon dakwon@redhat.com