ITextSelection sel = (ITextSelection) editor.getSelectionProvider().getSelection();
editor.getSelectionProvider().setSelection(CFDocUtils.selectWord(doc, sel.getOffset()));
sel = (ITextSelection) editor.getSelectionProvider().getSelection();
String functionName = sel.getText();
int startOffset = sel.getOffset();
FindReplaceDocumentAdapter search = new FindReplaceDocumentAdapter(doc);
try {
IRegion startPos = search.find(sel.getOffset() + functionName.length(), "name\\s?=\\s?[\"']" + functionName + "[\"']", true, false,
false, true);
if (startPos == null) {
startPos = search.find(sel.getOffset() + functionName.length(), "name\\s?=\\s?[\"']" + functionName + "[\"']", false, false, false,
true);
}
if (startPos == null) {
startPos = search.find(sel.getOffset() + functionName.length(), "function\\s" + functionName + "[(\\s]", false, false, false,
true);
}
if (startPos == null) {
startPos = search.find(sel.getOffset() + functionName.length(), "function\\s" + functionName + "[(\\s]", true, false, false,
true);
}
// search for assignment, backwards first
if (startPos == null) {
startPos = search.find(sel.getOffset() + functionName.length(), functionName + "[\\s]?=[^=]", false, false, false, true);
}
if (startPos == null) {
startPos = search.find(sel.getOffset() + functionName.length(), functionName + "[\\s]?=[^=]", true, false, false, true);
}
if (startPos == null) {
if (doc.getChar(startOffset - 1) == '.') {
String cfcInstance = CFDocUtils.selectWord(doc, sel.getOffset() - 2).getText();
IRegion assignmentPos = search.find(sel.getOffset() + cfcInstance.length(), cfcInstance + "[\\s]?=[\\s]?new\\s", false,
false, false, true);
if (assignmentPos == null) {
assignmentPos = search.find(sel.getOffset() + cfcInstance.length(), cfcInstance + "[\\s]?=[\\s]?createObject",
false, false, false, true);
}
if (assignmentPos == null) {
assignmentPos = search.find(sel.getOffset() + cfcInstance.length(), cfcInstance + "[\\s]?=[\\s]?entityNew", false,
false, false, true);
}
if (assignmentPos != null) {
//MappingManager mappingManager = new MappingManager();
CFDocument cfdoc = ((ICFDocument) doc).getCFDocument();
String CFCName = AssistUtils.getCFCName(cfcInstance, cfdoc);
IFile foundCFC = AssistUtils.findCFC(CFCName);
if (foundCFC == null) {
foundCFC = AssistUtils.findCFC(functionName);
}
if (foundCFC != null) {
OpenAtMethodAction openAction = new OpenAtMethodAction(foundCFC, "");
openAction.run();
}
}
}
startPos = search.find(sel.getOffset() + functionName.length(), functionName + "[\\s]?=[^=]", true, false, false, true);
}
if (startPos != null) {
startPos = search.find(startPos.getOffset(), functionName, true, true, false, true);
editor.getSelectionProvider().setSelection(CFDocUtils.selectWord(doc, startPos.getOffset()));
}
if (startPos == null || sel.getOffset() == startPos.getOffset()) {
DocItem st = ((CFMLEditor) editor).getSelectionCursorListener().getSelectedTag();
if (st.getName().equals("ASTComponent") || st.getName().equals("FunctionCall")) {