1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

218265 - replace Enum class with Java 5 enums

This commit is contained in:
Mike Kucera 2008-02-07 23:13:59 +00:00
parent 6a80d1f5da
commit ecf9c5833d
13 changed files with 106 additions and 203 deletions

View file

@ -236,7 +236,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
+ fTranslationUnit.getElementName()
+ " mode="+ (quickParseMode ? "skip all " : "skip indexed ") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ " time="+ ( System.currentTimeMillis() - startTime ) + "ms", //$NON-NLS-1$ //$NON-NLS-2$
IDebugLogConstants.MODEL, false);
DebugLogConstants.MODEL, false);
if (ast == null) {
return;
@ -249,7 +249,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
Util.debugLog("CModelBuilder2: building " //$NON-NLS-1$
+"children="+ fTranslationUnit.getElementInfo().internalGetChildren().size() //$NON-NLS-1$
+" time="+ (System.currentTimeMillis() - startTime) + "ms", //$NON-NLS-1$ //$NON-NLS-2$
IDebugLogConstants.MODEL, false);
DebugLogConstants.MODEL, false);
if (elementInfo instanceof ASTHolderTUInfo) {
((ASTHolderTUInfo)elementInfo).fAST= ast;
@ -269,7 +269,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
private void checkCanceled() {
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
Util.debugLog("CModelBuilder2: cancelled ", IDebugLogConstants.MODEL, false); //$NON-NLS-1$
Util.debugLog("CModelBuilder2: cancelled ", DebugLogConstants.MODEL, false); //$NON-NLS-1$
throw new OperationCanceledException();
}
}

View file

@ -6,27 +6,14 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser;
package org.eclipse.cdt.internal.core.model;
/**
* @author jcamelon
*
*/
public class Enum
{
protected Enum( int enumValue )
{
this.enumValue = enumValue;
}
private final int enumValue;
/**
* @return
*/
protected int getEnumValue()
{
return enumValue;
}
public enum DebugLogConstants {
PARSER,
MODEL,
SCANNER,
}

View file

@ -1,27 +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 Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.parser.Enum;
public interface IDebugLogConstants {
public class DebugLogConstant extends Enum {
protected DebugLogConstant( int value )
{
super( value );
}
}
public static final DebugLogConstant PARSER = new DebugLogConstant( 1 );
public static final DebugLogConstant MODEL = new DebugLogConstant ( 2 );
public static final DebugLogConstant SCANNER = new DebugLogConstant( 3 );
}

View file

@ -635,7 +635,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
} catch (Exception e) {
// use the debug log for this exception.
Util.debugLog( "Exception in CModelBuilder", IDebugLogConstants.MODEL); //$NON-NLS-1$
Util.debugLog( "Exception in CModelBuilder", DebugLogConstants.MODEL); //$NON-NLS-1$
}
}
@ -644,7 +644,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
mb.parse(quickParseMode);
} catch (Exception e) {
// use the debug log for this exception.
Util.debugLog( "Exception in contributed model builder", IDebugLogConstants.MODEL); //$NON-NLS-1$
Util.debugLog( "Exception in contributed model builder", DebugLogConstants.MODEL); //$NON-NLS-1$
}
}

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICLogConstants;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
import org.eclipse.cdt.internal.core.model.IDebugLogConstants.DebugLogConstant;
import org.eclipse.cdt.internal.core.util.CharArrayBuffer;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
@ -208,11 +207,11 @@ public class Util implements ICLogConstants {
Util.log(status, logType);
}
public static void debugLog(String message, DebugLogConstant client) {
public static void debugLog(String message, DebugLogConstants client) {
Util.debugLog(message, client, true);
}
public static void debugLog(String message, DebugLogConstant client,
public static void debugLog(String message, DebugLogConstants client,
boolean addTimeStamp) {
if (CCorePlugin.getDefault() == null)
return;
@ -238,12 +237,12 @@ public class Util implements ICLogConstants {
* @param client
* @return
*/
public static boolean isActive(DebugLogConstant client) {
if (client.equals(IDebugLogConstants.PARSER)) {
public static boolean isActive(DebugLogConstants client) {
if (client.equals(DebugLogConstants.PARSER)) {
return VERBOSE_PARSER;
} else if (client.equals(IDebugLogConstants.SCANNER))
} else if (client.equals(DebugLogConstants.SCANNER))
return VERBOSE_SCANNER;
else if (client.equals(IDebugLogConstants.MODEL)) {
else if (client.equals(DebugLogConstants.MODEL)) {
return VERBOSE_MODEL;
}
return false;

View file

@ -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,
}

View file

@ -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()

View file

@ -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$
}
}

View file

@ -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 );
}
}

View file

@ -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 enum ASTAccessVisibility {
public boolean isLessThan( ASTAccessVisibility other )
{
return getEnumValue() < other.getEnumValue();
}
public boolean isGreaterThan( ASTAccessVisibility other )
{
return getEnumValue() > other.getEnumValue();
}
PUBLIC,
PROTECTED,
PRIVATE,
}

View file

@ -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,
}

View file

@ -16,7 +16,7 @@ import java.io.InputStream;
import java.util.Iterator;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.model.IDebugLogConstants;
import org.eclipse.cdt.internal.core.model.DebugLogConstants;
import org.eclipse.cdt.internal.core.parser.InternalParserUtil;
import org.eclipse.cdt.internal.core.parser.ParserLogService;
import org.eclipse.core.resources.IFile;
@ -40,8 +40,8 @@ public class ParserUtil
return parserLogService;
}
private static IParserLogService parserLogService = new ParserLogService(IDebugLogConstants.PARSER );
private static IParserLogService scannerLogService = new ParserLogService(IDebugLogConstants.SCANNER );
private static IParserLogService parserLogService = new ParserLogService(DebugLogConstants.PARSER );
private static IParserLogService scannerLogService = new ParserLogService(DebugLogConstants.SCANNER );
/**
* @return

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* 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
@ -8,30 +8,28 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Mike Kucera (IBM)
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICLogConstants;
import org.eclipse.cdt.core.parser.AbstractParserLogService;
import org.eclipse.cdt.internal.core.model.DebugLogConstants;
import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.internal.core.model.IDebugLogConstants.DebugLogConstant;
/**
* @author jcamelon
*
*/
public class ParserLogService extends AbstractParserLogService
{
public class ParserLogService extends AbstractParserLogService {
final DebugLogConstant topic;
final boolean fIsTracing;
final boolean fIsTracingExceptions;
private final DebugLogConstants topic;
private final boolean fIsTracing;
private final boolean fIsTracingExceptions;
/**
* @param constant
*/
public ParserLogService(DebugLogConstant constant) {
public ParserLogService(DebugLogConstants constant) {
topic = constant;
if (CCorePlugin.getDefault() == null) {
fIsTracing= fIsTracingExceptions= false;
@ -42,26 +40,24 @@ public class ParserLogService extends AbstractParserLogService
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IParserLogService#traceLog(java.lang.String)
*/
public void traceLog(String message)
{
@Override
public void traceLog(String message) {
Util.debugLog( message, topic );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IParserLogService#errorLog(java.lang.String)
*/
public void errorLog(String message)
{
@Override
public void errorLog(String message) {
Util.log( message, ICLogConstants.CDT );
}
public boolean isTracing(){
@Override
public boolean isTracing() {
return fIsTracing;
}
@Override
public boolean isTracingExceptions() {
return fIsTracingExceptions;
}