CFDocument doc = ((ICFDocument) state.getIDocument()).getCFDocument();
return getCFCName(variableName, doc);
}
public static String getCFCName(String variableName, CFDocument doc) {
CFNodeList nodelist = doc.getDocumentRoot().getChildNodes();
String cfcName = null;
Iterator iter = nodelist.iterator();
while (iter.hasNext()) {
Object cfItem = iter.next();
if (cfItem instanceof CfmlComment) {
CfmlComment comment = (CfmlComment) cfItem;
String commentText = ((CfmlComment) cfItem).getItemData();
// Now get the type from the comment text
Pattern p = Pattern.compile(cfmlVarRE);
Matcher m = p.matcher(commentText);
if (m.find() && m.group(1).equalsIgnoreCase(variableName)) {
cfcName = m.group(2);
break;
}
} else if (cfItem instanceof CfmlTagItem) {
CfmlTagItem cfsetTag = (CfmlTagItem) cfItem;
if (!((CfmlTagItem) cfItem).getName().equalsIgnoreCase("cfset")) {
continue;
}
String tagText = ((CfmlTagItem) cfItem).getItemData();
Map<String, String> varMap = parseCfSetText(tagText);
if (varMap == null) {
continue;
} else {
if (varMap.get("variableName").equalsIgnoreCase(variableName)) {
cfcName = varMap.get("variableType");
break;
}
}
}
}
CFNodeList scriptNodes = doc.getDocumentRoot().selectNodes("//ASTAssignment");
Iterator i = scriptNodes.iterator();
while (i.hasNext()) {
ScriptItem assignment = (ScriptItem) i.next();
if (assignment.getFirstChild().getItemData().equals(variableName)) {
return assignment.getLastChild().getItemData().replaceAll("\\(.*", "");
}
}
scriptNodes = doc.getDocumentRoot().selectNodes("//ASTVarDeclaration");
i = scriptNodes.iterator();
while (i.hasNext()) {
ScriptItem assignment = (ScriptItem) i.next();
Iterator id = assignment.selectNodes("//ASTIdentifier").iterator();
while (id.hasNext()) {
ScriptItem identifier = (ScriptItem) id.next();