blob: 5bbf3e05e3f4b9736ad4bf6f9862f3ae1ff1e11d [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2020 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
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import junit.framework.Test;
//java 16 scenarios run with java 16 compliance
public class CompletionTests16_2 extends AbstractJavaModelCompletionTests {
static {
// TESTS_NAMES = new String[]{"test034"};
}
public CompletionTests16_2(String name) {
super(name);
}
public void setUpSuite() throws Exception {
if (COMPLETION_PROJECT == null) {
COMPLETION_PROJECT = setUpJavaProject("Completion", "16");
} else {
setUpProjectCompliance(COMPLETION_PROJECT, "16");
}
super.setUpSuite();
}
public static Test suite() {
return buildModelTestSuite(CompletionTests16_2.class);
}
// completion for local interface
public void test001() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy("/Completion/src/X.java",
"public seal class X permits Y{\n"
+ " public static void main(String[] args){\n"
+ " interf;\n}\n}\n"
+ " ");
this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "interf";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("interface[KEYWORD]{interface, null, null, interface, null, 49}", requestor.getResults());
}
// completion for local enum
public void test002() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy("/Completion/src/X.java",
"public seal class X permits Y{\n"
+ " public static void main(String[] args){\n"
+ " enu;\n}\n}\n"
+ " ");
this.workingCopies[0].getJavaProject(); // assuming single project for all working copies
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "enu";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("Enum[TYPE_REF]{Enum, java.lang, Ljava.lang.Enum;, null, null, 42}\n"
+ "enum[KEYWORD]{enum, null, null, enum, null, 49}",
requestor.getResults());
}
}