// TODO Auto-generated method stub
//CFMLEditor curDoc = (CFMLEditor) this.fViewer.getDocument();
//ICFDocument cfd = (ICFDocument) curDoc.getDocumentProvider().getDocument(curDoc.getEditorInput());
TextSelection sel = (TextSelection) this.fViewer.getSelection();
int startPos = sel.getOffset();
ICFDocument cfd = (ICFDocument) this.fViewer.getDocument();
DocItem cti = cfd.getTagAt(startPos, startPos, true);
if(cti != null && this.selectedTag != null) {
if(cti.getStartPosition() == this.selectedTag.getStartPosition()){
this.selectedTagWasSelected = true;
} else {
clearTagBeginEndMarkers();
this.selectedTagWasSelected = false;
}
} else {
clearTagBeginEndMarkers();
}
this.selectedTag = null;
try {
// cfcomponent returns ASTVarDeclaration -- syntax is null for whatever reason (ASTVar's from cfscript?!)
if(cti != null
&& !cti.getName().equals("CfmlComment") && !cti.getName().equals("cfscript")
&& !cti.getName().startsWith("AST") && !cti.getName().equals("ScriptItem")) {
if (cti instanceof CfmlTagItem) {
if (cti.getName().equals("CfmlCustomTag") || ((TagItem) cti).hasClosingTag()) {
markBeginEndTags((CfmlTagItem) cti);
}
}
}
} catch (Exception e) {
System.err.println(cti.getName());
e.printStackTrace();
}
CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
CFEPartition part = partitioner.findClosestPartition(startPos);
if(part == null) {
return;
}
startPos = part.offset;
if (cti != null) {
this.currentDocItem = cti;
this.selectedTag = cti;
} else {
this.currentDocItem = cfd.getTagAt(startPos, startPos, false);
while (this.currentDocItem == null && startPos >= 0 && part != null) {
startPos = part.offset;
this.currentDocItem = cfd.getTagAt(startPos, startPos + part.length + 1, false);
part = partitioner.getPreviousPartition(startPos);
}
this.selectedTag = this.currentDocItem;
}
}