Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2008-02-07 23:13:59 +0000
committerMike Kucera2008-02-07 23:13:59 +0000
commitecf9c5833d2df63b0d19a98e644f2b69c9c97b3a (patch)
tree32bf4bd20df74efb46d17394c23471dc7a6db4fd /core/org.eclipse.cdt.core/parser
parent6a80d1f5da5119d136f433a5b9b586afe9707100 (diff)
downloadorg.eclipse.cdt-ecf9c5833d2df63b0d19a98e644f2b69c9c97b3a.tar.gz
org.eclipse.cdt-ecf9c5833d2df63b0d19a98e644f2b69c9c97b3a.tar.xz
org.eclipse.cdt-ecf9c5833d2df63b0d19a98e644f2b69c9c97b3a.zip
218265 - replace Enum class with Java 5 enums
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/KeywordSetKey.java45
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java38
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserMode.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java34
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SimpleDeclarationStrategy.java23
7 files changed, 66 insertions, 150 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java
deleted file mode 100644
index fbd99a134fc..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.parser;
-
-/**
- * @author jcamelon
- *
- */
-public class Enum
-{
- protected Enum( int enumValue )
- {
- this.enumValue = enumValue;
- }
-
- private final int enumValue;
- /**
- * @return
- */
- protected int getEnumValue()
- {
- return enumValue;
- }
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/KeywordSetKey.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/KeywordSetKey.java
index 88d63d9e9c5..eefc2002e74 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/KeywordSetKey.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/KeywordSetKey.java
@@ -1,39 +1,32 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Mike Kucera (IBM) - convert to Java 5 enum
*******************************************************************************/
package org.eclipse.cdt.core.parser;
-public class KeywordSetKey extends Enum
-{
- public static final KeywordSetKey EMPTY = new KeywordSetKey( 0 );
- public static final KeywordSetKey DECL_SPECIFIER_SEQUENCE = new KeywordSetKey( 1 );
- public static final KeywordSetKey DECLARATION = new KeywordSetKey( 2 );
- public static final KeywordSetKey STATEMENT = new KeywordSetKey(3);
- public static final KeywordSetKey BASE_SPECIFIER = new KeywordSetKey(4);
- public static final KeywordSetKey POST_USING = new KeywordSetKey( 5 );
- public static final KeywordSetKey FUNCTION_MODIFIER = new KeywordSetKey( 6 );
- public static final KeywordSetKey NAMESPACE_ONLY = new KeywordSetKey(6);
- public static final KeywordSetKey MACRO = new KeywordSetKey( 7 );
- public static final KeywordSetKey PP_DIRECTIVE = new KeywordSetKey( 8 );
- public static final KeywordSetKey EXPRESSION = new KeywordSetKey( 9 );
- public static final KeywordSetKey MEMBER = new KeywordSetKey(10);
- public static final KeywordSetKey ALL = new KeywordSetKey( 11 );
- public static final KeywordSetKey KEYWORDS = new KeywordSetKey( 12 );
- public static final KeywordSetKey TYPES = new KeywordSetKey( 13 );
- /**
- * @param enumValue
- */
- protected KeywordSetKey(int enumValue) {
- super(enumValue);
- }
-
+public enum KeywordSetKey {
+ EMPTY,
+ DECL_SPECIFIER_SEQUENCE,
+ DECLARATION,
+ STATEMENT,
+ BASE_SPECIFIER,
+ POST_USING,
+ FUNCTION_MODIFIER,
+ NAMESPACE_ONLY,
+ MACRO,
+ PP_DIRECTIVE,
+ EXPRESSION,
+ MEMBER,
+ ALL,
+ KEYWORDS,
+ TYPES,
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java
index d73d09e3323..a9b27f55f63 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Mike Kucera (IBM)- convert to Java 5 enum
*******************************************************************************/
package org.eclipse.cdt.core.parser;
@@ -19,27 +20,20 @@ public class ParseError extends Error {
private final ParseErrorKind errorKind;
- public static class ParseErrorKind extends Enum
+ public enum ParseErrorKind
{
// the method called is not implemented in this particular implementation
- public static final ParseErrorKind METHOD_NOT_IMPLEMENTED = new ParseErrorKind( 0 );
+ METHOD_NOT_IMPLEMENTED,
// offset specified is within a section of code #if'd out by the preprocessor
// semantic context cannot be provided in this case
- public static final ParseErrorKind OFFSETDUPLE_UNREACHABLE = new ParseErrorKind( 1 );
+ OFFSETDUPLE_UNREACHABLE,
// offset range specified is not a valid identifier or qualified name
// semantic context cannot be provided in this case
- public static final ParseErrorKind OFFSET_RANGE_NOT_NAME = new ParseErrorKind( 2 );
+ OFFSET_RANGE_NOT_NAME,
- public static final ParseErrorKind TIMEOUT_OR_CANCELLED = new ParseErrorKind( 3 );
-
- /**
- * @param enumValue
- */
- protected ParseErrorKind(int enumValue) {
- super(enumValue);
- }
+ TIMEOUT_OR_CANCELLED,
}
public ParseErrorKind getErrorKind()
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java
index ce490a09a07..496a88c1381 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,34 +7,26 @@
*
* Contributors:
* IBM Corp. - Rational Software - initial implementation
+ * Mike Kucera (IBM) - convert to Java 5 enum
*******************************************************************************/
package org.eclipse.cdt.core.parser;
/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * Enumeration of base languages supported by CDT.
*/
-public class ParserLanguage extends Enum {
- public final static ParserLanguage C = new ParserLanguage( 1 );
- public final static ParserLanguage CPP = new ParserLanguage( 2 );
+public enum ParserLanguage {
+
+ C {
+ @Override public boolean isCPP() { return false; }
+ @Override public String toString() { return "C"; } //$NON-NLS-1$
+ },
+
+ CPP {
+ @Override public boolean isCPP() { return true; }
+ @Override public String toString() { return "C++"; } //$NON-NLS-1$
+ };
- private ParserLanguage( int value )
- {
- super( value );
- }
+ public abstract boolean isCPP();
- /**
- * @return
- */
- public boolean isCPP() {
- return ( this == CPP );
- }
-
- public String toString() {
- if( isCPP() ) return "C++"; //$NON-NLS-1$
- return "C"; //$NON-NLS-1$
- }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserMode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserMode.java
index 72abbda4a80..606d69bf9bb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserMode.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserMode.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Mike Kucera (IBM) - convert to Java 5 enum
*******************************************************************************/
package org.eclipse.cdt.core.parser;
@@ -14,28 +15,23 @@ package org.eclipse.cdt.core.parser;
* @author jcamelon
*
*/
-public class ParserMode extends Enum {
+public enum ParserMode {
// do not follow inclusions, do not parse function/method bodies
- public static final ParserMode QUICK_PARSE = new ParserMode( 1 );
+ QUICK_PARSE,
//follow inclusions, do not parse function/method bodies
- public static final ParserMode STRUCTURAL_PARSE = new ParserMode( 2 );
+ STRUCTURAL_PARSE,
// follow inclusions, parse function/method bodies
- public static final ParserMode COMPLETE_PARSE = new ParserMode( 3 );
+ COMPLETE_PARSE,
// follow inclusions, parse function/method bodies, stop at particular offset
// provide optimized lookup capability for querying symbols
- public static final ParserMode COMPLETION_PARSE = new ParserMode( 4 );
+ COMPLETION_PARSE,
// follow inclusions, parse function/method bodies, stop at particular offset
// provide specific semantic information about an offset range or selection
- public static final ParserMode SELECTION_PARSE = new ParserMode( 5 );
+ SELECTION_PARSE,
- protected ParserMode( int value )
- {
- super( value );
- }
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java
index 011e0d27152..8e2770083d9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java
@@ -1,42 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Mike Kucera (IBM) - convert to Java 5 enum
*******************************************************************************/
package org.eclipse.cdt.core.parser.ast;
-import org.eclipse.cdt.core.parser.Enum;
/**
- * @author jcamelon
- *
+ * Use compareTo() to order access restriction.
*/
-public class ASTAccessVisibility extends Enum {
-
- public static final ASTAccessVisibility PUBLIC = new ASTAccessVisibility( 1 );
- public static final ASTAccessVisibility PROTECTED = new ASTAccessVisibility( 2 );
- public static final ASTAccessVisibility PRIVATE = new ASTAccessVisibility( 3 );
-
- private ASTAccessVisibility( int constant)
- {
- super( constant );
- }
-
- public boolean isLessThan( ASTAccessVisibility other )
- {
- return getEnumValue() < other.getEnumValue();
- }
-
- public boolean isGreaterThan( ASTAccessVisibility other )
- {
- return getEnumValue() > other.getEnumValue();
- }
+public enum ASTAccessVisibility {
+ PUBLIC,
+ PROTECTED,
+ PRIVATE,
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SimpleDeclarationStrategy.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SimpleDeclarationStrategy.java
index 40b47c8df9d..9d3e54d8bd2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SimpleDeclarationStrategy.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/SimpleDeclarationStrategy.java
@@ -1,32 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
+ * Mike Kucera (IBM) - convert to Java 5 enum
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
-import org.eclipse.cdt.core.parser.Enum;
/**
* @author jcamelon
*
*/
-public class SimpleDeclarationStrategy extends Enum
-{
- public static final SimpleDeclarationStrategy TRY_CONSTRUCTOR = new SimpleDeclarationStrategy( 1 );
- public static final SimpleDeclarationStrategy TRY_FUNCTION = new SimpleDeclarationStrategy( 2 );
- public static final SimpleDeclarationStrategy TRY_VARIABLE = new SimpleDeclarationStrategy( 3 );
-
- /**
- * @param enumValue
- */
- public SimpleDeclarationStrategy(int enumValue)
- {
- super(enumValue);
- }
+public enum SimpleDeclarationStrategy {
+ TRY_CONSTRUCTOR,
+ TRY_FUNCTION,
+ TRY_VARIABLE,
}

Back to the top