| /******************************************************************************* |
| * 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 CompletionContextTests_1_5 extends AbstractJavaModelCompletionTests implements RelevanceConstants { |
| |
| public CompletionContextTests_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() { |
| TestSuite suite = new Suite(CompletionContextTests_1_5.class.getName()); |
| |
| if (true) { |
| Class c = CompletionContextTests_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 CompletionContextTests_1_5(methods[i].getName())); |
| } |
| } |
| return suite; |
| } |
| suite.addTest(new CompletionContextTests_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<T> {\n" + |
| " X<Object>.ZZZZ\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<T> {\n" + |
| " X<Object>.ZZZZ\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<T> {\n" + |
| " X<Object>.ZZZZ\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<T> {\n" + |
| " X<Object>.\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf(">.") + ">.".length(); |
| int tokenEnd = tokenStart + "".length() - 1; |
| int cursorLocation = str.lastIndexOf(">.") + ">.".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); |
| } |
| public void test0005() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0005/X.java", |
| "package test0005;\n" + |
| "@ZZZZ\n" + |
| "public class X {\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 test0006() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0006/X.java", |
| "package test0006;\n" + |
| "@ZZZZ\n" + |
| "public class X {\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 test0007() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0007/X.java", |
| "package test0007;\n" + |
| "@ZZZZ\n" + |
| "public class X {\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 test0008() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0008/X.java", |
| "package test0008;\n" + |
| "@\n" + |
| "public class X {\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("@") + "@".length(); |
| int tokenEnd = tokenStart + "".length() - 1; |
| int cursorLocation = str.lastIndexOf("@") + "@".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); |
| } |
| public void test0009() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0009/X.java", |
| "package test0009;\n" + |
| "class Y {\n" + |
| "}\n" + |
| "@Y.ZZZZ\n" + |
| "public class X {\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 test0010() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0010/X.java", |
| "package test0010;\n" + |
| "class Y {\n" + |
| "}\n" + |
| "@Y.ZZZZ\n" + |
| "public class X {\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 test0011() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0011/X.java", |
| "package test0011;\n" + |
| "class Y {\n" + |
| "}\n" + |
| "@Y.ZZZZ\n" + |
| "public class X {\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 test0012() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0012/X.java", |
| "package test0012;\n" + |
| "class Y {\n" + |
| "}\n" + |
| "@Y.\n" + |
| "public class X {\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("@Y.") + "@Y.".length(); |
| int tokenEnd = tokenStart + "".length() - 1; |
| int cursorLocation = str.lastIndexOf("@Y.") + "@Y.".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); |
| } |
| public void test0013() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0013/X.java", |
| "package test0013;\n" + |
| "@test0013.ZZZZ\n" + |
| "public class X {\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 test0014() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0014/X.java", |
| "package test0014;\n" + |
| "@test0014.ZZZZ\n" + |
| "public class X {\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 test0015() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0015/X.java", |
| "package test0015;\n" + |
| "@test0015.ZZZZ\n" + |
| "public class X {\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 test0016() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0016/X.java", |
| "package test0016;\n" + |
| "@test0016.\n" + |
| "public class X {\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("@test0016.") + "@test0016.".length(); |
| int tokenEnd = tokenStart + "".length() - 1; |
| int cursorLocation = str.lastIndexOf("@test0016.") + "@test0016.".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); |
| } |
| public void test0017() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0017/X.java", |
| "package test0017;\n" + |
| "@interface Y {\n" + |
| " int value();\n" + |
| "}\n" + |
| "@Y(ZZZZ)\n" + |
| "public class X {\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={I}\n" + |
| "expectedTypesKeys={I}", |
| result.context); |
| } |
| public void test0018() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0018/X.java", |
| "package test0018;\n" + |
| "@interface Y {\n" + |
| " int value();\n" + |
| "}\n" + |
| "@Y(ZZZZ)\n" + |
| "public class X {\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={I}\n" + |
| "expectedTypesKeys={I}", |
| result.context); |
| } |
| public void test0019() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0019/X.java", |
| "package test0019;\n" + |
| "@interface Y {\n" + |
| " int value();\n" + |
| "}\n" + |
| "@Y(ZZZZ)\n" + |
| "public class X {\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={I}\n" + |
| "expectedTypesKeys={I}", |
| result.context); |
| } |
| public void test0020() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0020/X.java", |
| "package test0020;\n" + |
| "@interface Y {\n" + |
| " int value();\n" + |
| "}\n" + |
| "@Y()\n" + |
| "public class X {\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("@Y(") + "@Y(".length(); |
| int tokenEnd = tokenStart + "".length() - 1; |
| int cursorLocation = str.lastIndexOf("@Y(") + "@Y(".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={I}\n" + |
| "expectedTypesKeys={I}", |
| result.context); |
| } |
| public void test0021() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0021/X.java", |
| "package test0021;\n" + |
| "@interface Y {\n" + |
| " int value1();\n" + |
| " int value2();\n" + |
| "}\n" + |
| "@Y(value1=1,ZZZZ)\n" + |
| "public class X {\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 test0022() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0022/X.java", |
| "package test0022;\n" + |
| "@interface Y {\n" + |
| " int value1();\n" + |
| " int value2();\n" + |
| "}\n" + |
| "@Y(value1=1,ZZZZ)\n" + |
| "public class X {\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 test0023() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0023/X.java", |
| "package test0023;\n" + |
| "@interface Y {\n" + |
| " int value1();\n" + |
| " int value2();\n" + |
| "}\n" + |
| "@Y(value1=1,ZZZZ)\n" + |
| "public class X {\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 test0024() throws JavaModelException { |
| this.workingCopies = new ICompilationUnit[1]; |
| this.workingCopies[0] = getWorkingCopy( |
| "/Completion/src3/test0024/X.java", |
| "package test0024;\n" + |
| "@interface Y {\n" + |
| " int value1();\n" + |
| " int value2();\n" + |
| "}\n" + |
| "@Y(value1=1,)\n" + |
| "public class X {\n" + |
| "}"); |
| |
| String str = this.workingCopies[0].getSource(); |
| int tokenStart = str.lastIndexOf("value1=1,") + "value1=1,".length(); |
| int tokenEnd = tokenStart + "".length() - 1; |
| int cursorLocation = str.lastIndexOf("value1=1,") + "value1=1,".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); |
| } |
| } |