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

Suppress validation kinds based on file pattern #1290

Merged
merged 1 commit into from
Sep 12, 2022

Conversation

angelozerr
Copy link
Contributor

Suppress validation kinds based on file pattern

Fixes #1275

Signed-off-by: azerr [email protected]

@angelozerr
Copy link
Contributor Author

angelozerr commented Sep 2, 2022

It starts working. If you add in your settings.json

"xml.validation.filters": [
      {
         "pattern": "**.exsd",
         "enabled": false
      },
      {
         "pattern": "**{.project,.classpath,plugin.xml,feature.xml}",
         "noGrammar": "ignore"
      }
   ]

But if you don't set this settings (not validation filter settings), LemMinx will use internally this default settings.

It should disable validation for exsd files, and disable the noGrammar hint for plugin.xml, .classpath, .project files.

I have not managed severity for error code because we don't need it for the moment.

The main idea that I implemented is that you can define all validation settings (xml.validation.enabled, xml.validation.noGrammar, etc) see https://github.com/redhat-developer/vscode-xml/blob/main/docs/Validation.md that we have for a given pattern.

For instance by default we have:

xml.validation.noGrammar : "hint" which display an information on root tag element which says that there are no grammar. It is a global validation settings.

For plugin.xml we don't want this "hint", so you can write a filter like this:

{
    "pattern": "plugin.xml",
    "noGrammar": "ignore"
 },

Here the result:

image

No I need to define this settings by default on LemMinX side

}

private static XMLValidationFilter[] createDefaultFilters() {
List<XMLValidationFilter> filters = new ArrayList<>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@merks here the default validation filter that LemMinX will use by default. Do you see another filter which should be done for other files?

@angelozerr angelozerr force-pushed the validation-filter2 branch 2 times, most recently from fbac28c to c7657a7 Compare September 12, 2022 07:23
@merks
Copy link

merks commented Sep 12, 2022

Thanks for asking. With PDE there are also *.product files (root element ) for defining products, *.target files (root element ) for defining target platforms, and category.xml (root element ) for defining update sites.

@angelozerr angelozerr marked this pull request as ready for review September 12, 2022 07:25
@angelozerr angelozerr force-pushed the validation-filter2 branch 2 times, most recently from 17cc7fa to f67c62a Compare September 12, 2022 07:29
@angelozerr
Copy link
Contributor Author

angelozerr commented Sep 12, 2022

Thanks for asking. With PDE there are also *.product files (root element ) for defining products, *.target files (root element ) for defining target platforms, and category.xml (root element ) for defining update sites.

Oh yes you are right, thanks for your feedback. I add those 3 file patterns. Thanks!

@angelozerr
Copy link
Contributor Author

@datho7561 please see too the vscode-xml PR redhat-developer/vscode-xml#774 which provides this new validation filter setting.

@angelozerr
Copy link
Contributor Author

angelozerr commented Sep 12, 2022

@merks I have tested quickly with WWD and my PR and I can confirm that it works: You will benefit with No grammar constraints for other XML files and not for plugin.xml for instance:

image

and you will continue to benefit with XML syntax validation from LemMinX in plugin.xml:

image

@merks
Copy link

merks commented Sep 12, 2022

@angelozerr Thanks! And also thanks from the uncounted users!!

Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

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

Works well. I also tried out the binary using neovim (so the lemminx settings use the defaults), and it works properly there as well. There we a few things I noticed in the code, and once they are addressed I think it should be good to merge.

@angelozerr angelozerr force-pushed the validation-filter2 branch 2 times, most recently from ee5a35e to e69d450 Compare September 12, 2022 15:03
@angelozerr
Copy link
Contributor Author

Works well. I also tried out the binary using neovim (so the lemminx settings use the defaults), and it works properly there as well. There we a few things I noticed in the code, and once they are addressed I think it should be good to merge.

To be consistent with symbol filter, I add it those XML validation filter classes in reflect-config.json

Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

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

Thank you, Angelo!

@datho7561 datho7561 merged commit de9c702 into eclipse:main Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suppress validation kinds based on file pattern
3 participants