-
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
TargetNamespace.1/2 error range fix #761
TargetNamespace.1/2 error range fix #761
Conversation
See if you can fix #703 too, as part of this PR |
a70fec4
to
9caf36d
Compare
@fbricon I'll add a fix for it as well. Should I include the code snippets that were originally mentioned in this PR, or open a separate issue to fix them? |
Huh which snippets are you referring to? |
1150fea
to
bc46add
Compare
@fbricon Oops. Sorry, I meant CodeActions. Angelo mentioned adding CodeActions in the issues. Should I make separate issues for these, or add them in this PR? |
bc46add
to
676c7d7
Compare
We'll add code actions separately, in 0.13.0 or later |
I see you already have 1 code action. We should then have the other one as well, to be consistent. Hopefully it should be fairly straightforward to add now |
ea81d9b
to
591f66e
Compare
f3a2451
to
39d5806
Compare
39d5806
to
1ec1702
Compare
Nice demo! |
...se/lemminx/extensions/contentmodel/participants/codeactions/TargetNamespace_1CodeAction.java
Show resolved
Hide resolved
...se/lemminx/extensions/contentmodel/participants/codeactions/TargetNamespace_1CodeAction.java
Outdated
Show resolved
Hide resolved
...se/lemminx/extensions/contentmodel/participants/codeactions/TargetNamespace_2CodeAction.java
Show resolved
Hide resolved
1ec1702
to
fc7ac7b
Compare
Thank you! |
fc7ac7b
to
c7f9a97
Compare
...minx/src/test/java/org/eclipse/lemminx/extensions/contentmodel/XMLSyntaxDiagnosticsTest.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/XMLPositionUtility.java
Show resolved
Hide resolved
c7f9a97
to
db59752
Compare
@datho7561 please fix the conflict |
db59752
to
d5893e0
Compare
Fixed |
// The error message has this form: | ||
// TargetNamespace.1: Expecting namespace 'NaN', but the target namespace of the | ||
// schema document is 'http://two-letter-name'. | ||
Matcher nsMatcher = NAMESPACE_EXTRACTOR.matcher(diagnosticMessage); |
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.
My worry is what if the namespace contains a '
(not url encoded like %XX) character?
@angelozerr do we need to worry about this?
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.
Good catch. I looked at the specification to see if '
is allowed in a namespace: https://www.w3.org/TR/xml/#NT-Name
My understanding from this document is that it isn't.
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.
Xerces doesn't complain when you write targetNamespace="'", so I think we should take care of even if it's not a common usecases.
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.
Working on it and unit tests for it
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.
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've pushed the code that implements the above (with tests) into this PR. Right now, it always tries to escape single quotes. I left it as a separate commit in case it we want to revert it. Other options could be:
- Always use double quotes when declaring
xmlns
if there is a single quote embedded in thetargetNamespace
- Don't give a code action if single quotes are prefered and there are single quotes in the
targetNamespace
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.
^This has been reverted back to the code that doesn't deal with single quotes in the namespace
...se/lemminx/extensions/contentmodel/participants/codeactions/TargetNamespace_1CodeAction.java
Outdated
Show resolved
Hide resolved
d5893e0
to
ea06c6f
Compare
...se/lemminx/extensions/contentmodel/participants/codeactions/TargetNamespace_1CodeAction.java
Show resolved
Hide resolved
72f8e87
to
1adb388
Compare
There are some issues with the build that I don't seem to have on my computer. |
I ran the tests under a fresh Fedora 32 VM with openjdk 11, using the included maven wrapper and there were no failed tests. |
If you repush your branch with amend (to restart the CI build) is it working better? |
1adb388
to
a68a567
Compare
...c/main/java/org/eclipse/lemminx/extensions/contentmodel/participants/XMLSchemaErrorCode.java
Outdated
Show resolved
Hide resolved
f2dfe80
to
c30cd98
Compare
I've reverted my changes that try to resolve single quotes in the namespace. This PR is ready for review. |
If the declared namespace of the root element is not the same as the namespace declared in the schema, the `xmlns` attribute of the root element is highlighted. If there is no namespace declared in the root element, but one is declared in the schema, the root element is highlighted. Added a CodeAction attached to `TargetNamespace.1` that replaces the namespace declared in the instance with the namespace declared in the schema. Added a CodeAction attached to `TargetNamespace.2` that adds the `xmlns` attribute to the root element and fills it with the namespace used in the schema. Fixes eclipse-lemminx#704, Fixes eclipse-lemminx#703 Signed-off-by: David Thompson <[email protected]>
c30cd98
to
6949126
Compare
If the declared namespace of the root element is not the same as
the namespace declared in the schema, the
xmlns
attribute of the rootelement is highlighted.
If there is no namespace declared in the root element, but one is
declared in the schema, the root element is highlighted.
Added a CodeAction attached to
TargetNamespace.1
that replacesthe namespace declared in the instance with the namespace declared in
the schema.
Added a CodeAction attached to
TargetNamespace.2
that adds thexmlns
attribute to the root element and fills it with the namespaceused in the schema.
Fixes #704, Fixes #703
Signed-off-by: David Thompson [email protected]