use of org.yakindu.sct.model.stext.stext.ImportScope in project statecharts by Yakindu.
the class PackageImportHyperlinkHelper method createPackageImportHyperlinksByOffset.
protected void createPackageImportHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
INode node = NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
if (node != null && node.getGrammarElement() instanceof RuleCall && node.getSemanticElement() instanceof ImportScope) {
NodeModelUtils.findNodesForFeature(node.getSemanticElement(), TypesPackage.Literals.PACKAGE__IMPORT);
ImportScope importScope = (ImportScope) node.getSemanticElement();
EList<String> imports = importScope.getImports();
for (String pkgImport : imports) {
Optional<PackageImport> mappedImport = mapper.findPackageImport(resource, pkgImport);
if (mappedImport.isPresent()) {
final URI targetURI = mappedImport.get().getUri();
XtextHyperlink result = getHyperlinkProvider().get();
result.setURI(targetURI);
Region region = new Region(node.getOffset(), node.getLength());
result.setHyperlinkRegion(region);
result.setHyperlinkText(targetURI.toString());
acceptor.accept(result);
}
}
}
}
use of org.yakindu.sct.model.stext.stext.ImportScope in project statecharts by Yakindu.
the class StextImportAwareScopeProvider method createNamespaceResolver.
protected List<ImportNormalizer> createNamespaceResolver(Scope scope, boolean ignoreCase) {
List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
ImportScope importScope = (ImportScope) scope;
for (String child : importScope.getImports()) {
Optional<PackageImport> pkgImport = mapper.findPackageImport(scope.eResource(), child);
if (pkgImport.isPresent()) {
ImportNormalizer resolver = createImportedNamespaceResolver(pkgImport.get().getNamespace(), ignoreCase);
if (resolver != null)
importedNamespaceResolvers.add(resolver);
}
}
return importedNamespaceResolvers;
}
use of org.yakindu.sct.model.stext.stext.ImportScope in project statecharts by Yakindu.
the class StextImportAwareScopeProvider method internalGetImportedNamespaceResolvers.
@Override
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) {
List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
List<ImportScope> importScopes = null;
if (context instanceof StateSpecification || context instanceof TransitionSpecification) {
importScopes = EcoreUtil2.getAllContentsOfType(getStatechart(context), ImportScope.class);
} else {
importScopes = EcoreUtil2.getAllContentsOfType(context, ImportScope.class);
}
for (ImportScope scope : importScopes) {
importedNamespaceResolvers.addAll(createNamespaceResolver(scope, ignoreCase));
}
return importedNamespaceResolvers;
}
Aggregations