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

Implement <?xml completion in DTD files #406

Merged
merged 1 commit into from
Jun 4, 2019
Merged

Implement <?xml completion in DTD files #406

merged 1 commit into from
Jun 4, 2019

Conversation

xorye
Copy link

@xorye xorye commented May 30, 2019

Fixes #267

Previously, the prolog in .dtd files were not being parsed by the DOMParser as a DOMProcessingInstruction, like .xml files were.

Changing XMLScanner.java fixed that. Now that the prolog in .dtd files are considered to be aDOMProcessingInstruction, prolog auto-completion now works in .dtd files.

Since .dtd files could now contain a DOMProcessingInstruction in their respective DOMDocument,
XMLFormatter.java had to be changed to take that into account. The "if else" structure in XMLFormatter.java was also cleaned up.

Signed-off-by: David Kwon [email protected]

ArrayList<DTDAttlistDecl> internalDecls = attlist.getInternalChildren();
if (decl.isDTDAttListDecl()) {
DTDAttlistDecl attlist = (DTDAttlistDecl) decl;
ArrayList<DTDAttlistDecl> internalDecls = attlist.getInternalChildren();
Copy link
Contributor

Choose a reason for hiding this comment

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

Change ArrayList to List

}
} else {
boolean multipleInternalAttlistDecls = false;
ArrayList<DTDDeclParameter> params = attlist.getParameters();
Copy link
Contributor

Choose a reason for hiding this comment

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

Change ArrayList to List

@angelozerr
Copy link
Contributor

Should line 204 be List as well?

yes please. The basic idea is to use interface and not implementation of collection, list. But problem comes from too DTDDeclNode#getParameters should return List (interface) and not ArrayList (implementation of List). Please change that too.

@xorye
Copy link
Author

xorye commented May 31, 2019

Ok, I have made the changes

private static void addPIToXMLBuilder(DOMNode node, XMLBuilder xml) {
DOMProcessingInstruction processingInstruction = (DOMProcessingInstruction) node;
xml.startPrologOrPI(processingInstruction.getTarget());
if (processingInstruction.hasAttributes()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A processing instruction will never have attributes, it's always text content (the case below).

@xorye
Copy link
Author

xorye commented Jun 3, 2019

@NikolasKomonen I have made the changes.

@@ -33,7 +34,7 @@
public DTDDeclParameter unrecognized; // holds all content after parsing goes wrong in a DTD declaration (ENTITY, ATTLIST, ...).
public DTDDeclParameter declType; // represents the actual name of the decl eg: ENTITY, ATTLIST, ...

ArrayList<DTDDeclParameter> parameters;
List<DTDDeclParameter> parameters;
Copy link
Contributor

Choose a reason for hiding this comment

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

private

Copy link
Author

Choose a reason for hiding this comment

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

@fbricon changed.

@fbricon fbricon merged commit a8bb969 into eclipse:master Jun 4, 2019
@angelozerr angelozerr added this to the v0.7.0 milestone Jun 7, 2019
@angelozerr angelozerr added completion This issue or enhancement is related to completion support DTD labels Jun 7, 2019
@fbricon fbricon removed this from the v0.7.0 milestone Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completion This issue or enhancement is related to completion support DTD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No <?xml completion in DTD files
5 participants