Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323929

Summary: [api] Class cast exception in org.eclipse.wst.css.core.internal.document.CSSSelector.getParentElement(Element)
Product: [WebTools] WTP Source Editing Reporter: Sarika Sinha <sarika.sinha>
Component: wst.cssAssignee: Sarika Sinha <sarika.sinha>
Status: CLOSED FIXED QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: thatnitind
Version: unspecified   
Target Milestone: 3.2.3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch to replace class cast exception with instanceof check in cssselector none

Description Sarika Sinha CLA 2010-08-30 01:31:49 EDT
Build Identifier: M20100811-0800

Instead of throwing Class cast exception, instance of check can be added to increase performance of css traversal.

Reproducible: Sometimes

Steps to Reproduce:
1.While trying to get the default style ofa  page where css is applied,class cast exception comes sometime. This can be replaced by instance of check.
Comment 1 Sarika Sinha CLA 2010-08-30 01:40:26 EDT
Created attachment 177700 [details]
Patch to replace class cast exception with instanceof check in cssselector

This patch replace the throwing of class cast exception with instance of check in cssSelector.getParentElement
Comment 2 Nick Sandonato CLA 2010-09-28 14:01:56 EDT
Hi, Sarika. Patch looks good overall. The one change I made was just a simplification of the if statement to be if(parent instanceof Element) since null is not an instance of Element, it would fail the check anyway. Thanks for the fix.
Comment 3 Nick Sandonato CLA 2010-09-28 14:09:15 EDT
Actually, it looks like Nitin released a fix yesterday that accomplished this change. His is slightly different though, but doesn't use the instanceof check. instead it uses Node#getNodeType() == Node.ELEMENT_NODE. Thanks for the patch, though.
Comment 4 Sarika Sinha CLA 2010-09-29 01:01:59 EDT
Thanks Nick.