blob: 9f860623bba5d652de8ed4887dd811a0fda03e11 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2009 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 org.eclipse.jdt.core.*;
import junit.framework.*;
public class JavadocCompletionContextTests_1_5 extends AbstractJavaModelCompletionTests {
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 static Test suite() {
return buildModelTestSuite(JavadocCompletionContextTests_1_5.class);
}
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\n"+
"completion token location=UNKNOWN",
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\n"+
"completion token location=UNKNOWN",
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\n"+
"completion token location=UNKNOWN",
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\n"+
"completion token location=UNKNOWN",
result.context);
}
}