Author: scabanovich
Date: 2012-04-24 20:57:58 -0400 (Tue, 24 Apr 2012)
New Revision: 40462
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
Log:
JBIDE-11539
https://issues.jboss.org/browse/JBIDE-11539
Unnecessary reference to document is removed.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2012-04-24
23:41:56 UTC (rev 40461)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2012-04-25
00:57:58 UTC (rev 40462)
@@ -386,9 +386,8 @@
if (context != null) {
IDOMDocument domDocument = domModel.getDocument();
context.setResource(file);
- if (document != null && context instanceof XmlContextImpl) {
- // Renew the document in context, since it might be cleared by
context.setResource() call
- ((XmlContextImpl)context).setDocument(document);
+ if (document == null && context instanceof XmlContextImpl) {
+ document = model.getStructuredDocument();
}
IProject project = file != null ? file.getProject() : getActiveProject();
@@ -396,7 +395,7 @@
context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(project));
if (context instanceof JspContextImpl && !(context instanceof
FaceletPageContextImpl)) {
// Fill JSP namespaces defined in TLDCMDocumentManager
- fillJSPNameSpaces((JspContextImpl)context);
+ fillJSPNameSpaces((JspContextImpl)context, document);
}
// The subsequently called functions may use the file and document
// already stored in context for their needs
@@ -520,9 +519,9 @@
* @param context
*/
@SuppressWarnings("rawtypes")
- private static void fillJSPNameSpaces(JspContextImpl context) {
- TLDCMDocumentManager manager =
TaglibController.getTLDCMDocumentManager(context.getDocument());
- List trackers = (manager == null? null :
manager.getCMDocumentTrackers(context.getDocument().getLength() - 1));
+ private static void fillJSPNameSpaces(JspContextImpl context, IDocument document) {
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+ List trackers = (manager == null? null :
manager.getCMDocumentTrackers(document.getLength() - 1));
for (int i = 0; trackers != null && i < trackers.size(); i++) {
TaglibTracker tt = (TaglibTracker)trackers.get(i);
final String prefix = tt.getPrefix() == null ? null : tt.getPrefix().trim();
@@ -530,7 +529,7 @@
if (prefix != null && prefix.length() > 0 &&
uri != null && uri.length() > 0) {
- IRegion region = new Region(0, context.getDocument().getLength());
+ IRegion region = new Region(0, document.getLength());
INameSpace nameSpace = new NameSpace(
uri, prefix,
TagLibraryManager.getLibraries(
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2012-04-24
23:41:56 UTC (rev 40461)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2012-04-25
00:57:58 UTC (rev 40462)
@@ -17,7 +17,6 @@
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -36,20 +35,13 @@
*
*/
public class XmlContextImpl extends ELContextImpl implements IXmlContext {
- protected IDocument document;
// Fix for JBIDE-5097: It must be a map of <IRegion to Map of <NS-Prefix to
NS>>
protected Map<IRegion, Map<String, INameSpace>> nameSpaces = new
HashMap<IRegion, Map<String, INameSpace>>();
protected Set<String> uris = new HashSet<String>();
- /**
- * Sets up the context resource and retrieves the document for the specified resource
- */
- @Override
- public void setResource(IFile resource) {
- super.setResource(resource);
-
- document = null;
+ public IDocument getDocument() {
+ IDocument document = null;
if (resource != null) {
FileEditorInput editorInput = null;
try {
@@ -59,24 +51,9 @@
releaseConnectedDocument(editorInput);
}
}
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.PageContext#getDocument()
- */
- public IDocument getDocument() {
return document;
}
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.PageContext#getDocument()
- */
- public void setDocument(IDocument document) {
- this.document = document;
- }
-
+
/*
* TODO: the visibility must differ between 'include'-like and
'template'-like inclusion
*