Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist')
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java64
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java93
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java236
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java67
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java95
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java215
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java48
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties4
9 files changed, 0 insertions, 851 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java
deleted file mode 100644
index e4b789cff9..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
-import org.eclipse.wst.jsdt.ui.text.java.IJavaCompletionProposal;
-
-/**
- * Implements IJavaCompletionProposal for use with JSPProposalCollector.
- *
- * @plannedfor 1.0
- */
-// public class JSPCompletionProposal extends CustomCompletionProposal
-// implements
-public class JSDTCompletionProposal extends JavaCompletionProposal implements IJavaCompletionProposal {
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483
- *
- * This is a wrapped proposal so we don't need to make "slow" calls to the
- * java proposal up front, only when needed for example, getAdditionalInfo()
- * reads external javadoc, and it makes no sense
- */
- ICompletionProposal fJavaCompletionProposal = null;
-
- public JSDTCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image,
- String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance,
- boolean updateReplacementLengthOnValidate) {
- super(replacementString, replacementOffset, replacementLength, image, displayString, relevance);
- super.setCursorPosition(cursorPosition);
- super.setContextInformation(contextInformation);
-// super(replacementString, replacementOffset, replacementLength,
-// cursorPosition, image, displayString, contextInformation,
-// additionalProposalInfo, relevance,
-// updateReplacementLengthOnValidate);
- }
-
- /**
- * Sets cursor position after applying.
- */
-
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- super.apply(viewer, trigger, stateMask, offset);
- }
-
-
- public String getAdditionalProposalInfo() {
- String additionalInfo = super.getAdditionalProposalInfo();
- ICompletionProposal javaProposal = getJavaCompletionProposal();
- if (javaProposal != null) {
- additionalInfo = javaProposal.getAdditionalProposalInfo();
- }
- return additionalInfo;
- }
-
- final public ICompletionProposal getJavaCompletionProposal() {
- return fJavaCompletionProposal;
- }
-
- final public void setJavaCompletionProposal(ICompletionProposal javaCompletionProposal) {
- fJavaCompletionProposal = javaCompletionProposal;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java
deleted file mode 100644
index 662cdbed48..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-
-import java.util.Arrays;
-import java.util.Vector;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapter;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
-
-public class JSDTContentAssistant extends AbstractContentAssistProcessor {
- private JSDTContentAssistantProcessor fContentAssistProcessor;
- private JSDTTemplateAssistProcessor fTemplateAssistProcessor;
- private JsTranslationAdapter fTranslationAdapter;
- private JSDTHtmlCompletionProcessor fHhtmlcomp;
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentPosition) {
- Vector proposals = new Vector();
- ICompletionProposal[] completionProposals;
- ICompletionProposal endScript = getHtmlContentAssistProcessor().getEndScriptProposal(viewer, documentPosition);
- if(endScript!=null) {
- return new ICompletionProposal[] {endScript};
- //proposals.add(endScript);
- }
- JSDTProposalCollector theCollector = getProposalCollector(viewer, documentPosition);
- /* add end script tag if needed */
-
- /* --------- Content Assistant --------- */
- getContentAssistProcessor().setProposalCollector(theCollector);
- completionProposals = getContentAssistProcessor().computeCompletionProposals(viewer, documentPosition);
- proposals.addAll(Arrays.asList(completionProposals));
- /* HTML Proposals */
- completionProposals = getHtmlContentAssistProcessor().computeCompletionProposals(viewer, documentPosition);
- proposals.addAll(Arrays.asList(completionProposals));
- /* --------- template completions --------- */
- getTemplateCompletionProcessor().setProposalCollector(theCollector);
- completionProposals = getTemplateCompletionProcessor().computeCompletionProposals(viewer, documentPosition);
- proposals.addAll(Arrays.asList(completionProposals));
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[0]);
- }
-
- private JSDTHtmlCompletionProcessor getHtmlContentAssistProcessor() {
- if (fHhtmlcomp == null) {
- fHhtmlcomp = new JSDTHtmlCompletionProcessor();
- }
- return fHhtmlcomp;
- }
-
- private JSDTContentAssistantProcessor getContentAssistProcessor() {
- if (fContentAssistProcessor == null) {
- fContentAssistProcessor = new JSDTContentAssistantProcessor();
- }
- return fContentAssistProcessor;
- }
- private JsTranslation getJSPTranslation(ITextViewer viewer, int offset) {
- IDOMModel xmlModel = null;
- try {
- xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
- IDOMDocument xmlDoc = xmlModel.getDocument();
- if (fTranslationAdapter == null) {
- fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
- }
- if (fTranslationAdapter != null) {
- return fTranslationAdapter.getJSPTranslation(true);
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- if (xmlModel != null) {
- xmlModel.releaseFromRead();
- }
- }
- return null;
- }
-
- protected JSDTProposalCollector getProposalCollector(ITextViewer viewer, int offset) {
- JsTranslation tran = getJSPTranslation(viewer, offset);
- return new JSDTProposalCollector(tran);
- }
-
- private JSDTTemplateAssistProcessor getTemplateCompletionProcessor() {
- if (fTemplateAssistProcessor == null) {
- fTemplateAssistProcessor = new JSDTTemplateAssistProcessor();
- }
- return fTemplateAssistProcessor;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java
deleted file mode 100644
index e0252e02a7..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java
+++ /dev/null
@@ -1,236 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.jsdt.core.ICompilationUnit;
-import org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapter;
-import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
-import org.osgi.framework.Bundle;
-
-public class JSDTContentAssistantProcessor extends AbstractContentAssistProcessor {
- private static final boolean DEBUG;
- private static final String JSDT_CORE_PLUGIN_ID = "org.eclipse.wst.jsdt.core"; //$NON-NLS-1$
- static {
- String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslation"); //$NON-NLS-1$
- DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
- protected String fErrorMessage = null;
- protected int fJspSourcePosition, fJavaPosition;
- private JSDTProposalCollector fProposalCollector;
- private JsTranslationAdapter fTranslationAdapter = null;
- protected StructuredTextViewer fViewer = null;
-
- public JSDTContentAssistantProcessor() {
- super();
- }
-
- /**
- * Returns a list of completion proposals based on the specified location
- * within the document that corresponds to the current cursor position
- * within the text viewer.
- *
- * @param viewer
- * the viewer whose document is used to compute the proposals
- * @param documentPosition
- * an offset within the document for which completions should be
- * computed
- * @return an array of completion proposals or <code>null</code> if no
- * proposals are possible
- */
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int pos) {
- initialize(pos);
- JSDTProposalCollector collector = null;
- IDOMModel xmlModel = null;
- try {
- if (viewer instanceof StructuredTextViewer) {
- fViewer = (StructuredTextViewer) viewer;
- }
- xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(fViewer.getDocument());
- IDOMDocument xmlDoc = xmlModel.getDocument();
- if (fTranslationAdapter == null) {
- fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
- }
- if (fTranslationAdapter != null) {
- JsTranslation translation = fTranslationAdapter.getJSPTranslation(true);
- fJavaPosition = getDocumentPosition();
- try {
- ICompilationUnit cu = translation.getCompilationUnit();
- // can't get java proposals w/out a compilation unit
- // or without a valid position
- if (cu == null || -1 == fJavaPosition) {
- return new ICompletionProposal[0];
- }
- collector = getProposalCollector();
- synchronized (cu) {
- cu.codeComplete(fJavaPosition, collector, null);
- }
- } catch (CoreException coreEx) {
- // a possible Java Model Exception due to not being a Web
- // (Java) Project
- coreEx.printStackTrace();
- }
- }
- } catch (Exception exc) {
- exc.printStackTrace();
- // throw out exceptions on code assist.
- } finally {
- if (xmlModel != null) {
- xmlModel.releaseFromRead();
- }
- }
- ICompletionProposal[] results = new ICompletionProposal[0];
- if (collector != null) {
- results = collector.getJSPCompletionProposals();
- if (results == null || results.length < 1) {
- fErrorMessage = JsUIMessages.Java_Content_Assist_is_not_UI_;
- }
- }
- return results;
- }
-
- /**
- * Returns information about possible contexts based on the specified
- * location within the document that corresponds to the current cursor
- * position within the text viewer.
- *
- * @param viewer
- * the viewer whose document is used to compute the possible
- * contexts
- * @param documentPosition
- * an offset within the document for which context information
- * should be computed
- * @return an array of context information objects or <code>null</code> if
- * no context could be found
- */
-
- public org.eclipse.jface.text.contentassist.IContextInformation[] computeContextInformation(org.eclipse.jface.text.ITextViewer viewer, int documentOffset) {
- return null;
- }
-
- /**
- * Returns a string of characters which when pressed should automatically
- * display content-assist proposals.
- *
- * @return string of characters
- */
- public java.lang.String getAutoProposalInvocationCharacters() {
- return null;
- }
-
- /**
- * Returns a string of characters which when pressed should automatically
- * display a content-assist tip.
- *
- * @return string of characters
- */
- public java.lang.String getAutoTipInvocationCharacters() {
- return null;
- }
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of possible completions.
- *
- * @return the auto activation characters for completion proposal or
- * <code>null</code> if no auto activation is desired
- */
-
- public char[] getCompletionProposalAutoActivationCharacters() {
- return null;
- }
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of context information.
- *
- * @return the auto activation characters for presenting context information
- * or <code>null</code> if no auto activation is desired
- */
-
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /**
- * Returns a validator used to determine when displayed context information
- * should be dismissed. May only return <code>null</code> if the processor
- * is incapable of computing context information.
- *
- * @return a context information validator, or <code>null</code> if the
- * processor is incapable of computing context information
- */
-
- public org.eclipse.jface.text.contentassist.IContextInformationValidator getContextInformationValidator() {
- return null;
- }
-
- protected int getDocumentPosition() {
- return fJspSourcePosition;
- }
-
-
- public String getErrorMessage() {
- // TODO: get appropriate error message
- // if (fCollector.getErrorMessage() != null &&
- // fCollector.getErrorMessage().length() > 0)
- // return fCollector.getErrorMessage();
- return fErrorMessage;
- }
-
- protected JSDTProposalCollector getProposalCollector() {
- return fProposalCollector;
- // return new JSPProposalCollector(translation);
- }
-
- /**
- * Initialize the code assist processor.
- */
- protected void initialize(int pos) {
- initializeJavaPlugins();
- fJspSourcePosition = pos;
- fErrorMessage = null;
- }
-
- /**
- * Initialize the Java Plugins that the JSP processor requires. See
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=143765 We should not call
- * "start", because that will cause that state to be remembered, and
- * re-started automatically during the next boot up sequence.
- *
- * ISSUE: we may be able to get rid of this all together, in future, since
- * 99% we probably have already used some JDT class by the time we need JDT
- * to be active ... but ... this is the safest fix for this point in 1.5
- * stream. Next release, let's just remove this, re-discover what ever bug
- * this was fixing (if any) and if there is one, then we'll either put back
- * in, as is, or come up with a more appropriate fix.
- *
- */
- protected void initializeJavaPlugins() {
- try {
- Bundle bundle = Platform.getBundle(JSDTContentAssistantProcessor.JSDT_CORE_PLUGIN_ID);
- bundle.loadClass("dummyClassNameThatShouldNeverExist"); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- // this is the expected result, we just want to
- // nudge the bundle to be sure its activated.
- }
- }
-
-
- public void release() {
- fTranslationAdapter = null;
- }
-
- public void setProposalCollector(JSDTProposalCollector translation) {
- this.fProposalCollector = translation;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java
deleted file mode 100644
index 6897f5eab9..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext;
-import org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapter;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-
-public class JSDTContetAssistInvocationContext extends JavaContentAssistInvocationContext {
- public static JSDTContetAssistInvocationContext getInstance(ITextViewer viewer, int offset, JSDTProposalCollector theCollector) {
- JsTranslation tran = JSDTContetAssistInvocationContext.getJSPTranslation(viewer);
- return new JSDTContetAssistInvocationContext(viewer, offset, theCollector);
- }
-
- private static JsTranslation getJSPTranslation(ITextViewer viewer) {
- JsTranslation fTranslation = null;
-
- IDOMModel xmlModel = null;
- try {
- xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
- IDOMDocument xmlDoc = xmlModel.getDocument();
- JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
- if (fTranslationAdapter != null) {
- fTranslation = fTranslationAdapter.getJSPTranslation(true);
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- if (xmlModel != null) {
- xmlModel.releaseFromRead();
- }
- }
- return fTranslation;
- }
- ITextViewer viewer;
-
- private JSDTContetAssistInvocationContext(ITextViewer viewer, int offset, JSDTProposalCollector theCollector) {
- super(viewer, offset, null);
- this.viewer = viewer;
- // this.offset=getJSPTranslation().getJavaOffset(offset);
- // CompletionProposalCollector theCollector = getProposalCollector();
- super.setCollector(theCollector);
- }
-
-// public IDocument getDocument() {
-// return
-// ((JSPTranslationExtension)getJSPTranslation(viewer)).getJavaDocument();
-//
-// }
-// protected CompletionProposalCollector getProposalCollector() {
-//
-// return ((CompletionProposalCollector) ( new JSPProposalCollector(
-// getJSPTranslation()) ));
-// }
-
- public IDocument getDocument() {
- return viewer.getDocument();
- }
-// public ICompilationUnit getCompilationUnit() {
-// return getJSPTranslation(viewer).getCompilationUnit();
-// }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java
deleted file mode 100644
index 2e7b60e40a..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-import java.util.ArrayList;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapter;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-
-/**
- *
- */
-/**
- * @author childsb
- *
- */
-public class JSDTHtmlCompletionProcessor {
-
- public JSDTHtmlCompletionProcessor() {}
-
-
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- /* add </script if necisary */
- ArrayList allProposals = new ArrayList();
- JsTranslation tran = getJSPTranslation(viewer);
- int missingAtOffset = tran.getMissingTagStart();
-
- return (ICompletionProposal[])allProposals.toArray(new ICompletionProposal[allProposals.size()]);
- }
-
- public ICompletionProposal getEndScriptProposal(ITextViewer viewer, int offset) {
- /* add </script if necisary */
-
- JsTranslation tran = getJSPTranslation(viewer);
- int missingAtOffset = tran.getMissingTagStart();
-
- if(offset>=missingAtOffset&& missingAtOffset>-1) {
-
- String allText = viewer.getDocument().get();
- String text = "</script>"; //$NON-NLS-1$
-
- int startInTag = -1;
- int replaceLength =0;
-
- for(int i=0;i<text.length() && allText.length()>offset-1;i++) {
- if(allText.charAt(offset-1)==text.charAt(i)) {
- startInTag = i;
- break;
- }
- }
-
- if(startInTag==-1 ) {
- String displayText = Messages.getString("JSDTHtmlCompletionProcessor.1"); //$NON-NLS-1$
- return new CustomCompletionProposal("\n" + text + "\n" ,offset,0,offset,null,displayText,null,Messages.getString("JSDTHtmlCompletionProcessor.4"),100); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- String text1 = allText.substring(offset - startInTag - 1, offset).toLowerCase();
- String text2 = text.substring(0, startInTag+1).toLowerCase();
- if(startInTag>-1 && text2.compareTo(text1)==0 ) {
- String displayText = Messages.getString("JSDTHtmlCompletionProcessor.5"); //$NON-NLS-1$
- return new CustomCompletionProposal(text ,offset-startInTag-1,0,text.length(),null,displayText,null,Messages.getString("JSDTHtmlCompletionProcessor.6"),100); //$NON-NLS-1$
- }
-
- }
-
- return null;
- }
- private JsTranslation getJSPTranslation(ITextViewer viewer) {
- IDOMModel xmlModel = null;
- try {
- xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
- IDOMDocument xmlDoc = xmlModel.getDocument();
-
- JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
-
- if (fTranslationAdapter != null) {
- return fTranslationAdapter.getJSPTranslation(true);
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- if (xmlModel != null) {
- xmlModel.releaseFromRead();
- }
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java
deleted file mode 100644
index c591612ef1..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java
+++ /dev/null
@@ -1,215 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.jsdt.core.CompletionProposal;
-import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalCollector;
-import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalComparator;
-import org.eclipse.wst.jsdt.ui.text.java.IJavaCompletionProposal;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
-
-/**
- * Passed into ICodeComplete#codeComplete(int offset, CompletionRequestor
- * requestor). Adapts IJavaCompletionProposals to JSPCompletion proposals. This
- * includes: - translating offsets - "fixing" up display strings - filtering
- * some unwanted proposals
- *
- * @plannedfor 1.0
- */
-public class JSDTProposalCollector extends CompletionProposalCollector {
- static char[] getTypeTriggers() {
- return CompletionProposalCollector.TYPE_TRIGGERS;
- }
- private Comparator fComparator;
- private JsTranslation fTranslation;
-
-// public List getGeneratedFunctionNames(){
-// if(fGeneratedFunctionNames==null){
-// fGeneratedFunctionNames = fTranslation.getGeneratedFunctionNames();
-// }
-// return fGeneratedFunctionNames;
-// }
- public JSDTProposalCollector(JsTranslation translation) {
- super(translation.getCompilationUnit());
- if (translation == null) {
- throw new IllegalArgumentException("JSPTranslation cannot be null"); //$NON-NLS-1$
- }
- fTranslation = translation;
- }
-
- /**
- * Cacluates the where the cursor should be after applying this proposal.
- * eg. method(|) if the method proposal chosen had params.
- *
- * @param proposal
- * @param completion
- * @param currentCursorOffset
- * @return
- */
- private int calculatePositionAfter(CompletionProposal proposal, String completion, int currentCursorOffset) {
- // calculate cursor position after
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=118398
- // int positionAfter = currentCursorOffset+completion.length();
- int positionAfter = completion.length();
- int kind = proposal.getKind();
- // may need better logic here...
- // put cursor inside parenthesis if there's params
- // only checking for any kind of declaration
- if (kind == CompletionProposal.ANONYMOUS_CLASS_DECLARATION || kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.POTENTIAL_METHOD_DECLARATION || kind == CompletionProposal.METHOD_REF) {
- String[] params = Signature.getParameterTypes(String.valueOf(proposal.getSignature()));
- if (completion.length() > 0 && params.length > 0) {
- positionAfter--;
- }
- }
- return positionAfter;
- }
-
- /**
- * Overridden to: - translate Java -> JSP offsets - fix
- * cursor-position-after - fix mangled servlet name in display string -
- * remove unwanted proposals (servlet constructor)
- */
-
- protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) {
- JSDTCompletionProposal jspProposal = null;
- // ignore constructor proposals (they're not relevant for our JSP
- // proposal list)
- if (!proposal.isConstructor()) {
-// if (proposal.getKind() == CompletionProposal.TYPE_REF) {
-// String signature = String.valueOf(proposal
-// .getDeclarationSignature());
-// String completion = String.valueOf(proposal.getCompletion());
-// if (completion.indexOf(signature) != -1) {
-// jspProposal = createAutoImportProposal(proposal);
-// }
-// }
- // default behavior
-// if (jspProposal == null) {
-// for(int i = 0;i<getGeneratedFunctionNames().size();i++){
-// if((new
-// String(proposal.getName())).equalsIgnoreCase((String)getGeneratedFunctionNames().get(i)))
-// return jspProposal;
-// }
- jspProposal = createJspProposal(proposal);
- // }
- }
- return jspProposal;
- }
-
-// private JSPCompletionProposal createAutoImportProposal(
-// CompletionProposal proposal) {
-//
-// JSPCompletionProposal jspProposal = null;
-//
-// String signature = new String(proposal.getDeclarationSignature());
-// String completion = new String(proposal.getCompletion());
-//
-// // it's fully qualified so we should
-// // add an import statement
-// // create an autoimport proposal
-// String newCompletion = completion.replaceAll(signature + ".", "");
-// //$NON-NLS-1$ //$NON-NLS-2$
-//
-// // java offset
-// int offset = proposal.getReplaceStart();
-// // replacement length
-// int length = proposal.getReplaceEnd() - offset;
-// // translate offset from Java > JSP
-// offset = fTranslation.getJspOffset(offset);
-// // cursor position after must be calculated
-// int positionAfter = calculatePositionAfter(proposal, newCompletion,
-// offset);
-//
-// // from java proposal
-// IJavaCompletionProposal javaProposal = super
-// .createJavaCompletionProposal(proposal);
-// proposal.getDeclarationSignature();
-// Image image = javaProposal.getImage();
-// String displayString = javaProposal.getDisplayString();
-// displayString = getTranslation().fixupMangledName(displayString);
-// IContextInformation contextInformation = javaProposal
-// .getContextInformation();
-// // don't do this, it's slow
-// // String additionalInfo = javaProposal.getAdditionalProposalInfo();
-// int relevance = javaProposal.getRelevance();
-//
-// boolean updateLengthOnValidate = true;
-//
-// jspProposal = new AutoImportProposal(completion, newCompletion, offset,
-// length, positionAfter, image, displayString,
-// contextInformation, null, relevance, updateLengthOnValidate);
-//
-// // https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483
-// // set wrapped java proposal so additional info can be calculated on
-// // demand
-// jspProposal.setJavaCompletionProposal(javaProposal);
-//
-// return jspProposal;
-// }
- private JSDTCompletionProposal createJspProposal(CompletionProposal proposal) {
- JSDTCompletionProposal jspProposal;
- String completion = String.valueOf(proposal.getCompletion());
- // java offset
- int offset = proposal.getReplaceStart();
- // replacement length
- int length = proposal.getReplaceEnd() - offset;
- // translate offset from Java > JSP
- // cursor position after must be calculated
- int positionAfter = calculatePositionAfter(proposal, completion, offset);
- // from java proposal
- IJavaCompletionProposal javaProposal = super.createJavaCompletionProposal(proposal);
- proposal.getDeclarationSignature();
- Image image = javaProposal.getImage();
- String displayString = javaProposal.getDisplayString();
- displayString = getTranslation().fixupMangledName(displayString);
-// for(int i = 0;i<getGeneratedFunctionNames().size();i++){
-// displayString.replace((String)getGeneratedFunctionNames().get(i), "");
-// }
- IContextInformation contextInformation = javaProposal.getContextInformation();
- // String additionalInfo = javaProposal.getAdditionalProposalInfo();
- int relevance = javaProposal.getRelevance();
- boolean updateLengthOnValidate = true;
- jspProposal = new JSDTCompletionProposal(completion, offset, length, positionAfter, image, displayString, contextInformation, null, relevance, updateLengthOnValidate);
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483
- // set wrapped java proposal so additional info can be calculated on
- // demand
- jspProposal.setJavaCompletionProposal(javaProposal);
- return jspProposal;
- }
-
- private Comparator getComparator() {
- if (fComparator == null) {
- fComparator = new CompletionProposalComparator();
- }
- return fComparator;
- }
-
- /**
- * Ensures that we only return JSPCompletionProposals.
- *
- * @return an array of JSPCompletionProposals
- */
- public JSDTCompletionProposal[] getJSPCompletionProposals() {
- List results = new ArrayList();
- IJavaCompletionProposal[] javaProposals = getJavaCompletionProposals();
- // need to filter out non JSPCompletionProposals
- // because their offsets haven't been translated
- for (int i = 0; i < javaProposals.length; i++) {
- if (javaProposals[i] instanceof JSDTCompletionProposal) {
- results.add(javaProposals[i]);
- }
- }
- Collections.sort(results, getComparator());
- return (JSDTCompletionProposal[]) results.toArray(new JSDTCompletionProposal[results.size()]);
- }
-
- public JsTranslation getTranslation() {
- return fTranslation;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java
deleted file mode 100644
index 1229657381..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.jsdt.internal.ui.text.java.TemplateCompletionProposalComputer;
-import org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext;
-import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapter;
-
-public class JSDTTemplateAssistProcessor {
- TemplateCompletionProposalComputer fJavaTemplateCompletion;
- JSDTProposalCollector fProposalCollector;
- JsTranslationAdapter fTranslationAdapter;
- IProgressMonitor monitor;
-
- public JSDTTemplateAssistProcessor() {
- monitor = new NullProgressMonitor();
- }
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- JavaContentAssistInvocationContext context = getInvocationContext(viewer, offset);
- List props = getTemplateCompletionProposalComputer().computeCompletionProposals(context, monitor);
- return (ICompletionProposal[]) props.toArray(new ICompletionProposal[] {});
- }
-
- private JavaContentAssistInvocationContext getInvocationContext(ITextViewer viewer, int offset) {
- return JSDTContetAssistInvocationContext.getInstance(viewer, offset, getProposalCollector());
- }
-
- protected JSDTProposalCollector getProposalCollector() {
- return fProposalCollector;
- // return new JSPProposalCollector(translation);
- }
-
- private TemplateCompletionProposalComputer getTemplateCompletionProposalComputer() {
- if (fJavaTemplateCompletion == null) {
- fJavaTemplateCompletion = new TemplateCompletionProposalComputer();
- }
- return fJavaTemplateCompletion;
- }
-
- public void setProposalCollector(JSDTProposalCollector translation) {
- this.fProposalCollector = translation;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java
deleted file mode 100644
index b6d635a571..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author childsb
- *
- */
-public class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.internal.contentassist.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages() {
- }
-
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties
deleted file mode 100644
index e3b0f1f914..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-JSDTHtmlCompletionProcessor.1=<> end with </script>
-JSDTHtmlCompletionProcessor.4=Close the script tag.
-JSDTHtmlCompletionProcessor.5=<> end with </script>
-JSDTHtmlCompletionProcessor.6=Close the script tag.

Back to the top