diff options
author | David Audel | 2005-02-21 17:24:02 +0000 |
---|---|---|
committer | David Audel | 2005-02-21 17:24:02 +0000 |
commit | 5b0866f1cda464a8164beeea02560de34d69c4f0 (patch) | |
tree | d74c25ef32577cd0fc876e591276f58e4a1f0427 | |
parent | d54840c2cf76987b881913ebc5e05cef5477704b (diff) | |
download | eclipse.jdt.core-5b0866f1cda464a8164beeea02560de34d69c4f0.tar.gz eclipse.jdt.core-5b0866f1cda464a8164beeea02560de34d69c4f0.tar.xz eclipse.jdt.core-5b0866f1cda464a8164beeea02560de34d69c4f0.zip |
bug 83321
3 files changed, 79 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java new file mode 100644 index 0000000000..92d4d18d57 --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.parser; + + +import java.util.Map; + +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + + + +public class EnumCompletionParserTest extends AbstractCompletionTest { +public EnumCompletionParserTest(String testName) { + super(testName); +} + +protected Map getCompilerOptions() { + Map options = super.getCompilerOptions(); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + return options; +} + +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83321 + */ +public void test0001(){ + String str = + "public class Completion {\n" + + " /*here*/\n" + + "}\n" + + "enum Natural {\n" + + " ONE;\n" + + "}\n"; + + String completeBehind = "/*here*/"; + int cursorLocation = str.indexOf("/*here*/") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = ""; + String expectedUnitDisplayString = + "public class Completion {\n" + + " <CompleteOnType:>;\n" + + " public Completion() {\n" + + " }\n" + + "}\n" + + "enum Natural {\n" + + " ONE(),\n" + + " Natural() {\n" + + " }\n" + + " <clinit>() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +} diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java index 435c1c4278..29e0ea7fb7 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java @@ -47,7 +47,8 @@ public class TestAll extends TestCase { testClasses.add(CompletionParserTestKeyword.class); testClasses.add(GenericsCompletionParserTest.class); testClasses.add(AnnotationCompletionParserTest.class); - + testClasses.add(EnumCompletionParserTest.class); + /* selection tests */ testClasses.add(ExplicitConstructorInvocationSelectionTest.class); testClasses.add(SelectionTest.class); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java index 797c9b24e9..9da2d6b859 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java @@ -2707,9 +2707,10 @@ protected void consumeEnumConstantHeaderName() { } } long namePosition = this.identifierPositionStack[this.identifierPtr]; - char[] constantName = this.identifierStack[this.identifierPtr--]; + char[] constantName = this.identifierStack[this.identifierPtr]; final int sourceEnd = (int) namePosition; FieldDeclaration enumConstant = createFieldDeclaration(constantName, (int) (namePosition >>> 32), sourceEnd); + this.identifierPtr--; this.identifierLengthPtr--; enumConstant.modifiersSourceStart = this.intStack[this.intPtr--]; enumConstant.modifiers = this.intStack[this.intPtr--]; |