if (region == null || !(fTextEditor instanceof ScriptEditor))
return null;
int offset = region.getOffset();
IModelElement input = EditorUtility.getEditorInputModelElement(fTextEditor, false);
if (input == null)
return null;
try {
IDocument document = fTextEditor.getDocumentProvider().getDocument(
fTextEditor.getEditorInput());
IRegion wordRegion = ScriptWordFinder.findWord(document, offset);
if (wordRegion == null)
return null;
if (input instanceof ISourceModule) {
ISourceModule sm = (ISourceModule) input;
IModelElement modelElement = sm.getModelElement();
RutaSelectionParser parser = new RutaSelectionParser();
ModuleDeclaration moduleDeclaration = parser.parse(sm);
String word = document.get(wordRegion.getOffset(), wordRegion.getLength());
RutaReferenceVisitor referenceVisitor = new RutaReferenceVisitor(wordRegion.getOffset());
moduleDeclaration.traverse(referenceVisitor);
ASTNode node = referenceVisitor.getResult();
if (node instanceof RutaVariableReference
&& moduleDeclaration instanceof RutaModuleDeclaration) {
RutaVariableReference vr = (RutaVariableReference) node;
RutaModuleDeclaration parsed = (RutaModuleDeclaration) moduleDeclaration;
if (vr.getType() == RutaTypeConstants.RUTA_TYPE_AT) {
String nodeText = vr.getStringRepresentation();
Collection<String> importedTypeSystems = parsed.descriptorInfo.getImportedTypeSystems();
List<IHyperlink> result = new ArrayList<IHyperlink>();
for (String tsString : importedTypeSystems) {
IFolder folder = modelElement.getScriptProject().getProject()
.getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
String xmlFilePath = tsString.replaceAll("\\.", "/");
xmlFilePath = xmlFilePath.substring(0, xmlFilePath.length()) + ".xml";
Set<String> types = getTypes(folder, xmlFilePath);
if (types.contains(nodeText)) {