private boolean isJavascriptTag(HTMLSpecialNode item) { if (item == null) { return false; } if (!item.getName().equalsIgnoreCase("script")) // $NON-NLS-1$ { return false; } String type = item.getAttributeValue("type"); // $NON-NLS-1$ if (type != null && !HTMLParser.isJavaScript(item)) { return false; } return true; }
@Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof HTMLOutlineItem) { // delegates to the parse node it references to return getChildren(((HTMLOutlineItem) parentElement).getReferenceNode()); } // Handle expansion of link tags pointing to stylesheets if (parentElement instanceof HTMLElementNode) { HTMLElementNode item = (HTMLElementNode) parentElement; if (isStylesheetLinkTag(item)) { String attribute = getExternalCSSReference(item); if (attribute != null && attribute.length() > 0) { return getExternalChildren(item, attribute, ICSSConstants.CONTENT_TYPE_CSS); } } else { IParseNode[] styleNodes = item.getCSSStyleNodes(); IParseNode[] jsAttrNodes = item.getJSAttributeNodes(); if (styleNodes.length > 0 || jsAttrNodes.length > 0) { List<IParseNode> children = new ArrayList<IParseNode>(); children.addAll(Arrays.asList(styleNodes)); children.addAll(Arrays.asList(jsAttrNodes)); children.addAll(Arrays.asList(item.getChildren())); return filter(children.toArray(new IParseNode[children.size()])); } } } // Handle embedded languages (JS and CSS) if (parentElement instanceof HTMLSpecialNode) { // HTMLSpecialNode always has the root node of the nested language as its child; we want to // skip that and // get the content below HTMLSpecialNode item = (HTMLSpecialNode) parentElement; // Special case of external JS file String attribute = getExternalJSReference(item); if (attribute != null && attribute.length() > 0) { return getExternalChildren(item, attribute, IJSConstants.CONTENT_TYPE_JS); } return getChildren(item.getChild(0)); } return super.getChildren(parentElement); }
private String getExternalJSReference(HTMLSpecialNode item) { if (!isJavascriptTag(item)) { return null; } return item.getAttributeValue("src"); // $NON-NLS-1$ }