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