mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[java-rd] IDEA-322563 Improve editing experience in Remote Dev for Java
- tests GitOrigin-RevId: 93c130aeac685d8fd9b016d4b5bb8f36482140d3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d2af2f9736
commit
3055e90294
21
java/java-frontback-tests/intellij.java.frontback.tests.iml
Normal file
21
java/java-frontback-tests/intellij.java.frontback.tests.iml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="easymock" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="mockito" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="assertJ" level="project" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="kotlin-test" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" exported="" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.java.frontback.psi.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework.junit5" exported="" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.backend.workspace" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.java.frontback.impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.tests" exported="" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij;
|
||||
|
||||
import com.intellij.openapi.module.ModuleTypeId;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BasicDefaultLightProjectDescriptor extends LightProjectDescriptor {
|
||||
|
||||
public BasicDefaultLightProjectDescriptor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getModuleTypeId() {
|
||||
return ModuleTypeId.JAVA_MODULE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij;
|
||||
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
|
||||
public final class PathJavaTestUtil {
|
||||
public static String getCommunityJavaTestDataPath() {
|
||||
return PathManagerEx.getTestDataPath();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,447 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.BasicDefaultLightProjectDescriptor;
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@TestDataPath("$CONTENT_ROOT/testData")
|
||||
public abstract class AbstractBasicCompleteStatementTest extends LightPlatformCodeInsightTestCase {
|
||||
private CodeStyleSettings mySettings;
|
||||
private CommonCodeStyleSettings myJavaSettings;
|
||||
|
||||
private static String getActionId() {
|
||||
return IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath() + "/codeInsight/completeStatement/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mySettings = CodeStyle.getSettings(getProject());
|
||||
myJavaSettings = mySettings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
public void testAddMissingSemicolon() { doTest(); }
|
||||
|
||||
public void testAddMissingSemicolonToPackageStatement() { doTest(); }
|
||||
|
||||
public void testAddMissingSemicolonAfterAnonymous() { doTest(); }
|
||||
|
||||
public void testAddMissingParen() { doTest(); }
|
||||
|
||||
public void testCompleteIf() { doTest(); }
|
||||
|
||||
public void testCompleteIfKeyword() { doTest(); }
|
||||
|
||||
public void testCompleteIfStatementGoesToThen() { doTest(); }
|
||||
|
||||
public void testAddBracesToIfAndElse() { doTest(); }
|
||||
|
||||
public void testAddBracesToIfThenOneLiner() { doTest(); }
|
||||
|
||||
public void testCompleteIfKeywordStatementGoesToThen() { doTest(); }
|
||||
|
||||
public void testIndentation() { doTest(); }
|
||||
|
||||
public void testErrorNavigation() { doTest(); }
|
||||
|
||||
public void testStringLiteral() { doTest(); }
|
||||
|
||||
public void testCompleteCatch() { doTest(); }
|
||||
|
||||
public void testCompleteCatchLParen() { doTest(); }
|
||||
|
||||
public void testAlreadyCompleteCatch() {
|
||||
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNoBlockReformat() { doTest(); }
|
||||
|
||||
public void testCompleteCatchWithExpression() { doTest(); }
|
||||
|
||||
public void testCompleteCatchBody() { doTest(); }
|
||||
|
||||
public void testSCR11147() { doTest(); }
|
||||
|
||||
public void testNoErrors() { doTest(); }
|
||||
|
||||
public void testThrow() { doTest(); }
|
||||
|
||||
public void testReturn() { doTest(); }
|
||||
|
||||
public void testEmptyLine() { doTest(); }
|
||||
|
||||
public void testBlock() { doTest(); }
|
||||
|
||||
public void testTwoStatementsInLine() { doTest(); }
|
||||
|
||||
public void testFor() { doTest(); }
|
||||
|
||||
public void testEmptyFor() { doTest(); }
|
||||
|
||||
public void testForEach() { doTest(); }
|
||||
|
||||
public void testForBlock() { doTest(); }
|
||||
|
||||
public void testForIncrementExpressionAndBody() { doTest(); }
|
||||
|
||||
public void testEmptyBeforeReturn() { doTest(); }
|
||||
|
||||
public void testIf() { doTest(); }
|
||||
|
||||
public void testIfWithComment() { doTest(); }
|
||||
|
||||
public void testIfWithoutParentheses() { doTest(); }
|
||||
|
||||
public void testBeforeStatement() { doTest(); }
|
||||
|
||||
public void testTry1() { doTest(); }
|
||||
|
||||
public void testInsideResourceVariable() { doTest(); }
|
||||
|
||||
public void testBlock1() { doTest(); }
|
||||
|
||||
public void testAfterFor() { doTest(); }
|
||||
|
||||
public void testBeforeFor() { doTest(); }
|
||||
|
||||
public void testForSingleStatementInBody() { doTest(); }
|
||||
|
||||
public void testForEachSingleStatementInBody() { doTest(); }
|
||||
|
||||
public void testForEachNextStatementNotIndented() { doTest(); }
|
||||
|
||||
public void testAtBlockEnd() { doTest(); }
|
||||
|
||||
public void testForceBlock() { doTest(); }
|
||||
|
||||
public void testElseIf() { doTest(); }
|
||||
|
||||
public void testBlockBeforeElseIf() { doTest(); }
|
||||
|
||||
public void testIncompleteElseIf() { doTest(); }
|
||||
|
||||
public void testField() { doTest(); }
|
||||
|
||||
public void testMethod() { doTest(); }
|
||||
|
||||
public void testLikelyField() { doTest(); }
|
||||
|
||||
public void testVoidMethodIncomplete() { doTest(); }
|
||||
|
||||
public void testFieldWithEquals() { doTest(); }
|
||||
|
||||
public void testClass() { doTest(); }
|
||||
|
||||
public void testInnerEnumBeforeMethod() { doTest(); }
|
||||
|
||||
public void testInnerEnumBeforeMethodWithSpace() { doTest(); }
|
||||
|
||||
public void testCompleteElseIf() { doTest(); }
|
||||
|
||||
public void testReformatElseIf() { doTest(); }
|
||||
|
||||
public void testCompleteStringLiteral() { doTest(); }
|
||||
|
||||
public void testNonAbstractMethodWithSemicolon() { doTest(); }
|
||||
|
||||
public void testReturnFromNonVoid() { doTest(); }
|
||||
|
||||
public void testReturnFromVoid() { doTest(); }
|
||||
|
||||
public void testIncompleteCall() { doTest(); }
|
||||
|
||||
public void testCompleteCall() { doTest(); }
|
||||
|
||||
public void testStartNewBlock() { doTest(); }
|
||||
|
||||
public void testInPrecedingBlanks() { doTest(); }
|
||||
|
||||
public void testNoBlockReturn() { doTest(); }
|
||||
|
||||
public void testInComment() { doTest(); }
|
||||
|
||||
public void testInComment2() { doTest(); }
|
||||
|
||||
public void testInComment3() { doTest(); }
|
||||
|
||||
public void testInComment4() { doTest(); }
|
||||
|
||||
public void testSCR22904() { doTest(); }
|
||||
|
||||
public void testSCR30227() { doTest(); }
|
||||
|
||||
public void testFieldWithInitializer() { doTest(); }
|
||||
|
||||
public void testFieldBeforeAnnotation() { doTest(); }
|
||||
|
||||
public void testMethodBeforeAnnotation() { doTest(); }
|
||||
|
||||
public void testMethodBeforeCommentField() { doTest(); }
|
||||
|
||||
public void testMethodBeforeCommentMethod() { doTest(); }
|
||||
|
||||
public void testCloseAnnotationWithArrayInitializer() { doTest(); }
|
||||
|
||||
public void testParenthesized() { doTest(); }
|
||||
|
||||
public void testCompleteBreak() { doTest(); }
|
||||
|
||||
public void testCompleteIfNextLineBraceStyle() {
|
||||
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCompleteIfNextLineBraceStyle2() {
|
||||
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSCR36110() { doTest(); }
|
||||
|
||||
public void testSCR37331() { doTest(); }
|
||||
|
||||
public void testGenericBeforeVar() { doTest(); }
|
||||
|
||||
public void testIDEADEV434() {
|
||||
mySettings.getCommonSettings(JavaLanguage.INSTANCE).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
|
||||
doTest();
|
||||
mySettings.getCommonSettings(JavaLanguage.INSTANCE).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEADEV1093() { doTest(); }
|
||||
|
||||
public void testIDEADEV1710() { doTest(); }
|
||||
|
||||
public void testInterfaceMethodSemicolon() { doTest(); }
|
||||
|
||||
public void testSynchronized() { doTest(); }
|
||||
|
||||
public void testCdrEndlessLoop() { doTest(); }
|
||||
|
||||
public void testFollowedByComment() { doTest(); }
|
||||
|
||||
public void testBraceFixNewLine() { doTest(); }
|
||||
|
||||
public void testSwitchKeyword() { doTest(); }
|
||||
|
||||
public void testSwitchKeywordWithCondition() { doTest(); }
|
||||
|
||||
public void testSwitchBraces() { doTest(); }
|
||||
|
||||
public void testCaseColon() { doTest(); }
|
||||
|
||||
public void testMultipleCasesColon() { doTest(); }
|
||||
|
||||
public void testDefaultColon() { doTest(); }
|
||||
|
||||
public void testNewInParentheses() { doTest(); }
|
||||
|
||||
public void testIDEADEV20713() { doTest(); }
|
||||
|
||||
public void testIDEA22125() { doTest(); }
|
||||
|
||||
public void testIDEA22385() { doTest(); }
|
||||
|
||||
public void testIDEADEV40479() { doTest(); }
|
||||
|
||||
public void testMultilineReturn() { doTest(); }
|
||||
|
||||
public void testMultilineCall() { doTest(); }
|
||||
|
||||
public void testVarargCall() { doTest(); }
|
||||
|
||||
public void testOverloadedCall() { doTest(); }
|
||||
|
||||
public void testIDEADEV13019() { doTestBracesNextLineStyle(); }
|
||||
|
||||
public void testIDEA25139() { doTestBracesNextLineStyle(); }
|
||||
|
||||
public void testClassBracesNextLine() { doTestBracesNextLineStyle(); }
|
||||
|
||||
public void testBeforeIfRBrace() {
|
||||
mySettings.getCommonSettings(JavaLanguage.INSTANCE).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNoUnnecessaryEmptyLineAtCodeBlock() { doTest(); }
|
||||
|
||||
public void testForStatementGeneration() { doTest(); }
|
||||
|
||||
public void testSpaceAfterSemicolon() {
|
||||
mySettings.getCommonSettings(JavaLanguage.INSTANCE).SPACE_AFTER_SEMICOLON = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNoSpaceAfterSemicolon() {
|
||||
myJavaSettings.SPACE_AFTER_SEMICOLON = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testForUpdateGeneration() { doTest(); }
|
||||
|
||||
public void testReformatForHeader() { doTest(); }
|
||||
|
||||
public void testValidCodeBlock() { doTest(); }
|
||||
|
||||
public void testValidCodeBlockWithEmptyLineAfterIt() { doTest(); }
|
||||
|
||||
public void testFromJavadocParameterDescriptionEndToNextParameter() { doTest(); }
|
||||
|
||||
public void testFromJavadocParameterDescriptionMiddleToNextParameter() { doTest(); }
|
||||
|
||||
public void testLastJavadocParameterDescription() { doTest(); }
|
||||
|
||||
public void testLastJavadocParameterDescriptionToReturn() { doTest(); }
|
||||
|
||||
public void testCompleteMethodCallAtReturn() { doTest(); }
|
||||
|
||||
public void testGenericMethodBody() { doTest(); }
|
||||
|
||||
public void testDefaultMethodBody() { doTest(); }
|
||||
|
||||
public void testStaticInterfaceMethodBody() { doTest(); }
|
||||
|
||||
public void testPrivateInterfaceMethodBody() { doTest(); }
|
||||
|
||||
public void testAddMethodBodyFromInsideAnnotation() { doTest(); }
|
||||
|
||||
public void testArrayInitializerRBracket() { doTest(); }
|
||||
|
||||
public void testArrayInitializerRBrace() { doTest(); }
|
||||
|
||||
public void testArrayInitializerRBrace2() { doTest(); }
|
||||
|
||||
public void testMultiArrayInitializerRBrace() { doTest(); }
|
||||
|
||||
public void testMultiArrayInitializerRBrace2() { doTest(); }
|
||||
|
||||
public void testArrayInitializerSeveralLines() { doTest(); }
|
||||
|
||||
public void testReturnInLambda() { doTest(); }
|
||||
|
||||
public void testSemicolonAfterLambda() { doTest(); }
|
||||
|
||||
public void testModuleInfo() { doTest(); }
|
||||
|
||||
public void testDoubleFieldDeclaration() { doTest(); }
|
||||
|
||||
public void testAddTernaryColon() { doTest(); }
|
||||
|
||||
public void testRecord() { doTest(); }
|
||||
|
||||
public void testRecordWithComponent() { doTest(); }
|
||||
|
||||
public void testRecordWithComponentNoBody() { doTest(); }
|
||||
|
||||
public void testClassBeforeRecord() { doTest(); }
|
||||
|
||||
public void testVarargMethod() { doTest(); }
|
||||
|
||||
public void testVarargMethod2() { doTest(); }
|
||||
|
||||
public void testVarargMethod3() { doTest(); }
|
||||
|
||||
public void testSemicolonAfterSwitchExpression() { doTest(); }
|
||||
|
||||
public void testOverloadedMethod() { doTest(); }
|
||||
|
||||
public void testOverloadedMethodNoCaretHint() { doTest(); }
|
||||
|
||||
public void testOverloadedMethodOneOrThree() { doTest(); }
|
||||
public void testOverloadedMethodOneOrThree2() { doTest(); }
|
||||
|
||||
public void testOverloadedMethodOneOrThree3() { doTest(); }
|
||||
|
||||
public void testMissingComma() { doTest(); }
|
||||
|
||||
public void testInInjection() { doTest(); }
|
||||
|
||||
public void testNativeMethod() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNativePrivateMethod() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnSwitchExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnSwitchExpression2() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnSwitchExpression3() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSwitchAtTheEndOfClass() { doTest(); }
|
||||
|
||||
public void testAddMissingLambdaBody() { doTest(); }
|
||||
|
||||
public void testAddMissingLambdaBody2() { doTest(); }
|
||||
|
||||
public void testBlockInSwitchRule() { doTest(); }
|
||||
|
||||
public void testSwitchAddArrow() { doTest(); }
|
||||
|
||||
public void testYieldSemicolon() { doTest(); }
|
||||
public void testCommentSmartEnter() { doTest(false); }
|
||||
|
||||
@Override
|
||||
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return new BasicDefaultLightProjectDescriptor();
|
||||
}
|
||||
|
||||
private void doTestBracesNextLineStyle() {
|
||||
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
myJavaSettings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
myJavaSettings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest(boolean ignoreTrailingSpaces) {
|
||||
String name = getTestName(false);
|
||||
doFileTest(name + ".java", name + "_after.java", ignoreTrailingSpaces);
|
||||
}
|
||||
|
||||
protected void doFileTest(String filePathBefore, String filePathAfter, boolean ignoreTrailingSpaces) {
|
||||
configureByFile(filePathBefore);
|
||||
invokeAction();
|
||||
checkResultByFile(null, filePathAfter, ignoreTrailingSpaces);
|
||||
}
|
||||
|
||||
private static void invokeAction() {
|
||||
final String actionId = getActionId();
|
||||
final AnAction action = ActionManager.getInstance().getAction(actionId);
|
||||
//noinspection HardCodedStringLiteral
|
||||
assertNotNull("Can find registered action with id=" + actionId, action);
|
||||
action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaBackspaceTest extends LightPlatformCodeInsightTestCase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testBracket1() { doTest(); }
|
||||
|
||||
public void testBracket2() { doTest(); }
|
||||
|
||||
public void testBracket3() { doTest(); }
|
||||
|
||||
public void testBracket4() { doTest(); }
|
||||
|
||||
public void testIdea186011() { doTest(); }
|
||||
|
||||
public void testQuote1() { doTest(); }
|
||||
|
||||
public void testQuote2() { doTest(); }
|
||||
|
||||
public void testQuoteAndCommentAfter() { doTest(); }
|
||||
|
||||
protected void doTest() {
|
||||
@NonNls String path = "/codeInsight/backspace/";
|
||||
|
||||
configureByFile(path + getTestName(false) + ".java");
|
||||
backspace();
|
||||
checkResultByFile(path + getTestName(false) + "_after.java");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaEditingTest extends EditingTestBase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
|
||||
public void testAutoWrapAndTrailingWhiteSpaces() {
|
||||
mySettings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
|
||||
mySettings.setDefaultRightMargin(30);
|
||||
CommonCodeStyleSettings.IndentOptions indentOptions = mySettings.getIndentOptions(null);
|
||||
indentOptions.USE_TAB_CHARACTER = true;
|
||||
indentOptions.INDENT_SIZE = 4;
|
||||
indentOptions.TAB_SIZE = 4;
|
||||
indentOptions.CONTINUATION_INDENT_SIZE = 4;
|
||||
UISettings.getInstance().setFontFace("Tahoma");
|
||||
UISettings.getInstance().setFontSize(11);
|
||||
|
||||
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
scheme.setEditorFontName("Tahoma");
|
||||
scheme.setEditorFontSize(11);
|
||||
|
||||
configureByFile("/codeInsight/editing/before" + getTestName(false) + ".java");
|
||||
backspace();
|
||||
int offset = getEditor().getDocument().getText().indexOf("comment");
|
||||
getEditor().getCaretModel().moveToOffset(offset + "comment".length());
|
||||
for (int i = 0; i < 20; i++) {
|
||||
type(' ');
|
||||
}
|
||||
|
||||
// Check that no unnecessary line feed is introduced.
|
||||
assertEquals(4, getEditor().getDocument().getLineCount());
|
||||
}
|
||||
|
||||
|
||||
public void testMethodBracesInAnonymous() {
|
||||
configureFromFileText("a.java", "class Foo{{ new MethodClosure(new Object() {void fake()<caret>}, 2) }}");
|
||||
type('{');
|
||||
checkResultByText("class Foo{{ new MethodClosure(new Object() {void fake(){<caret>}}, 2) }}");
|
||||
type('}');
|
||||
checkResultByText("class Foo{{ new MethodClosure(new Object() {void fake(){}<caret>}, 2) }}");
|
||||
}
|
||||
|
||||
public void testNoClosingTagInsertedForJavaDocTypeParameter() {
|
||||
// Inspired by IDEA-70898.
|
||||
|
||||
String initial =
|
||||
"""
|
||||
/**
|
||||
* @param <T<caret>
|
||||
*/
|
||||
class Test<T> {
|
||||
}""";
|
||||
init(initial, JavaFileType.INSTANCE);
|
||||
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
final boolean old = settings.JAVADOC_GENERATE_CLOSING_TAG;
|
||||
|
||||
try {
|
||||
settings.JAVADOC_GENERATE_CLOSING_TAG = true;
|
||||
type("> <test-tag>");
|
||||
String expected =
|
||||
"""
|
||||
/**
|
||||
* @param <T> <test-tag><caret></test-tag>
|
||||
*/
|
||||
class Test<T> {
|
||||
}""";
|
||||
checkResultByText(expected);
|
||||
}
|
||||
finally {
|
||||
settings.JAVADOC_GENERATE_CLOSING_TAG = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testHungryBackspaceWinsOverSmartBackspace() {
|
||||
init("""
|
||||
class Test {
|
||||
void m() {
|
||||
\s
|
||||
<caret>}
|
||||
}""", JavaFileType.INSTANCE);
|
||||
executeAction("EditorHungryBackSpace");
|
||||
checkResultByText("""
|
||||
class Test {
|
||||
void m() {<caret>}
|
||||
}""");
|
||||
}
|
||||
|
||||
public void testDeleteToWordStartAndQuotes() {
|
||||
String text = "one \"two\" <caret>\"three\"";
|
||||
init(text, JavaFileType.INSTANCE);
|
||||
executeAction(IdeActions.ACTION_EDITOR_DELETE_TO_WORD_START);
|
||||
checkResultByText("one <caret>\"three\"");
|
||||
}
|
||||
|
||||
public void testDeleteToWordStartAndSingleQuotes() {
|
||||
String text = "one 'two' <caret>'three'";
|
||||
init(text, JavaFileType.INSTANCE);
|
||||
executeAction(IdeActions.ACTION_EDITOR_DELETE_TO_WORD_START);
|
||||
checkResultByText("one <caret>'three'");
|
||||
}
|
||||
|
||||
public void testDeleteToWordStartWhenCaretInsideQuotes() {
|
||||
String text = "one \"two<caret>\"";
|
||||
init(text, JavaFileType.INSTANCE);
|
||||
executeAction(IdeActions.ACTION_EDITOR_DELETE_TO_WORD_START);
|
||||
checkResultByText("one \"<caret>\"");
|
||||
}
|
||||
|
||||
public void testDeleteToWordStartWhenCaretAfterCommaSeparatedLiterals() {
|
||||
String text = "one \"two\", <caret>";
|
||||
init(text, JavaFileType.INSTANCE);
|
||||
executeAction(IdeActions.ACTION_EDITOR_DELETE_TO_WORD_START);
|
||||
checkResultByText("one \"two\"<caret>");
|
||||
}
|
||||
|
||||
public void testDeleteToWordStartWhenCaretBetweenTwoLiterals() {
|
||||
String text = "one \"two\"<caret>\"three\"";
|
||||
init(text, JavaFileType.INSTANCE);
|
||||
executeAction(IdeActions.ACTION_EDITOR_DELETE_TO_WORD_START);
|
||||
checkResultByText("one <caret>\"three\"");
|
||||
}
|
||||
|
||||
public void testNoTypeParameterClosingTagCompletion() {
|
||||
init(
|
||||
"""
|
||||
/**
|
||||
* @param <P<caret>
|
||||
* @author <a href='mailto:xxx@xxx.com'>Mr. Smith</a>
|
||||
*/
|
||||
public class Test<P> {
|
||||
}""",
|
||||
JavaFileType.INSTANCE
|
||||
);
|
||||
|
||||
CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
boolean oldValue = settings.JAVADOC_GENERATE_CLOSING_TAG;
|
||||
settings.JAVADOC_GENERATE_CLOSING_TAG = true;
|
||||
try {
|
||||
type('>');
|
||||
}
|
||||
finally {
|
||||
settings.JAVADOC_GENERATE_CLOSING_TAG = oldValue;
|
||||
}
|
||||
checkResultByText(
|
||||
"""
|
||||
/**
|
||||
* @param <P>
|
||||
* @author <a href='mailto:xxx@xxx.com'>Mr. Smith</a>
|
||||
*/
|
||||
public class Test<P> {
|
||||
}"""
|
||||
);
|
||||
}
|
||||
|
||||
public void testSmartHomeInJavadoc() {
|
||||
init("""
|
||||
/**
|
||||
* some text<caret>
|
||||
*/
|
||||
class C {}""",
|
||||
JavaFileType.INSTANCE);
|
||||
home();
|
||||
checkResultByText("""
|
||||
/**
|
||||
* <caret>some text
|
||||
*/
|
||||
class C {}""");
|
||||
}
|
||||
|
||||
public void testSmartHomeWithSelectionInJavadoc() {
|
||||
init("""
|
||||
/**
|
||||
* some text<caret>
|
||||
*/
|
||||
class C {}""",
|
||||
JavaFileType.INSTANCE);
|
||||
homeWithSelection();
|
||||
checkResultByText("""
|
||||
/**
|
||||
* <selection><caret>some text</selection>
|
||||
*/
|
||||
class C {}""");
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.codeInsight.defaultAction.DefaultActionTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaLBraceTest extends DefaultActionTestCase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testArrayInitializer() { doTest(); }
|
||||
public void testArrayInitializerNoSpace() { doTest(); }
|
||||
public void testInsideCodeBlock() { doTest(); }
|
||||
public void testOutsideCodeBlock() { doTest(); }
|
||||
public void testArrayInitializerBegins() { doTest(); }
|
||||
public void testArrayInitializer1_5Style() { doTest(); }
|
||||
|
||||
protected void doTest() {
|
||||
configureByFile(getTestPath() + ".java");
|
||||
performAction('{');
|
||||
checkResultByFile(getTestPath() + "_after.java");
|
||||
}
|
||||
|
||||
private String getTestPath() {
|
||||
return "/codeInsight/defaultAction/lbrace/" + getTestName(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.codeInsight.defaultAction.DefaultActionTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaLBracketTest extends DefaultActionTestCase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void test1() { doTest(); }
|
||||
|
||||
public void test2() { doTest(); }
|
||||
|
||||
public void test3() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
String path = "/codeInsight/defaultAction/lbracket/";
|
||||
|
||||
configureByFile(path + getTestName(false) + ".java");
|
||||
performAction('[');
|
||||
checkResultByFile(path + getTestName(false) + "_after.java");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.codeInsight.defaultAction.DefaultActionTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaLParenthTest extends DefaultActionTestCase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void test1() { doTest(); }
|
||||
public void test2() { doTest(); }
|
||||
public void test3() { doTest(); }
|
||||
public void test4() { doTest(); }
|
||||
public void test5() { doTest(); }
|
||||
public void test6() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
String path = "/codeInsight/defaultAction/lparenth/";
|
||||
|
||||
configureByFile(path + getTestName(false) + ".java");
|
||||
performAction('(');
|
||||
checkResultByFile(path + getTestName(false) + "_after.java");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
|
||||
public abstract class AbstractBasicJavaQuoteTest extends LightPlatformCodeInsightTestCase {
|
||||
public void testDouble1() { doTest("<caret>", "\"<caret>\""); }
|
||||
|
||||
public void testDouble2() { doTest("<caret>\"\"", "\"<caret>\"\"\""); }
|
||||
|
||||
public void testDoubleClosing() { doTest("\"<caret>\"", "\"\"<caret>"); }
|
||||
|
||||
public void testDoubleClosingWithText() { doTest("\"text<caret>\"", "\"text\"<caret>"); }
|
||||
|
||||
public void testDoubleEscape() { doTest(" \"\\<caret>\" ", " \"\\\"<caret>\" "); }
|
||||
|
||||
public void testDoubleEscapeClosing() { doTest(" \"\\\\<caret>\" ", " \"\\\\\"<caret> "); }
|
||||
|
||||
public void testBeforeIdentifier() { doTest("foo(<caret>a);", "foo(\"<caret>a);"); }
|
||||
|
||||
public void testDoubleInString() { doTest("\"Hello\"<caret> world\";", "\"Hello\"\"<caret> world\";"); }
|
||||
|
||||
public void testBeforeStringWithEscape() { doTest("foo(P + <caret>\"\\n\" + \"xxx\" + E)", "foo(P + \"<caret>\"\"\\n\" + \"xxx\" + E)"); }
|
||||
|
||||
public void testSingleInString() {
|
||||
doTest(" \"<caret>\" ", " \"'<caret>\" ", '\'');
|
||||
}
|
||||
|
||||
public void testSingleInComment() {
|
||||
doTest("/* <caret> */", "/* '<caret> */", '\'');
|
||||
}
|
||||
|
||||
public void testSingleInStringAfterEscape() {
|
||||
doTest(" split(text, '\\<caret>); ", " split(text, '\\'<caret>); ", '\'');
|
||||
}
|
||||
|
||||
|
||||
public void testDoubleQuoteInTextBlock() { doTest(" \"\"\" <caret> \"\"\" ", " \"\"\" \"<caret> \"\"\" "); }
|
||||
|
||||
public void testSingleQuoteInTextBlock() {
|
||||
doTest(" \"\"\" <caret> \"\"\" ", " \"\"\" '<caret> \"\"\" ", '\'');
|
||||
}
|
||||
|
||||
public void testTextBlockClosing() {
|
||||
doTest(" \"\"\".<caret>\"\"\" ", " \"\"\".\"<caret>\"\" ");
|
||||
doTest(" \"\"\".\"<caret>\"\" ", " \"\"\".\"\"<caret>\" ");
|
||||
doTest(" \"\"\".\"\"<caret>\" ", " \"\"\".\"\"\"<caret> ");
|
||||
}
|
||||
|
||||
private void doTest(String before, String after, char c) {
|
||||
doFileTest("class C {{\n " + before + "\n}}",
|
||||
"class C {{\n " + after + "\n}}",
|
||||
c);
|
||||
}
|
||||
|
||||
protected void doTest(String before, String after) {
|
||||
doTest(before, after, '\"');
|
||||
}
|
||||
|
||||
protected void doFileTest(String completeBefore, String expectedResult, char c) {
|
||||
configureFromFileText("a.java", completeBefore);
|
||||
TypedAction.getInstance().actionPerformed(getEditor(), c, ((EditorEx)getEditor()).getDataContext());
|
||||
checkResultByText(expectedResult);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
protected void doFileTest(String completeBefore, String expectedResult) {
|
||||
doFileTest(completeBefore, expectedResult, '\"');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.codeInsight.defaultAction.DefaultActionTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaRBraceTest extends DefaultActionTestCase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
|
||||
public void testMethodClosingBrace() { doTest(); }
|
||||
|
||||
protected void doTest() {
|
||||
String path = "/codeInsight/defaultAction/rbrace/";
|
||||
|
||||
configureByFile(path + getTestName(false) + ".java");
|
||||
performAction('}');
|
||||
checkResultByFile(path + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
public void testClosingNestedArrayInitializer() { doTest(); }
|
||||
public void testClosingArrayInitializer() { doTest(); }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.codeInsight.defaultAction.DefaultActionTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaRBracketTest extends DefaultActionTestCase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void test1() { doTest(); }
|
||||
|
||||
public void test2() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
String path = "/codeInsight/defaultAction/rbracket/";
|
||||
|
||||
configureByFile(path + getTestName(false) + ".java");
|
||||
performAction(']');
|
||||
checkResultByFile(path + getTestName(false) + "_after.java");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.codeInsight.defaultAction.DefaultActionTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaRParenthTest extends DefaultActionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/defaultAction/rparenth/";
|
||||
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void test1() { doTest(); }
|
||||
|
||||
public void test2() { doTest(); }
|
||||
|
||||
public void test3() { doTest(); }
|
||||
|
||||
public void test4() { doTest(); }
|
||||
|
||||
public void test5() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
performAction(')');
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.BasicDefaultLightProjectDescriptor;
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class AbstractBasicJavaSelectWordTest extends SelectWordTestBase {
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return new BasicDefaultLightProjectDescriptor();
|
||||
}
|
||||
|
||||
|
||||
public void testTest1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testTest2() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testIfThenElse1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testIfThenElse2() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testElseIf() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testMiddleElseIf() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testJavaDoc1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testParams1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testCall1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testCall2() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testCallMultiline() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testCallMultiline2() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testBlock1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testBlock2() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testBlock3() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testArray1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testThis() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testTryCatchFinally() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testCast1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testLiteralEscape() {
|
||||
doTest("java", false);
|
||||
}
|
||||
|
||||
public void testLiteralEscape1() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testSwitch() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testSwitch2() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testSwitch3() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testJavaStartLine() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testJavaEndLine() {
|
||||
doTest("java", false);
|
||||
}
|
||||
|
||||
public void testJavaTypeParameter() {
|
||||
doTest("java", false);
|
||||
}
|
||||
|
||||
public void testStringCamelHumps() {
|
||||
EditorSettingsExternalizable.getInstance().setCamelWords(true);
|
||||
try {
|
||||
doTest("java");
|
||||
}
|
||||
finally {
|
||||
EditorSettingsExternalizable.getInstance().setCamelWords(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testCommentQuotes() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testLongCommentWithPunctuation() {
|
||||
doTest("java");
|
||||
}
|
||||
|
||||
public void testMiddleMethod() { doTest("java"); }
|
||||
|
||||
public void testLastMethod() { doTest("java"); }
|
||||
|
||||
public void testDocumentedMethod() { doTest("java"); }
|
||||
|
||||
public void testMethodWithComment() { doTest("java"); }
|
||||
|
||||
public void testFieldWithComment() { doTest("java"); }
|
||||
|
||||
public void testSeparateFieldModifier() { doTest("java"); }
|
||||
|
||||
public void testUnderscoredWordAtComment() { doTest("java"); }
|
||||
|
||||
public void testMethodFromParameterList() { doTest("java"); }
|
||||
|
||||
public void testForHeader() { doTest("java"); }
|
||||
|
||||
public void testBlockComment() { doTest("java"); }
|
||||
|
||||
public void testAnonymousClass() { doTest("java"); }
|
||||
|
||||
public void testTwoComments() { doTest("java"); }
|
||||
|
||||
public void testWordWithApostrophe() { doTest("java"); }
|
||||
|
||||
public void testWordWithApostropheInDocComment() { doTest("java"); }
|
||||
|
||||
public void testWordWithHyphen() { doTest("java"); }
|
||||
|
||||
public void testEmptyLineInSwitchCase() { doTest("java"); }
|
||||
|
||||
public void testUnrelatedParenthesis() { doTest("java"); }
|
||||
|
||||
public void testSwitchCaseInTheMiddle() { doTest("java"); }
|
||||
|
||||
public void testTextBlockNoTrailingLine() { doTest("java"); }
|
||||
|
||||
public void testTextBlockTrailingLine() { doTest("java"); }
|
||||
|
||||
public void testTextBlockEmptyLines() { doTest("java"); }
|
||||
|
||||
public void testLineComments() { doTest("java"); }
|
||||
|
||||
public void testLineCommentsAtStart() { doTest("java"); }
|
||||
|
||||
public void testLineCommentsAtEnd() { doTest("java"); }
|
||||
|
||||
public void testRecordParams() { doTest("java"); }
|
||||
|
||||
public void testWhitespaces() { doTest("java"); }
|
||||
|
||||
public void testWhitespacesAtFileStart() { doTest("java"); }
|
||||
|
||||
public void testWhitespacesAtFileEnd() { doTest("java"); }
|
||||
|
||||
public void testWhitespacesInTheMiddleOfTheLine() { doTest("java"); }
|
||||
|
||||
|
||||
public void testEndOfFile() throws IOException {
|
||||
VirtualFile otherFile = WriteAction.computeAndWait(() -> {
|
||||
VirtualFile res = getSourceRoot().createChildData(null, "zzzzzzzzzzzz.txt");
|
||||
VfsUtil.saveText(res, StringUtil.repeat("a", 1000));
|
||||
return res;
|
||||
});
|
||||
try {
|
||||
doTest("java");
|
||||
// these are preconditions actually, assuming this hasn't changed since test start
|
||||
assertTrue(otherFile.getLength() > getVFile().getLength());
|
||||
assertSame(getFile().getNextSibling(), PsiManager.getInstance(getProject()).findFile(otherFile));
|
||||
}
|
||||
finally {
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
try {
|
||||
otherFile.delete(null);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public abstract class AbstractBasicJavaTypingTest extends BasePlatformTestCase {
|
||||
|
||||
public void testMulticaretSkipSemicolon() {
|
||||
doTest(';');
|
||||
}
|
||||
|
||||
public void testMulticaretSkipGt() {
|
||||
doTest('>');
|
||||
}
|
||||
|
||||
public void testMulticaretInsertGt() {
|
||||
doTest('<');
|
||||
}
|
||||
|
||||
public void testMulticaretSkipRParen() {
|
||||
doTest(')');
|
||||
}
|
||||
|
||||
public void testMulticaretInsertRParen() {
|
||||
doTest('(');
|
||||
}
|
||||
|
||||
public void testMulticaretSkipQuote() {
|
||||
doTest('"');
|
||||
}
|
||||
|
||||
public void testMulticaretInsertQuote() {
|
||||
doTest('"');
|
||||
}
|
||||
|
||||
public void testColumnMode() {
|
||||
myFixture.configureByFile(getTestName(true) + "_before.java");
|
||||
((EditorEx)myFixture.getEditor()).setColumnMode(true);
|
||||
myFixture.type('(');
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.java");
|
||||
}
|
||||
|
||||
public void testInvalidInitialSyntax() {
|
||||
myFixture.configureByFile(getTestName(true) + "_before.java");
|
||||
myFixture.type('\\');
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); // emulates background commit after typing first character
|
||||
myFixture.type('\\');
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.java");
|
||||
}
|
||||
|
||||
public void testFixIfByBraceNewObject() {
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testFixIfByBraceCompositeCondition() {
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testInsertPairParenBeforeTryBlock() {
|
||||
doTest('(');
|
||||
}
|
||||
|
||||
public void testInsertPairedBraceBeforeDot() {
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testInsertPairedBraceForLambdaBody() {
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testInsertPairedBraceForLocalClass() {
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testInsertPairedBraceForLocalRecord() {
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testSemicolonInStringLiteral() {
|
||||
doTest(';');
|
||||
}
|
||||
|
||||
public void testSemicolonInComment() {
|
||||
doTest(';');
|
||||
}
|
||||
|
||||
public void testSemicolonBeforeRightParenMoved() {
|
||||
doMultiTypeTest(';');
|
||||
}
|
||||
|
||||
public void testSemicolonBeforeRightParenNotMoved() {
|
||||
doMultiTypeTest(';');
|
||||
}
|
||||
|
||||
public void testSemicolonBeforeRightParenInLiterals() {
|
||||
doMultiTypeTest(';');
|
||||
}
|
||||
|
||||
public void testSemicolonBeforeRightParenInBlockComment() {
|
||||
doTest(';');
|
||||
}
|
||||
|
||||
public void testCommaInDefaultAnnotationStringArgumentWhenArrayIsExpected() { doTest(','); }
|
||||
|
||||
public void testQuestionAfterPolyadicBoolean() { doTest('?'); }
|
||||
|
||||
protected void doTest(char c) {
|
||||
myFixture.configureByFile(getTestName(true) + "_before.java");
|
||||
myFixture.type(c);
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.java");
|
||||
}
|
||||
|
||||
protected void doTestUndo() {
|
||||
TextEditor fileEditor = TextEditorProvider.getInstance().getTextEditor(myFixture.getEditor());
|
||||
UndoManager.getInstance(getProject()).undo(fileEditor);
|
||||
myFixture.checkResultByFile(getTestName(true) + "_afterUndo.java");
|
||||
}
|
||||
|
||||
private void doMultiTypeTest(char c) {
|
||||
myFixture.configureByFile(getTestName(true) + "_before.java");
|
||||
List<Integer> whereToType = findWhereToType(myFixture.getEditor().getDocument().getImmutableCharSequence());
|
||||
assertNotNull("Test file must have at least one place where to type!", whereToType);
|
||||
assertFalse("Test file must have at least one place where to type!", whereToType.isEmpty());
|
||||
for (Integer offset : whereToType) {
|
||||
myFixture.getEditor().getCaretModel().moveToOffset(offset);
|
||||
myFixture.type(c);
|
||||
}
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.java");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/java/java-tests/testData/codeInsight/typing";
|
||||
}
|
||||
|
||||
private static List<Integer> findWhereToType(@NotNull CharSequence content) {
|
||||
List<Integer> offsets = new ArrayList<>();
|
||||
Matcher m = Pattern.compile("/\\*typehere\\*/").matcher(content);
|
||||
while (m.find()) {
|
||||
offsets.add(m.end());
|
||||
}
|
||||
offsets.sort(Comparator.reverseOrder());
|
||||
return offsets;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.PathJavaTestUtil;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavadocTypedHandlerFunctionalTest extends LightPlatformCodeInsightTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/editorActions/javadocTypedHandler/";
|
||||
|
||||
public void testEmptyTag() {
|
||||
doTest('>');
|
||||
}
|
||||
|
||||
public void testComment() {
|
||||
doTest('>');
|
||||
}
|
||||
|
||||
public void testCodeTag() {
|
||||
doTest('>');
|
||||
}
|
||||
|
||||
public void testTypeParam() {
|
||||
doTest('>');
|
||||
}
|
||||
|
||||
public void testDocTagStart() {
|
||||
doTest('@');
|
||||
}
|
||||
|
||||
private void doTest(char typedChar) {
|
||||
String testName = getTestName(true);
|
||||
configureByFile(BASE_PATH + testName + ".java");
|
||||
type(typedChar);
|
||||
checkResultByFile(BASE_PATH + testName + "_after.java");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathJavaTestUtil.getCommunityJavaTestDataPath();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.editorActions.AbstractBasicJavadocTypedHandler;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public abstract class AbstractBasicJavadocTypedHandlerTest {
|
||||
|
||||
private static final String CARET_MARKER = "<caret>";
|
||||
|
||||
@Test
|
||||
public void correctEmptyTagStart() {
|
||||
doTest("<first></first><second><caret>", "second");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void standaloneBracket() {
|
||||
doTest("asdf ><caret>", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyElement() {
|
||||
doTest("<tag/><caret>", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void closingTag() {
|
||||
doTest("<tag></tag><caret>", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startTagOnNewLine() {
|
||||
doTest("<t\nag><caret>", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tagWithAttribute() {
|
||||
doTest("<a href='www'><caret>", "a");
|
||||
}
|
||||
|
||||
private static void doTest(String text, String expected) {
|
||||
StringBuilder normalized = new StringBuilder();
|
||||
int offset = text.indexOf(CARET_MARKER);
|
||||
normalized.append(text, 0, offset);
|
||||
normalized.append(text.substring(offset + CARET_MARKER.length()));
|
||||
CharSequence actual = AbstractBasicJavadocTypedHandler.getTagName(normalized.toString(), offset);
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.editor;
|
||||
|
||||
import com.intellij.ide.highlighter.HighlighterFactory;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.StringEscapesTokenTypes;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import com.intellij.testFramework.propertyBased.CheckHighlighterConsistency;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class AbstractBasicJavaHighlighterTest extends LightPlatformCodeInsightTestCase {
|
||||
protected EditorHighlighter myHighlighter;
|
||||
protected Document myDocument;
|
||||
private final ArrayList<Editor> myEditorsToRelease = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
for (Editor editor : myEditorsToRelease) {
|
||||
EditorFactory.getInstance().releaseEditor(editor);
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
addSuppressedException(e);
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
public void testEnteringSomeQuotes() {
|
||||
Editor editor = initDocument("""
|
||||
class C {
|
||||
void foo() {
|
||||
first();
|
||||
second();
|
||||
}
|
||||
}""");
|
||||
WriteCommandAction.runWriteCommandAction(getProject(), () -> {
|
||||
myDocument.insertString(myDocument.getText().lastIndexOf("first"), "'''");
|
||||
myDocument.insertString(myDocument.getText().lastIndexOf("second"), " ");
|
||||
});
|
||||
CheckHighlighterConsistency.performCheck(editor);
|
||||
}
|
||||
|
||||
public void testUnicodeEscapeSequence() {
|
||||
String prefix = """
|
||||
class A {
|
||||
String s = ""\"
|
||||
""";
|
||||
initDocument(prefix +
|
||||
"\\uuuuu005c\\\"\"\";\n" +
|
||||
"}");
|
||||
HighlighterIterator iterator = myHighlighter.createIterator(prefix.length());
|
||||
assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());
|
||||
iterator.advance();
|
||||
assertEquals(JavaTokenType.TEXT_BLOCK_LITERAL, iterator.getTokenType());
|
||||
}
|
||||
|
||||
public void testUnicodeBackslashEscapesUnicodeSequence() {
|
||||
String prefix = """
|
||||
class A {
|
||||
String s = ""\"
|
||||
""";
|
||||
initDocument(prefix +
|
||||
"\\u005c\\u0040\"\"\";\n" +
|
||||
"}");
|
||||
HighlighterIterator iterator = myHighlighter.createIterator(prefix.length());
|
||||
assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());
|
||||
iterator.advance();
|
||||
assertEquals(JavaTokenType.TEXT_BLOCK_LITERAL, iterator.getTokenType());
|
||||
}
|
||||
|
||||
protected Editor initDocument(String text) {
|
||||
EditorFactory editorFactory = EditorFactory.getInstance();
|
||||
myDocument = editorFactory.createDocument(text);
|
||||
final Editor editor = editorFactory.createEditor(myDocument, getProject());
|
||||
|
||||
myHighlighter = HighlighterFactory
|
||||
.createHighlighter(JavaFileType.INSTANCE, EditorColorsManager.getInstance().getGlobalScheme(), getProject());
|
||||
((EditorEx)editor).setHighlighter(myHighlighter);
|
||||
|
||||
myEditorsToRelease.add(editor);
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,508 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.lexer;
|
||||
|
||||
import com.intellij.testFramework.LexerTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavaLexerTest extends LexerTestCase {
|
||||
public void testClassicNumericLiterals() {
|
||||
doTest("0 1234 01234 0x1234",
|
||||
"""
|
||||
INTEGER_LITERAL ('0')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('1234')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('01234')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0x1234')""");
|
||||
|
||||
doTest("0L 1234l 01234L 0x1234l",
|
||||
"""
|
||||
LONG_LITERAL ('0L')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('1234l')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('01234L')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('0x1234l')""");
|
||||
|
||||
doTest("0f 1e1f 2.f .3f 0f 3.14f 6.022137e+23f",
|
||||
"""
|
||||
FLOAT_LITERAL ('0f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('1e1f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('2.f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('.3f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('0f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('3.14f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('6.022137e+23f')""");
|
||||
|
||||
doTest("0d 1e1 2. .3 0.0 3.14 1e-9d 1e137",
|
||||
"""
|
||||
DOUBLE_LITERAL ('0d')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('1e1')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('2.')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('.3')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0.0')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('3.14')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('1e-9d')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('1e137')""");
|
||||
|
||||
doTest(". e0 x1 ax .e .p 08 .0e .0f",
|
||||
"""
|
||||
DOT ('.')
|
||||
WHITE_SPACE (' ')
|
||||
IDENTIFIER ('e0')
|
||||
WHITE_SPACE (' ')
|
||||
IDENTIFIER ('x1')
|
||||
WHITE_SPACE (' ')
|
||||
IDENTIFIER ('ax')
|
||||
WHITE_SPACE (' ')
|
||||
DOT ('.')
|
||||
IDENTIFIER ('e')
|
||||
WHITE_SPACE (' ')
|
||||
DOT ('.')
|
||||
IDENTIFIER ('p')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('08')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('.0e')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('.0f')""");
|
||||
}
|
||||
|
||||
public void testTigerNumericLiterals() {
|
||||
doTest("0xap0f 0xab.p0F 0x.abcP0f 0xabc.defP0F",
|
||||
"""
|
||||
FLOAT_LITERAL ('0xap0f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('0xab.p0F')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('0x.abcP0f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('0xabc.defP0F')""");
|
||||
|
||||
doTest("0xap1 0xab.P12 0x.abcP123d 0xabc.defP1234D",
|
||||
"""
|
||||
DOUBLE_LITERAL ('0xap1')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0xab.P12')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0x.abcP123d')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0xabc.defP1234D')""");
|
||||
|
||||
doTest("p0",
|
||||
"IDENTIFIER ('p0')");
|
||||
}
|
||||
|
||||
public void testCoinNumericLiterals() {
|
||||
doTest("1_2 0_1 012__34 0x1_2_3_4 0B0 0b0001_0010_0100_1000",
|
||||
"""
|
||||
INTEGER_LITERAL ('1_2')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0_1')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('012__34')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0x1_2_3_4')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0B0')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0b0001_0010_0100_1000')""");
|
||||
|
||||
doTest("1_2L 0_7l 012__34l 0x1_2_3_4L 0B0L 0b0001_0010_0100_1000l",
|
||||
"""
|
||||
LONG_LITERAL ('1_2L')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('0_7l')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('012__34l')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('0x1_2_3_4L')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('0B0L')
|
||||
WHITE_SPACE (' ')
|
||||
LONG_LITERAL ('0b0001_0010_0100_1000l')""");
|
||||
|
||||
doTest("1_0f 1e1_2f 2_2.f .3_3f 3.14_16f 6.022___137e+2_3f",
|
||||
"""
|
||||
FLOAT_LITERAL ('1_0f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('1e1_2f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('2_2.f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('.3_3f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('3.14_16f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('6.022___137e+2_3f')""");
|
||||
|
||||
doTest("0_0d 1e1_1 2_2. .3_3 3.141_592 1e-9_9d 1e1__3_7",
|
||||
"""
|
||||
DOUBLE_LITERAL ('0_0d')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('1e1_1')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('2_2.')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('.3_3')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('3.141_592')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('1e-9_9d')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('1e1__3_7')""");
|
||||
|
||||
doTest("0xa_ap1_0f 0xa_b.p22F 0x.ab__cP0f 0xa_bc.d_efP0F",
|
||||
"""
|
||||
FLOAT_LITERAL ('0xa_ap1_0f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('0xa_b.p22F')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('0x.ab__cP0f')
|
||||
WHITE_SPACE (' ')
|
||||
FLOAT_LITERAL ('0xa_bc.d_efP0F')""");
|
||||
|
||||
doTest("0xa_ap1 0xa_b.P1_2 0x.a_bcP1___23d 0xa_bc.de_fP1_234D",
|
||||
"""
|
||||
DOUBLE_LITERAL ('0xa_ap1')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0xa_b.P1_2')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0x.a_bcP1___23d')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0xa_bc.de_fP1_234D')""");
|
||||
}
|
||||
|
||||
public void testMalformedCoinLiterals() {
|
||||
doTest("_1 _b ._ 0_ 0_8 0x_f 0b_1 0B2 0x1.0_p-1 1.0e_1022 0._1",
|
||||
"""
|
||||
IDENTIFIER ('_1')
|
||||
WHITE_SPACE (' ')
|
||||
IDENTIFIER ('_b')
|
||||
WHITE_SPACE (' ')
|
||||
DOT ('.')
|
||||
IDENTIFIER ('_')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0_')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0_8')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0x_f')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0b_1')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0B2')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0x1.0_p-1')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('1.0e_1022')
|
||||
WHITE_SPACE (' ')
|
||||
DOUBLE_LITERAL ('0._1')""");
|
||||
}
|
||||
|
||||
public void testMalformedOperators() {
|
||||
doTest("(i > = 0)",
|
||||
"""
|
||||
LPARENTH ('(')
|
||||
IDENTIFIER ('i')
|
||||
WHITE_SPACE (' ')
|
||||
GT ('>')
|
||||
WHITE_SPACE (' ')
|
||||
EQ ('=')
|
||||
WHITE_SPACE (' ')
|
||||
INTEGER_LITERAL ('0')
|
||||
RPARENTH (')')
|
||||
""");
|
||||
}
|
||||
|
||||
public void testJava8Tokens() {
|
||||
doTest("none :: ->",
|
||||
"IDENTIFIER ('none')\nWHITE_SPACE (' ')\nDOUBLE_COLON ('::')\nWHITE_SPACE (' ')\nARROW ('->')");
|
||||
}
|
||||
|
||||
public void testUnicodeLiterals() {
|
||||
doTest("Ɐ Σx dΦ",
|
||||
"IDENTIFIER ('Ɐ')\nWHITE_SPACE (' ')\nIDENTIFIER ('Σx')\nWHITE_SPACE (' ')\nIDENTIFIER ('dΦ')");
|
||||
}
|
||||
|
||||
public void testTextBlockLiterals() {
|
||||
doTest("\"\"\"\n hi there. \"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\"\\n hi there. \"\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\" ')");
|
||||
doTest("\"\"\".\\\"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\".\\\"\"\" ')");
|
||||
doTest("\"\"\".\\\\\"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\".\\\\\"\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\"\".\\\\\\\"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\".\\\\\\\"\"\" ')");
|
||||
doTest("\"\"\"\"\"\"+\"\"\"\"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\"\"\"\"')\nPLUS ('+')\nTEXT_BLOCK_LITERAL ('\"\"\"\"\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\\\"\"\".\"\"\" ", "BAD_CHARACTER ('\\')\nTEXT_BLOCK_LITERAL ('\"\"\".\"\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\"\"\n \"\\\"\"\" \"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\"\\n \"\\\"\"\" \"\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\"\"\n \"\"\\\"\"\" \"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\"\\n \"\"\\\"\"\" \"\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\"\" \n\"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\" \\n\"\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\"\"\n \\u005C\"\"\"\n \"\"\"", "TEXT_BLOCK_LITERAL ('\"\"\"\\n \\u005C\"\"\"\\n \"\"\"')"); // unicode escaped backslash '\'
|
||||
|
||||
doTest("\"\"\"\n\\{}\"\"\"", "TEXT_BLOCK_LITERAL ('\"\"\"\\n\\{}\"\"\"')");
|
||||
doTest("\"\"\"\n ...\n\"\" \"\"\" ", "TEXT_BLOCK_LITERAL ('\"\"\"\\n ...\\n\"\" \"\"\"')\nWHITE_SPACE (' ')");
|
||||
}
|
||||
|
||||
public void testStringTemplatesJDK21_Preview() {
|
||||
doTest("\"\\{}\"", "STRING_TEMPLATE_BEGIN ('\"\\{')\nSTRING_TEMPLATE_END ('}\"')");
|
||||
doTest("\"\"\"\n\\{}\"\"\"", "TEXT_BLOCK_TEMPLATE_BEGIN ('\"\"\"\\n\\{')\nTEXT_BLOCK_TEMPLATE_END ('}\"\"\"')");
|
||||
doTest("\"\\{123}\"", "STRING_TEMPLATE_BEGIN ('\"\\{')\nINTEGER_LITERAL ('123')\nSTRING_TEMPLATE_END ('}\"')");
|
||||
doTest("\"\"\"\n\\{123}\"\"\"", "TEXT_BLOCK_TEMPLATE_BEGIN ('\"\"\"\\n\\{')\nINTEGER_LITERAL ('123')\nTEXT_BLOCK_TEMPLATE_END ('}\"\"\"')");
|
||||
doTest("\"\\{new int[][] {{}}}\"", """
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
NEW_KEYWORD ('new')
|
||||
WHITE_SPACE (' ')
|
||||
INT_KEYWORD ('int')
|
||||
LBRACKET ('[')
|
||||
RBRACKET (']')
|
||||
LBRACKET ('[')
|
||||
RBRACKET (']')
|
||||
WHITE_SPACE (' ')
|
||||
LBRACE ('{')
|
||||
LBRACE ('{')
|
||||
RBRACE ('}')
|
||||
RBRACE ('}')
|
||||
STRING_TEMPLATE_END ('}"')""");
|
||||
doTest("\"\"\"\n\\{new int[][] {{}}}\"\"\"", """
|
||||
TEXT_BLOCK_TEMPLATE_BEGIN ('""\"\\n\\{')
|
||||
NEW_KEYWORD ('new')
|
||||
WHITE_SPACE (' ')
|
||||
INT_KEYWORD ('int')
|
||||
LBRACKET ('[')
|
||||
RBRACKET (']')
|
||||
LBRACKET ('[')
|
||||
RBRACKET (']')
|
||||
WHITE_SPACE (' ')
|
||||
LBRACE ('{')
|
||||
LBRACE ('{')
|
||||
RBRACE ('}')
|
||||
RBRACE ('}')
|
||||
TEXT_BLOCK_TEMPLATE_END ('}""\"')""");
|
||||
doTest("\"\\{x} + \\{y} = \\{x + y}\"", """
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('x')
|
||||
STRING_TEMPLATE_MID ('} + \\{')
|
||||
IDENTIFIER ('y')
|
||||
STRING_TEMPLATE_MID ('} = \\{')
|
||||
IDENTIFIER ('x')
|
||||
WHITE_SPACE (' ')
|
||||
PLUS ('+')
|
||||
WHITE_SPACE (' ')
|
||||
IDENTIFIER ('y')
|
||||
STRING_TEMPLATE_END ('}"')""");
|
||||
doTest("\"\"\"\n\\{x} +\n \\{y} = \\{x + y}\"\"\"", """
|
||||
TEXT_BLOCK_TEMPLATE_BEGIN ('""\"\\n\\{')
|
||||
IDENTIFIER ('x')
|
||||
TEXT_BLOCK_TEMPLATE_MID ('} +\\n \\{')
|
||||
IDENTIFIER ('y')
|
||||
TEXT_BLOCK_TEMPLATE_MID ('} = \\{')
|
||||
IDENTIFIER ('x')
|
||||
WHITE_SPACE (' ')
|
||||
PLUS ('+')
|
||||
WHITE_SPACE (' ')
|
||||
IDENTIFIER ('y')
|
||||
TEXT_BLOCK_TEMPLATE_END ('}""\"')""");
|
||||
doTest("\"\\{}\" }\"", """
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
WHITE_SPACE (' ')
|
||||
RBRACE ('}')
|
||||
STRING_LITERAL ('"')""");
|
||||
doTest("\"\\{\"hello\"}\" ", "STRING_TEMPLATE_BEGIN ('\"\\{')\nSTRING_LITERAL ('\"hello\"')\nSTRING_TEMPLATE_END ('}\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\"\"\n \\{\"\"\"\n!\"\"\" }\"\"\" ", """
|
||||
TEXT_BLOCK_TEMPLATE_BEGIN ('""\"\\n \\{')
|
||||
TEXT_BLOCK_LITERAL ('""\"\\n!""\"')
|
||||
WHITE_SPACE (' ')
|
||||
TEXT_BLOCK_TEMPLATE_END ('}""\"')
|
||||
WHITE_SPACE (' ')""");
|
||||
doTest("""
|
||||
"\\{fruit[0]}, \\{STR."\\{fruit[1]}, \\{fruit[2]}"}"
|
||||
""",
|
||||
"""
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('fruit')
|
||||
LBRACKET ('[')
|
||||
INTEGER_LITERAL ('0')
|
||||
RBRACKET (']')
|
||||
STRING_TEMPLATE_MID ('}, \\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('fruit')
|
||||
LBRACKET ('[')
|
||||
INTEGER_LITERAL ('1')
|
||||
RBRACKET (']')
|
||||
STRING_TEMPLATE_MID ('}, \\{')
|
||||
IDENTIFIER ('fruit')
|
||||
LBRACKET ('[')
|
||||
INTEGER_LITERAL ('2')
|
||||
RBRACKET (']')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
WHITE_SPACE ('\\n')""");
|
||||
doTest("""
|
||||
STR."\\{STR."\\{STR."\\{STR."\\{STR."\\{STR."\\{STR.""}"}"}"}"}"}"
|
||||
""",
|
||||
"""
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"\\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_LITERAL ('""')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
STRING_TEMPLATE_END ('}"')
|
||||
WHITE_SPACE ('\\n')""");
|
||||
doTest("""
|
||||
""\"
|
||||
"\\{}""\"""",
|
||||
"""
|
||||
TEXT_BLOCK_TEMPLATE_BEGIN ('""\"\\n "\\{')
|
||||
TEXT_BLOCK_TEMPLATE_END ('}""\"')""");
|
||||
doTest("""
|
||||
STR.""\"
|
||||
xx
|
||||
\\{STR."String \\{a} String"}
|
||||
xx""\"""",
|
||||
"""
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
TEXT_BLOCK_TEMPLATE_BEGIN ('""\"\\nxx\\n\\{')
|
||||
IDENTIFIER ('STR')
|
||||
DOT ('.')
|
||||
STRING_TEMPLATE_BEGIN ('"String \\{')
|
||||
IDENTIFIER ('a')
|
||||
STRING_TEMPLATE_END ('} String"')
|
||||
TEXT_BLOCK_TEMPLATE_END ('}\\nxx""\"')""");
|
||||
}
|
||||
|
||||
public void testStringLiterals() {
|
||||
doTest("\"", "STRING_LITERAL ('\"')");
|
||||
doTest("\" ", "STRING_LITERAL ('\" ')");
|
||||
doTest("\"\"", "STRING_LITERAL ('\"\"')");
|
||||
doTest("\"\" ", "STRING_LITERAL ('\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"x\n ", "STRING_LITERAL ('\"x')\nWHITE_SPACE ('\\n ')");
|
||||
doTest("\"\\\"\" ", "STRING_LITERAL ('\"\\\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\\", "STRING_LITERAL ('\"\\')");
|
||||
doTest("\"\\u", "STRING_LITERAL ('\"\\u')");
|
||||
doTest("\"\n\"", "STRING_LITERAL ('\"')\nWHITE_SPACE ('\\n')\nSTRING_LITERAL ('\"')");
|
||||
doTest("\"\\n\" ", "STRING_LITERAL ('\"\\n\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\\uuuuuu005c\"\" ", "STRING_LITERAL ('\"\\uuuuuu005c\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\\u005c\"\" ", "STRING_LITERAL ('\"\\u005c\"\"')\nWHITE_SPACE (' ')");
|
||||
doTest("\"\\u005\" ", "STRING_LITERAL ('\"\\u005\"')\nWHITE_SPACE (' ')"); // broken unicode escape
|
||||
doTest("\"\\u00\" ", "STRING_LITERAL ('\"\\u00\"')\nWHITE_SPACE (' ')"); // broken unicode escape
|
||||
doTest("\"\\u0\" ", "STRING_LITERAL ('\"\\u0\"')\nWHITE_SPACE (' ')"); // broken unicode escape
|
||||
doTest("\"\\u\" ", "STRING_LITERAL ('\"\\u\"')\nWHITE_SPACE (' ')"); // broken unicode escape
|
||||
|
||||
// see also com.intellij.java.codeInsight.daemon.LightAdvHighlightingTest#testStringLiterals
|
||||
doTest(" \"\\u000a\" ", "WHITE_SPACE (' ')\nSTRING_LITERAL ('\"\\u000a\"')\nWHITE_SPACE (' ')");
|
||||
|
||||
doTest("\"\\{}\"", "STRING_LITERAL ('\"\\{}\"')");
|
||||
}
|
||||
|
||||
public void testCharLiterals() {
|
||||
doTest("'\\u005c\\u005c'", "CHARACTER_LITERAL (''\\u005c\\u005c'')"); // unicode escaped escaped slash '\\'
|
||||
doTest("\\u0027\\u005c\\u005c'", "CHARACTER_LITERAL ('\\u0027\\u005c\\u005c'')"); // unicode escaped escaped slash '\\'
|
||||
doTest("'\\u1234' ", "CHARACTER_LITERAL (''\\u1234'')\nWHITE_SPACE (' ')");
|
||||
doTest("'\\u1234\\u0027 ", "CHARACTER_LITERAL (''\\u1234\\u0027')\nWHITE_SPACE (' ')");
|
||||
doTest("'x' ", "CHARACTER_LITERAL (''x'')\nWHITE_SPACE (' ')");
|
||||
doTest("'", "CHARACTER_LITERAL (''')");
|
||||
doTest("\\u0027", "CHARACTER_LITERAL ('\\u0027')");
|
||||
doTest("' ", "CHARACTER_LITERAL ('' ')");
|
||||
doTest("'\\u0020", "CHARACTER_LITERAL (''\\u0020')");
|
||||
doTest("''", "CHARACTER_LITERAL ('''')");
|
||||
doTest("'\\u0027", "CHARACTER_LITERAL (''\\u0027')");
|
||||
doTest("\\u0027\\u0027", "CHARACTER_LITERAL ('\\u0027\\u0027')");
|
||||
doTest("'\\u007F' 'F' ", "CHARACTER_LITERAL (''\\u007F'')\nWHITE_SPACE (' ')\nCHARACTER_LITERAL (''F'')\nWHITE_SPACE (' ')");
|
||||
doTest("'\\u005C' ", "CHARACTER_LITERAL (''\\u005C' ')"); // closing quote is escaped with unicode escaped backslash
|
||||
}
|
||||
|
||||
public void testComments() {
|
||||
doTest("//", "END_OF_LINE_COMMENT ('//')");
|
||||
doTest("\\u002f\\u002F", "END_OF_LINE_COMMENT ('\\u002f\\u002F')");
|
||||
doTest("//\n", "END_OF_LINE_COMMENT ('//')\nWHITE_SPACE ('\\n')");
|
||||
doTest("//\\u000A", "END_OF_LINE_COMMENT ('//')\nWHITE_SPACE ('\\u000A')");
|
||||
doTest("//x\n", "END_OF_LINE_COMMENT ('//x')\nWHITE_SPACE ('\\n')");
|
||||
doTest("/\\u002fx\n", "END_OF_LINE_COMMENT ('/\\u002fx')\nWHITE_SPACE ('\\n')");
|
||||
doTest("/*/ ", "C_STYLE_COMMENT ('/*/ ')");
|
||||
doTest("/\\u002A/ ", "C_STYLE_COMMENT ('/\\u002A/ ')");
|
||||
doTest("/**/ ", "C_STYLE_COMMENT ('/**/')\nWHITE_SPACE (' ')");
|
||||
doTest("\\u002f**/ ", "C_STYLE_COMMENT ('\\u002f**/')\nWHITE_SPACE (' ')");
|
||||
doTest("/*x*/ ", "C_STYLE_COMMENT ('/*x*/')\nWHITE_SPACE (' ')");
|
||||
doTest("/*x\\u002a\\u002F\\u0020", "C_STYLE_COMMENT ('/*x\\u002a\\u002F')\nWHITE_SPACE ('\\u0020')");
|
||||
doTest("/***/ ", "DOC_COMMENT ('/***/')\nWHITE_SPACE (' ')");
|
||||
doTest("/*\\u002a*/ ", "DOC_COMMENT ('/*\\u002a*/')\nWHITE_SPACE (' ')");
|
||||
doTest("/**x*/ ", "DOC_COMMENT ('/**x*/')\nWHITE_SPACE (' ')");
|
||||
doTest("/**\\u0078*/ ", "DOC_COMMENT ('/**\\u0078*/')\nWHITE_SPACE (' ')");
|
||||
doTest("/*", "C_STYLE_COMMENT ('/*')");
|
||||
doTest("/\\u002a", "C_STYLE_COMMENT ('/\\u002a')");
|
||||
doTest("/**", "DOC_COMMENT ('/**')");
|
||||
doTest("/*\\u002a", "DOC_COMMENT ('/*\\u002a')");
|
||||
doTest("/***", "DOC_COMMENT ('/***')");
|
||||
doTest("/**\\u002a", "DOC_COMMENT ('/**\\u002a')");
|
||||
doTest("#! ", "END_OF_LINE_COMMENT ('#! ')");
|
||||
doTest("\\u0023! ", "BAD_CHARACTER ('\\')\nIDENTIFIER ('u0023')\nEXCL ('!')\nWHITE_SPACE (' ')");
|
||||
doTest("/", "DIV ('/')");
|
||||
doTest("1/2", "INTEGER_LITERAL ('1')\nDIV ('/')\nINTEGER_LITERAL ('2')");
|
||||
doTest("//\\\\u000A test", "END_OF_LINE_COMMENT ('//\\\\u000A test')"); // escaped backslash, not a unicode escape
|
||||
doTest("//\\\\\\u000A test",
|
||||
"END_OF_LINE_COMMENT ('//\\\\')\nWHITE_SPACE ('\\u000A ')\nIDENTIFIER ('test')"); // escaped backslash, followed by a unicode escape
|
||||
}
|
||||
|
||||
public void testWhitespace() {
|
||||
doTest(" ", "WHITE_SPACE (' ')");
|
||||
doTest("\t", "WHITE_SPACE ('\t')");
|
||||
doTest("\n", "WHITE_SPACE ('\\n')");
|
||||
doTest("\r", "WHITE_SPACE ('\r')");
|
||||
doTest("\\u000A", "WHITE_SPACE ('\\u000A')");
|
||||
doTest("\\u000d", "WHITE_SPACE ('\\u000d')");
|
||||
doTest("\\u000d\n\\u000a", "WHITE_SPACE ('\\u000d\\n\\u000a')");
|
||||
doTest("\\", "BAD_CHARACTER ('\\')");
|
||||
doTest("\\u", "BAD_CHARACTER ('\\')\nIDENTIFIER ('u')");
|
||||
doTest("\\u0", "BAD_CHARACTER ('\\')\nIDENTIFIER ('u0')");
|
||||
doTest("\\u00", "BAD_CHARACTER ('\\')\nIDENTIFIER ('u00')");
|
||||
doTest("\\u000", "BAD_CHARACTER ('\\')\nIDENTIFIER ('u000')");
|
||||
doTest("\\u000A", "WHITE_SPACE ('\\u000A')");
|
||||
doTest("\\u000A\\u000A", "WHITE_SPACE ('\\u000A\\u000A')");
|
||||
doTest("\\\\u000A", "BAD_CHARACTER ('\\')\nBAD_CHARACTER ('\\')\nIDENTIFIER ('u000A')");
|
||||
doTest("\\\\\\u000A", "BAD_CHARACTER ('\\')\nBAD_CHARACTER ('\\')\nWHITE_SPACE ('\\u000A')");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull String getDirPath() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.lexer
|
||||
|
||||
import com.intellij.lexer.Lexer
|
||||
import com.intellij.testFramework.LexerTestCase
|
||||
|
||||
abstract class AbstractBasicJavadocLexerTest : LexerTestCase() {
|
||||
fun testSnippetAttributes() {
|
||||
doTest("""
|
||||
/**
|
||||
* {@snippet attr1 = "attr1 value" attr2 = 'attr2 value' attr3 = attr3Value :
|
||||
* foo {}
|
||||
* }
|
||||
*/
|
||||
""".trimIndent().trim(),
|
||||
"""DOC_COMMENT_START ('/**')
|
||||
DOC_SPACE ('\n')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_START ('{')
|
||||
DOC_TAG_NAME ('@snippet')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attr1')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('=')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_QUOTE ('"')
|
||||
DOC_TAG_VALUE_TOKEN ('attr1 value')
|
||||
DOC_TAG_VALUE_QUOTE ('"')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attr2')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('=')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_QUOTE (''')
|
||||
DOC_TAG_VALUE_TOKEN ('attr2 value')
|
||||
DOC_TAG_VALUE_QUOTE (''')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attr3')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('=')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attr3Value')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_COLON (':')
|
||||
DOC_SPACE (' \n')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' foo {}')
|
||||
DOC_SPACE (' \n')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_END ('}')
|
||||
DOC_SPACE ('\n')
|
||||
DOC_COMMENT_END ('*/')""")
|
||||
}
|
||||
|
||||
fun testAttributeNextToColon() {
|
||||
doTest("""
|
||||
/**
|
||||
* {@snippet attr1 = attrVal:
|
||||
* foo {}
|
||||
* }
|
||||
*/
|
||||
""".trimIndent().trim(),
|
||||
"""DOC_COMMENT_START ('/**')
|
||||
DOC_SPACE ('\n')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_START ('{')
|
||||
DOC_TAG_NAME ('@snippet')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attr1')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('=')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attrVal')
|
||||
DOC_TAG_VALUE_COLON (':')
|
||||
DOC_SPACE (' \n')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' foo {}')
|
||||
DOC_SPACE (' \n')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_END ('}')
|
||||
DOC_SPACE ('\n')
|
||||
DOC_COMMENT_END ('*/')""")
|
||||
}
|
||||
|
||||
fun testAttributeListOnSeveralLines() {
|
||||
doTest("""
|
||||
/**
|
||||
* Attributes:
|
||||
* {@snippet attr1=""
|
||||
* attr2=''
|
||||
* :
|
||||
* }
|
||||
*/
|
||||
""".trimIndent().trim(),
|
||||
"""DOC_COMMENT_START ('/**')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' Attributes:')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_START ('{')
|
||||
DOC_TAG_NAME ('@snippet')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attr1')
|
||||
DOC_TAG_VALUE_TOKEN ('=')
|
||||
DOC_TAG_VALUE_QUOTE ('"')
|
||||
DOC_TAG_VALUE_QUOTE ('"')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_TOKEN ('attr2')
|
||||
DOC_TAG_VALUE_TOKEN ('=')
|
||||
DOC_TAG_VALUE_QUOTE (''')
|
||||
DOC_TAG_VALUE_QUOTE (''')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_COLON (':')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_END ('}')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_END ('*/')""")
|
||||
}
|
||||
|
||||
|
||||
fun testColonOnNextLine() {
|
||||
doTest("""
|
||||
/**
|
||||
* {@snippet
|
||||
* :
|
||||
* }
|
||||
*/
|
||||
""".trimIndent().trim(),
|
||||
"""DOC_COMMENT_START ('/**')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_START ('{')
|
||||
DOC_TAG_NAME ('@snippet')
|
||||
DOC_SPACE (' \n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_COLON (':')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_END ('}')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_END ('*/')""")
|
||||
}
|
||||
|
||||
fun testBalancedBraces() {
|
||||
doTest("""
|
||||
/**
|
||||
* {@snippet
|
||||
* :
|
||||
* B0 {
|
||||
* {
|
||||
*
|
||||
* }
|
||||
* B1 }
|
||||
* }
|
||||
*/
|
||||
""".trimIndent().trim(),
|
||||
"""DOC_COMMENT_START ('/**')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_START ('{')
|
||||
DOC_TAG_NAME ('@snippet')
|
||||
DOC_SPACE (' \n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_SPACE (' ')
|
||||
DOC_TAG_VALUE_COLON (':')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' B0 {')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' {')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' }')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' B1 }')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_LEADING_ASTERISKS ('*')
|
||||
DOC_COMMENT_DATA (' ')
|
||||
DOC_INLINE_TAG_END ('}')
|
||||
DOC_SPACE ('\n ')
|
||||
DOC_COMMENT_END ('*/')""")
|
||||
}
|
||||
|
||||
abstract override fun createLexer(): Lexer
|
||||
|
||||
override fun getDirPath(): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.lexer;
|
||||
|
||||
import com.intellij.lexer.LayeredLexer;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.lexer.LexerBase;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class AbstractBasicLayeredLexerTest extends TestCase {
|
||||
public void testInTheMiddle() {
|
||||
Lexer lexer = setupLexer("s=\"abc\\ndef\";");
|
||||
|
||||
assertEquals("s", nextToken(lexer));
|
||||
assertEquals("=", nextToken(lexer));
|
||||
assertEquals("\"abc", nextToken(lexer));
|
||||
assertEquals("\\n", nextToken(lexer));
|
||||
assertEquals("def\"", nextToken(lexer));
|
||||
assertEquals(";", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
public void testModification() {
|
||||
Lexer lexer = setupLexer("s=\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\";");
|
||||
assertEquals("s", nextToken(lexer));
|
||||
assertEquals("=", nextToken(lexer));
|
||||
assertEquals("\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"", nextToken(lexer));
|
||||
assertEquals(";", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
|
||||
lexer.start(lexer.getBufferSequence(), 2, lexer.getBufferEnd(), (short) 1);
|
||||
assertEquals("\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"", nextToken(lexer));
|
||||
assertEquals(";", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
|
||||
public void testInTheAtStartup() {
|
||||
Lexer lexer = setupLexer("s=\"\\ndef\";");
|
||||
|
||||
assertEquals("s", nextToken(lexer));
|
||||
assertEquals("=", nextToken(lexer));
|
||||
assertEquals("\"", nextToken(lexer));
|
||||
assertEquals("\\n", nextToken(lexer));
|
||||
assertEquals("def\"", nextToken(lexer));
|
||||
assertEquals(";", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
public void testInTheAtEnd() {
|
||||
Lexer lexer = setupLexer("s=\"abc\\n\";");
|
||||
|
||||
assertEquals("s", nextToken(lexer));
|
||||
assertEquals("=", nextToken(lexer));
|
||||
assertEquals("\"abc", nextToken(lexer));
|
||||
assertEquals("\\n", nextToken(lexer));
|
||||
assertEquals("\"", nextToken(lexer));
|
||||
assertEquals(";", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
public void testNonTerminated() {
|
||||
Lexer lexer = setupLexer("s=\"abc\\n");
|
||||
|
||||
assertEquals("s", nextToken(lexer));
|
||||
assertEquals("=", nextToken(lexer));
|
||||
assertEquals("\"abc", nextToken(lexer));
|
||||
assertEquals("\\n", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
public void testNonTerminated2() {
|
||||
Lexer lexer = setupLexer("s=\"abc\\");
|
||||
|
||||
assertEquals("s", nextToken(lexer));
|
||||
assertEquals("=", nextToken(lexer));
|
||||
assertEquals("\"abc", nextToken(lexer));
|
||||
assertEquals("\\", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
public void testUnicode() {
|
||||
Lexer lexer = setupLexer("s=\"\\uFFFF\";");
|
||||
assertEquals("s", nextToken(lexer));
|
||||
assertEquals("=", nextToken(lexer));
|
||||
assertEquals("\"", nextToken(lexer));
|
||||
assertEquals("\\uFFFF", nextToken(lexer));
|
||||
assertEquals("\"", nextToken(lexer));
|
||||
assertEquals(";", nextToken(lexer));
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
public void testDelegatesWithBigStates() {
|
||||
final LayeredLexer lexer = new LayeredLexer(new SimpleStateSteppingLexer());
|
||||
lexer.registerSelfStoppingLayer(new SimpleStateSteppingLexer(),
|
||||
new IElementType[]{TokenType.CODE_FRAGMENT},
|
||||
IElementType.EMPTY_ARRAY);
|
||||
|
||||
lexer.start("1234567890123#1234567890123#1234567890123");
|
||||
assertLexerSequence(lexer,
|
||||
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3",
|
||||
"#",
|
||||
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3",
|
||||
"#",
|
||||
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3"
|
||||
);
|
||||
}
|
||||
|
||||
protected abstract Lexer setupLexer(String text);
|
||||
|
||||
private static void assertLexerSequence(Lexer lexer, String... tokenTexts) {
|
||||
for (String tokenText : tokenTexts) {
|
||||
assertEquals(tokenText, nextToken(lexer));
|
||||
}
|
||||
assertNull(lexer.getTokenType());
|
||||
}
|
||||
|
||||
private static String nextToken(Lexer lexer) {
|
||||
assertNotNull(lexer.getTokenType());
|
||||
final String s = lexer.getBufferSequence().subSequence(lexer.getTokenStart(), lexer.getTokenEnd()).toString();
|
||||
lexer.advance();
|
||||
return s;
|
||||
}
|
||||
|
||||
private static class SimpleStateSteppingLexer extends LexerBase {
|
||||
|
||||
private static final char MARK = '#';
|
||||
|
||||
private CharSequence myBuffer;
|
||||
private int myStartOffset;
|
||||
private int myEndOffset;
|
||||
private int myState;
|
||||
private int myPos;
|
||||
|
||||
@Override
|
||||
public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
|
||||
myBuffer = buffer;
|
||||
myStartOffset = startOffset;
|
||||
myEndOffset = endOffset;
|
||||
myState = initialState;
|
||||
|
||||
myPos = myStartOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getState() {
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IElementType getTokenType() {
|
||||
if (myPos >= myEndOffset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (findNextMarkIfStoppedOnMarkAndNotAtStart() != myEndOffset) {
|
||||
return TokenType.CODE_FRAGMENT;
|
||||
}
|
||||
|
||||
return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTokenStart() {
|
||||
return myPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTokenEnd() {
|
||||
if (myPos == myEndOffset) {
|
||||
return myPos;
|
||||
}
|
||||
|
||||
final int nextMark = findNextMarkIfStoppedOnMarkAndNotAtStart();
|
||||
if (nextMark != myEndOffset) {
|
||||
return nextMark + 1;
|
||||
}
|
||||
return myPos + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void advance() {
|
||||
myPos = getTokenEnd();
|
||||
|
||||
if (myState == 0) {
|
||||
myState = 1;
|
||||
}
|
||||
else {
|
||||
myState <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CharSequence getBufferSequence() {
|
||||
return myBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferEnd() {
|
||||
return myEndOffset;
|
||||
}
|
||||
|
||||
private int findNextMarkIfStoppedOnMarkAndNotAtStart() {
|
||||
if (myPos == myStartOffset ||
|
||||
myPos < myEndOffset && myBuffer.charAt(myPos) != MARK) {
|
||||
return myEndOffset;
|
||||
}
|
||||
|
||||
int i = myPos + 1;
|
||||
while (i < myEndOffset && myBuffer.charAt(i) != MARK) {
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicCommonJavaParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicCommonJavaParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/commonParsing", configurator);
|
||||
}
|
||||
|
||||
public void testSCR5202() { doTest(true); }
|
||||
public void testIncompleteCodeBlock() { doTest(true); }
|
||||
public void testImportListBug() { doTest(true); }
|
||||
public void testRefParamsAfterError() { doTest(true); }
|
||||
public void testUnclosedComment() { doTest(true); }
|
||||
public void testIncompleteFor() { doTest(true); }
|
||||
public void testVarPackage() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicExpressionParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicExpressionParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/expressionParsing", configurator);
|
||||
}
|
||||
|
||||
public void testAssignment0() { doTest(true); }
|
||||
|
||||
public void testAssignment1() { doTest(true); }
|
||||
|
||||
public void testCond0() { doTest(true); }
|
||||
|
||||
public void testCond1() { doTest(true); }
|
||||
|
||||
public void testCond2() { doTest(true); }
|
||||
|
||||
public void testCond3() { doTest(true); }
|
||||
|
||||
public void testCondOr0() { doTest(true); }
|
||||
|
||||
public void testCondOr1() { doTest(true); }
|
||||
|
||||
public void testCondAnd0() { doTest(true); }
|
||||
|
||||
public void testCondAnd1() { doTest(true); }
|
||||
|
||||
public void testOr0() { doTest(true); }
|
||||
|
||||
public void testOr1() { doTest(true); }
|
||||
|
||||
public void testXor0() { doTest(true); }
|
||||
|
||||
public void testXor1() { doTest(true); }
|
||||
|
||||
public void testAnd0() { doTest(true); }
|
||||
|
||||
public void testAnd1() { doTest(true); }
|
||||
|
||||
public void testInstanceOf0() { doTest(true); }
|
||||
|
||||
public void testInstanceOf1() { doTest(true); }
|
||||
|
||||
public void testNot0() { doTest(true); }
|
||||
|
||||
public void testNot1() { doTest(true); }
|
||||
|
||||
public void testCast0() { doTest(true); }
|
||||
|
||||
public void testParenth() { doTest(true); }
|
||||
|
||||
public void testParenth1() { doTest(true); }
|
||||
|
||||
public void testNewInExprList() { doTest(true); }
|
||||
|
||||
public void testNew0() { doTest(true); }
|
||||
|
||||
public void testNew1() { doTest(true); }
|
||||
|
||||
public void testNew2() { doTest(true); }
|
||||
|
||||
public void testNew3() { doTest(true); }
|
||||
|
||||
public void testNew4() { doTest(true); }
|
||||
|
||||
public void testNew5() { doTest(true); }
|
||||
|
||||
public void testNew6() { doTest(true); }
|
||||
|
||||
public void testNew7() { doTest(true); }
|
||||
|
||||
public void testNew8() { doTest(true); }
|
||||
|
||||
public void testNew9() { doTest(true); }
|
||||
|
||||
public void testNew10() { doTest(true); }
|
||||
|
||||
public void testNew11() { doTest(true); }
|
||||
|
||||
public void testNew12() { doTest(true); }
|
||||
|
||||
public void testNew13() { doTest(true); }
|
||||
|
||||
public void testNew14() { doTest(true); }
|
||||
|
||||
public void testNew15() { doTest(true); }
|
||||
|
||||
public void testExprList0() { doTest(true); }
|
||||
|
||||
public void testExprList1() { doTest(true); }
|
||||
|
||||
public void testExprList2() { doTest(true); }
|
||||
|
||||
public void testExprList3() { doTest(true); }
|
||||
|
||||
public void testExprList4() { doTest(true); }
|
||||
|
||||
public void testExprList5() { doTest(true); }
|
||||
|
||||
public void testExprList6() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer0() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer1() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer2() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer3() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer4() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer5() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer6() { doTest(true); }
|
||||
|
||||
public void testArrayInitializer7() { doTest(true); }
|
||||
|
||||
public void testPinesInReferenceExpression0() { doTest(true); }
|
||||
|
||||
public void testPinesInReferenceExpression1() { doTest(true); }
|
||||
|
||||
public void testGE() { doTest(true); }
|
||||
|
||||
public void testIncompleteCast() { doTest(true); }
|
||||
|
||||
public void testShiftRight() { doTest(true); }
|
||||
|
||||
public void testAnonymousErrors() { doTest(true); }
|
||||
|
||||
public void testAnonymousErrors1() { doTest(true); }
|
||||
|
||||
public void testAnonymousWithTypeParams() { doTest(true); }
|
||||
|
||||
public void testAnonymous2() { doTest(true); }
|
||||
|
||||
public void testIncompleteDecl() { doTest(true); }
|
||||
|
||||
public void testIllegalWildcard() { doTest(true); }
|
||||
|
||||
public void testQualifiedSuperMethodCall() { doTest(true); }
|
||||
|
||||
public void testQualifiedSuperMethodCall1() { doTest(true); }
|
||||
|
||||
public void testSuperMethodCallTypeParameterList() { doTest(true); }
|
||||
|
||||
public void testPrimitiveClassObjectAccess() { doTest(true); }
|
||||
|
||||
public void testPrimitiveClassObjectAccessError() { doTest(true); }
|
||||
|
||||
public void testPrimitiveArrayClassObjectAccessError() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicImportParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicImportParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/importParsing", configurator);
|
||||
}
|
||||
|
||||
public void testUnclosed0() { doTest(true); }
|
||||
public void testUnclosed1() { doTest(true); }
|
||||
public void testUnclosed2() { doTest(true); }
|
||||
|
||||
public void testStaticImport() { doTest(true); }
|
||||
public void testStaticImport1() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageExtension;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.platform.backend.workspace.WorkspaceModelTopics;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.testFramework.ParsingTestCase;
|
||||
import com.intellij.testFramework.TestDataFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class AbstractBasicJavaParsingTestCase extends ParsingTestCase {
|
||||
|
||||
private final AbstractBasicJavaParsingTestConfigurator myConfigurator;
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public AbstractBasicJavaParsingTestCase(String dataPath, AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
this(dataPath, "java", configurator);
|
||||
}
|
||||
|
||||
public AbstractBasicJavaParsingTestCase(String dataPath, String fileExt, AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("psi/" + dataPath, fileExt, configurator.getJavaParserDefinition());
|
||||
myConfigurator = configurator;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
getProject().registerService(WorkspaceModelTopics.class, new WorkspaceModelTopics());
|
||||
myConfigurator.setUp(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PathManagerEx.getTestDataPath(PathManagerEx.TestDataLookupStrategy.COMMUNITY_FROM_ULTIMATE);
|
||||
}
|
||||
|
||||
public final <T> void addExplicit(@NotNull LanguageExtension<T> collector, @NotNull Language language, @NotNull T object) {
|
||||
addExplicitExtension(collector, language, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiFile createFile(@NotNull String name, @NotNull String text) {
|
||||
PsiFile file = super.createFile(name, text);
|
||||
myConfigurator.configure(file);
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
protected void doParserTest(Consumer<PsiBuilder> parser) {
|
||||
String name = getTestName(false);
|
||||
try {
|
||||
doParserTest(loadFile(name + "." + myFileExt), parser);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setLanguageLevel(@NotNull LanguageLevel languageLevel) {
|
||||
myConfigurator.setLanguageLevel(languageLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkResult(@NotNull @TestDataFile String targetDataName, @NotNull PsiFile file) throws IOException {
|
||||
doCheckResult(myFullDataPath, targetDataName + "_node.txt",
|
||||
DebugUtil.nodeTreeAsElementTypeToString(file.getNode(), !skipSpaces()).trim());
|
||||
if (myConfigurator.checkPsi()) {
|
||||
super.checkResult(targetDataName, file);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doParserTest(String text, Consumer<PsiBuilder> parser) {
|
||||
String name = getTestName(false);
|
||||
myFile = myConfigurator.createPsiFile(this, name, text, parser);
|
||||
try {
|
||||
checkResult(name, myFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser;
|
||||
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface AbstractBasicJavaParsingTestConfigurator {
|
||||
ParserDefinition getJavaParserDefinition();
|
||||
|
||||
void setUp(@NotNull AbstractBasicJavaParsingTestCase thinJavaParsingTestCase);
|
||||
|
||||
void configure(@NotNull PsiFile file);
|
||||
|
||||
@NotNull
|
||||
PsiFile createPsiFile(@NotNull AbstractBasicJavaParsingTestCase thinJavaParsingTestCase,
|
||||
@NotNull String name,
|
||||
@NotNull String text,
|
||||
@NotNull Consumer<PsiBuilder> parser);
|
||||
|
||||
boolean checkPsi();
|
||||
|
||||
void setLanguageLevel(@NotNull LanguageLevel level);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.parser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicJavadocParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicJavadocParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/javadocParsing", configurator);
|
||||
}
|
||||
|
||||
public void testJavadoc0() { doTest(true); }
|
||||
public void testJavadoc1() { doTest(true); }
|
||||
|
||||
public void testTag0() { doTest(true); }
|
||||
public void testTag1() { doTest(true); }
|
||||
public void testTag2() { doTest(true); }
|
||||
public void testTag3() { doTest(true); }
|
||||
public void testTag4() { doTest(true); }
|
||||
public void testTag5() { doTest(true); }
|
||||
public void testTag6() { doTest(true); }
|
||||
|
||||
public void testInlineTag0() { doTest(true); }
|
||||
public void testInlineTag1() { doTest(true); }
|
||||
public void testInlineTag2() { doTest(true); }
|
||||
public void testInlineTag3() { doTest(true); }
|
||||
|
||||
public void testSeeTag0() { doTest(true); }
|
||||
public void testSeeTag1() { doTest(true); }
|
||||
public void testSeeTag2() { doTest(true); }
|
||||
public void testSeeTag3() { doTest(true); }
|
||||
public void testSeeTag4() { doTest(true); }
|
||||
public void testSeeTag5() { doTest(true); }
|
||||
public void testSeeTag6() { doTest(true); }
|
||||
public void testSeeTag7() { doTest(true); }
|
||||
public void testSeeTag8() { doTest(true); }
|
||||
public void testSeeTag9() { doTest(true); }
|
||||
public void testSeeTag10() { doTest(true); }
|
||||
public void testSeeTag11() { doTest(true); }
|
||||
public void testSeeTag12() { doTest(true); }
|
||||
public void testSeeTag13() { doTest(true); }
|
||||
public void testSeeTag14() { doTest(true); }
|
||||
public void testSeeTag15() { doTest(true); }
|
||||
public void testSeeTag16() { doTest(true); }
|
||||
|
||||
public void testLinkTag0() { doTest(true); }
|
||||
public void testLinkTag1() { doTest(true); }
|
||||
public void testLinkTag2() { doTest(true); }
|
||||
public void testLinkTag3() { doTest(true); }
|
||||
public void testLinkTag4() { doTest(true); }
|
||||
public void testLinkTag5() { doTest(true); }
|
||||
public void testLinkTag6() { doTest(true); }
|
||||
|
||||
public void testParamTag0() { doTest(true); }
|
||||
public void testParamTag1() { doTest(true); }
|
||||
|
||||
public void testLinkPlainTag0() { doTest(true); }
|
||||
public void testLinkPlainTag1() { doTest(true); }
|
||||
public void testLinkPlainTag2() { doTest(true); }
|
||||
|
||||
public void testException0() { doTest(true); }
|
||||
|
||||
public void testSymbols01() { doTest(true); }
|
||||
public void testSymbols02() { doTest(true); }
|
||||
public void testSymbols03() { doTest(true); }
|
||||
public void testSymbols04() { doTest(true); }
|
||||
public void testSymbols05() { doTest(true); }
|
||||
|
||||
public void testAdjacent01() { doTest(true); }
|
||||
public void testSeparated01() { doTest(true); }
|
||||
|
||||
public void testTypeParam() { doTest(true); }
|
||||
public void testParameterlessTag() { doTest(true); }
|
||||
|
||||
public void testCodeTag() { doTest(true); }
|
||||
public void testMultilineCodeTag() { doTest(true); }
|
||||
public void testCodeTagWithBraces() { doTest(true); }
|
||||
public void testLiteralTag() { doTest(true); }
|
||||
|
||||
public void testIDEADEV_41403() { doTest(true); }
|
||||
|
||||
public void testValueQualified() { doTest(true); }
|
||||
public void testValueUnqualifiedWithHash() { doTest(true); }
|
||||
public void testValueUnqualifiedWithoutHash() { doTest(true); }
|
||||
|
||||
public void testThrowsTag() { doTest(true); }
|
||||
public void testUsesTag() { doTest(true); }
|
||||
public void testProvidesTag() { doTest(true); }
|
||||
public void testInlineTagIndex() { doTest(true); }
|
||||
public void testInlineTagSummary() { doTest(true); }
|
||||
|
||||
public void testSnippetTag0() { doTest(true); }
|
||||
public void testSnippetTag1() { doTest(true); }
|
||||
public void testSnippetTag2() { doTest(true); }
|
||||
public void testSnippetTag3() { doTest(true); }
|
||||
public void testSnippetTag4() { doTest(true); }
|
||||
public void testSnippetTag5() { doTest(true); }
|
||||
public void testSnippetTag6() { doTest(true); }
|
||||
public void testSnippetTag7() { doTest(true); }
|
||||
public void testSnippetTag8() { doTest(true); }
|
||||
public void testSnippetTag9() { doTest(true); }
|
||||
public void testSnippetTag10() { doTest(true); }
|
||||
public void testSnippetTag11() { doTest(true); }
|
||||
public void testSnippetTag12() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.annotationParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicAnnotationDeclarationParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicAnnotationDeclarationParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/annotationParsing/declaration", configurator);
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(true); }
|
||||
|
||||
public void testDefault() { doTest(true); }
|
||||
|
||||
public void testNested() { doTest(true); }
|
||||
|
||||
public void testInner() { doTest(true); }
|
||||
|
||||
public void testOtherMembers() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.annotationParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicAnnotationParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicAnnotationParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/annotationParsing/annotation", configurator);
|
||||
}
|
||||
|
||||
public void testMarker() { doTest(true); }
|
||||
|
||||
public void testSimple1() { doTest(true); }
|
||||
|
||||
public void testSimple2() { doTest(true); }
|
||||
|
||||
public void testComplex() { doTest(true); }
|
||||
|
||||
public void testMultiple() { doTest(true); }
|
||||
|
||||
public void testArray() { doTest(true); }
|
||||
|
||||
public void testNested() { doTest(true); }
|
||||
|
||||
public void testParameterAnnotation() { doTest(true); }
|
||||
|
||||
public void testPackageAnnotation() { doTest(true); }
|
||||
|
||||
public void testParameterizedMethod() { doTest(true); }
|
||||
|
||||
public void testQualifiedAnnotation() { doTest(true); }
|
||||
|
||||
public void testEnumSmartTypeCompletion() { doTest(true); }
|
||||
|
||||
public void testErrors() { doTest(true); }
|
||||
|
||||
public void testTypeAnnotations() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.declarationParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicClassParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicClassParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/declarationParsing/class", configurator);
|
||||
}
|
||||
|
||||
public void testNoClass() { doTest(true); }
|
||||
|
||||
public void testNoType() { doTest(true); }
|
||||
|
||||
public void testSemicolon() { doTest(true); }
|
||||
|
||||
public void testSemicolon2() { doTest(true); }
|
||||
|
||||
public void testParametrizedClass() { doTest(true); }
|
||||
|
||||
public void testPines() { doTest(true); }
|
||||
|
||||
public void testForError() { doTest(true); }
|
||||
|
||||
public void testEnum1() { doTest(true); }
|
||||
|
||||
public void testEnum2() { doTest(true); }
|
||||
|
||||
public void testEnumWithConstants1() { doTest(true); }
|
||||
|
||||
public void testEnumWithConstants2() { doTest(true); }
|
||||
|
||||
public void testEnumWithConstants3() { doTest(true); }
|
||||
|
||||
public void testEnumWithConstants4() { doTest(true); }
|
||||
|
||||
public void testEnumWithConstants5() { doTest(true); }
|
||||
|
||||
public void testEnumWithConstants6() { doTest(true); }
|
||||
|
||||
public void testEnumWithConstantsDoubleComma() { doTest(true); }
|
||||
|
||||
public void testEnumWithInitializedConstants() { doTest(true); }
|
||||
|
||||
public void testEnumWithAnnotatedConstants() { doTest(true); }
|
||||
|
||||
public void testEnumWithImport() { doTest(true); }
|
||||
|
||||
public void testEnumWithoutConstants() { doTest(true); }
|
||||
|
||||
public void testEmptyImportList() { doTest(true); }
|
||||
|
||||
public void testLongClass() { doTest(false); }
|
||||
|
||||
public void testIncompleteAnnotation() { doTest(true); }
|
||||
|
||||
public void testExtraOpeningBraceInMethod() { doTest(true); }
|
||||
|
||||
public void testExtraClosingBraceInMethod() { doTest(true); }
|
||||
|
||||
public void testErrors0() { doTest(true); }
|
||||
|
||||
public void testErrors1() { doTest(true); }
|
||||
|
||||
public void testErrors2() { doTest(true); }
|
||||
|
||||
public void testErrors3() { doTest(true); }
|
||||
|
||||
public void testErrors4() { doTest(true); }
|
||||
|
||||
public void testErrors5() { doTest(true); }
|
||||
|
||||
public void testRecord() { doTest(true); }
|
||||
|
||||
public void testRecordWithComponents() { doTest(true); }
|
||||
|
||||
public void testRecordNoClosingParenthesis() { doTest(true); }
|
||||
|
||||
public void testRecordNoComponents() { doTest(true); }
|
||||
|
||||
public void testRecordWithTypeParameters() { doTest(true); }
|
||||
|
||||
public void testRecordNoClosingTypeBracket() { doTest(true); }
|
||||
|
||||
public void testRecordWithModifiers() { doTest(true); }
|
||||
|
||||
public void testRecordInCodeBlock() { doTest(true); }
|
||||
|
||||
public void testLocalRecord() { doTest(true); }
|
||||
|
||||
public void testLocalRecordWithTypeParams() { doTest(true); }
|
||||
|
||||
public void testLocalRecordWithoutParens() { doTest(true); }
|
||||
|
||||
public void testCompactConstructor0() { doTest(true); }
|
||||
|
||||
public void testCompactConstructor1() { doTest(true); }
|
||||
|
||||
public void testRecordTypeInOlderJava() {
|
||||
setLanguageLevel(LanguageLevel.JDK_13);
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testSealedInterface() {
|
||||
doTest(true);
|
||||
}
|
||||
public void testSealedClassOldLanguageLevel() {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doTest(true);
|
||||
}
|
||||
public void testNonSealedClass() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testProvidesList() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testUnnamedClass0() {
|
||||
doTest(true);
|
||||
}
|
||||
public void testUnnamedClass1() {
|
||||
doTest(true);
|
||||
}
|
||||
public void testUnnamedClass2() {
|
||||
doTest(true);
|
||||
}
|
||||
public void testUnnamedClass3() {
|
||||
doTest(true);
|
||||
}
|
||||
public void testUnnamedClass4() {
|
||||
doTest(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.declarationParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicCommentBindingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicCommentBindingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/declarationParsing/commentBinding", configurator);
|
||||
}
|
||||
|
||||
public void testBindBefore1() { doTest(true); }
|
||||
public void testBindBefore2() { doTest(true); }
|
||||
public void testBindBefore3() { doTest(true); }
|
||||
public void testBindBefore3a() { doTest(true); }
|
||||
public void testBindBefore4() { doTest(true); }
|
||||
public void testBindBefore5() { doTest(true); }
|
||||
|
||||
public void testBindBeforeClass1() { doTest(true); }
|
||||
public void testBindBeforeClass2() { doTest(true); }
|
||||
public void testBindBeforeClass3() { doTest(true); }
|
||||
public void testBindBeforeClass4() { doTest(true); }
|
||||
public void testBindBeforeClass5() { doTest(true); }
|
||||
public void testBindBeforeClass6() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.declarationParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicFieldParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicFieldParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/declarationParsing/field", configurator);
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(true); }
|
||||
|
||||
public void testMulti() { doTest(true); }
|
||||
|
||||
public void testUnclosedBracket() { doTest(true); }
|
||||
|
||||
public void testMissingInitializer() { doTest(true); }
|
||||
|
||||
public void testUnclosedComma() { doTest(true); }
|
||||
|
||||
public void testUnclosedSemicolon() { doTest(true); }
|
||||
|
||||
public void testMissingInitializerExpression() { doTest(true); }
|
||||
|
||||
public void testMultiLineUnclosed0() { doTest(true); }
|
||||
|
||||
public void testMultiLineUnclosed1() { doTest(true); }
|
||||
|
||||
public void testComplexInitializer() { doTest(true); }
|
||||
|
||||
public void testErrors() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.declarationParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicMethodParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicMethodParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/declarationParsing/method", configurator);
|
||||
}
|
||||
|
||||
public void testNormal1() { doTest(true); }
|
||||
|
||||
public void testNormal2() { doTest(true); }
|
||||
|
||||
public void testUnclosed1() { doTest(true); }
|
||||
|
||||
public void testUnclosed2() { doTest(true); }
|
||||
|
||||
public void testUnclosed3() { doTest(true); }
|
||||
|
||||
public void testUnclosed4() { doTest(true); }
|
||||
|
||||
public void testUnclosed5() { doTest(true); }
|
||||
|
||||
public void testUnclosed6() { doTest(true); }
|
||||
|
||||
public void testGenericMethod() { doTest(true); }
|
||||
|
||||
public void testGenericMethodErrors() { doTest(true); }
|
||||
|
||||
public void testErrors0() { doTest(true); }
|
||||
|
||||
public void testErrors1() { doTest(true); }
|
||||
|
||||
public void testErrors2() { doTest(true); }
|
||||
|
||||
public void testErrors3() { doTest(true); }
|
||||
|
||||
public void testCompletionHack() { doTest(true); }
|
||||
|
||||
public void testCompletionHack1() { doTest(true); }
|
||||
|
||||
public void testNoLocalMethod() { doTest(true); }
|
||||
|
||||
public void testWildcardParsing() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicAnnotationParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicAnnotationParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/annotations", configurator);
|
||||
}
|
||||
|
||||
public void testMarker() { doParserTest("@Preliminary"); }
|
||||
|
||||
public void testSimple0() { doParserTest("@Copyright(\"blah-blah-blah\")"); }
|
||||
|
||||
public void testSimple1() { doParserTest("@Copyright(treatedAsValue)"); }
|
||||
|
||||
public void testComplex() { doParserTest("@Author(first=\"Eugene\", second=\"Another Eugene\")"); }
|
||||
|
||||
public void testMultiple() { doParserTest("@Preliminary @Other(name=value)"); }
|
||||
|
||||
public void testArray() { doParserTest("@Endorsers({\"Children\", \"Unscrupulous dentists\"})"); }
|
||||
|
||||
public void testNested() { doParserTest("@Author(@Name(first=\"Eugene\", second=\"Yet One Eugene\"))"); }
|
||||
|
||||
public void testQualifiedAnnotation() { doParserTest("@org.jetbrains.annotations.Nullable"); }
|
||||
|
||||
public void testExtraCommaInList() { doParserTest("@Anno({0, 1,})"); }
|
||||
|
||||
public void testParameterizedAnnotation() { doParserTest("@Nullable<T>"); }
|
||||
|
||||
public void testFirstNameMissed() { doParserTest("@Anno(value1, param2=value2)"); }
|
||||
|
||||
protected abstract void doParserTest(String text);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicDeclarationParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicDeclarationParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/declarations", configurator);
|
||||
}
|
||||
|
||||
public void testEmptyBody0() { doParserTest("{ }"); }
|
||||
public void testEmptyBody1() { doParserTest("{ "); }
|
||||
public void testEmptyBody2() { doParserTest("{ @Null }"); }
|
||||
|
||||
public void testNoType() { doParserTest("{ new X(); }"); }
|
||||
public void testExtraSemicolon() { doParserTest("{ class C { }; }"); }
|
||||
public void testParameterizedClass() { doParserTest("{ public class A <T extends java.util.List> { } }"); }
|
||||
public void testPines() { doParserTest("{ class A<T extends List<String>> extends List<List<Integer>> { } }"); }
|
||||
public void testIncompleteAnnotation() { doParserTest("{ public class Foo { public void testSomething(); @Null } }"); }
|
||||
public void testClassInit() { doParserTest("{ { /*comment*/ } }"); }
|
||||
|
||||
public void testEnumSmartTypeCompletion() {
|
||||
doParserTest(
|
||||
"""
|
||||
{ @Preliminary(A.B
|
||||
#) public class TimeTravel {}
|
||||
@Preliminary(a=A.B
|
||||
#) public class TimeTravel {}
|
||||
@Preliminary(a=A.B
|
||||
#, b=c) public class TimeTravel {} }""");
|
||||
}
|
||||
|
||||
public void testEnumBody0() { doParserTest("{ ; }", false, true); }
|
||||
public void testEnumBody1() { doParserTest("{ RED, GREEN, BLUE; }", false, true); }
|
||||
public void testEnumBody2() { doParserTest("{ RED, GREEN, BLUE }", false, true); }
|
||||
public void testEnumBody3() { doParserTest("{ RED, GREEN, BLUE, }", false, true); }
|
||||
public void testEnumBody4() { doParserTest("{ RED(0), GREEN(1), BLUE(2); }", false, true); }
|
||||
public void testEnumBody5() { doParserTest("{ @ANNOTATION A(10) }", false, true); }
|
||||
public void testEnumBody6() { doParserTest("{ RED, GREEN, BLUE\n OurEnum() {} }", false, true); }
|
||||
public void testEnumBody7() { doParserTest("{ , ; }", false, true); }
|
||||
public void testEnumBody8() { doParserTest("{ A, }", false, true); }
|
||||
public void testEnumBody9() { doParserTest("{ , B }", false, true); }
|
||||
public void testEnumWithInitializedConstants() { doParserTest("{ A(10) { },\n B { void method() {} } }", false, true); }
|
||||
public void testEnumWithoutConstants() { doParserTest("{ private A }", false, true); }
|
||||
|
||||
public void testAnnoDeclaration() { doParserTest("{ public @interface Annotation {} }"); }
|
||||
public void testAnnoSimple() { doParserTest("{ int foo (); }", true, false); }
|
||||
public void testAnnoDefault() { doParserTest("{ Class foo() default String.class; }", true, false); }
|
||||
public void testAnnoNested() { doParserTest("{ @interface Inner { String bar () default \"<unspecified>\"; } }", true, false); }
|
||||
public void testAnnoInner() { doParserTest("{ @interface Inner { double bar () default 0.0; } }"); }
|
||||
public void testAnnoOtherMembers() { doParserTest("{ int field;\n void m() {}\n class C {}\n interface I {} }", true, false); }
|
||||
public void testAnnoLoop() { doParserTest("{ @@@ int i; }"); }
|
||||
|
||||
public void testTypeAnno() {
|
||||
doParserTest(
|
||||
"""
|
||||
{ class C<@D T extends @F Object> extends @F Object {
|
||||
@F int @F[] method() throws @F Exception {
|
||||
a = this instanceof @F C;
|
||||
C<@F @G C> c = new @Q C<@F C>();
|
||||
c = (@F Object)c;
|
||||
Class c = @TA String.class;
|
||||
@F C.field++;
|
||||
}
|
||||
} }""");
|
||||
}
|
||||
|
||||
public void testReceiver() {
|
||||
doParserTest(
|
||||
"{ void m1(C this);" +
|
||||
" void m2(T T.this);" +
|
||||
" void m3(X Y.Z);" +
|
||||
" T f1 = (T this) -> { };" +
|
||||
" T f2 = (T T.this) -> { }; }");
|
||||
}
|
||||
|
||||
public void testFieldSimple() { doParserTest("{ int field = 0; }"); }
|
||||
public void testFieldMulti() { doParserTest("{ int field1 = 0, field2; }"); }
|
||||
public void testUnclosedBracket() { doParserTest("{ int field[ }"); }
|
||||
public void testMissingInitializer() { doParserTest("{ int field = }"); }
|
||||
public void testUnclosedComma() { doParserTest("{ int field, }"); }
|
||||
public void testUnclosedSemicolon() { doParserTest("{ int field }"); }
|
||||
public void testMissingInitializerExpression() { doParserTest("{ int field=; }"); }
|
||||
public void testMultiLineUnclosed() { doParserTest("{ int \n Object o; }"); }
|
||||
public void testUnclosedField1() { doParserTest("{ String f1\n\n @Anno String f2; }"); }
|
||||
public void testUnclosedField2() { doParserTest("{ String f1\n\n @Anno\n String f2; }"); }
|
||||
|
||||
public void testMethodNormal0() { doParserTest("{ void f() {} }"); }
|
||||
public void testMethodNormal1() { doParserTest("{ void f(); }"); }
|
||||
public void testMethodNormal2() { doParserTest("{ default public void f() { } }"); }
|
||||
public void testSemicolons() { doParserTest("{ void f() {}; void g() {}; }"); }
|
||||
public void testUnclosed0() { doParserTest("{ void f() }"); }
|
||||
public void testExtension() { doParserTest("{ default int f() throws E { return 42; } }"); }
|
||||
public void testUnclosed1() { doParserTest("{ void f( }"); }
|
||||
public void testUnclosed2() { doParserTest("{ void f()\n void g(); }"); }
|
||||
public void testUnclosed3() { doParserTest("{ void f(int a }"); }
|
||||
public void testUnclosed4() { doParserTest("{ void f(int a,, }"); }
|
||||
public void testUnclosed5() { doParserTest("{ void f(int a,); }"); }
|
||||
public void testUnclosed6() { doParserTest("{ void f() default ; }", true, false); }
|
||||
public void testUnclosed7() { doParserTest("{ void f() default {return 42;} }", true, false); }
|
||||
public void testUnclosed8() { doParserTest("{ void f() default }"); }
|
||||
public void testUnclosed9() { doParserTest("{ void f(int a; void bar(); }"); }
|
||||
public void testConstructorBrackets() { doParserTest("{ A() [] { } }"); }
|
||||
public void testVarArgBrackets() { doParserTest("{ void foo(int... x[]); }"); }
|
||||
|
||||
public void testGenericMethod() {
|
||||
doParserTest(
|
||||
"""
|
||||
{ public static <E> test();
|
||||
<E> void test1();
|
||||
<E1 extends Integer, E2 extends Runnable> String test2(); }""");
|
||||
}
|
||||
|
||||
public void testGenericMethodErrors() { doParserTest("{ <Error sss /> test <error>(); }"); }
|
||||
public void testErrors() { doParserTest("{ public static <error descr=\"2\">protected int f1 = 0; }"); }
|
||||
public void testCompletionHack0() { doParserTest("{ <X IntelliJIdeaRulezz>\n String s = \"\"; }"); }
|
||||
public void testCompletionHack1() { doParserTest("{ <X\n String s = \"\"; }"); }
|
||||
public void testCompletionHack2() { doParserTest("{ String foo() def }", true, false); }
|
||||
public void testWildcardParsing() { doParserTest("{ List<? extends B> x(Collection<? super B> x); }"); }
|
||||
public void testParameterAnnotation() { doParserTest("{ void foo (@Annotation(value=77) int param) {} }"); }
|
||||
public void testParameterizedMethod() { doParserTest("{ @Nullable <T> T bar() {} }"); }
|
||||
public void testMethodNameOmitted() { doParserTest("{ void(); }"); }
|
||||
|
||||
private void doParserTest(String text) {
|
||||
doParserTest(text, false, false);
|
||||
}
|
||||
|
||||
protected abstract void doParserTest(String text, boolean isAnnotation, boolean isEnum);
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicExpressionParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicExpressionParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/expressions", configurator);
|
||||
}
|
||||
|
||||
public void testAssignment0() { doParserTest("a = 0"); }
|
||||
|
||||
public void testAssignment1() { doParserTest("a ="); }
|
||||
|
||||
public void testBinary0() { doParserTest("a + b"); }
|
||||
|
||||
public void testBinary1() { doParserTest("a < b"); }
|
||||
|
||||
public void testBinary2() { doParserTest("a > = b"); }
|
||||
|
||||
public void testBinary3() { doParserTest("a >/**/= b"); }
|
||||
|
||||
public void testCond0() { doParserTest("cond ? true : false"); }
|
||||
|
||||
public void testCond1() { doParserTest("cond ?"); }
|
||||
|
||||
public void testCond2() { doParserTest("cond ? true"); }
|
||||
|
||||
public void testCond3() { doParserTest("cond ? true :"); }
|
||||
|
||||
public void testCond4() { doParserTest("cond ? true : false ? true : false"); }
|
||||
|
||||
public void testCondOr0() { doParserTest("a || b || c"); }
|
||||
|
||||
public void testCondOr1() { doParserTest("a ||"); }
|
||||
|
||||
public void testOr0() { doParserTest("a | b | c"); }
|
||||
|
||||
public void testOr1() { doParserTest("a |"); }
|
||||
|
||||
public void testInstanceOf0() { doParserTest("a instanceof String"); }
|
||||
|
||||
public void testInstanceOf1() { doParserTest("a instanceof"); }
|
||||
|
||||
public void testInstanceOfPattern0() { doParserTest("x instanceof Foo v"); }
|
||||
|
||||
public void testInstanceOfPattern1() { doParserTest("x instanceof final Foo v"); }
|
||||
|
||||
public void testInstanceOfPattern2() { doParserTest("x instanceof @Ann() final Foo v"); }
|
||||
|
||||
public void testInstanceOfPattern3() { doParserTest("x instanceof (Foo v)"); }
|
||||
|
||||
public void testInstanceOfPattern4() { doParserTest("x instanceof Foo v && v > 10"); }
|
||||
|
||||
public void testNot0() { doParserTest("!!a"); }
|
||||
|
||||
public void testNot1() { doParserTest("!"); }
|
||||
|
||||
public void testCast0() { doParserTest("(Type)var"); }
|
||||
|
||||
public void testCast1() { doParserTest("(double)1 / 5"); }
|
||||
|
||||
public void testParenth0() { doParserTest("(c)"); }
|
||||
|
||||
public void testParenth1() { doParserTest("(this).f--"); }
|
||||
|
||||
public void testParenth2() { doParserTest("("); }
|
||||
|
||||
public void testParenth3() { doParserTest("(a < b)"); }
|
||||
|
||||
public void testNewInExprList() { doParserTest("call(new)"); }
|
||||
|
||||
public void testNew0() { doParserTest("new A()"); }
|
||||
|
||||
public void testNew1() { doParserTest("new A[1][]"); }
|
||||
|
||||
public void testNew2() { doParserTest("new A[]"); }
|
||||
|
||||
public void testNew3() { doParserTest("new A[][1]"); }
|
||||
|
||||
public void testNew4() { doParserTest("new A[][]{null}"); }
|
||||
|
||||
public void testNew5() { doParserTest("new A[1]{null}"); }
|
||||
|
||||
public void testNew6() { doParserTest("new"); }
|
||||
|
||||
public void testNew7() { doParserTest("new A"); }
|
||||
|
||||
public void testNew8() { doParserTest("new A["); }
|
||||
|
||||
public void testNew9() { doParserTest("new int"); }
|
||||
|
||||
public void testNew10() { doParserTest("new int()"); }
|
||||
|
||||
public void testNew11() { doParserTest("new String[0"); }
|
||||
|
||||
public void testNew12() { doParserTest("new int[1][2]"); }
|
||||
|
||||
public void testNew13() { doParserTest("new int[1][][2]"); }
|
||||
|
||||
public void testNew14() { doParserTest("Q.new A()"); }
|
||||
|
||||
public void testNew15() { doParserTest("new C<?>.B()"); }
|
||||
|
||||
public void testNew16() { doParserTest("new C<>()"); }
|
||||
|
||||
public void testNew17() { doParserTest("new Map<String, >()"); }
|
||||
|
||||
public void testNew18() { doParserTest("new int @A [2] @B"); }
|
||||
|
||||
public void testNew19() { doParserTest("new A(f; o)"); }
|
||||
|
||||
public void testExprList0() { doParserTest("f(1,2)"); }
|
||||
|
||||
public void testExprList1() { doParserTest("f("); }
|
||||
|
||||
public void testExprList2() { doParserTest("f(1"); }
|
||||
|
||||
public void testExprList3() { doParserTest("f(1,"); }
|
||||
|
||||
public void testExprList4() { doParserTest("f(1,)"); }
|
||||
|
||||
public void testExprList5() { doParserTest("f(1,,2)"); }
|
||||
|
||||
public void testExprList6() { doParserTest("f(,2)"); }
|
||||
|
||||
public void testArrayInitializer0() { doParserTest("{ }"); }
|
||||
|
||||
public void testArrayInitializer1() { doParserTest("{ 1 }"); }
|
||||
|
||||
public void testArrayInitializer2() { doParserTest("{ 1, }"); }
|
||||
|
||||
public void testArrayInitializer3() { doParserTest("{ 1,2 }"); }
|
||||
|
||||
public void testArrayInitializer4() { doParserTest("{ 1 2 }"); }
|
||||
|
||||
public void testArrayInitializer5() { doParserTest("{ { }"); }
|
||||
|
||||
public void testArrayInitializer6() { doParserTest("{ , }"); }
|
||||
|
||||
public void testArrayInitializer7() { doParserTest("{ , , 7 }"); }
|
||||
|
||||
public void testArrayInitializer8() { doParserTest("{ 8, , , }"); }
|
||||
|
||||
public void testArrayInitializer9() { doParserTest("{ , 9 }"); }
|
||||
|
||||
public void testPinesInReferenceExpression0() { doParserTest("Collections.<String>sort(null)"); }
|
||||
|
||||
public void testPinesInReferenceExpression1() { doParserTest("this.<String>sort(null)"); }
|
||||
|
||||
public void testPinesInReferenceExpression2() { doParserTest("<String>super(null)"); }
|
||||
|
||||
public void testGE0() { doParserTest("x >>>= 8 >> 2"); }
|
||||
|
||||
public void testGE1() { doParserTest("x >= 2"); }
|
||||
|
||||
public void testIncompleteCast() { doParserTest("f((ArrayList<String>) )"); }
|
||||
|
||||
public void testShiftRight() { doParserTest("x >>= 2"); }
|
||||
|
||||
public void testCorruptAnnoInCast() { doParserTest("(@&"); }
|
||||
|
||||
public void testIllegalWildcard() { doParserTest("this.<?>foo()"); }
|
||||
|
||||
public void testIllegalBound() { doParserTest("C.<T extends S>foo()"); }
|
||||
|
||||
public void testQualifiedSuperMethodCall0() { doParserTest("new D().super(0)"); }
|
||||
|
||||
public void testQualifiedSuperMethodCall1() { doParserTest("d.super(0)"); }
|
||||
|
||||
public void testQualifiedSuperMethodCall2() { doParserTest("(new O()).<T>super()"); }
|
||||
|
||||
public void testQualifiedSuperMethodCall3() { doParserTest("C.A.super()"); }
|
||||
|
||||
public void testSuperMethodCallTypeParameterList() { doParserTest("super()"); }
|
||||
|
||||
public void testPrimitiveClassObjectAccess() { doParserTest("int.class"); }
|
||||
|
||||
public void testPrimitiveFieldAccess() { doParserTest("int.x"); }
|
||||
|
||||
public void testChainedClassObjectAccess() { doParserTest("A.class.B.class"); }
|
||||
|
||||
public void testChainedThisObjectAccess() { doParserTest("A.this.B.this"); }
|
||||
|
||||
public void testAnnotatedRefExpr0() { doParserTest("@A C1.@B() C2"); }
|
||||
|
||||
public void testAnnotatedRefExpr1() { doParserTest("@A C1.@B() ()"); }
|
||||
|
||||
public void testMethodRef0() { doParserTest("a.b.C::m"); }
|
||||
|
||||
public void testMethodRef1() { doParserTest("a.b.C<T>::new"); }
|
||||
|
||||
public void testMethodRef2() { doParserTest("C::<T>m"); }
|
||||
|
||||
public void testMethodRef3() { doParserTest("a[i]::m"); }
|
||||
|
||||
public void testMethodRef4() { doParserTest("int[]::clone"); }
|
||||
|
||||
public void testMethodRef5() { doParserTest("(f ? list.map(String::length) : Collections.emptyList())::iterator"); }
|
||||
|
||||
public void testLambdaExpression0() { doParserTest("p -> 42"); }
|
||||
|
||||
public void testLambdaExpression1() { doParserTest("p -> "); }
|
||||
|
||||
public void testLambdaExpression2() { doParserTest("p -> {"); }
|
||||
|
||||
public void testLambdaExpression3() { doParserTest("(p) -> { }"); }
|
||||
|
||||
public void testLambdaExpression4() { doParserTest("(p, v) -> null"); }
|
||||
|
||||
public void testLambdaExpression5() { doParserTest("(p, v -> null"); }
|
||||
|
||||
public void testLambdaExpression6() { doParserTest("(p, v, -> null"); }
|
||||
|
||||
public void testLambdaExpression7() { doParserTest("(p -> null)"); }
|
||||
|
||||
public void testLambdaExpression8() { doParserTest("(I)(p) -> null"); }
|
||||
|
||||
public void testLambdaExpression9() { doParserTest("(I)p -> null"); }
|
||||
|
||||
public void testLambdaExpression10() { doParserTest("(I)(p -> null)"); }
|
||||
|
||||
public void testLambdaExpression11() { doParserTest("() -> { }"); }
|
||||
|
||||
public void testLambdaExpression12() { doParserTest("(I1 & I2) () -> null"); }
|
||||
|
||||
public void testLambdaExpression13() { doParserTest("(I1 & I2) () -> {}"); }
|
||||
|
||||
public void testLambdaExpression14() { doParserTest("(String t) -> t"); }
|
||||
|
||||
public void testLambdaExpression15() { doParserTest("(int a, int b) -> a + b"); }
|
||||
|
||||
public void testLambdaExpression16() { doParserTest("(final int x) -> x"); }
|
||||
|
||||
public void testLambdaExpression17() { doParserTest("(String s -> s"); }
|
||||
|
||||
public void testLambdaExpression18() { doParserTest("(java.lang.String s, -> s"); }
|
||||
|
||||
public void testLambdaExpression19() { doParserTest("(@A T t) -> (null)"); }
|
||||
|
||||
public void testLambdaExpression20() { doParserTest("(@A T) -> (null)"); }
|
||||
|
||||
public void testLambdaExpression21() { doParserTest("(T @A() [] x) -> { }"); }
|
||||
|
||||
public void testLambdaExpression22() { doParserTest("(T x @A() []) -> { }"); }
|
||||
|
||||
public void testLambdaExpression23() { doParserTest("(T... t) -> t.length"); }
|
||||
|
||||
public void testLambdaExpression24() { doParserTest("var -> var"); }
|
||||
|
||||
public void testLambdaExpression25() { doParserTest("(var) -> var"); }
|
||||
|
||||
public void testLambdaExpression26() { doParserTest("(var var) -> var"); }
|
||||
|
||||
public void testLambdaExpression27() { doParserTest("z > (w) -> v"); }
|
||||
|
||||
public void testTextBlockLiteral0() { doParserTest("\"\"\".\"\"\""); }
|
||||
|
||||
public void testSwitch0() { doParserTest("switch (i) { case 1 -> 1; default -> 2; }"); }
|
||||
|
||||
public void testYieldAsExpr0() { doParserTest("yield.run()"); }
|
||||
|
||||
public void testYieldAsExpr1() { doParserTest("yield++"); }
|
||||
|
||||
public void testYieldAsExpr2() { doParserTest("yield += 2"); }
|
||||
|
||||
public void testYieldAsExpr3() { doParserTest("yield ? 10 : 20"); }
|
||||
|
||||
public void testStringTemplate1() { doParserTest(); }
|
||||
|
||||
public void testStringTemplate2() { doParserTest(); }
|
||||
|
||||
public void testStringTemplate3() { doParserTest(); }
|
||||
|
||||
public void testStringTemplate4() { doParserTest(); }
|
||||
|
||||
public void testStringTemplate5() { doParserTest(); }
|
||||
|
||||
public void testStringTemplate6() { doParserTest(); }
|
||||
|
||||
public void testStringTemplate7() { doParserTest(); }
|
||||
|
||||
public void testStringTemplate8() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate1() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate2() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate3() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate4() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate5() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate6() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate7() { doParserTest(); }
|
||||
|
||||
public void testTextBlockTemplate8() { doParserTest(); }
|
||||
|
||||
protected abstract void doParserTest(String text);
|
||||
|
||||
protected abstract void doParserTest();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicFileParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicFileParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/files", configurator);
|
||||
}
|
||||
|
||||
public void testEmptyFile() { doParserTest(""); }
|
||||
|
||||
public void testPackage() { doParserTest("package a.b.c;"); }
|
||||
public void testAnnotatedPackage() { doParserTest("@Anno package a.b.c;"); }
|
||||
public void testUnclosedPackage0() { doParserTest("package"); }
|
||||
public void testUnclosedPackage1() { doParserTest("package a."); }
|
||||
|
||||
public void testImport0() { doParserTest("import java.util.*;"); }
|
||||
public void testImport1() { doParserTest("import java.util.Arrays;"); }
|
||||
public void testStaticImport0() { doParserTest("import static java.util.Arrays.*;"); }
|
||||
public void testStaticImport1() { doParserTest("import static java.util.Arrays.sort;"); }
|
||||
public void testUnclosedImport0() { doParserTest("import"); }
|
||||
public void testUnclosedImport1() { doParserTest("import java.awt.*"); }
|
||||
public void testUnclosedImport2() { doParserTest("import java.awt."); }
|
||||
public void testUnclosedImport3() { doParserTest("import static a"); }
|
||||
public void testImportBrokenFromBeginning() { doParserTest("xx import a;"); }
|
||||
|
||||
public void testExtraSemicolons() { doParserTest("package p;;\nimport a;;\nclass C{};"); }
|
||||
public void testFileWithClass() { doParserTest("package a;\nimport b;\npublic class C { }\nclass D { }"); }
|
||||
|
||||
public void testBindBefore0() { doParserTest("class A{\n // comment\n int field;\n}"); }
|
||||
public void testBindBefore1() { doParserTest("class A{\n // comment\n\n int field;\n}"); }
|
||||
public void testBindBefore2() { doParserTest("class A{ // comment\n int field;\n}"); }
|
||||
public void testBindBefore3() { doParserTest("class A{// comment\n int field;\n}"); }
|
||||
public void testBindBefore4() { doParserTest("class A{\n // comment 1\n // comment 2\n // comment 3\n int field;\n}"); }
|
||||
|
||||
public void testBindDocComment0() { doParserTest("/** class comment */\nclass A { }"); }
|
||||
public void testBindDocComment1() { doParserTest("/** file comment */\npackage a;\nclass A { }"); }
|
||||
public void testBindDocComment2() { doParserTest("/** file comment */\nimport a;\nclass A { }"); }
|
||||
public void testBindDocComment3() { doParserTest("class A {\n /** field comment */\n int f;\n}"); }
|
||||
public void testBindDocComment4() { doParserTest("class A {\n /** field comment */\n// field comment\n int f;\n}"); }
|
||||
|
||||
protected abstract void doParserTest(String text);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicModuleParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicModuleParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/modules", configurator);
|
||||
}
|
||||
|
||||
public void testSimple0() { doParserTest("module M1 { }"); }
|
||||
|
||||
public void testSimple1() { doParserTest("module a.b. /*here!*/ c { }"); }
|
||||
|
||||
public void testSimple2() { doParserTest("/* comment */\nmodule X { }"); }
|
||||
|
||||
public void testPackaged() { doParserTest("package pkg;\nmodule M { }"); }
|
||||
|
||||
public void testImports() { doParserTest("import java.lang.Deprecated;\nmodule M { }"); }
|
||||
|
||||
public void testModifierList0() { doParserTest("open module M { }"); }
|
||||
|
||||
public void testModifierList1() { doParserTest("@Deprecated module M { }"); }
|
||||
|
||||
public void testName0() { doParserTest("module A. { }"); }
|
||||
|
||||
public void testName1() { doParserTest("module A..B { }"); }
|
||||
|
||||
public void testName2() { doParserTest("module A B { }"); }
|
||||
|
||||
public void testName3() { doParserTest("module .A { }"); }
|
||||
|
||||
public void testIncomplete0() { doParserTest("module"); }
|
||||
|
||||
public void testIncomplete1() { doParserTest("module X"); }
|
||||
|
||||
public void testIncomplete2() { doParserTest("module {"); }
|
||||
|
||||
public void testIncomplete3() { doParserTest("module X {"); }
|
||||
|
||||
public void testIncomplete4() { doParserTest("module X { junk"); }
|
||||
|
||||
public void testBadContent() { doParserTest("module X {\n some junk\n}"); }
|
||||
|
||||
public void testExtras() { doParserTest("module one { }\nmodule another { }"); }
|
||||
|
||||
public void testSemicolons() { doParserTest("module M { ;;; }"); }
|
||||
|
||||
public void testRequires0() { doParserTest("module M { requires }"); }
|
||||
|
||||
public void testRequires1() { doParserTest("module M { requires X }"); }
|
||||
|
||||
public void testRequires2() { doParserTest("module M { requires transitive static X; }"); }
|
||||
|
||||
public void testRequires3() { doParserTest("module M { requires private X; }"); }
|
||||
|
||||
public void testRequires4() { doParserTest("module M { requires A, B; }"); }
|
||||
|
||||
public void testExports0() { doParserTest("module M { exports }"); }
|
||||
|
||||
public void testExports1() { doParserTest("module M { exports pkg }"); }
|
||||
|
||||
public void testExports2() { doParserTest("module M { exports pkg; }"); }
|
||||
|
||||
public void testExports3() { doParserTest("module M { exports pkg to }"); }
|
||||
|
||||
public void testExports4() { doParserTest("module M { exports pkg to ; }"); }
|
||||
|
||||
public void testExports5() { doParserTest("module M { exports pkg to A }"); }
|
||||
|
||||
public void testExports6() { doParserTest("module M { exports pkg to A, }"); }
|
||||
|
||||
public void testExports7() { doParserTest("module M { exports pkg to A, ; }"); }
|
||||
|
||||
public void testExports8() { doParserTest("module M { exports pkg to , B; }"); }
|
||||
|
||||
public void testOpens0() { doParserTest("module M { opens }"); }
|
||||
|
||||
public void testOpens1() { doParserTest("module M { opens pkg to A, B; }"); }
|
||||
|
||||
public void testUses0() { doParserTest("module M { uses }"); }
|
||||
|
||||
public void testUses1() { doParserTest("module M { uses C }"); }
|
||||
|
||||
public void testUses2() { doParserTest("module M { uses java.nio.file.spi.FileSystemProvider; }"); }
|
||||
|
||||
public void testProvides0() { doParserTest("module M { provides }"); }
|
||||
|
||||
public void testProvides1() { doParserTest("module M { provides Spi }"); }
|
||||
|
||||
public void testProvides2() { doParserTest("module M { provides Spi ; }"); }
|
||||
|
||||
public void testProvides3() { doParserTest("module M { provides Spi with }"); }
|
||||
|
||||
public void testProvides4() { doParserTest("module M { provides Spi with ; }"); }
|
||||
|
||||
public void testProvides5() { doParserTest("module M { provides Spi with Impl }"); }
|
||||
|
||||
public void testProvides6() { doParserTest("module M { provides Spi with Impl; }"); }
|
||||
|
||||
public void testProvides7() { doParserTest("module M { provides Spi _ }"); }
|
||||
|
||||
public void testProvides8() { doParserTest("module M { provides Spi with Impl1, Impl2, }"); }
|
||||
|
||||
protected abstract void doParserTest(String text);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicPatternParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicPatternParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/patterns", configurator);
|
||||
}
|
||||
|
||||
public void testRecord0() { doParserTest("Point(int x, int y)"); }
|
||||
|
||||
public void testRecord1() { doParserTest("Point()"); }
|
||||
|
||||
public void testRecord2() { doParserTest("Box<Object>(String s)"); }
|
||||
|
||||
public void testRecord3() { doParserTest("NamedRecord(String s) name"); }
|
||||
|
||||
public void testRecord4() { doParserTest("Rec(,)"); }
|
||||
|
||||
public void testRecord5() { doParserTest("Rec(,,)"); }
|
||||
|
||||
public void testRecord6() { doParserTest("Rec(String s int i)"); }
|
||||
|
||||
public void testRecord7() { doParserTest("Rec(int a,) a"); }
|
||||
|
||||
public void testRecord8() { doParserTest("Rec(int a, "); }
|
||||
|
||||
public void testRecord9() { doParserTest("Rec(int a"); }
|
||||
|
||||
public void testRecord10() { doParserTest("Rec r"); }
|
||||
|
||||
public void testRecord11() { doParserTest("Rec(var x) r"); }
|
||||
|
||||
public void testRecord12() { doParserTest("Rec(String)"); }
|
||||
|
||||
public void testRecordUnnamed0() { doParserTest("Point(_)"); }
|
||||
|
||||
public void testRecordUnnamed1() { doParserTest("Point(int x, _)"); }
|
||||
|
||||
public void testRecordUnnamed2() { doParserTest("Point(_, int y)"); }
|
||||
|
||||
public void testRecordUnnamed3() { doParserTest("Point(_, _)"); }
|
||||
|
||||
protected abstract void doParserTest(String text);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicReferenceParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicReferenceParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/references", configurator);
|
||||
}
|
||||
|
||||
public void testReference0() { doRefParserTest("a", false); }
|
||||
public void testReference1() { doRefParserTest("a.", true); }
|
||||
public void testReference2() { doRefParserTest("a.b", false); }
|
||||
|
||||
public void testType0() { doTypeParserTest("int"); }
|
||||
public void testType1() { doTypeParserTest("a.b"); }
|
||||
public void testType2() { doTypeParserTest("int[]"); }
|
||||
public void testType3() { doTypeParserTest("int[]["); }
|
||||
public void testType4() { doTypeParserTest("Map<String,List<String>>"); }
|
||||
public void testType5() { doTypeParserTest("Object[]..."); }
|
||||
public void testType6() { doTypeParserTest("@English String @NonEmpty []"); }
|
||||
public void testType7() { doTypeParserTest("Diamond<>"); }
|
||||
public void testType8() { doTypeParserTest("A|"); }
|
||||
public void testType9() { doTypeParserTest("A|B"); }
|
||||
public void testType10() { doTypeParserTest("Diamond<@TA>"); }
|
||||
|
||||
public void testTypeParams0() { doTypeParamsParserTest("<T>"); }
|
||||
public void testTypeParams1() { doTypeParamsParserTest("<T, U>"); }
|
||||
public void testTypeParams2() { doTypeParamsParserTest("<T"); }
|
||||
public void testTypeParams3() { doTypeParamsParserTest("<T hack>"); }
|
||||
public void testTypeParams4() { doTypeParamsParserTest("<T hack"); }
|
||||
public void testTypeParams5() { doTypeParamsParserTest("<T extends X & Y<Z>>"); }
|
||||
public void testTypeParams6() { doTypeParamsParserTest("<T supers X>"); }
|
||||
public void testTypeParams7() { doTypeParamsParserTest("<T extends X, Y>"); }
|
||||
public void testTypeParams8() { doTypeParamsParserTest("<?>"); }
|
||||
|
||||
public void testAnyTypeParams() { doTypeParamsParserTest("<any T>"); }
|
||||
public void testAnyTypeArgs() { doTypeParserTest("T<E_SRC, any, E_DST, ?>"); }
|
||||
|
||||
protected abstract void doRefParserTest(String text, boolean incomplete);
|
||||
|
||||
protected abstract void doTypeParserTest(String text);
|
||||
|
||||
protected abstract void doTypeParamsParserTest(String text);
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.partial;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicStatementParserTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicStatementParserTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-partial/statements", configurator);
|
||||
}
|
||||
|
||||
public void testBlockSimple() { doBlockParserTest("{ {} }"); }
|
||||
public void testBlockEmpty() { doBlockParserTest("{ ; }"); }
|
||||
public void testAnonymousInSmartCompletion() { doBlockParserTest("{ new Foo(hash\n#) {};\n new Foo(hash\n#, bar) {};\n new Foo(hash\n#x) {}; }"); }
|
||||
public void testBlockIncomplete0() { doBlockParserTest("{ /*}"); }
|
||||
public void testBlockIncomplete1() { doBlockParserTest("{ { }"); }
|
||||
public void testBlockIncomplete2() { doBlockParserTest("{ else; catch; finally; }"); }
|
||||
public void testSCR5202() { doBlockParserTest("{ String.class.\n String[] strings; }"); }
|
||||
|
||||
public void testAssertNormal0() { doParserTest("assert cond;"); }
|
||||
public void testAssertNormal1() { doParserTest("assert cond : message;"); }
|
||||
|
||||
public void testAssignmentSimple0() { doParserTest("int[] a;\n a[0] = 0;"); }
|
||||
public void testAssignmentSimple1() { doParserTest("a=1; int b=2;"); }
|
||||
|
||||
public void testBreakNormal0() { doParserTest("break;"); }
|
||||
public void testBreakNormal1() { doParserTest("break LABEL;"); }
|
||||
public void testBreakIncomplete() { doParserTest("break"); }
|
||||
|
||||
public void testYield() { doParserTest("yield yield;"); }
|
||||
public void testYieldNested() { doParserTest("yield switch (0) { default: yield 42; };"); }
|
||||
public void testYieldIncomplete0() { doParserTest("yield "); }
|
||||
public void testYieldIncomplete1() { doParserTest("yield x"); }
|
||||
public void testYieldCall() { doParserTest("foo.yield();"); }
|
||||
public void testYieldDecrement() { doParserTest("yield ++yield;"); }
|
||||
public void testYieldCallNonQualified() { doParserTest("yield();"); }
|
||||
public void testYieldCallNonQualifiedWithLambda() { doParserTest("yield(() -> {});"); }
|
||||
public void testYieldLambda() { doParserTest("yield () -> {};"); }
|
||||
public void testYieldAssignment() { doParserTest("yield = 10;"); }
|
||||
public void testYieldCompatibility() { setLanguageLevel(LanguageLevel.JDK_12); doParserTest("yield(2);"); }
|
||||
public void testYieldWithTextBlock() { doParserTest("yield \"\"\"foo\"\"\""); }
|
||||
|
||||
public void testContinueNormal0() { doParserTest("continue;"); }
|
||||
public void testContinueNormal1() { doParserTest("continue LABEL;"); }
|
||||
|
||||
public void testLocalVar0() { doParserTest("List<Integer> list;"); }
|
||||
public void testLocalVar1() { doParserTest("p.@A T<P> x;"); }
|
||||
public void testLocalVar3() { doParserTest("var var;"); }
|
||||
public void testLocalVar4() { doParserTest("final var x;"); }
|
||||
public void testLocalVar5() { doParserTest("@A var x;"); }
|
||||
public void testLocalVar6() { doParserTest("@A var"); }
|
||||
public void testLocalVar7() { doParserTest("int"); }
|
||||
|
||||
public void testExprStatement0() { doParserTest("var"); }
|
||||
public void testExprStatement1() { doParserTest("int."); }
|
||||
|
||||
public void testDoNormal() { doParserTest("do{}while(true);"); }
|
||||
public void testDoIncomplete0() { doParserTest("do"); }
|
||||
public void testDoIncomplete1() { doParserTest("do foo();"); }
|
||||
public void testDoIncomplete2() { doParserTest("do foo(); while"); }
|
||||
public void testDoIncomplete3() { doParserTest("do foo(); while("); }
|
||||
public void testDoIncomplete4() { doParserTest("do foo(); while();"); }
|
||||
public void testDoIncomplete5() { doParserTest("do foo(); while(\n g();"); }
|
||||
public void testDoIncomplete6() { doParserTest("do foo(); while(cond)"); }
|
||||
|
||||
public void testFor() { doParserTest("for(Iterator<String> it = null; it.hasNext();) { String s = it.next(); }"); }
|
||||
public void testForNormal0() { doParserTest("for(int i = 0; i < 10; i++)\n ;"); }
|
||||
public void testForNormal1() { doParserTest("for( ; ; ) foo();"); }
|
||||
public void testForNormal2() { doParserTest("for(var x = 0; ;) ;"); }
|
||||
public void testForNormal3() { doParserTest("for(var x : list) ;"); }
|
||||
public void testForNormal4() { doParserTest("for(foo();;) ;"); }
|
||||
public void testForNormal5() { doParserTest("for(((foo()));;) ;"); }
|
||||
public void testForNormal6() { doParserTest("for (getI(getS()); a; b = true)"); }
|
||||
public void testForIncorrect() { doParserTest("for ((Point(var x, var y)) : pointArray) ;"); } // pattern with parens can't be parsed
|
||||
public void testForIncomplete0() { doParserTest("for"); }
|
||||
public void testForIncomplete1() { doParserTest("for("); }
|
||||
public void testForIncomplete2() { doParserTest("for(int i = 0;"); }
|
||||
public void testForIncomplete3() { doParserTest("for(int i = 0; i < 10"); }
|
||||
public void testForIncomplete4() { doParserTest("for(int i = 0; i < 10;"); }
|
||||
public void testForIncomplete5() { doParserTest("for(int i = 0; i < 10; i++"); }
|
||||
public void testForIncomplete6() { doParserTest("for(int i = 0; i < 10; i++)"); }
|
||||
public void testForIncomplete7() { doParserTest("for() foo();"); }
|
||||
public void testForIncomplete8() { doParserTest("for(int i = 0;) foo();"); }
|
||||
public void testForIncomplete9() { doParserTest("for(int i = 0; i < 0) foo();"); }
|
||||
public void testForIncomplete10() { doParserTest("for(var x"); }
|
||||
public void testForInvalid0() { doParserTest("for(if (i<0) i++; ;) ;"); }
|
||||
public void testForInvalid1() { doParserTest("for(class C { }; ;) ;"); }
|
||||
public void testForComments0() { doParserTest("for(int i=0; i<1; i++ /**/) ;"); }
|
||||
public void testForComments1() { doParserTest("for(int i=0; i<1; i++, j++ /**/) ;"); }
|
||||
|
||||
public void testForEach() { doParserTest("for(Object o : map.entrySet()) ;"); }
|
||||
public void testForEach1() { doParserTest("for (Point(var x, var y) : pointArray) ;"); }
|
||||
public void testForEachIncomplete0() { doParserTest("for(Object : list) ;"); }
|
||||
public void testForEachIncomplete1() { doParserTest("for (Point(var x, var y) : pointArray ;"); }
|
||||
public void testForEachIncomplete2() { doParserTest("for (Point(var x, var y) : ) ;"); }
|
||||
public void testForEachIncomplete3() { doParserTest("for (Point(var x, var y) ) ;"); }
|
||||
public void testForEachIncomplete4() { doParserTest("for (Point(var x, var y) "); }
|
||||
public void testForEachIncomplete5() { doParserTest("for (Point(var x, var y) foo.bar + 1) ;"); }
|
||||
|
||||
public void testIfNormalWithElse() { doParserTest("if (a){ f1(); } else{ f2(); }"); }
|
||||
public void testIfNormalNoElse() { doParserTest("if (a) f1();"); }
|
||||
public void testIfIncomplete0() { doParserTest("if"); }
|
||||
public void testIfIncomplete1() { doParserTest("if ("); }
|
||||
public void testIfIncomplete2() { doParserTest("if (\n foo();"); }
|
||||
public void testIfIncomplete3() { doParserTest("if (cond"); }
|
||||
public void testIfIncomplete4() { doParserTest("if (cond)"); }
|
||||
public void testIfIncomplete5() { doParserTest("if () foo();"); }
|
||||
public void testIfIncomplete6() { doParserTest("if (cond) foo(); else"); }
|
||||
|
||||
public void testLabelSimple() { doParserTest("Loop:\n while(true) ;"); }
|
||||
|
||||
public void testReturnNoResult() { doParserTest("return;"); }
|
||||
public void testReturnWithResult() { doParserTest("return 10;"); }
|
||||
public void testReturnIncomplete0() { doParserTest("return"); }
|
||||
public void testReturnIncomplete1() { doParserTest("return a"); }
|
||||
|
||||
public void testSwitchNormal() { doParserTest("switch(o){}"); }
|
||||
public void testSwitchIncomplete0() { doParserTest("switch"); }
|
||||
public void testSwitchIncomplete1() { doParserTest("switch("); }
|
||||
public void testSwitchIncomplete2() { doParserTest("switch(o"); }
|
||||
public void testSwitchIncomplete3() { doParserTest("switch(o)"); }
|
||||
public void testSwitchIncomplete4() { doParserTest("switch(){}"); }
|
||||
public void testSwitchIncomplete5() { doParserTest("switch(\n foo();"); }
|
||||
|
||||
public void testSwitchLabelsNormal() { doParserTest("case 1: break; default: break;"); }
|
||||
public void testSwitchLabelsMultiple() { doParserTest("case 1, 2: break;"); }
|
||||
public void testSwitchLabelsIncomplete0() { doParserTest("case"); }
|
||||
public void testSwitchLabelsIncomplete1() { doParserTest("case 2"); }
|
||||
public void testSwitchLabelsIncomplete2() { doParserTest("default"); }
|
||||
public void testSwitchLabelsIncomplete3() { doParserTest("default 3:"); }
|
||||
public void testSwitchLabelsIncomplete4() { doParserTest("case :"); }
|
||||
public void testSwitchLabelsIncomplete5() { doParserTest("case 1, : break;"); }
|
||||
|
||||
public void testSwitchRules0() { doParserTest("default ->"); }
|
||||
public void testSwitchRules1() { doParserTest("default -> return;"); }
|
||||
public void testSwitchRules2() { doParserTest("case 1 -> { }"); }
|
||||
public void testSwitchRules3() { doParserTest("case 1 -> { };;"); }
|
||||
public void testSwitchRules4() { doParserTest("case 1 -> throw new Exception()"); }
|
||||
public void testSwitchRules5() { doParserTest("case 1 -> throw new Exception();"); }
|
||||
public void testSwitchRules6() { doParserTest("case 1 -> digit = '1'"); }
|
||||
public void testSwitchRules7() { doParserTest("case 1 -> '1';"); }
|
||||
public void testSwitchRules8() { doParserTest("case 1 -> ;"); }
|
||||
public void testSwitchRules9() { doParserTest("case b -> f(b);"); }
|
||||
public void testSwitchRules10() { doParserTest("case (b) -> f(b);"); }
|
||||
public void testSwitchRules11() { doParserTest("case 1, 2 -> { }"); }
|
||||
public void testSwitchRules12() { doParserTest("case 1, -> { }"); }
|
||||
public void testSwitchRules13() { doParserTest("case null, default -> { }"); }
|
||||
public void testSwitchRules14() { doParserTest("case default -> { }"); }
|
||||
|
||||
public void testSwitchRulesWithPattern1() { doParserTest("case int[] ia -> { }"); }
|
||||
public void testSwitchRulesWithPattern2() { doParserTest("case Integer i -> { }"); }
|
||||
public void testSwitchRulesWithPattern3() { doParserTest("case A when when when.foo() -> {}"); }
|
||||
public void testSwitchRulesWithPattern4() { doParserTest("case null, default -> { }"); }
|
||||
public void testSwitchRulesWithPattern5() { doParserTest("case null -> { }"); }
|
||||
public void testSwitchRulesWithPattern6() { doParserTest("case Integer i when true -> { }"); }
|
||||
public void testSwitchRulesWithPattern7() { doParserTest("case R(int i) when true -> {}"); }
|
||||
public void testSwitchRulesWithPattern8() { doParserTest("case R(int i) when a < b -> {}"); }
|
||||
public void testSwitchRulesWithPatternIncomplete1() { doParserTest("case (Integer i -> { }"); }
|
||||
public void testSwitchRulesWithPatternIncomplete2() { doParserTest("case Integer i, -> { }"); }
|
||||
public void testSwitchRulesWithPatternIncomplete3() { doParserTest("case Integer i when -> { }"); }
|
||||
|
||||
public void testSyncNormal() { doParserTest("synchronized(o){}"); }
|
||||
public void testSyncIncomplete0() { doParserTest("synchronized"); }
|
||||
public void testSyncIncomplete1() { doParserTest("synchronized("); }
|
||||
public void testSyncIncomplete2() { doParserTest("synchronized(o"); }
|
||||
public void testSyncIncomplete3() { doParserTest("synchronized(o)"); }
|
||||
public void testSyncIncomplete4() { doParserTest("synchronized(){}"); }
|
||||
public void testSyncIncomplete5() { doParserTest("synchronized(\n foo();"); }
|
||||
|
||||
public void testThrowNormal() { doParserTest("throw e;"); }
|
||||
public void testThrowIncomplete0() { doParserTest("throw"); }
|
||||
public void testThrowIncomplete1() { doParserTest("throw e"); }
|
||||
|
||||
public void testTryNormal0() { doParserTest("try{}catch(E e){}"); }
|
||||
public void testTryNormal1() { doParserTest("try{}catch(final E e){}finally{}"); }
|
||||
public void testTryNormal2() { doParserTest("try{}finally{}"); }
|
||||
public void testTryNormal3() { doParserTest("try{}catch(A|B e){}"); }
|
||||
public void testTryNormal4() { doParserTest("try(R r = 0){}"); }
|
||||
public void testTryNormal5() { doParserTest("try(R1 r1 = 1; R2 r2 = 2){}"); }
|
||||
public void testTryNormal6() { doParserTest("try(R r = 0;){}"); }
|
||||
public void testTryNormal7() { doParserTest("try(r){}"); }
|
||||
public void testTryNormal8() { doParserTest("try(r;){}"); }
|
||||
public void testTryNormal9() { doParserTest("try(r1; R r2 = 0){}"); }
|
||||
public void testTryNormal10() { doParserTest("try(this){}"); }
|
||||
public void testTryNormal11() { doParserTest("try(new R()){}"); }
|
||||
public void testTryNormal12() { doParserTest("try(R.create()){}"); }
|
||||
public void testTryNormal13() { doParserTest("try(var r = null){}"); }
|
||||
public void testTryIncomplete0() { doParserTest("try"); }
|
||||
public void testTryIncomplete1() { doParserTest("try{}"); }
|
||||
public void testTryIncomplete2() { doParserTest("try{}catch"); }
|
||||
public void testTryIncomplete3() { doParserTest("try{}catch("); }
|
||||
public void testTryIncomplete4() { doParserTest("try{}catch(E"); }
|
||||
public void testTryIncomplete5() { doParserTest("try{}catch(E e"); }
|
||||
public void testTryIncomplete6() { doParserTest("try{}catch(E e)"); }
|
||||
public void testTryIncomplete7() { doParserTest("try{}finally"); }
|
||||
public void testTryIncomplete8() { doParserTest("try{}catch(A|)"); }
|
||||
public void testTryIncomplete9() { doParserTest("try{}catch(A|B)"); }
|
||||
public void testTryIncomplete10() { doParserTest("try({}"); }
|
||||
public void testTryIncomplete11() { doParserTest("try(){}"); }
|
||||
public void testTryIncomplete12() { doParserTest("try(;){}"); }
|
||||
public void testTryIncomplete13() { doParserTest("try(final ){}"); }
|
||||
public void testTryIncomplete14() { doParserTest("try(int){}"); }
|
||||
public void testTryIncomplete15() { doParserTest("try(R r){}"); }
|
||||
public void testTryIncomplete16() { doParserTest("try(R r =){}"); }
|
||||
public void testTryIncomplete17() { doParserTest("try(R r = 0;;){}"); }
|
||||
public void testTryIncomplete18() { doParserTest("try(R<T> r){}"); }
|
||||
public void testTryIncomplete19() { doParserTest("try(var r){}"); }
|
||||
|
||||
public void testWhileNormal() { doParserTest("while (true) foo();"); }
|
||||
public void testWhileIncomplete0() { doParserTest("while"); }
|
||||
public void testWhileIncomplete1() { doParserTest("while ("); }
|
||||
public void testWhileIncomplete2() { doParserTest("while(\n foo();"); }
|
||||
public void testWhileIncomplete3() { doParserTest("while(cond"); }
|
||||
public void testWhileIncomplete4() { doParserTest("while(cond)"); }
|
||||
public void testWhileIncomplete5() { doParserTest("while() foo();"); }
|
||||
|
||||
public void testExprStmtStarts() { doParserTest("col < allCells[0]"); }
|
||||
|
||||
public void testConstructorRef() { doParserTest("Foo::new"); }
|
||||
public void testConstructorWithTypeParamsRef() { doParserTest("Foo<Integer>::new"); }
|
||||
|
||||
public void testVarLabel() { doParserTest("var: foo();"); }
|
||||
|
||||
protected abstract void doBlockParserTest(String text);
|
||||
|
||||
protected abstract void doParserTest(String text);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicAssertParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicAssertParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/assert", configurator);
|
||||
}
|
||||
|
||||
public void testNormal1() {
|
||||
doTest(true); }
|
||||
public void testNormal2() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicAssignmentParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicAssignmentParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/assignment", configurator);
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicCodeBlockParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicCodeBlockParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/codeBlock", configurator);
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(true); }
|
||||
|
||||
public void testAnonymousInSmartCompletion() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicDeclarationsWithGenericsParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicDeclarationsWithGenericsParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/genericsParsing", configurator);
|
||||
}
|
||||
|
||||
public void testLocalVar() { doTest(true); }
|
||||
|
||||
public void testFor() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicDoWhileParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicDoWhileParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/do-while", configurator);
|
||||
}
|
||||
|
||||
public void testNormal() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
|
||||
public void testUncomplete3() { doTest(true); }
|
||||
|
||||
public void testUncomplete4() { doTest(true); }
|
||||
|
||||
public void testUncomplete5() { doTest(true); }
|
||||
|
||||
public void testUncomplete6() { doTest(true); }
|
||||
|
||||
public void testUncomplete7() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicForParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicForParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/for", configurator);
|
||||
}
|
||||
|
||||
public void testNormal1() { doTest(true); }
|
||||
public void testNormal2() { doTest(true); }
|
||||
public void testForEach1() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
public void testUncomplete3() { doTest(true); }
|
||||
public void testUncomplete4() { doTest(true); }
|
||||
public void testUncomplete5() { doTest(true); }
|
||||
public void testUncomplete6() { doTest(true); }
|
||||
public void testUncomplete7() { doTest(true); }
|
||||
public void testUncomplete8() { doTest(true); }
|
||||
public void testUncomplete9() { doTest(true); }
|
||||
public void testUncomplete10() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicIfParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicIfParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/if", configurator);
|
||||
}
|
||||
|
||||
public void testNormalWithElse() { doTest(true); }
|
||||
|
||||
public void testNormalNoElse() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
|
||||
public void testUncomplete3() { doTest(true); }
|
||||
|
||||
public void testUncomplete4() { doTest(true); }
|
||||
|
||||
public void testUncomplete5() { doTest(true); }
|
||||
|
||||
public void testUncomplete6() { doTest(true); }
|
||||
|
||||
public void testUncomplete7() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicLabelParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicLabelParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/label", configurator);
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicReturnParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicReturnParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/return", configurator);
|
||||
}
|
||||
|
||||
public void testNormalNoResult() { doTest(true); }
|
||||
public void testNormalWithResult() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicSwitchParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicSwitchParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/switch", configurator);
|
||||
}
|
||||
|
||||
public void testNormal() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
public void testUncomplete3() { doTest(true); }
|
||||
public void testUncomplete4() { doTest(true); }
|
||||
public void testUncomplete5() { doTest(true); }
|
||||
public void testUncomplete6() { doTest(true); }
|
||||
public void testUncomplete7() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicSynchronizedParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicSynchronizedParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/synchronized", configurator);
|
||||
}
|
||||
|
||||
public void testNormal() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
public void testUncomplete3() { doTest(true); }
|
||||
public void testUncomplete4() { doTest(true); }
|
||||
public void testUncomplete5() { doTest(true); }
|
||||
public void testUncomplete6() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicThrowParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicThrowParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/throw", configurator);
|
||||
}
|
||||
|
||||
public void testNormal() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicTryParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicTryParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/try", configurator);
|
||||
}
|
||||
|
||||
public void testNormal1() { doTest(true); }
|
||||
|
||||
public void testNormal2() { doTest(true); }
|
||||
|
||||
public void testNormal3() { doTest(true); }
|
||||
|
||||
public void testNormal4() { doTest(true); }
|
||||
|
||||
public void testIncomplete1() { doTest(true); }
|
||||
|
||||
public void testIncomplete2() { doTest(true); }
|
||||
|
||||
public void testIncomplete3() { doTest(true); }
|
||||
|
||||
public void testIncomplete4() { doTest(true); }
|
||||
|
||||
public void testIncomplete5() { doTest(true); }
|
||||
|
||||
public void testIncomplete6() { doTest(true); }
|
||||
|
||||
public void testIncomplete7() { doTest(true); }
|
||||
|
||||
public void testIncomplete8() { doTest(true); }
|
||||
|
||||
public void testIncomplete9() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.parser.statementParsing;
|
||||
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestCase;
|
||||
import com.intellij.java.parser.AbstractBasicJavaParsingTestConfigurator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractBasicWhileParsingTest extends AbstractBasicJavaParsingTestCase {
|
||||
public AbstractBasicWhileParsingTest(@NotNull AbstractBasicJavaParsingTestConfigurator configurator) {
|
||||
super("parser-full/statementParsing/while", configurator);
|
||||
}
|
||||
|
||||
public void testNormal() { doTest(true); }
|
||||
|
||||
public void testUncomplete1() { doTest(true); }
|
||||
public void testUncomplete2() { doTest(true); }
|
||||
public void testUncomplete3() { doTest(true); }
|
||||
public void testUncomplete4() { doTest(true); }
|
||||
public void testUncomplete5() { doTest(true); }
|
||||
public void testUncomplete6() { doTest(true); }
|
||||
}
|
||||
Reference in New Issue
Block a user