JBoss Tools SVN: r19596 - trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-12-28 08:00:01 -0500 (Mon, 28 Dec 2009)
New Revision: 19596
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java
Log:
JBIDE-5579: NullPointerException in EclipseUIUtil.getActiveEditor().
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-28 11:43:38 UTC (rev 19595)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java 2009-12-28 13:00:01 UTC (rev 19596)
@@ -42,7 +42,7 @@
if (editor instanceof ITextEditor) {
return (ITextEditor) editor;
} else {
- return (ITextEditor) editor.getAdapter(ITextEditor.class);
+ return editor == null ? null : (ITextEditor)editor.getAdapter(ITextEditor.class);
}
}
}
15 years
JBoss Tools SVN: r19595 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-12-28 06:43:38 -0500 (Mon, 28 Dec 2009)
New Revision: 19595
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5383
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-25 19:28:46 UTC (rev 19594)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-28 11:43:38 UTC (rev 19595)
@@ -521,7 +521,7 @@
synchronized (namedBeans) {
if(attemptToResolveAmbiguousNames) {
Set<String> names = new HashSet<String>();
- for (IBean bean : result) {
+ for (IBean bean : namedBeans) {
if(names.contains(bean.getName())) {
continue;
}
15 years
JBoss Tools SVN: r19594 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/el and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-12-25 14:28:46 -0500 (Fri, 25 Dec 2009)
New Revision: 19594
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5383
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2009-12-25 19:27:02 UTC (rev 19593)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2009-12-25 19:28:46 UTC (rev 19594)
@@ -27,10 +27,18 @@
/**
* Returns all @Named beans.
- *
+ *
+ * @param attemptToResolveAmbiguousNames
+ * if there are a few beans with the same name and
+ * attemptToResolveAmbiguousNames==true the manager should try to
+ * resolve the EL name. If any of the beans are alternatives, the
+ * manager will eliminate all beans that are not alternatives,
+ * expect for producer methods and fields of beans that are
+ * alternatives. If the name of a bean is not resolvable then
+ * both beans would be included in the result list.
* @return all @Named beans
*/
- Set<IBean> getNamedBeans();
+ Set<IBean> getNamedBeans(boolean attemptToResolveAmbiguousNames);
/**
* Returns the set of beans which match the given EL name.
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java 2009-12-25 19:27:02 UTC (rev 19593)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java 2009-12-25 19:28:46 UTC (rev 19594)
@@ -95,7 +95,7 @@
resolvedBeans = manager.getBeans(varName, true);
beans.addAll(resolvedBeans);
} else {
- resolvedBeans = manager.getNamedBeans();
+ resolvedBeans = manager.getNamedBeans(true);
for (IBean bean : resolvedBeans) {
if(bean.getName().startsWith(varName)) {
beans.add(bean);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-25 19:27:02 UTC (rev 19593)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-25 19:28:46 UTC (rev 19594)
@@ -27,7 +27,6 @@
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDICoreNature;
-import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
@@ -153,7 +152,7 @@
public Set<IBean> getBeans(boolean attemptToResolveAmbiguousDependency,
IType beanType, IAnnotationDeclaration... qualifiers) {
- // TODO Auto-generated method stub
+ // TODO
return null;
}
@@ -514,12 +513,29 @@
/*
* (non-Javadoc)
- * @see org.jboss.tools.cdi.core.IBeanManager#getNamedBeans()
+ * @see org.jboss.tools.cdi.core.IBeanManager#getNamedBeans(boolean)
*/
- public Set<IBean> getNamedBeans() {
+ public Set<IBean> getNamedBeans(boolean attemptToResolveAmbiguousNames) {
+ //TODO use a cache for named beans with attemptToResolveAmbiguousNames==true
Set<IBean> result = new HashSet<IBean>();
synchronized (namedBeans) {
- result.addAll(namedBeans);
+ if(attemptToResolveAmbiguousNames) {
+ Set<String> names = new HashSet<String>();
+ for (IBean bean : result) {
+ if(names.contains(bean.getName())) {
+ continue;
+ }
+ Set<IBean> beans = getBeans(bean.getName(), attemptToResolveAmbiguousNames);
+ if(beans.isEmpty()) {
+ result.add(bean);
+ } else {
+ result.addAll(beans);
+ names.add(bean.getName());
+ }
+ }
+ } else {
+ result.addAll(namedBeans);
+ }
}
return result;
}
15 years
JBoss Tools SVN: r19593 - in trunk: jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist and 1 other directories.
by jbosstools-commits@lists.jboss.org
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);
}
15 years
JBoss Tools SVN: r19592 - trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-12-25 13:51:18 -0500 (Fri, 25 Dec 2009)
New Revision: 19592
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5383
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2009-12-25 18:50:39 UTC (rev 19591)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2009-12-25 18:51:18 UTC (rev 19592)
@@ -382,7 +382,7 @@
String elStartChar = "#"; //$NON-NLS-1$
String documentContent = ref.getELModel().getSource();
// Is '}'-bracket exists? If not - add the
- if(getELEndPosition(offset + proposalPrefix.length(), documentContent) == -1) {
+ if(getELEndPosition(offset - ref.getStartPosition(), documentContent) == -1) {
proposalSufix = "}"; //$NON-NLS-1$
}
15 years
JBoss Tools SVN: r19591 - trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-12-25 13:50:39 -0500 (Fri, 25 Dec 2009)
New Revision: 19591
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
Log:
JBIDE-3378: Seam EL validation does not use same technique as the EL resolver (Continued)
The methods are also proposed for the getters/setters
The validator says OK on methods like isSomethingToBeHere() in EL
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2009-12-25 18:43:15 UTC (rev 19590)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2009-12-25 18:50:39 UTC (rev 19591)
@@ -958,7 +958,8 @@
if (((info.getSourceType()!=null && info.getSourceType().isInterface()) || info.isPublic())
&& !info.isConstructor()
&& !info.isStatic() && !info.isJavaLangObject()
- && !info.isGetter() && !info.isSetter()) {
+// && !info.isGetter() && !info.isSetter() // Fix for JBIDE-3378
+ ) {
methods.add(info);
}
} catch (JavaModelException e) {
15 years
JBoss Tools SVN: r19590 - trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-12-25 13:43:15 -0500 (Fri, 25 Dec 2009)
New Revision: 19590
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5383
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2009-12-25 18:19:49 UTC (rev 19589)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2009-12-25 18:43:15 UTC (rev 19590)
@@ -77,7 +77,7 @@
ELReference ref = context.getELReference(offset);
if(ref!=null) {
for (ELExpression expresion : ref.getEl()) {
- if(ref.getStartPosition() + expresion.getStartPosition()<=offset && (ref.getStartPosition() + expresion.getEndPosition()>offset)) {
+ if(ref.getStartPosition() + expresion.getStartPosition()<=offset && (ref.getStartPosition() + expresion.getEndPosition()>=offset)) {
ELInvocationExpression ie = ELUtil.findExpression(expresion.getModel(), offset - ref.getStartPosition());
String el = "#{"; //$NON-NLS-1$
if(ie!=null) {
15 years
JBoss Tools SVN: r19589 - in trunk: cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca and 22 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-12-25 13:19:49 -0500 (Fri, 25 Dec 2009)
New Revision: 19589
Added:
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/IEditorWrapper.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/KbELProposalProcessor.java
Removed:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/IEditorWrapper.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/CDIELProposalProcessor.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java
trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java
trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
trunk/struts/tests/org.jboss.tools.struts.text.ext.test/META-INF/MANIFEST.MF
Log:
https://jira.jboss.org/jira/browse/JBIDE-5383
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -16,7 +16,8 @@
org.eclipse.wst.xml.ui,
org.eclipse.jdt.ui,
org.eclipse.jface.text,
- org.eclipse.wst.sse.ui
+ org.eclipse.wst.sse.ui,
+ org.jboss.tools.jst.web.kb
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor.0
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/CDIELProposalProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/CDIELProposalProcessor.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/ca/CDIELProposalProcessor.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -16,12 +16,12 @@
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.internal.core.el.CdiElResolver;
-import org.jboss.tools.common.el.ui.ca.ELProposalProcessor;
+import org.jboss.tools.jst.web.kb.el.KbELProposalProcessor;
/**
* @author Alexey Kazakov
*/
-public class CDIELProposalProcessor extends ELProposalProcessor {
+public class CDIELProposalProcessor extends KbELProposalProcessor {
/*
* (non-Javadoc)
Modified: trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -140,7 +140,9 @@
org.eclipse.wst.common.uriresolver;visibility:=reexport,
org.eclipse.core.net,
org.eclipse.jdt.core,
- org.eclipse.jdt.ui
+ org.eclipse.jdt.ui,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.jface.text
Bundle-Version: 2.0.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ManifestVersion: 2
Added: 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 (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.util;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class EclipseUIUtil {
+
+ /**
+ * Returns the active text editor.
+ *
+ * @return
+ */
+ public static ITextEditor getActiveEditor() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ IEditorPart editor = page.getActiveEditor();
+ if (editor instanceof IEditorWrapper) {
+ editor = ((IEditorWrapper) editor).getEditor();
+ }
+ if (editor instanceof ITextEditor) {
+ return (ITextEditor) editor;
+ } else {
+ return (ITextEditor) editor.getAdapter(ITextEditor.class);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the file is open in active editor.
+ *
+ * @param file
+ * @return
+ */
+ public static boolean isOpenInActiveEditor(IFile file) {
+ ITextEditor editor = EclipseUIUtil.getActiveEditor();
+ if (editor != null) {
+ IEditorInput editorInput = editor.getEditorInput();
+ if (editorInput instanceof IFileEditorInput) {
+ IFileEditorInput fileInput = (IFileEditorInput) editorInput;
+ return file.equals(fileInput.getFile());
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseUIUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -44,6 +44,11 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.common.CommonPlugin;
public final class FileUtil {
@@ -713,14 +718,14 @@
}
return null;
}
-
+
static boolean startsWith(byte[] bs, byte[] prefix) {
for (int i = 0; i < prefix.length; i++) {
if(bs[i] != prefix[i]) return false;
}
return true;
}
-
+
static int getIndex(byte[] bs, byte b, int offset) {
for (int i = offset; i < bs.length; i++) {
if(bs[i] == b) return i;
@@ -728,4 +733,38 @@
return -1;
}
-}
+ /**
+ * Returns the content of the file. If this file is open in an active editor
+ * then the content of the editor will be returned.
+ *
+ * @param file
+ * @return
+ */
+ public static String getContentFromEditorOrFile(IFile file) {
+ ITextEditor editor = EclipseUIUtil.getActiveEditor();
+ if (editor != null) {
+ IEditorInput editorInput = editor.getEditorInput();
+ if (editorInput instanceof IFileEditorInput) {
+ IFileEditorInput fileInput = (IFileEditorInput) editorInput;
+ if (file.equals(fileInput.getFile())) {
+ IDocumentProvider dp = editor.getDocumentProvider();
+ try {
+ dp.connect(fileInput);
+ IDocument doc = dp.getDocument(fileInput);
+ return doc.get();
+ } catch (CoreException e) {
+ CommonPlugin.getDefault().logError(e);
+ } finally {
+ dp.disconnect(fileInput);
+ }
+ }
+ }
+ }
+ try {
+ return FileUtil.readStream(file);
+ } catch (CoreException e) {
+ CommonPlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/IEditorWrapper.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/IEditorWrapper.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/IEditorWrapper.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.util;
+
+import org.eclipse.ui.IEditorPart;
+
+public interface IEditorWrapper {
+ public IEditorPart getEditor();
+
+}
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -47,6 +47,7 @@
private IMarker[] markerArray;
private boolean needToInitMarkers = false;
private List<SyntaxError> syntaxErrors;
+ private String source;
/* (non-Javadoc)
* @see org.jboss.tools.seam.core.ISeamTextSourceReference#getLength()
@@ -111,19 +112,20 @@
this.path = path;
}
+ public String getSourceText() {
+ if(source==null) {
+ source = getELModel().getSource();
+ }
+ return source;
+ }
+
/**
* @return the el
*/
public ELExpression[] getEl() {
if(el==null) {
Set<ELExpression> exps = new HashSet<ELExpression>();
- String content = null;
- try {
- content = FileUtil.readStream(getResource());
- } catch (CoreException e) {
- ELCorePlugin.getDefault().logError(e);
- }
- String elText = content.substring(startPosition, startPosition + length);
+ String elText = FileUtil.getContentFromEditorOrFile(resource);
int startEl = elText.indexOf("#{"); //$NON-NLS-1$
if(startEl>-1) {
ELParser parser = ELParserUtil.getJbossFactory().createParser();
@@ -306,4 +308,12 @@
public int hashCode() {
return path.hashCode() + startPosition;
}
+
+ public ELModel getELModel() {
+ ELExpression[] exprs = getEl();
+ if(exprs.length>0) {
+ return exprs[0].getModel();
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.el.core.ca;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -27,6 +28,7 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.common.el.core.ELCorePlugin;
+import org.jboss.tools.common.el.core.ELReference;
import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInstance;
@@ -68,6 +70,26 @@
private static ELParserFactory defaultFactory = ELParserUtil.getJbossFactory();
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.ELResolver#getProposals(org.jboss.tools.common.el.core.resolver.ELContext, int)
+ */
+ public List<TextProposal> getProposals(ELContext context, int offset) {
+ ELReference ref = context.getELReference(offset);
+ if(ref!=null) {
+ for (ELExpression expresion : ref.getEl()) {
+ if(ref.getStartPosition() + expresion.getStartPosition()<=offset && (ref.getStartPosition() + expresion.getEndPosition()>offset)) {
+ ELInvocationExpression ie = ELUtil.findExpression(expresion.getModel(), offset - ref.getStartPosition());
+ String el = "#{"; //$NON-NLS-1$
+ if(ie!=null) {
+ el = el + ref.getSourceText().substring(ie.getStartPosition(), offset - ref.getStartPosition());
+ }
+ return getProposals(context, el, offset);
+ }
+ }
+ }
+ return Collections.emptyList();
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.tools.common.el.core.resolver.ELResolver2#getProposals(org.jboss.tools.common.el.core.resolver.ELContext, java.lang.String)
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -42,6 +42,13 @@
ELReference[] getELReferences();
/**
+ * Returns the EL reference by the offset.
+ *
+ * @return
+ */
+ ELReference getELReference(int offset);
+
+ /**
* Returns EL Resolvers which are declared for this resource
* @return
*/
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -30,6 +30,7 @@
* (non-Javadoc)
* @see org.jboss.tools.common.el.core.resolver.ELContext#getVars()
*/
+ @Override
public Var[] getVars() {
return allVars.toArray(new Var[allVars.size()]);
}
@@ -48,6 +49,7 @@
* (non-Javadoc)
* @see org.jboss.tools.common.el.core.resolver.ELContext#getVars(int)
*/
+ @Override
public Var[] getVars(int offset) {
if(offset<0) {
return getVars();
@@ -82,6 +84,7 @@
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.IXmlContext#getELReferences()
*/
+ @Override
public ELReference[] getELReferences() {
if(elReferences==null) {
if(elReferenceSet==null || elReferenceSet.isEmpty()) {
@@ -99,4 +102,18 @@
elReferenceSet.add(reference);
elReferences = null;
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.SimpleELContext#getELReference(int)
+ */
+ @Override
+ public ELReference getELReference(int offset) {
+ ELReference[] refs = getELReferences();
+ for (int i = 0; i < refs.length; i++) {
+ if(refs[i].getStartPosition()<=offset && (refs[i].getStartPosition() + refs[i].getLength()>offset)) {
+ return refs[i];
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -30,6 +30,12 @@
List<TextProposal> getProposals(ELContext context, String el, int offset);
/**
+ * @param context
+ * @return proposal list
+ */
+ List<TextProposal> getProposals(ELContext context, int offset);
+
+ /**
* Resolves EL operand.
* @param context
* @param operand
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -96,4 +96,12 @@
public Var[] getVars(int offset) {
return getVars();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.ELContext#getELReference(int)
+ */
+ public ELReference getELReference(int offset) {
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -15,7 +15,8 @@
org.eclipse.jdt.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.wst.xml.ui
+ org.eclipse.wst.xml.ui,
+ org.jboss.tools.common.ui
Bundle-Vendor: %Bundle-Vendor.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.jboss.tools.vpe.resref.core
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -34,40 +34,26 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceCompletionProposal;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
+import org.jboss.tools.common.el.core.ELReference;
import org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.model.ELUtil;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
-import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
-import org.jboss.tools.common.el.core.resolver.SimpleELContext;
-import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.el.ui.ElUiPlugin;
-import org.jboss.tools.common.model.ui.texteditors.xmleditor.XMLTextEditor;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.common.text.ext.IEditorWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.common.util.EclipseUIUtil;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -348,6 +334,8 @@
abstract protected Image getImage();
+ abstract protected ELContext getELContext(IFile file);
+
/**
*
* @param start start of relevant region in document
@@ -356,134 +344,167 @@
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset, int start, int end) {
- try {
- ITextEditor part = getActiveEditor();
- if (part == null) {
- return NO_PROPOSALS;
- }
+ ITextEditor part = EclipseUIUtil.getActiveEditor();
+ if (part == null) {
+ return NO_PROPOSALS;
+ }
- IEditorInput editorInput = part.getEditorInput();
- if (!(editorInput instanceof IFileEditorInput)) {
- return NO_PROPOSALS;
- }
+ IEditorInput editorInput = part.getEditorInput();
+ if (!(editorInput instanceof IFileEditorInput)) {
+ return NO_PROPOSALS;
+ }
- IFile file = ((IFileEditorInput)editorInput).getFile();
- if (!isEnabled(file)) {
- return NO_PROPOSALS;
- }
+ IFile file = ((IFileEditorInput) editorInput).getFile();
+ if (!isEnabled(file)) {
+ return NO_PROPOSALS;
+ }
- //TODO Now this will work only for EL.
- // If we need CA for expressions/variables without #{}, it should be handled separately.
+ ELContext context = getELContext(file);
+ if (context == null) {
+ return NO_PROPOSALS;
+ }
- boolean isInEl = checkStartPositionInEL(viewer, offset);
- String prefix= getPrefix(viewer, offset, start, end);
+ ELReference ref = context.getELReference(offset);
+ if(ref==null) {
+ return NO_PROPOSALS;
+ }
- // JBIDE-3290 Quick-fix - this supresses the EL-proposals suggestions
- // in case of no "#{"-prefix is typed
+ ELResolver[] resolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
- if (!isInEl) {
- return NO_PROPOSALS;
- }
+ List<ICompletionProposal> resultList = new ArrayList<ICompletionProposal>();
- prefix = (prefix == null ? "" : prefix); //$NON-NLS-1$
+ String prefix= getPrefix(viewer, offset, start, end);
- String proposalPrefix = ""; //$NON-NLS-1$
- String proposalSufix = ""; //$NON-NLS-1$
- String elStartChar = "#"; //$NON-NLS-1$
- String documentContent = null;
- IDocument document = viewer.getDocument();
- if (!isInEl) {
- // Work only with attribute value for JSP/HTML
- if((part instanceof XMLTextEditor) || (!isAttributeValue(viewer, offset))) {
- return NO_PROPOSALS;
- }
- prefix = ""; // Clear prefix because it's not the part of EL //$NON-NLS-1$
- if(isCharSharp(viewer, offset-1) || isCharDollar(viewer, offset-1)) {
- proposalPrefix = "{"; //$NON-NLS-1$
- if (isCharDollar(viewer, offset-1)) {
- elStartChar = "$"; //$NON-NLS-1$
+ prefix = (prefix == null ? "" : prefix); //$NON-NLS-1$
+
+ String proposalPrefix = ""; //$NON-NLS-1$
+ String proposalSufix = ""; //$NON-NLS-1$
+ String elStartChar = "#"; //$NON-NLS-1$
+ String documentContent = ref.getELModel().getSource();
+ // Is '}'-bracket exists? If not - add the
+ if(getELEndPosition(offset + proposalPrefix.length(), documentContent) == -1) {
+ proposalSufix = "}"; //$NON-NLS-1$
+ }
+
+ for (int i = 0; i < resolvers.length; i++) {
+ List<TextProposal> suggestions = resolvers[i].getProposals(context,
+ offset);
+ List<TextProposal> uniqueSuggestions = AbstractELCompletionEngine
+ .makeProposalsUnique(suggestions);
+
+ for (TextProposal kbProposal : uniqueSuggestions) {
+ String string = kbProposal.getReplacementString();
+ Image image = kbProposal.hasImage() ? kbProposal.getImage()
+ : getImage();
+ if (string.length() >= 0) {
+ string = proposalPrefix + string + proposalSufix;
+ if (string.length() > 0 && ('#' == string.charAt(0) || '$' == string.charAt(0)))
+ string = elStartChar + string.substring(1);
+
+ if (string.startsWith("['") && string.endsWith("']") && prefix != null && prefix.endsWith(".")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ String newPrefix = prefix.substring(0, prefix.length() - 1);
+ resultList.add(new Proposal(string, prefix, newPrefix, offset, offset - 1 + string.length() - proposalSufix.length(), image));
+ } else {
+ resultList.add(new Proposal(string, prefix, offset, offset + string.length() - proposalSufix.length(), image));
}
- } else {
- proposalPrefix = "#{"; //$NON-NLS-1$
}
+ }
+ }
+ if (resultList.isEmpty()) {
+ return NO_PROPOSALS;
+ }
- if(document != null) {
- documentContent = document.get(0,offset) + proposalPrefix + document.get(offset, document.getLength() - offset);
- }
- } else {
- if(viewer.getDocument() != null) {
- documentContent = document.get();
- }
+ ICompletionProposal[] resultArray = new ICompletionProposal[resultList
+ .size()];
+ resultArray = resultList.toArray(resultArray);
+ Arrays.sort(resultArray, new Comparator<ICompletionProposal>() {
+ public int compare(ICompletionProposal arg0,
+ ICompletionProposal arg1) {
+ String str0 = (arg0 == null ? "" : arg0.getDisplayString()); //$NON-NLS-1$
+ String str1 = (arg1 == null ? "" : arg1.getDisplayString()); //$NON-NLS-1$
+ return str0.compareTo(str1);
}
+ });
+ return resultArray;
+ }
- // Is '}'-bracket exists? If not - add the
- if(getELEndPosition(offset + proposalPrefix.length(), documentContent) == -1) {
- proposalSufix = "}"; //$NON-NLS-1$
- }
+ /*
+ * Checks if the EL operand ending character is present
+ * @return
+ */
+ private int getELEndPosition(int initialOffset, String restOfCurrentValue) {
+ int offset = -1;
- ELResolver[] resolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
+ char inQuotesChar = 0;
+ while (++offset < restOfCurrentValue.length() - initialOffset) {
+ if (inQuotesChar == 0) {
+ if ('}' == restOfCurrentValue.charAt(initialOffset + offset))
+ return offset;
- List<ICompletionProposal> resultList = new ArrayList<ICompletionProposal>();
- for (int i = 0; i < resolvers.length; i++) {
+ if ('#' == restOfCurrentValue.charAt(initialOffset + offset))
+ return -1;
- if(isInEl && (prefix == null || prefix.length() == 0)) {
- String el = viewer.getDocument().get().substring(start, offset) + "a"; //$NON-NLS-1$
- ELModel model = resolvers[i].getParserFactory().createParser().parse(el);
- ELInvocationExpression expr = ELUtil.findExpression(model, el.length());
- if(expr == null) {
- break;
- }
- }
+ if ('<' == restOfCurrentValue.charAt(initialOffset + offset))
+ return -1;
- List<Var> vars = ElVarSearcher.findAllVars(viewer, offset, resolvers[i].getParserFactory());
+ if ('>' == restOfCurrentValue.charAt(initialOffset + offset))
+ return -1;
- SimpleELContext elContext = new SimpleELContext();
- elContext.setResource(file);
- elContext.setVars(vars);
- List<TextProposal> suggestions = resolvers[i].getProposals(elContext, prefix, offset);
- List<TextProposal> uniqueSuggestions = AbstractELCompletionEngine.makeProposalsUnique(suggestions);
+ if ('/' == restOfCurrentValue.charAt(initialOffset + offset) &&
+ (initialOffset + offset + 1 < restOfCurrentValue.length() &&
+ '>' == restOfCurrentValue.charAt(initialOffset + offset + 1)))
+ return -1;
- for (TextProposal kbProposal : uniqueSuggestions) {
- String string = kbProposal.getReplacementString();
- Image image = kbProposal.hasImage() ?
- kbProposal.getImage() :
- getImage();
+ if ('"' == restOfCurrentValue.charAt(initialOffset + offset) ||
+ '\'' == restOfCurrentValue.charAt(initialOffset + offset)) {
+ inQuotesChar = restOfCurrentValue.charAt(initialOffset + offset);
+ }
- if (string.length() >= 0) {
- string = proposalPrefix + string + proposalSufix;
- if (string.length() > 0 && ('#' == string.charAt(0) || '$' == string.charAt(0)))
- string = elStartChar + string.substring(1);
+ if ('\\' == restOfCurrentValue.charAt(initialOffset + offset)) {
+ int backslashCount = 1;
+
+ while ((initialOffset + offset + backslashCount) < restOfCurrentValue.length() &&
+ restOfCurrentValue.charAt(initialOffset + offset + backslashCount) == '\\') {
+ backslashCount++;
+ }
- if (string.startsWith("['") && string.endsWith("']") && prefix != null && prefix.endsWith(".")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- String newPrefix = prefix.substring(0, prefix.length() - 1);
- resultList.add(new Proposal(string, prefix, newPrefix, offset, offset - 1 + string.length() - proposalSufix.length(), image));
- } else {
- resultList.add(new Proposal(string, prefix, offset, offset + string.length() - proposalSufix.length(), image));
- }
- }
+ if (initialOffset + offset + backslashCount >= restOfCurrentValue.length())
+ return -1;
+
+ if (backslashCount % 2 == 1 &&
+ ('"' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount) ||
+ '\'' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount))) {
+ inQuotesChar = restOfCurrentValue.charAt(initialOffset + offset + backslashCount);
+ offset += backslashCount;
+ }
}
- }
- if (resultList.isEmpty()) {
- return NO_PROPOSALS;
- }
+ } else {
+ if ('"' == restOfCurrentValue.charAt(initialOffset + offset) ||
+ '\'' == restOfCurrentValue.charAt(initialOffset + offset)) {
+ inQuotesChar = 0;
+ }
- ICompletionProposal[] resultArray = new ICompletionProposal[resultList.size()];
- resultArray = resultList.toArray(resultArray);
- Arrays.sort(resultArray, new Comparator<ICompletionProposal>() {
- public int compare(ICompletionProposal arg0,
- ICompletionProposal arg1) {
- String str0 = (arg0 == null ? "" : arg0.getDisplayString()); //$NON-NLS-1$
- String str1 = (arg1 == null ? "" : arg1.getDisplayString()); //$NON-NLS-1$
- return str0.compareTo(str1);
- }});
- return resultArray;
- } catch (BadLocationException x) {
- ElUiPlugin.getDefault().logError(x);
- return NO_PROPOSALS;
- } catch (StringIndexOutOfBoundsException e) {
- ElUiPlugin.getDefault().logError(e);
- return NO_PROPOSALS;
+ if ('\\' == restOfCurrentValue.charAt(initialOffset + offset)) {
+ int backslashCount = 1;
+
+ while ((initialOffset + offset + backslashCount) < restOfCurrentValue.length() &&
+ restOfCurrentValue.charAt(initialOffset + offset + backslashCount) == '\\') {
+ backslashCount++;
+ }
+
+ if (initialOffset + offset + backslashCount >= restOfCurrentValue.length())
+ return -1;
+
+ if (backslashCount % 2 == 1 &&
+ ('"' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount) ||
+ '\'' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount))) {
+ inQuotesChar = 0;
+ offset += backslashCount;
+ }
+ }
+ }
}
+ return -1;
}
/**
@@ -522,26 +543,6 @@
return document.get().substring(expr.getStartPosition(), offset);
}
- private boolean isAttributeValue(ITextViewer viewer, int offset) {
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(viewer, offset);
-
- if(treeNode instanceof Node) {
- Node node = (Node) treeNode;
- while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) {
- node = node.getParentNode();
- }
- if(node instanceof IDOMNode) {
- IDOMNode xmlnode = (IDOMNode) node;
- ITextRegion completionRegion = getCompletionRegion(offset, node);
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE != completionRegion.getType())
- return false;
- ITextRegion nextRegion = getCompletionRegion(offset + 1, node);
- return DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE == nextRegion.getType();
- }
- }
- return false;
- }
-
/*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
*/
@@ -598,172 +599,4 @@
public String getErrorMessage() {
return null; // no custom error message
}
-
- /*
- * Returns active text editor
- * @return
- */
- private ITextEditor getActiveEditor() {
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page= window.getActivePage();
- if (page != null) {
- IEditorPart editor= page.getActiveEditor();
- if (editor instanceof IEditorWrapper)
- editor = ((IEditorWrapper) editor).getEditor();
-
- if (editor instanceof ITextEditor)
- return (ITextEditor) editor;
- else
- return (ITextEditor)editor.getAdapter(ITextEditor.class);
- }
- }
- return null;
- }
-
- private boolean isCharSharp(ITextViewer viewer, int offset) throws BadLocationException {
- IDocument doc= viewer.getDocument();
- if (doc == null || offset > doc.getLength() || offset < 0) {
- return false;
- }
-
- return '#' == doc.getChar(offset);
- }
-
- private boolean isCharDollar(ITextViewer viewer, int offset) throws BadLocationException {
- IDocument doc= viewer.getDocument();
- if (doc == null || offset > doc.getLength() || offset < 0) {
- return false;
- }
-
- return '$' == doc.getChar(offset);
- }
-
- /*
- * Checks if the EL start starting characters are present
- * @param viewer
- * @param offset
- * @return
- * @throws BadLocationException
- */
- private boolean checkStartPositionInEL(ITextViewer viewer, int offset) throws BadLocationException {
-
- // JBIDE-1676: Do not even try to get IStructuredDocument in case of not-a-structured document
- // This will prevent class cast exceptions while using the editors other than StructuredEditor
- // (CompilationUnitEditor, for example).
- IStructuredDocumentRegion sdRegion =
- (viewer.getDocument() instanceof IStructuredDocument ?
- ContentAssistUtils.getStructuredDocumentRegion(viewer, offset) :
- null);
- ITextRegion region = (sdRegion == null ? null : sdRegion.getRegionAtCharacterOffset(offset));
-
- int startIndex = (region == null ? 0 : sdRegion.getStartOffset() + region.getStart());
-
- IDocument doc= viewer.getDocument();
- if (doc == null || offset > doc.getLength())
- return false;
- int quotaCount = 0;
- while (--offset >= startIndex) {
- if ('}' == doc.getChar(offset))
- return false;
-
- if ('"' == doc.getChar(offset) || '\'' == doc.getChar(offset)) {
- int backslashCount = 0;
- while (doc.getChar(offset - 1 - backslashCount) == '\\') {
- backslashCount++;
- }
- if (backslashCount%2 == 0)
- quotaCount++;
- }
-
- if ('{' == doc.getChar(offset) &&
- (offset - 1) >= 0 &&
- ('#' == doc.getChar(offset - 1) ||
- '$' == doc.getChar(offset - 1))) {
- if(quotaCount % 2 == 0) {
- return true;
- }
- }
- }
- return false;
- }
-
- /*
- * Checks if the EL operand ending character is present
- * @return
- */
- private int getELEndPosition(int initialOffset, String restOfCurrentValue) {
- int offset = -1;
-
- char inQuotesChar = 0;
- while (++offset < restOfCurrentValue.length() - initialOffset) {
- if (inQuotesChar == 0) {
- if ('}' == restOfCurrentValue.charAt(initialOffset + offset))
- return offset;
-
- if ('#' == restOfCurrentValue.charAt(initialOffset + offset))
- return -1;
-
- if ('<' == restOfCurrentValue.charAt(initialOffset + offset))
- return -1;
-
- if ('>' == restOfCurrentValue.charAt(initialOffset + offset))
- return -1;
-
- if ('/' == restOfCurrentValue.charAt(initialOffset + offset) &&
- (initialOffset + offset + 1 < restOfCurrentValue.length() &&
- '>' == restOfCurrentValue.charAt(initialOffset + offset + 1)))
- return -1;
-
- if ('"' == restOfCurrentValue.charAt(initialOffset + offset) ||
- '\'' == restOfCurrentValue.charAt(initialOffset + offset)) {
- inQuotesChar = restOfCurrentValue.charAt(initialOffset + offset);
- }
-
- if ('\\' == restOfCurrentValue.charAt(initialOffset + offset)) {
- int backslashCount = 1;
-
- while ((initialOffset + offset + backslashCount) < restOfCurrentValue.length() &&
- restOfCurrentValue.charAt(initialOffset + offset + backslashCount) == '\\') {
- backslashCount++;
- }
-
- if (initialOffset + offset + backslashCount >= restOfCurrentValue.length())
- return -1;
-
- if (backslashCount % 2 == 1 &&
- ('"' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount) ||
- '\'' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount))) {
- inQuotesChar = restOfCurrentValue.charAt(initialOffset + offset + backslashCount);
- offset += backslashCount;
- }
- }
- } else {
- if ('"' == restOfCurrentValue.charAt(initialOffset + offset) ||
- '\'' == restOfCurrentValue.charAt(initialOffset + offset)) {
- inQuotesChar = 0;
- }
-
- if ('\\' == restOfCurrentValue.charAt(initialOffset + offset)) {
- int backslashCount = 1;
-
- while ((initialOffset + offset + backslashCount) < restOfCurrentValue.length() &&
- restOfCurrentValue.charAt(initialOffset + offset + backslashCount) == '\\') {
- backslashCount++;
- }
-
- if (initialOffset + offset + backslashCount >= restOfCurrentValue.length())
- return -1;
-
- if (backslashCount % 2 == 1 &&
- ('"' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount) ||
- '\'' == restOfCurrentValue.charAt(initialOffset + offset + backslashCount))) {
- inQuotesChar = 0;
- offset += backslashCount;
- }
- }
- }
- }
- return -1;
- }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -89,6 +89,7 @@
org.eclipse.jdt.launching,
org.eclipse.wst.html.core,
org.eclipse.pde.ui,
- org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)"
+ org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)",
+ org.jboss.tools.common.ui
Bundle-Version: 2.0.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/EditorPartWrapper.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -45,7 +45,7 @@
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.text.ext.IEditorWrapper;
+import org.jboss.tools.common.util.IEditorWrapper;
public class EditorPartWrapper extends EditorPart implements IReusableEditor, IEditorWrapper {
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -28,5 +28,6 @@
org.jboss.tools.common.el.core,
org.eclipse.emf.ecore;bundle-version="[2.5.0,3.0.0)",
org.eclipse.wst.css.core,
- org.eclipse.wst.html.core
+ org.eclipse.wst.html.core,
+ org.jboss.tools.common.ui
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Deleted: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/IEditorWrapper.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/IEditorWrapper.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/IEditorWrapper.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.text.ext;
-
-import org.eclipse.ui.IEditorPart;
-
-public interface IEditorWrapper {
- public IEditorPart getEditor();
-
-}
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -19,8 +19,8 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.common.text.ext.IEditorWrapper;
import org.jboss.tools.common.text.ext.IMultiPageEditor;
+import org.jboss.tools.common.util.IEditorWrapper;
/**
* @author Jeremy
Modified: trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/common/plugins/org.jboss.tools.common.ui/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -12,7 +12,9 @@
org.eclipse.core.resources,
org.eclipse.ui.ide,
org.eclipse.jst.j2ee.ui,
- org.eclipse.ui.forms
+ org.eclipse.ui.forms,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.jface.text
Export-Package: org.jboss.tools.common.ui,
org.jboss.tools.common.ui.preferences,
org.jboss.tools.common.ui.widget.editor,
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -22,6 +22,7 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
@@ -34,9 +35,9 @@
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.el.core.resolver.ELResolution;
import org.jboss.tools.common.el.core.resolver.ELResolutionImpl;
-import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELSegmentImpl;
import org.jboss.tools.common.el.core.resolver.IVariable;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -46,9 +47,13 @@
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-public class JSFMessageELCompletionEngine implements ELResolver {
+public class JSFMessageELCompletionEngine extends AbstractELCompletionEngine<IVariable> {
private static final Image JSF_EL_MESSAGES_PROPOSAL_IMAGE = JSFModelPlugin.getDefault().getImage(JSFModelPlugin.CA_JSF_MESSAGES_IMAGE_PATH);
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine#getELProposalImage()
+ */
public Image getELProposalImage() {
return JSF_EL_MESSAGES_PROPOSAL_IMAGE;
}
@@ -57,10 +62,18 @@
public JSFMessageELCompletionEngine() {}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.ELResolver#getParserFactory()
+ */
public ELParserFactory getParserFactory() {
return factory;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine#log(java.lang.Exception)
+ */
protected void log(Exception e) {
JSFModelPlugin.getPluginLog().logError(e);
}
@@ -497,4 +510,24 @@
return result;
}
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine#getMemberInfoByVariable(org.jboss.tools.common.el.core.resolver.IVariable, boolean)
+ */
+ @Override
+ protected MemberInfo getMemberInfoByVariable(IVariable var,
+ boolean onlyEqualNames) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine#resolveVariables(org.eclipse.core.resources.IFile, org.jboss.tools.common.el.core.model.ELInvocationExpression, boolean, boolean)
+ */
+ @Override
+ public List<IVariable> resolveVariables(IFile file,
+ ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -17,7 +17,8 @@
org.jboss.tools.common.model.ui;bundle-version="2.0.0",
org.eclipse.ui.ide;bundle-version="3.4.1",
org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
- org.eclipse.jst.j2ee;bundle-version="1.1.300"
+ org.eclipse.jst.j2ee;bundle-version="1.1.300",
+ org.jboss.tools.common.ui
Bundle-Localization: plugin
Bundle-ClassPath: jsf-ui-test.jar
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -27,7 +27,8 @@
org.jboss.tools.common.el.core;bundle-version="2.0.0",
org.jboss.tools.common.model.ui;bundle-version="2.0.0",
org.eclipse.wst.xml.ui;bundle-version="1.1.0",
- org.eclipse.jdt.ui;bundle-version="3.5.0"
+ org.eclipse.jdt.ui;bundle-version="3.5.0",
+ org.jboss.tools.common.ui
Bundle-ClassPath: jsf-test.jar
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
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 16:50:30 UTC (rev 19588)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -213,6 +213,10 @@
public ELResolution resolve(ELContext context, ELExpression operand, int offset) {
return new ELResolutionImpl(operand);
}
+
+ public List<TextProposal> getProposals(ELContext context, int offset) {
+ return Collections.emptyList();
+ }
};
ElVarSearcher varSearcher = new ElVarSearcher(file, fakeEngine);
List<Var> vars = varSearcher.findAllVars(file, getOffset());
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -23,8 +23,9 @@
org.eclipse.wst.validation,
org.eclipse.ui.editors;visibility:=reexport,
org.eclipse.ui.ide,
- org.eclipse.wst.css.core;bundle-version="1.1.300",
- org.eclipse.wst.html.core;bundle-version="1.1.300"
+ org.eclipse.wst.css.core,
+ org.eclipse.wst.html.core,
+ org.jboss.tools.common.el.ui
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
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 16:50:30 UTC (rev 19588)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -231,37 +231,31 @@
ELContextImpl context = new ELContextImpl();
context.setResource(file);
context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
- String content = null;
- try {
- content = FileUtil.readStream(file);
- int startEl = content.indexOf("#{"); //$NON-NLS-1$
- if(startEl<0)
- startEl = content.indexOf("${"); //$NON-NLS-1$
- if(startEl>-1) {
- ELParser parser = ELParserUtil.getJbossFactory().createParser();
- ELModel model = parser.parse(content);
- List<SyntaxError> errors = model.getSyntaxErrors();
- for (ELInstance instance : model.getInstances()) {
- for(ELInvocationExpression ie : instance.getExpression().getInvocations()){
- ELReference elReference = new KbELReference();
- elReference.setResource(file);
- elReference.setEl(new ELExpression[]{ie});
- elReference.setLength(ie.getLength());
- elReference.setStartPosition(ie.getStartPosition());
- List<SyntaxError> elErrors = new ArrayList<SyntaxError>();
- for (SyntaxError error : errors) {
- if(error.getPosition()>=ie.getStartPosition() && error.getPosition()<=ie.getEndPosition()) {
- elErrors.add(error);
- }
+ String content = FileUtil.getContentFromEditorOrFile(file);
+ int startEl = content.indexOf("#{"); //$NON-NLS-1$
+ if(startEl<0)
+ startEl = content.indexOf("${"); //$NON-NLS-1$
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(content);
+ List<SyntaxError> errors = model.getSyntaxErrors();
+ for (ELInstance instance : model.getInstances()) {
+ for(ELInvocationExpression ie : instance.getExpression().getInvocations()){
+ ELReference elReference = new KbELReference();
+ elReference.setResource(file);
+ elReference.setEl(new ELExpression[]{ie});
+ elReference.setLength(ie.getLength());
+ elReference.setStartPosition(ie.getStartPosition());
+ List<SyntaxError> elErrors = new ArrayList<SyntaxError>();
+ for (SyntaxError error : errors) {
+ if(error.getPosition()>=ie.getStartPosition() && error.getPosition()<=ie.getEndPosition()) {
+ elErrors.add(error);
}
- elReference.setSyntaxErrors(elErrors);
- context.addELReference(elReference);
}
+ elReference.setSyntaxErrors(elErrors);
+ context.addELReference(elReference);
}
}
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- return null;
}
return context;
}
@@ -270,13 +264,7 @@
ELContextImpl context = new ELContextImpl();
context.setResource(file);
context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
- String content = null;
- try {
- content = FileUtil.readStream(file);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- return null;
- }
+ String content = FileUtil.getContentFromEditorOrFile(file);
FastJavaPartitionScanner scaner = new FastJavaPartitionScanner();
Document document = new Document(content);
scaner.setRange(document, 0, document.getLength());
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/KbELProposalProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/KbELProposalProcessor.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/KbELProposalProcessor.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.el;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.ui.ca.ELProposalProcessor;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class KbELProposalProcessor extends ELProposalProcessor {
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.el.ui.ca.ELProposalProcessor#getELContext(org.eclipse.core.resources.IFile)
+ */
+ @Override
+ protected ELContext getELContext(IFile file) {
+ return PageContextFactory.createPageContext(file);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/KbELProposalProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2009-12-25 18:19:49 UTC (rev 19589)
@@ -13,14 +13,14 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.el.ui.ca.ELProposalProcessor;
+import org.jboss.tools.jst.web.kb.el.KbELProposalProcessor;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
/**
* @author Alexey Kazakov
*/
-public class SeamELProposalProcessor extends ELProposalProcessor {
+public class SeamELProposalProcessor extends KbELProposalProcessor {
/*
* (non-Javadoc)
Modified: trunk/struts/tests/org.jboss.tools.struts.text.ext.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.text.ext.test/META-INF/MANIFEST.MF 2009-12-25 16:50:30 UTC (rev 19588)
+++ trunk/struts/tests/org.jboss.tools.struts.text.ext.test/META-INF/MANIFEST.MF 2009-12-25 18:19:49 UTC (rev 19589)
@@ -17,7 +17,8 @@
org.jboss.tools.common.text.ext,
org.jboss.tools.jst.jsp,
org.jboss.tools.jst.jsp.test,
- org.jboss.tools.jst.web
+ org.jboss.tools.jst.web,
+ org.jboss.tools.common.ui
Export-Package: org.jboss.tools.struts.text.tests
Bundle-Vendor: %Bundle-Vendor.0
Bundle-Localization: plugin
15 years
JBoss Tools SVN: r19588 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-12-25 11:50:30 -0500 (Fri, 25 Dec 2009)
New Revision: 19588
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java
Log:
JBIDE-4916
optimization
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java 2009-12-25 16:49:28 UTC (rev 19587)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java 2009-12-25 16:50:30 UTC (rev 19588)
@@ -15,16 +15,8 @@
import java.util.Map;
import java.util.TreeMap;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2;
-import org.eclipse.jface.fieldassist.IContentProposal;
-import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.meta.XChild;
import org.jboss.tools.common.meta.XModelEntity;
@@ -32,10 +24,7 @@
import org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintAList;
import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.ui.attribute.adapter.JavaClassContentAssistProvider;
import org.jboss.tools.common.model.ui.texteditors.propertyeditor.AbstractPropertiesContentAssistProcessor;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.hibernate.ui.xml.form.HibConfig3PropertyFormLayoutData;
import org.jboss.tools.hibernate.xml.model.impl.HibConfigComplexPropertyImpl;
@@ -52,7 +41,6 @@
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
int offset) {
Context context = getContext(viewer, offset);
- String text = viewer.getDocument().get();
List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
@@ -62,28 +50,15 @@
return new ICompletionProposal[0];
}
if(context.isInPropertyName()) {
- int nameOffset = context.getNameOffset();
- String namePrefix = nameOffset < offset ? text.substring(nameOffset, offset) : ""; //$NON-NLS-1$
String[] ps = attributes.keySet().toArray(new String[0]);
for (int i = 0; i < ps.length; i++) {
- if(context.hasProperty(ps[i])) continue;
- String description = getDescription(ps[i]);
- if(ps[i].startsWith(namePrefix)) {
- CompletionProposal proposal = new CompletionProposal(
- ps[i],
- nameOffset,
- context.getNameLength(),
- ps[i].length(),
- null,
- ps[i],
- null,
- description);
+ String description = getDescription(ps[i]); //set more substantial description
+ ICompletionProposal proposal = getNameProposal(ps[i], description, context);
+ if(proposal != null) {
result.add( proposal);
}
}
} else if(context.isInValue()) {
- int valueOffset = context.getValueOffset();
- String valuePrefix = valueOffset < offset && valueOffset >= 0 ? text.substring(valueOffset, offset) : ""; //$NON-NLS-1$
String propertyName = context.getPropertyName();
if(attributes.containsKey(propertyName)) {
XAttribute attr = attributes.get(propertyName);
@@ -95,40 +70,14 @@
String[] vs = ((XAttributeConstraintAList)c).getValues();
for (int i = 0; i < vs.length; i++) {
if(vs[i].length() == 0) continue;
- if(vs[i].startsWith(valuePrefix)) {
- CompletionProposal proposal = new CompletionProposal(
- vs[i],
- valueOffset,
- context.getValueLength(),
- vs[i].length(),
- null,
- vs[i],
- null,
- vs[i]); //should we put more substantial description?
+ String description = vs[i]; //set more substantial description
+ ICompletionProposal proposal = getValueProposal(vs[i], description, context);
+ if(proposal != null) {
result.add( proposal);
}
}
} else if("AccessibleJava".equals(attr.getEditor().getName())) { //$NON-NLS-1$
- JavaClassContentAssistProvider p = new JavaClassContentAssistProvider();
- p.init(object, null, attr);
- IContentProposalProvider pp = p.getContentProposalProvider();
- IContentProposal[] ps = pp.getProposals(valuePrefix, valuePrefix.length());
- IProject project = EclipseResourceUtil.getProject(object);
- IJavaProject jp = EclipseResourceUtil.getJavaProject(project);
- if(ps != null) for (int i = 0; i < ps.length; i++) {
- String value = ps[i].getContent();
- String descr = getDescription(jp, value);
- CompletionProposal proposal = new CompletionProposal(
- value,
- valueOffset,
- context.getValueLength(),
- value.length(),
- null,
- ps[i].getLabel(),
- null,
- descr != null ? descr : ps[i].getDescription());
- result.add(proposal);
- }
+ result.addAll(getJavaTypeContentProposals(attr, context));
} else {
//TODO
}
@@ -173,14 +122,4 @@
return description;
}
- public static String getDescription(IJavaProject jp, String value) {
- String descr = null;
- if(jp != null) try {
- IType type = EclipseJavaUtil.findType(jp, value);
- if(type != null) descr = JavadocContentAccess2.getHTMLContent(type, true);
- } catch (JavaModelException e) {
- //ignore
- }
- return descr;
- }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java 2009-12-25 16:49:28 UTC (rev 19587)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentProposalProvider.java 2009-12-25 16:50:30 UTC (rev 19588)
@@ -78,22 +78,7 @@
}
}
} else if("AccessibleJava".equals(attr.getEditor().getName())) { //$NON-NLS-1$
- JavaClassContentAssistProvider p = new JavaClassContentAssistProvider();
- p.init(object, null, attr);
- IContentProposalProvider pp = p.getContentProposalProvider();
- IContentProposal[] ps = pp.getProposals(valuePrefix, valuePrefix.length());
- IJavaProject jp = getJavaProject();
- for (int i = 0; i < ps.length; i++) {
- String descr = ps[i].getDescription();
- if(descr == null || descr.length() == 0) {
- String value = ps[i].getContent();
- descr = HibernatePropertiesContentAssistProcessor.getDescription(jp, value);
- IContentProposal p2 = AttributeContentProposalProviderFactory.makeContentProposal(value, ps[i].getLabel(), descr);
- result.add(p2);
- } else {
- result.add(ps[i]);
- }
- }
+ result.addAll(getJavaTypeContentProposals(contents, position));
} else {
//TODO
}
@@ -103,27 +88,8 @@
return result.toArray(new IContentProposal[0]);
}
- boolean isNameAttribute() {
- return attribute.getName().equals(XModelObjectConstants.ATTR_NAME);
+ protected boolean isPropertyEntity(String entity) {
+ return super.isPropertyEntity(entity) || HibConfigComplexPropertyImpl.ENT_PROPERTY.equals(entity);
}
- String getPropertyName() {
- String value = null;
- if(data != null) {
- value = data.getValue(XModelObjectConstants.ATTR_NAME);
-
- } else if(object != null
- && (object.getModelEntity().getName().equals(PropertiesLoader.ENT_PROPERTY)
- || object.getModelEntity().getName().equals(HibConfigComplexPropertyImpl.ENT_PROPERTY))) {
- value = object.getAttributeValue(XModelObjectConstants.ATTR_NAME);
-
- }
- return value;
-
- }
-
- IJavaProject getJavaProject() {
- IProject project = EclipseResourceUtil.getProject(object);
- return EclipseResourceUtil.getJavaProject(project);
- }
}
15 years
JBoss Tools SVN: r19587 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui: texteditors/propertyeditor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-12-25 11:49:28 -0500 (Fri, 25 Dec 2009)
New Revision: 19587
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/PropertiesContentProposalProvider.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/propertyeditor/AbstractPropertiesContentAssistProcessor.java
Log:
JBIDE-4916
optimization
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/PropertiesContentProposalProvider.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/PropertiesContentProposalProvider.java 2009-12-25 14:02:29 UTC (rev 19586)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/PropertiesContentProposalProvider.java 2009-12-25 16:49:28 UTC (rev 19587)
@@ -10,10 +10,21 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.attribute.adapter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.meta.action.XEntityData;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.loaders.impl.PropertiesLoader;
+import org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
+import org.jboss.tools.common.model.ui.texteditors.propertyeditor.AbstractPropertiesContentAssistProcessor;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
/**
*
@@ -27,4 +38,58 @@
public PropertiesContentProposalProvider() {}
+ /**
+ * Helper method to get java type proposals.
+ *
+ * @param contents
+ * @param position
+ * @return
+ */
+ protected List<IContentProposal> getJavaTypeContentProposals(String contents, int position) {
+ List<IContentProposal> result = new ArrayList<IContentProposal>();
+ String valuePrefix = contents.substring(0, position);
+ JavaClassContentAssistProvider p = new JavaClassContentAssistProvider();
+ p.init(object, null, attribute);
+ IContentProposalProvider pp = p.getContentProposalProvider();
+ IContentProposal[] ps = pp.getProposals(valuePrefix, valuePrefix.length());
+ IJavaProject jp = getJavaProject();
+ for (int i = 0; i < ps.length; i++) {
+ String descr = ps[i].getDescription();
+ if (descr == null || descr.length() == 0) {
+ String value = ps[i].getContent();
+ descr = AbstractPropertiesContentAssistProcessor.getDescription(jp, value);
+ IContentProposal p2 = AttributeContentProposalProviderFactory
+ .makeContentProposal(value, ps[i].getLabel(), descr);
+ result.add(p2);
+ } else {
+ result.add(ps[i]);
+ }
+ }
+ return result;
+ }
+
+ protected String getPropertyName() {
+ String value = null;
+ if(data != null) {
+ value = data.getValue(XModelObjectConstants.ATTR_NAME);
+
+ } else if(object != null && isPropertyEntity(object.getModelEntity().getName())) {
+ value = object.getAttributeValue(XModelObjectConstants.ATTR_NAME);
+
+ }
+ return value;
+ }
+
+ protected boolean isPropertyEntity(String entity) {
+ return PropertiesLoader.ENT_PROPERTY.equals(entity);
+ }
+
+ protected boolean isNameAttribute() {
+ return attribute.getName().equals(XModelObjectConstants.ATTR_NAME);
+ }
+
+ protected IJavaProject getJavaProject() {
+ IProject project = EclipseResourceUtil.getProject(object);
+ return EclipseResourceUtil.getJavaProject(project);
+ }
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/propertyeditor/AbstractPropertiesContentAssistProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/propertyeditor/AbstractPropertiesContentAssistProcessor.java 2009-12-25 14:02:29 UTC (rev 19586)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/propertyeditor/AbstractPropertiesContentAssistProcessor.java 2009-12-25 16:49:28 UTC (rev 19587)
@@ -1,16 +1,30 @@
package org.jboss.tools.common.model.ui.texteditors.propertyeditor;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.loaders.impl.PropertiesLoader;
+import org.jboss.tools.common.model.ui.attribute.adapter.JavaClassContentAssistProvider;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class AbstractPropertiesContentAssistProcessor implements IContentAssistProcessor {
protected XModelObject object;
@@ -59,6 +73,8 @@
int valueLength;
String propertyValue;
Set<String> allProperties = new HashSet<String>();
+
+ String text;
public boolean isInComment() {
return inComment;
@@ -75,10 +91,18 @@
public int getNameLength() {
return nameLength;
}
+
+ public String getNamePrefix() {
+ return nameOffset < offset ? text.substring(nameOffset, offset) : ""; //$NON-NLS-1$
+ }
public int getValueOffset() {
return valueOffset;
}
+
+ public String getValuePrefix() {
+ return valueOffset < offset && valueOffset >= 0 ? text.substring(valueOffset, offset) : ""; //$NON-NLS-1$
+ }
public int getValueLength() {
return valueLength;
@@ -100,6 +124,7 @@
public Context getContext(ITextViewer viewer, int offset) {
Context context = new Context();
context.offset = offset;
+ context.text = viewer.getDocument().get();
XModelObject[] ps = object.getChildren();
for (int i = 0; i < ps.length; i++) {
String name = ps[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
@@ -159,4 +184,115 @@
}
return body.length();
}
+
+ /**
+ * Helper method to create property name proposal.
+ * @param name
+ * @param description
+ * @param context
+ * @return
+ */
+ protected ICompletionProposal getNameProposal(String name, String description, Context context) {
+ int nameOffset = context.getNameOffset();
+ String namePrefix = context.getNamePrefix();
+ if(context.hasProperty(name)) return null;
+ if(!name.startsWith(namePrefix)) return null;
+ CompletionProposal proposal = new CompletionProposal(
+ name,
+ nameOffset,
+ context.getNameLength(),
+ name.length(),
+ null,
+ name,
+ null,
+ description);
+ return proposal;
+ }
+
+ /**
+ * Helper method to create property value proposal.
+ *
+ * @param value
+ * @param description
+ * @param context
+ * @return
+ */
+ protected ICompletionProposal getValueProposal(String value, String description, Context context) {
+ int valueOffset = context.getValueOffset();
+ String valuePrefix = context.getValuePrefix();
+ if(value.length() == 0) return null;
+ if(!value.startsWith(valuePrefix)) return null;
+ CompletionProposal proposal = new CompletionProposal(
+ value,
+ valueOffset,
+ context.getValueLength(),
+ value.length(),
+ null,
+ value,
+ null,
+ description);
+ return proposal;
+ }
+
+ /**
+ * Helper method to get java type proposals.
+ *
+ * @param attr
+ * @param context
+ * @return
+ */
+ protected List<ICompletionProposal> getJavaTypeContentProposals(Context context) {
+ return getJavaTypeContentProposals(null, context);
+ }
+
+ /**
+ * Helper method to get java type proposals.
+ *
+ * @param attr
+ * @param context
+ * @return
+ */
+ protected List<ICompletionProposal> getJavaTypeContentProposals(XAttribute attr, Context context) {
+ String valuePrefix = context.getValuePrefix();
+ List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
+ JavaClassContentAssistProvider p = new JavaClassContentAssistProvider();
+ p.init(object, null, attr);
+ IContentProposalProvider pp = p.getContentProposalProvider();
+ IContentProposal[] ps = pp.getProposals(valuePrefix, valuePrefix.length());
+ IProject project = EclipseResourceUtil.getProject(object);
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(project);
+ if(ps != null) for (int i = 0; i < ps.length; i++) {
+ String value = ps[i].getContent();
+ String descr = getDescription(jp, value);
+ CompletionProposal proposal = new CompletionProposal(
+ value,
+ context.getValueOffset(),
+ context.getValueLength(),
+ value.length(),
+ null,
+ ps[i].getLabel(),
+ null,
+ descr != null ? descr : ps[i].getDescription());
+ result.add(proposal);
+ }
+ return result;
+ }
+
+ /**
+ * Helper methods that gets description for java type.
+ * @param jp
+ * @param value
+ * @return
+ */
+ public static String getDescription(IJavaProject jp, String typeName) {
+ String descr = null;
+ if(jp != null) try {
+ IType type = EclipseJavaUtil.findType(jp, typeName);
+ if(type != null) descr = JavadocContentAccess2.getHTMLContent(type, true);
+ } catch (JavaModelException e) {
+ //ignore
+ }
+ return descr;
+ }
+
}
15 years