blob: 6ac4f9357d1d5bf007d04a8da854fe5a3e7e0854 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2008 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.wst.jsdt.core.tests.model;
import org.eclipse.wst.jsdt.core.*;
import org.eclipse.wst.jsdt.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() {
return buildModelTestSuite(JavadocCompletionContextTests_1_5.class);
}
public void test0001() throws JavaScriptModelException {
this.workingCopies = new IJavaScriptUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src3/test0001/X.js",
"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 JavaScriptModelException {
this.workingCopies = new IJavaScriptUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src3/test0002/X.js",
"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 JavaScriptModelException {
this.workingCopies = new IJavaScriptUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src3/test0003/X.js",
"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 JavaScriptModelException {
this.workingCopies = new IJavaScriptUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src3/test0004/X.js",
"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);
}
}