Author: vrubezhny
Date: 2009-12-25 14:27:02 -0500 (Fri, 25 Dec 2009)
New Revision: 19593
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
Log:
JBIDE-5578: ClassCastException occures when the proper context cannot be created
Issue is fixed
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java 2009-12-25
18:51:18 UTC (rev 19592)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java 2009-12-25
19:27:02 UTC (rev 19593)
@@ -56,6 +56,9 @@
* @return
*/
public static boolean isOpenInActiveEditor(IFile file) {
+ if(file == null)
+ return false;
+
ITextEditor editor = EclipseUIUtil.getActiveEditor();
if (editor != null) {
IEditorInput editorInput = editor.getEditorInput();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-12-25
18:51:18 UTC (rev 19592)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-12-25
19:27:02 UTC (rev 19593)
@@ -13,10 +13,12 @@
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
import org.w3c.dom.Attr;
@@ -32,11 +34,19 @@
@SuppressWarnings("restriction")
public class FaceletPageContectAssistProcessor extends JspContentAssistProcessor {
private static final String JSFC_ATTRIBUTE_NAME = "jsfc"; //$NON-NLS-1$
-
private boolean replaceJsfcTags;
/*
* (non-Javadoc)
+ * @see
org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
+ */
+ @Override
+ protected ELContext createContext() {
+ return PageContextFactory.createPageContext(getResource(),
PageContextFactory.FACELETS_PAGE_CONTEXT_TYPE);
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#getContext()
*/
@Override
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-12-25
18:51:18 UTC (rev 19592)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-12-25
19:27:02 UTC (rev 19593)
@@ -39,6 +39,7 @@
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -54,8 +55,18 @@
*/
@SuppressWarnings("restriction")
public class JspContentAssistProcessor extends XmlContentAssistProcessor {
+
/*
* (non-Javadoc)
+ * @see
org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
+ */
+ @Override
+ protected ELContext createContext() {
+ return PageContextFactory.createPageContext(getResource(),
PageContextFactory.JSP_PAGE_CONTEXT_TYPE);
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#getContext()
*/
@Override
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-12-25
18:51:18 UTC (rev 19592)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-12-25
19:27:02 UTC (rev 19593)
@@ -46,7 +46,7 @@
*/
@Override
protected ELContext createContext() {
- return PageContextFactory.createPageContext(getResource());
+ return PageContextFactory.createPageContext(getResource(),
PageContextFactory.XML_PAGE_CONTEXT_TYPE);
}
@Override
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 2009-12-25
18:51:18 UTC (rev 19592)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-12-25
19:27:02 UTC (rev 19593)
@@ -86,6 +86,7 @@
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.common.util.EclipseUIUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jst.web.kb.el.KbELReference;
import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
@@ -158,15 +159,25 @@
}
/**
- * Creates a page context for the specified context type
+ * Creates a page context for the specified context file
*
* @param file
* @param contentType
* @return
*/
public static ELContext createPageContext(IFile file) {
- return getInstance().createPageContext(file, null);
+ return createPageContext(file, null);
}
+ /**
+ * Creates a page context for the specified context type
+ *
+ * @param file
+ * @param contentType
+ * @return
+ */
+ public static ELContext createPageContext(IFile file, String contextType) {
+ return getInstance().createPageContext(file, null, contextType);
+ }
/**
* Cleans up the context for the file specified
@@ -316,13 +327,14 @@
* @param parents List of parent contexts
* @return
*/
- private ELContext createPageContext(IFile file, List<String> parents) {
- ELContext context = parents == null ? null : getSavedContext(file);
+ private ELContext createPageContext(IFile file, List<String> parents, String
defaultContextType) {
+ boolean isContextCachingAllowed = !EclipseUIUtil.isOpenInActiveEditor(file) &&
file != null;
+ ELContext context = isContextCachingAllowed ? getSavedContext(file) : null;
if (context != null) {
return context;
}
if (file == null)
- return createPageContextInstance(null);
+ return createContextInstanceOfType(defaultContextType);
IContentType type = IDE.getContentType(file);
String typeId = (type == null ? null : type.getId());
@@ -349,7 +361,9 @@
IDOMModel domModel = (IDOMModel) model;
IDOMDocument document = domModel.getDocument();
- context = createPageContextInstance(domModel.getContentTypeIdentifier());
+ context = defaultContextType == null ?
+ createPageContextInstance(domModel.getContentTypeIdentifier()) :
+ createContextInstanceOfType(defaultContextType);
if (context == null)
return null;
@@ -376,7 +390,7 @@
}
}
- if (context != null && parents != null) {
+ if (context != null && isContextCachingAllowed) {
saveConvext(context);
}
@@ -385,6 +399,10 @@
private ELContext createPageContextInstance(String contentType) {
String contextType = IncludeContextBuilder.getContextType(contentType);
+ return createContextInstanceOfType(contextType);
+ }
+
+ private ELContext createContextInstanceOfType(String contextType) {
if (JSP_PAGE_CONTEXT_TYPE.equals(contextType)) {
return new JspContextImpl();
} else if (FACELETS_PAGE_CONTEXT_TYPE.equals(contextType)) {
@@ -392,7 +410,6 @@
}
return new XmlContextImpl();
}
-
/**
* Sets up the context with namespaces and according libraries from the
TagLibraryManager
*
@@ -546,7 +563,7 @@
continue;
// Fix for JBIDE-5083 <<<
- ELContext includedContext = createPageContext(file, newParentList);
+ ELContext includedContext = createPageContext(file, newParentList, null);
if (includedContext != null)
((IIncludedContextSupport)context).addIncludedContext(includedContext);
}
Show replies by date