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

Support references in included files for codelens + diagnostics. #1452

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

angelozerr
Copy link
Contributor

Search references inincluded files for codelens + diagnostics.

Signed-off-by: azerr [email protected]

@angelozerr angelozerr force-pushed the references-validation-include branch 2 times, most recently from e0ae33c to 37891f9 Compare January 13, 2023 17:35
@angelozerr angelozerr changed the title Search references inincluded files for codelens + diagnostics. Search references in included files for codelens + diagnostics. Jan 13, 2023
@angelozerr
Copy link
Contributor Author

Given this XML file:

<docbook>
	<xref linkend="s1" />
	<section id="s1" />
	<xref linkend="ch1" />
	<xi:include href="sub-book.xml" />
</docbook>

with sub-book.xml file:

<book>
	<chapter id="ch1" />
	<chapter id="ch2"/>
	<xref linkend="s1" />
	<xref linkend="s1" />
	<xref linkend="ch1" />
	<xref linkend="ch1" />
</book>

and an expression like this:

{
  "pattern": "**/*.xml",
  "expressions": [
    {
      "from": "xref/@linkend",
      "to": "@id"
    }
  ]
}
  • the included xref in sub-book.xml is not used to count codelens: <section id="s1" /> should show [3 references]
  • the diagnostic report ch1 as an error although it is defined in the sub-book.xml

@angelozerr angelozerr marked this pull request as ready for review January 13, 2023 17:49
@angelozerr angelozerr changed the title Search references in included files for codelens + diagnostics. Support references in included files for codelens + diagnostics. Jan 13, 2023
@angelozerr angelozerr force-pushed the references-validation-include branch 2 times, most recently from 02f5fba to b4c7d23 Compare January 13, 2023 17:53
@datho7561
Copy link
Contributor

I think that it would be nice to disable this when "xml.validation.xInclude.enabled": false,

@datho7561
Copy link
Contributor

I get a FileNotFoundException when the referenced xi:include/@href doesn't exist

@angelozerr
Copy link
Contributor Author

angelozerr commented Jan 13, 2023

I think that it would be nice to disable this when "xml.validation.xInclude.enabled": false,

I would like to avoid doing that, because my idea is to remove all XSD, RNG support and delegate references with XML references. For XSD, xsd:include is not linked to xiinclude.

For the moment the include is hard coded, but my idea is to give the capability to customize it when you write an xm reference expression like:

{
  "pattern": "**/*.xml",
  "include": [
      "include/@href",
      "import/@href"
   ],
  "expressions": [
    {
      "from": "xref/@linkend",
      "to": "@id"
    }
  ]
}

@angelozerr
Copy link
Contributor Author

I get a FileNotFoundException when the referenced xi:include/@href doesn't exist

I removed the log

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.

Looks good. Thanks, Angelo!

@datho7561 datho7561 added bug Something isn't working code action references labels Jan 13, 2023
@datho7561 datho7561 added this to the 0.24.0 milestone Jan 13, 2023
@datho7561 datho7561 merged commit d1aee14 into eclipse:main Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code action references
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants