private String getScriptingPartitionType(IStructuredDocumentRegion coreNode) {
String language = null;
String type = null;
String result = IHTMLPartitions.SCRIPT;
IStructuredDocumentRegion node = coreNode;
ITextRegion attrNameRegion = null;
while (node != null && isValidScriptingRegionType(node.getType())) {
node = node.getPrevious();
}
ITextRegionList regions = node.getRegions();
if (regions.size() > 4 && regions.get(1).getType() == DOMRegionContext.XML_TAG_NAME) {
ITextRegion potentialLanguageRegion = regions.get(1);
String potentialLanguageString = node.getText(potentialLanguageRegion);
if (potentialLanguageString.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT)) {
for (int i = 0; i < regions.size(); i++) {
ITextRegion region = regions.get(i);
String regionType = region.getType();
if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
attrNameRegion = region;
else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
String attrName = node.getText(attrNameRegion);
if (attrName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_LANGUAGE))
language = StringUtils.strip(node.getText(region));
else if (attrName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_TYPE)) {
type = StringUtils.strip(node.getText(region));
/*
* Avoid partition names built with MIME subtypes,
* e.g. type="text/javascript;e4x=1"
*/
if (type != null) {