Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 207194 - [hotbug] [HTMLAttributeValidator] Validator is JSP oriented (not usable for other plugins)
Summary: [hotbug] [HTMLAttributeValidator] Validator is JSP oriented (not usable for o...
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.html (show other bugs)
Version: 2.0.1   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 2.0.2 M202   Edit
Assignee: Amy Wu CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-23 12:24 EDT by Roy Ganor CLA
Modified: 2008-01-09 16:45 EST (History)
2 users (show)

See Also:


Attachments
org.eclipse.wst.html.core.patch (5.08 KB, patch)
2007-12-11 17:42 EST, Amy Wu CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roy Ganor CLA 2007-10-23 12:24:39 EDT
the private method signutare in org.eclipse.wst.html.core.internal.validate.HTMLAttributeValidator :

private boolean hasJSPRegion(ITextRegion container) 

should be replaced with:

protected boolean hasForeignRegion(ITextRegion container) 
---------            -------  
this will enable the PHP and other plugins to use this validator.

bests,

BTW - I wanted to workaround this validator by duplicate it, but there are many "package" classes in this mechanism. too bad for us I guess. but this is the reason I set it to major and it will be very important to have it on 2.0.2.
Have I said thank you guys?
Comment 1 Nitin Dahyabhai CLA 2007-10-24 03:44:16 EDT
Roy, the method's not meant to be independently callable, so how would changing the access rule enable its usage by other plug-ins?  I can understand the desire to at least rename it, though.  Additionally, the isNestedTagName() method contains duplicates of some JSP-only text region contexts.  There might be a better way to accomplish the same goal.
Comment 2 Roy Ganor CLA 2007-10-24 03:48:15 EDT
Nitin,
We will inherit from this class and override the hasForeignRegion() method, then we will register our validator instead of the original one.

We are used to it here in the PDT project :-)


(In reply to comment #1)
> Roy, the method's not meant to be independently callable, so how would changing
> the access rule enable its usage by other plug-ins?  I can understand the
> desire to at least rename it, though.  Additionally, the isNestedTagName()
> method contains duplicates of some JSP-only text region contexts.  There might
> be a better way to accomplish the same goal.

Comment 3 Roy Ganor CLA 2007-10-31 08:07:02 EDT
Any progress on this issue? 

it is a major bug for the PHP users since they get the 'undefined attribute name' error message
Comment 4 Nitin Dahyabhai CLA 2007-10-31 12:12:21 EDT
I'm not sure I like the idea of making that class extendable.  You'd still have to swap out the original HTMLAttributeValidator instance at runtime in favor of a subclass you create, right?  Why not a private copy?
Comment 5 Roy Ganor CLA 2007-10-31 12:40:10 EDT
you don't have to do the CLASS extendable, there are more ways you can support PHP regions. You can set an extension point to add foreign languages, just like JSP region type.

A private copy will make our lives miserable since we will need to update it whenever you guys fix the classes. this is not what you want, exactly like JSP guys don't like it.

Regards,

Comment 6 Amy Wu CLA 2007-10-31 13:45:20 EDT
I agree with Nitin that the validator class is not meant to be subclassed.  In fact, all the classes in org.eclipse.wst.html.core.internal.validate should be package protected.

I know private copying can be a pain, but it's actually better to do that when possible instead of subclassing internal classes. By having your own copy, you have more control, and you won't get stuck if we change behaviour in an internal class that is not beneficial to you.  HTML validation, specifically, is likely to change a good deal in WTP 3.0 to fix bug 170646.

I know that if you try to create your own copy of HTMLAttributeValidator, you'll run into package protected classes, but in most cases, those package protected classes are not essential to the main logic of HTMLAttributeValidator#validate().

Most of the package protected classes are just to figure out how to write the error message. If you're providing your own validator, you can/should also provide your own error messages.
Comment 7 Roy Ganor CLA 2007-10-31 14:22:44 EDT
please admit that it is very frustrating that you can put effort to be JSP sensetive and you don't see any point in adding PHP checks.

What if I asked you to add these changes in this class?

private boolean isNestedTagName(String regionType) {
 final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
 final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
 final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
 final String JSP_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
 final String PHP_OPEN = "PHP_OPEN"; //$NON-NLS-1$

 boolean result = regionType.equals(PHP_OPEN) || regionType.equals(JSP_SCRIPTLET_OPEN) || regionType.equals(JSP_EXPRESSION_OPEN) || regionType.equals(JSP_DECLARATION_OPEN) || regionType.equals(JSP_DIRECTIVE_OPEN);
 return result;
}

Would it be a problem? it is exactly the same check as JSP?

Regards,
- Roy
Comment 8 Nitin Dahyabhai CLA 2007-12-03 12:41:15 EST
It's very similar, but the JSP-ness stems from a history where ALL of the core plug-ins were one big plug-in and ALL of the UI plug-ins were one large plug-in (note the misspelled comment about "expedency").  In future cases we want to avoid anything like that.
Comment 9 Amy Wu CLA 2007-12-11 17:42:52 EST
Created attachment 85010 [details]
org.eclipse.wst.html.core.patch

This patch renames hasJSPRegion() to hasNestedRegion() and removes the call to check isNestedTagName() altogether in hasNestedRegion().  All hasNestedRegion() will check is if the region passed in is an ITextRegionContainer with at least one region in it.  If it is, then the region is considered a nested region and nested regions will be ignored by the html attribute validator.
Comment 10 Amy Wu CLA 2007-12-11 17:48:11 EST
Roy, please let me know if this patch solves your problem.  If so, and you still want this fixed in WTP 2.0.2, I'll mark this as a hotbug requested by the PDT project.
Comment 11 Roy Ganor CLA 2007-12-16 06:17:40 EST
yes it perfectly solves my problem,
Great to hear it will be merged to 2.0.2!

Thank you,
Comment 12 Amy Wu CLA 2008-01-09 16:45:53 EST
fix released for next week's wtp 2.0.2 ibuild and for this week's wtp 3.0m5 ibuild.