| /******************************************************************************* |
| * Copyright (c) 2005 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.jdt.core.tests.model; |
| |
| import java.lang.reflect.Method; |
| |
| import org.eclipse.jdt.core.*; |
| import org.eclipse.jdt.internal.codeassist.RelevanceConstants; |
| |
| import junit.framework.*; |
| |
| public class JavadocCompletionContextTests_1_5 extends AbstractJavaModelCompletionTests implements RelevanceConstants { |
| |
| public JavadocCompletionContextTests_1_5(String name) { |
| super(name); |
| } |
| public void setUpSuite() throws Exception { |
| if (COMPLETION_PROJECT == null) { |
| COMPLETION_PROJECT = setUpJavaProject("Completion", "1.5"); |
| } else { |
| setUpProjectCompliance(COMPLETION_PROJECT, "1.5"); |
| } |
| super.setUpSuite(); |
| } |
| |
| public void tearDownSuite() throws Exception { |
| super.tearDownSuite(); |
| } |
| public static Test suite() { |
| TestSuite suite = new Suite(JavadocCompletionContextTests_1_5.class.getName()); |
| |
| if (true) { |
| Class c = JavadocCompletionContextTests_1_5.class; |
| Method[] methods = c.getMethods(); |
| for (int i = 0, max = methods.length; i < max; i++) { |
| if (methods[i].getName().startsWith("test")) { //$NON-NLS-1$ |
| suite.addTest(new JavadocCompletionContextTests_1_5(methods[i].getName())); |
| } |
| } |
| return suite; |
| } |
| suite.addTest(new JavadocCompletionContextTests_1_5("test0214")); |
| return suite; |
| } |
| public void test0001() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0001/X.java", |
| "package test0001;\n" + |
| "public class X {\n" + |
| " /**\n" + |
| " * @param <ZZZZ\n" + |
| " */\n" + |
| " public <T> void foo(){}\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("ZZZZ"); |
| int tokenEnd = tokenStart + "ZZZZ".length() - 1; |
| int cursorLocation = str.lastIndexOf("ZZZZ") + "ZZZZ".length(); |
| |
| CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation); |
| |
| assertResults( |
| "completion offset="+(cursorLocation)+"\n" + |
| "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + |
| "completion token=\"ZZZZ\"\n" + |
| "completion token kind=TOKEN_KIND_NAME\n" + |
| "expectedTypesSignatures=null\n" + |
| "expectedTypesKeys=null", |
| result.context); |
| } |
| public void test0002() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0002/X.java", |
| "package test0002;\n" + |
| "public class X {\n" + |
| " /**\n" + |
| " * @param <ZZZZ\n" + |
| " */\n" + |
| " public <T> void foo(){}\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("ZZZZ"); |
| int tokenEnd = tokenStart + "ZZZZ".length() - 1; |
| int cursorLocation = str.lastIndexOf("ZZZZ"); |
| |
| CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation); |
| |
| assertResults( |
| "completion offset="+(cursorLocation)+"\n" + |
| "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + |
| "completion token=\"\"\n" + |
| "completion token kind=TOKEN_KIND_NAME\n" + |
| "expectedTypesSignatures=null\n" + |
| "expectedTypesKeys=null", |
| result.context); |
| } |
| public void test0003() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0003/X.java", |
| "package test0003;\n" + |
| "public class X {\n" + |
| " /**\n" + |
| " * @param <ZZZZ\n" + |
| " */\n" + |
| " public <T> void foo(){}\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("ZZZZ"); |
| int tokenEnd = tokenStart + "ZZZZ".length() - 1; |
| int cursorLocation = str.lastIndexOf("ZZZZ") + "ZZ".length(); |
| |
| CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation); |
| |
| assertResults( |
| "completion offset="+(cursorLocation)+"\n" + |
| "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + |
| "completion token=\"ZZ\"\n" + |
| "completion token kind=TOKEN_KIND_NAME\n" + |
| "expectedTypesSignatures=null\n" + |
| "expectedTypesKeys=null", |
| result.context); |
| } |
| public void test0004() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0004/X.java", |
| "package test0004;\n" + |
| "public class X {\n" + |
| " /**\n" + |
| " * @param <\n" + |
| " */\n" + |
| " public <T> void foo(){}\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("@param <") + "@param <".length(); |
| int tokenEnd = tokenStart + "".length() - 1; |
| int cursorLocation = str.lastIndexOf("@param <") + "@param <".length(); |
| |
| CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation); |
| |
| assertResults( |
| "completion offset="+(cursorLocation)+"\n" + |
| "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + |
| "completion token=\"\"\n" + |
| "completion token kind=TOKEN_KIND_NAME\n" + |
| "expectedTypesSignatures=null\n" + |
| "expectedTypesKeys=null", |
| result.context); |
| } |
| } |