5. 使用如下的代码替换internalCreate中的代码
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;
}
6. 下面让我们加一个private方法来建立符号(Symbol)。