angelozerr / eclipse-wtp-xml-search

Eclipse WTP/XML Search
Other
12 stars 6 forks source link

improved code completion of attritubes in jsp file #33

Closed kuozhang closed 10 years ago

kuozhang commented 10 years ago

jsp tokenizer doesn't detect the attribute value really well, causes the code completion proposal to replace more text than it should

kuozhang commented 10 years ago

In jsp file like:

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<liferay-ui:message key="

foo,bar

<p>foo, bar</p>

There is a code completion for the "key" attribute, it will remove all the contents after the quote, that's because the jsp tokenizer treates these contents as type of XML_TAG_ATTRIBUTE_VALUE if there is no end quote.
Xml file doesn't have this issue, because it treates the contents like "Hello" as a XML_TAG_ATTRIBUTE_NAME.

You can tell from the different colors.

in xml, jsp-xml

in jsp jsp-jsp

gamerson commented 10 years ago

Thanks Kuo,

Angelo in Kuo's last example the completion in JSP editors will wipe out the remainder of the file contents. So Kuo's code just adds a sanity check into the replacement length to make sure that the replacement text isn't going to wipe out too much, in other words it wont erase newlines special tags, etc. If it encounters these situations it simply sets replacement length as 0 which makes it a pure insert, which I think that is a good fallback.

On Tue, Oct 14, 2014 at 1:18 PM, Kuo Zhang notifications@github.com wrote:

In jsp file like:

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<liferay-ui:message key="

foo,bar

foo, bar

There is a code completion for the "key" attribute, it will remove all the contents after the quote, that's because the jsp tokenizer treates these contents as type of XML_TAG_ATTRIBUTE_VALUE if there is no end quote.

Xml file doesn't have this issue, because it treates the contents like "Hello" as a XML_TAG_ATTRIBUTE_NAME.

You can tell from the different colors.

in xml, [image: jsp-xml] https://cloud.githubusercontent.com/assets/4946639/4624304/c3905a76-5360-11e4-8b2c-c50dd167508c.png

in jsp [image: jsp-jsp] https://cloud.githubusercontent.com/assets/4946639/4624305/c7847bf8-5360-11e4-9060-b0a2659902b2.png

— Reply to this email directly or view it on GitHub https://github.com/angelozerr/eclipse-wtp-xml-search/pull/33#issuecomment-58991488 .

Greg Amerson Liferay Developer Tools Liferay, Inc. www.liferay.com

angelozerr commented 10 years ago

Very good idea! Thank's @kuozhang and @gamerson