/** * Retrieves value of "prefix" node of the YANG module, which is identified by the given {@code * info}. * * @param info {@link ElementIndexInfo}, which identifies the quested module * @return value of "prefix" node, if it existed; an empty string otherwise. */ public static String retrieveModulePrefix(ElementIndexInfo info) { String defaultPrefix = ""; try { Module importedModule = YangCorePlugin.createYangFile(info.getPath()).getModule(); SimpleNode<String> prefixNode = importedModule.getPrefix(); if (prefixNode != null) { defaultPrefix = prefixNode.getValue(); } } catch (YangModelException ex) { YangCorePlugin.log(ex, "Yang source file could not be loaded."); } return defaultPrefix; }
@Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { @SuppressWarnings("deprecation") String info = super.getHoverInfo(textViewer, hoverRegion); if (info != null) { return HelpCompositionUtils.wrapHtmlText(info, null); } String hoverInfo = null; YangEditor editor = (YangEditor) getEditor(); if (editor != null) { try { Module module = editor.getModule(); if (module != null) { ASTNode node = module.getNodeAtPosition(hoverRegion.getOffset()); hoverInfo = HelpCompositionUtils.getNodeHelp(node); } } catch (YangModelException e) { YangCorePlugin.log(e); } } return hoverInfo; }