扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:atomic_age 来源:天极开发 2007年10月13日
关键字:
在本页阅读全文(共4页)
protected ISymbol internalCreate(String symbolName, int scope, IAdaptable context, List problems) { //得到上下文 final IStructuredDocumentContext sContext =(IStructuredDocumentContext) context.getAdapter(IstructuredDocumentContext.class); // 为上下文建立一个DOM上下文 final IDOMContextResolver domResolver = IStructuredDocumentContextResolverFactory.INSTANCE.getDOMContextResolver(sContext); if (domResolver != null) { final Node curNode = domResolver.getNode(); // node必须是XML属性 if (curNode instanceof Attr) { final Attr attr = (Attr) curNode; final Node owningElement = attr.getOwnerElement(); if (owningElement != null) { IProject iProject = workspaceResolver.getProject(); if (iProject != null) { return handleSymbolCreation(symbolName, sContext, attr, owningElement, iProject); } } } } return null; } |
private ISymbol handleSymbolCreation(final String symbolName, final IStructuredDocumentContext context, final Attr attr, final Node owningElement, final IProject project) { // 建立Tab库 final ITaglibContextResolver resolver =IStructuredDocumentContextResolverFactory.INSTANCE .getTaglibContextResolver(context); if (resolver == null || !resolver.canResolveContext(context)) { return null; } final String uri = resolver.getTagURIForNodeName(owningElement); IBeanInstanceSymbol beanSymbol = null; // 处理核心标签库 if ("http://oracle.com/tutorial/fake/taglib".equals(uri)) { final String elementName = owningElement.getLocalName(); final String attrName = attr.getName(); if ("locallyDeclaredBean".equals(elementName)) { if ("var".equals(attrName)) { final NamedNodeMap attrMap = owningElement.getAttributes(); final Node baseNameNode = attrMap.getNamedItem("classname"); if (baseNameNode instanceof Attr) { // 得到bean的名字 final String className = ((Attr)baseNameNode).getValue(); // 建立一个新的空Bean实例符号 beanSymbol = SymbolFactory.eINSTANCE.createIBeanInstanceSymbol(); beanSymbol.setName(attr.getValue()); try { IJavaProject javaProject = JavaCore.create(project); IType type = javaProject.findType(className); if (type != null) { IJavaTypeDescriptor2 javaTypeDescriptor = SymbolFactory.eINSTANCE.createIJavaTypeDescriptor2(); javaTypeDescriptor.setType(type); beanSymbol.setJavaTypeDescriptor(javaTypeDescriptor); } } catch (JavaModelException jme) { } } } } } return beanSymbol; } |
<t:locallyDeclaredBean var="x" classname="beans.MyBean"/> |
图4 |
<?xml version="1.0" encoding="UTF-8"?> <grammar-annotation xmlns="http://org.eclipse.jsf.core/grammarAnnotationSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.eclipse.jsf.core/grammarAnnotationSchema D:\\EclipseWTPLatest\\WTPWorkspace\\org.eclipse.jst.jsf.core\\schema\\grammar-annotations.xsd "> <cm-element name="locallyDeclaredBean"> <cm-attribute name="var"> <property name="contributes-value-binding"> < value>true</value> </property> <property name="value-binding-scope"> <value>request</value> </property> <property name="value-binding-symbol-factory"> <value>tutorial.locallyDeclaredBean</value> </property> </cm-attribute> </cm-element> </grammar-annotation> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者