use of org.yakindu.sct.model.stext.scoping.IPackageImport2URIMapper.PackageImport in project statecharts by Yakindu.
the class STextProposalProvider method completeImportScope_Imports.
@Override
public void completeImportScope_Imports(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
StringProposalDelegate stringProposalDelegate = new StringProposalDelegate(acceptor, context);
Set<PackageImport> allImports = mapper.getAllImports(model.eResource());
for (PackageImport pkgImport : allImports) {
ConfigurableCompletionProposal doCreateProposal = doCreateProposal("\"" + pkgImport.getName() + "\"", computePackageStyledString(pkgImport), getIncludeImage(), pkgImport.getUri().isFile() ? -1 : 1, context);
stringProposalDelegate.accept(doCreateProposal);
}
}
use of org.yakindu.sct.model.stext.scoping.IPackageImport2URIMapper.PackageImport 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.scoping.IPackageImport2URIMapper.PackageImport 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;
}
Aggregations