removing more JDT internal
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java
index 86749fb..dc0daf6 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPContentAssistProcessor.java
@@ -19,7 +19,6 @@
import java.util.Vector;
import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -953,11 +952,10 @@
for (int i = 0; i < regularJSPResults.length; i++) {
ICompletionProposal test = regularJSPResults[i];
- // System.out.println("proposal > " + test.getDisplayString());
- // System.out.println("relevance > " + ((JavaCompletionProposal)
- // test).getRelevance());
- //
- if (isRelevanceAllowed(((JavaCompletionProposal) test).getRelevance())) {
+ System.out.println("proposal > " + test.getDisplayString());
+ System.out.println("relevance > " + ((CustomCompletionProposal) test).getRelevance());
+
+ if (isRelevanceAllowed(((CustomCompletionProposal) test).getRelevance())) {
filteredProposals.add(test);
}
}
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPJavaContentAssistProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPJavaContentAssistProcessor.java
index 7cacbca..228c937 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPJavaContentAssistProcessor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPJavaContentAssistProcessor.java
@@ -14,7 +14,6 @@
import java.util.List;
import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.internal.ui.text.java.JavaParameterListValidator;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JavaParameterListValidator.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JavaParameterListValidator.java
new file mode 100644
index 0000000..07f0182
--- /dev/null
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JavaParameterListValidator.java
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.ui.internal.contentassist;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+
+
+/**
+ *
+ * @author pavery
+ */
+public class JavaParameterListValidator implements IContextInformationValidator, IContextInformationPresenter {
+
+ private int fPosition;
+ private ITextViewer fViewer;
+ private IContextInformation fInformation;
+
+ private int fCurrentParameter;
+
+
+
+ public JavaParameterListValidator() {
+ }
+
+ /**
+ * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
+ * @see IContextInformationPresenter#install(IContextInformation, ITextViewer, int)
+ */
+ public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
+ fPosition= documentPosition;
+ fViewer= viewer;
+ fInformation= info;
+
+ fCurrentParameter= -1;
+ }
+
+ private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
+ while (pos < end) {
+ char curr= d.getChar(pos);
+ pos++;
+ if (curr == '*') {
+ if (pos < end && d.getChar(pos) == '/') {
+ return pos + 1;
+ }
+ }
+ }
+ return end;
+ }
+
+ private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
+ while (pos < end) {
+ char curr= d.getChar(pos);
+ pos++;
+ if (curr == '\\') {
+ // ignore escaped characters
+ pos++;
+ } else if (curr == ch) {
+ return pos;
+ }
+ }
+ return end;
+ }
+
+ private int getCharCount(IDocument document, int start, int end, char increment, char decrement, boolean considerNesting) throws BadLocationException {
+
+ Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
+
+ int nestingLevel= 0;
+ int charCount= 0;
+ while (start < end) {
+ char curr= document.getChar(start++);
+ switch (curr) {
+ case '/':
+ if (start < end) {
+ char next= document.getChar(start);
+ if (next == '*') {
+ // a comment starts, advance to the comment end
+ start= getCommentEnd(document, start + 1, end);
+ } else if (next == '/') {
+ // '//'-comment: nothing to do anymore on this line
+ start= end;
+ }
+ }
+ break;
+ case '*':
+ if (start < end) {
+ char next= document.getChar(start);
+ if (next == '/') {
+ // we have been in a comment: forget what we read before
+ charCount= 0;
+ ++ start;
+ }
+ }
+ break;
+ case '"':
+ case '\'':
+ start= getStringEnd(document, start, end, curr);
+ break;
+ default:
+
+ if (considerNesting) {
+
+ if ('(' == curr)
+ ++ nestingLevel;
+ else if (')' == curr)
+ -- nestingLevel;
+
+ if (nestingLevel != 0)
+ break;
+ }
+
+ if (increment != 0) {
+ if (curr == increment)
+ ++ charCount;
+ }
+
+ if (decrement != 0) {
+ if (curr == decrement)
+ -- charCount;
+ }
+ }
+ }
+
+ return charCount;
+ }
+
+ /**
+ * @see IContextInformationValidator#isContextInformationValid(int)
+ */
+ public boolean isContextInformationValid(int position) {
+
+ try {
+ if (position < fPosition)
+ return false;
+
+ IDocument document= fViewer.getDocument();
+ IRegion line= document.getLineInformationOfOffset(fPosition);
+
+ if (position < line.getOffset() || position >= document.getLength())
+ return false;
+
+ return (getCharCount(document, fPosition, position, '(', ')', false) >= 0);
+
+ } catch (BadLocationException x) {
+ return false;
+ }
+ }
+
+ /**
+ * @see IContextInformationPresenter#updatePresentation(int, TextPresentation)
+ */
+ public boolean updatePresentation(int position, TextPresentation presentation) {
+
+ int currentParameter= -1;
+
+ try {
+ currentParameter= getCharCount(fViewer.getDocument(), fPosition, position, ',', (char) 0, true);
+ } catch (BadLocationException x) {
+ return false;
+ }
+
+ if (fCurrentParameter != -1) {
+ if (currentParameter == fCurrentParameter)
+ return false;
+ }
+
+ presentation.clear();
+ fCurrentParameter= currentParameter;
+
+ String s= fInformation.getInformationDisplayString();
+ int start= 0;
+ int occurrences= 0;
+ while (occurrences < fCurrentParameter) {
+ int found= s.indexOf(',', start);
+ if (found == -1)
+ break;
+ start= found + 1;
+ ++ occurrences;
+ }
+
+ if (occurrences < fCurrentParameter) {
+ presentation.addStyleRange(new StyleRange(0, s.length(), null, null, SWT.NORMAL));
+ return true;
+ }
+
+ if (start == -1)
+ start= 0;
+
+ int end= s.indexOf(',', start);
+ if (end == -1)
+ end= s.length();
+
+ if (start > 0)
+ presentation.addStyleRange(new StyleRange(0, start, null, null, SWT.NORMAL));
+
+ if (end > start)
+ presentation.addStyleRange(new StyleRange(start, end - start, null, null, SWT.BOLD));
+
+ if (end < s.length())
+ presentation.addStyleRange(new StyleRange(end, s.length() - end, null, null, SWT.NORMAL));
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JavaTypeFinder.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JavaTypeFinder.java
index 58880d5..73b2574 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JavaTypeFinder.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JavaTypeFinder.java
@@ -20,7 +20,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
@@ -33,17 +33,12 @@
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceConstants;
import org.eclipse.wst.xml.uriresolver.util.URIHelper;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
/**
- * @version 5.0
+ *
*/
-
public class JavaTypeFinder {
// COPIED TO REMOVE INTERNAL DEPENDENCY FOR NOW...
- // org.eclipse.jdt.internal.compiler.env.AccPublic
- static int AccPublic = 0x0001;
// org.eclipse.jdt.internal.codeassist.R_DEFAULT
static int R_DEFAULT = 0;
@@ -81,13 +76,13 @@
public void acceptClass(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
// forbid inner classes as they don't work [yet]
if (enclosingTypeNames == null || enclosingTypeNames.length == 0)
- collector.acceptClass(packageName, simpleTypeName, getCompletionName(packageName, enclosingTypeNames, simpleTypeName), AccPublic, 0, 0, R_DEFAULT);
+ collector.acceptClass(packageName, simpleTypeName, getCompletionName(packageName, enclosingTypeNames, simpleTypeName), Flags.AccPublic, 0, 0, R_DEFAULT);
}
public void acceptInterface(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
// forbid inner classes as they don't work [yet]
if (this.allowInterfaces && (enclosingTypeNames == null || enclosingTypeNames.length == 0))
- collector.acceptInterface(packageName, simpleTypeName, getCompletionName(packageName, enclosingTypeNames, simpleTypeName), AccPublic, 0, 0, R_DEFAULT);
+ collector.acceptInterface(packageName, simpleTypeName, getCompletionName(packageName, enclosingTypeNames, simpleTypeName), Flags.AccPublic, 0, 0, R_DEFAULT);
}
public JavaTypeResultCollector getCollector() {
@@ -95,19 +90,6 @@
}
}
- public static void initJDT() {
- // The following code will initialize the Java UI plugin if it
- // is not already initialized.
- try {
- Bundle jdtUI = Platform.getBundle("org.eclipse.jdt.ui"); //$NON-NLS-1$
- Bundle jdtCore = Platform.getBundle("org.eclipse.jdt.core"); //$NON-NLS-1$
- jdtUI.start();
- jdtCore.start();
- } catch (BundleException e1) {
- // problems initializing plugins
- }
- }
-
public static ICompletionProposal[] getBeanProposals(IResource resource, int replacementStart, int replacementLength) {
ICompletionProposal[] typeProposals = getTypeProposals(resource, replacementStart, replacementLength);
ICompletionProposal[] serialProposals = getSerializedProposals(resource, replacementStart, replacementLength);
@@ -159,7 +141,7 @@
}
protected static ICompletionProposal[] findTypeProposals(IResource resource, int replacementStart, int replacementLength, boolean allowInterfaces) {
- initJDT();
+
JavaTypeNameRequestor requestor = new JavaTypeNameRequestor(allowInterfaces);
requestor.getCollector().setReplacementStart(replacementStart);
requestor.getCollector().setReplacementLength(replacementLength);
@@ -189,8 +171,6 @@
public static IJavaProject getJavaProject(IResource resource) {
IProject proj = resource.getProject();
IJavaProject javaProject = JavaCore.create(proj);
- // IJavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
- // IJavaProject javaProject = javaModel.getJavaProject(proj.getName());
return javaProject;
}
}
\ No newline at end of file