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

Add completions support inside CDATA content #1626

Conversation

pablocabrera85
Copy link

Addresses this enhancement request

To facilitate the implementation of embedded language features inside the XML supporting the completion request inside CDATA blocks is required.

The changes where added in a backward compatible way an as such an increment in version was pushed from 0.27.1-SNAPSHOT to 0.28.0-SNAPSHOT

Mockito was added as a dependency as it is easier to mock interfaces and verify invocations rather than implement a new completion participant

@@ -287,5 +287,11 @@
<version>9.4.53.v20231009</version>
<scope>test</scope>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use mockito for test.

@fbricon @datho7561 do you think it can be a good idea to use mockito?

@angelozerr
Copy link
Contributor

@pablocabrera85 have you a concrete sample with CDATA completion participant?

@pablocabrera85
Copy link
Author

Hi @angelozerr .

The following are some of the examples I'm aware of:

  • Script blocks inside HTML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
 <title>XHTML 1.0 Strict Example</title>
 <script type="application/javascript">
 <![CDATA[
 function loadpdf() {
    document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
 }
 ]]>
 </script>
 </head>
 <body onload="loadpdf()">
 </body>
</html>

MuleSoft also has some components that allow to use scripting language like Groovy, Python and Ruby

<scripting:execute  engine="Groovy">
    <scripting:code ><![CDATA[flow = registry.lookupByName("test-flow").get();
        if (flow.isStarted())
	        flow.stop()
        else
	        flow.start()]]>
    </scripting:code>
</scripting:execute>

And also they have a transformation language:

<ee:transform doc:id="747f74d4-cb66-4f8e-8222-24784e6863ae"
  doc:name="Transform" doc:timestamp="1510861248434">
    <ee:message>
        <ee:set-payload>
          <![CDATA[%dw 2.0
            output application/json
            ---
            {
              // YOUR DW SCRIPT
            }
          ]]>
       </ee:set-payload>
    </ee:message>
</ee:transform>

I found this article talking about SQL inside XML

@angelozerr
Copy link
Contributor

The following are some of the examples I'm aware of:

Sorry I wanted to know if there were an implementation to manage completion with JavaScript inside XML.

Your PR is great but I would like to avoid providing a participant API if it exists none implementation.

Could you deal JavaScript completion on your side with your PR?

@pablocabrera85
Copy link
Author

Yes, without this PR, we end up manually process the DOM to check if we are in a CDATA block to cover for this scenario. It would be great if we could avoid manually processing the DOM and just use the lemminx APIs

@angelozerr
Copy link
Contributor

Yes, without this PR, we end up manually process the DOM to check if we are in a CDATA block to cover for this scenario. It would be great if we could avoid manually processing the DOM and just use the lemminx APIs

That's great,could you share your project which does that please?

@pablocabrera85
Copy link
Author

@angelozerr Sorry for the late reply. The code is in a private repository, and unfortunately I no longer have access to it, as I was affected by the latest round of layoffs. I'll close this PR.

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.

2 participants