eclipse / lemminx Goto Github PK
View Code? Open in Web Editor NEWXML Language Server
License: Eclipse Public License 2.0
XML Language Server
License: Eclipse Public License 2.0
Add completion settings (like client snippet support) when completion is done.
Ex: for Spring file, open completion provides
bean>property
Today folding uses custom lsp4j classes https://github.com/angelozerr/lsp4xml/tree/master/org.eclipse.lsp4xml/src/main/java/toremove/org/eclipse/lsp4j
Once eclipse-lsp4j/lsp4j#169 will be implemented, use thoses folding classes.
Add support for textDocument/documentLink
https://microsoft.github.io/language-server-protocol/specification#textDocument_documentLink for extension.
One extension for web (web.xml) could manage hyperlink for welcome-file to open it:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
One extension for String could manage hyperlink for class to open the Java class:
<bean class="MyClass" />
I don't know if it's an hard task, but I tell me if we could use our XML scanner to validate XML files for no well XML (XML which doesn't end an element tag, etc).
Today, I'm using Xerces to do that, but the main problem is that SAXParserException contains only a start line/character and not the end.
I have studied WTP XML validator and they do like this:
validate XML file with their internal DOM (structured region) https://github.com/eclipse/webtools.sourceediting/blob/master/xml/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/MarkupValidator.java -> it looks like of our XMLDocument
validate XML file with their internal Token https://github.com/eclipse/webtools.sourceediting/blob/master/xml/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/StreamingMarkupValidator.java -> it looks like of our XML Scanner.
The benefit to do that is that you can highlight the element tag when there is an error.
For the XML Schema error, WTP adjust the start/end location according error message like https://github.com/microclimate-devops/xml-language-server does too.
I would like to follow the same idea than WTP/XML Editor:
IMHO, if we can do that, we will have a clean validation mean and it will be easy to extend too validation to valiudate other things (ex: validate java class defines in @Class attribute, etc)
@fbricon @NikolasKomonen what do you think about that?
Add support for textDocument/foldingRange
, which allows editors to provide folding support (for code XML tag). See LSP proposal: https://github.com/Microsoft/vscode-languageserver-protocol-foldingprovider/blob/master/protocol.foldingProvider.md
https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange
It requires upstream lsp4j implementation: eclipse-lsp4j/lsp4j#169
@NikolasKomonen if you wish to work on adjust range for XML syntax errors, please do that in https://github.com/angelozerr/lsp4xml/blob/master/org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/contentmodel/participants/diagnostics/XMLSyntaxErrorCode.java
You can find XML Syntax/Schema error code list at https://wiki.xmldation.com/Support/Validator/. You must filter thoses codes and keep just XML Syntax error code. Me I'm working on XML Schema error code in #72
Please update tests at https://github.com/angelozerr/lsp4xml/blob/master/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/contentmodel/XMLSyntaxDiagnosticsTest.java
To check the adjust to do, I suggest you to consume the lsp4xml language server inside vscode and see if it highlights attributes value, name, elements, etc according the XML syntax error code.
Good luck!
Support hover over
If a tag is not properly closed eg <tag </tag>
the scanner will not be smart enough to recognise the start of a new tag.
The scanner should search for the closing tag, while also checking if it sees a new opening tag.
This will be helpful since it will indicate and un-closed tag to every service that uses the Scanner and will prevent incorrect Node structures, Incorrect Document Validations, Formatting...
At most the Scanner will return the new opening bracket Token (eg '<') instead of the wrong closing bracket Token.
Not sure about schema validation
it would be nice to have the completion based on the xsd (and maybe also on a DTD? or is too old?)
XML Parser should take care of XML prolog
<?xml version="1.0" encoding="UTF-8"?>
<root />
Gives the capability to assocoiate a give file (ex : .project
, .classpath
) with a XML Schema to benefit with compeltion and validatioin. Indeed Eclispe files .project
, .classpath
doesn't define an XML Schema in their root. Associate a XMl Schema with a given file name pattern could be helpful.
The question is about file pattern. We could manage at hand '*' pattern like https://github.com/microclimate-devops/xml-language-server/blob/master/server/xml-server/src/com/ibm/ctools/ls/xml/XMLLanguageServer.java#L119 does but I find it's a little limitaed.
My idea @fbricon @NikolasKomonen is to support minimatch pattern with my Minimatch port in Java https://github.com/angelozerr/minimatch.java
Are you OK with this new dependency?
JDT-LS uses <?m2e execute onConfiguration?>
and this is not recognized in XMLScanner
... or call exception.printStackTrace();
stdio is used to exchange messages with the client. Logging to standard streams will break the client/server communication.
Either log messages via a logging facade (slf4j?) to a log file, and/or log messages to the client
The package name is org.eclipse.xml...
. Typical Eclipse projects use an org.eclipse.<projectName>
as root package. To avoid necessary further refactoring when moving to Eclipse.org, we should consider deciding of a projectName already and adopt this in package name asap.
Configure emmet tabs (and other settings?)
Create a way to end the server extension process if the IDE stops responding.
XMLDocument provides usefull method like Position positionAt(int position)
. Some support (like folding, format) doesn't requires the use of XML node, so we parse XML document although we don't need it.
The idea of this issue is to have 2 structures:
Add support for textDocument/codeAction
https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction :
Before initializeRootLogger() is called check if the settings were actually changed.
In Windows OS, when I execute it, I have this error:
Running org.eclipse.lsp4xml.utils.LoggerTest
août 09, 2018 4:52:10 PM org.eclipse.lsp4xml.utils.LoggerTest testLogCreated
GRAVE: @@Log Message@@
Tests run: 3, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec <<< FAILURE!
assertTestFormatting(org.eclipse.lsp4xml.utils.LoggerTest) Time elapsed: 0.001 sec <<< FAILURE!
org.junit.ComparisonFailure: expected:<[Sep 16, 1997 04:05:05 org.my.test.Class mySourceMethod()
Message: Formatting Log Message
at declaringClass.methodName(fileName.java:1)
at declaringClass2.methodName2.drl.java(fileName2.java:2)
at declaringClass.methodName.apk.java(fileName:3)]
> but was:<[sept. 16, 1997 04:05:05 org.my.test.Class mySourceMethod()
Message: Formatting Log Message
at declaringClass.methodName(fileName.java:1)
at declaringClass2.methodName2.drl.java(fileName2.java:2)
at declaringClass.methodName.apk.java(fileName:3)
]
>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at org.eclipse.lsp4xml.utils.LoggerTest.assertTestFormatting(LoggerTest.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
@fbricon @NikolasKomonen could you fix this problem please? It seems that date are hard coded in the JUnit test. Thanks!
It looks like the parser does not handle CDATA, I'm currently working on implementing this. Let me know if there is anything you would like to discuss.
Add completion for comment and #region (to fold custom content https://github.com/angelozerr/lsp4xml/wiki/Features#folding)
It should be nice to have a formatting XML support. Format should be done:
There are 2 strategies to do that:
We need too defines formatting preferences. Here the WTP/ XML Editor preferences:
I see as part of this project tries to implement it's own parser. I think it's a really hard task from short to long term!
Have you consider re-using Eclipse WTP parser or some other parser (like the one used by IntelliJ) to build the server upon?
Add JUnit for tolerant XMLParser
@NikolasKomonen please follow this issue to track JUnit that I will do. Once I will push my work, please give me feedback to know if you will like tests and do the same thing for CDATA #5
Rename an XML tag name.
@NikolasKomonen please add a link to your VSCode client project which consumes lsp4xml in README https://github.com/angelozerr/lsp4xml#clients
Thanks!
Build failed every time https://travis-ci.org/angelozerr/lsp4xml/builds/422519278?utm_source=email&utm_medium=notification because of
3.45s$ ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
--2018-08-30 12:05:36-- https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar
Resolving repo.maven.apache.org (repo.maven.apache.org)... 151.101.20.215
Connecting to repo.maven.apache.org (repo.maven.apache.org)|151.101.20.215|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2018-08-30 12:05:36 ERROR 403: Forbidden.
@fbricon have you an idea about this problem?
Today ClientLogHandler is every time enabled. I don't know if it is the wished behaviour.
If we see the code of LogHelper, the initializationObject cannot be never null (empty but not null)
public static void initializeRootLogger(LanguageClient newLanguageClient, Map<?, ?> initializationObject) {
if(newLanguageClient == null || initializationObject == null) {
return;
}
So the following code which enable )ClientHandler is done evry time.
Logger logger = Logger.getLogger("");
unregisterAllHandlers(logger.getHandlers());
logger.setLevel(Level.SEVERE);
logger.setUseParentHandlers(false);// Stops output to console
try {
logger.addHandler(LogHelper.getClientHandler(newLanguageClient));
} catch (Exception e) {
// TODO: handle exception
}
To fix that, I think we should:
if(newLanguageClient == null || initializationObject == null || initializationObject.isEmpty()) {
use property
lsp4xml.logs.client.enabled
to know if client must be enabled or notlsp4xml.logPath
should be perhaps replaced with lsp4xml.logs.file.path
What do you think about that?
Add support for codelens https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens for extension.
Here a screenshot with XSD types references
This issue requires the add of codelens preferences in vscode-xml. See the PR redhat-developer/vscode-xml#161
Cache XML Schema, because for the moment, the XML Schema is loaded each time you type something. But there is not freeze because publish diagnostics is done in async mode. To fix that, I think XML catalog should help us and I need to read https://xerces.apache.org/xerces2-j/faq-grammars.html
Add support for textDocument/references
https://microsoft.github.io/language-server-protocol/specification#textDocument_references for extension
One extension for XSD could find the references of xs:complexType (references by xs:element, etc) :
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://maven.apache.org/POM/4.0.0" targetNamespace="http://maven.apache.org/POM/4.0.0">
<xs:element name="project" type="Model">
...
</xs:element>
<xs:complexType name="Model">
A Find References did in the "Model" of txs:complexType shoudl return xs:element
Here a references demo with XMLSchema.xsd
The references should work with other element like:
When modifying the document textDocument/didChange will trigger on each keystroke even if done together quickly. This also ends up triggering validation each time.
A fix, similar to jdtls, should help speed everything up. Unless this whole issue is already handled by something I missed.
Use message properties to define error message.
The XMLScanner is setup for comments, but it is not handled in XMLFormatting, formatting will remove the comments.
To fix add consideration of comments in XMLParser
It should be cool to give the capability to customize formatting. We need to collect which settings we need and implement the formatting with thoses settings.
Here settings for WTP/XML Editor:
Here the HTML formatting option for vscode html language service https://github.com/Microsoft/vscode-html-languageservice/blob/master/src/services/htmlFormatter.ts#L55
let htmlOptions: IBeautifyHTMLOptions = {
indent_size: options.insertSpaces ? tabSize : 1,
indent_char: options.insertSpaces ? ' ' : '\t',
wrap_line_length: getFormatOption(options, 'wrapLineLength', 120),
unformatted: getTagsFormatOption(options, 'unformatted', void 0),
content_unformatted: getTagsFormatOption(options, 'contentUnformatted', void 0),
indent_inner_html: getFormatOption(options, 'indentInnerHtml', false),
preserve_newlines: getFormatOption(options, 'preserveNewLines', true),
max_preserve_newlines: getFormatOption(options, 'maxPreserveNewLines', 32786),
indent_handlebars: getFormatOption(options, 'indentHandlebars', false),
end_with_newline: includesEnd && getFormatOption(options, 'endWithNewline', false),
extra_liners: getTagsFormatOption(options, 'extraLiners', void 0),
wrap_attributes: getFormatOption(options, 'wrapAttributes', 'auto'),
wrap_attributes_indent_size: getFormatOption(options, 'wrapAttributesIndentSize', void 0),
eol: '\n'
};
@NikolasKomonen do you want to work on this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.