mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
fixing warnings in LR parser plugins
This commit is contained in:
parent
76beb6c750
commit
fe47120500
12 changed files with 36 additions and 25 deletions
|
@ -191,7 +191,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
|
||||
undoStack.add(new IUndoAction() {
|
||||
public void undo() {
|
||||
if(DEBUG) DebugUtil.printMethodTrace("undo");
|
||||
|
||||
bindingScopeStack.removeLast();
|
||||
symbolTable = symbolTableScopeStack.removeLast();
|
||||
|
@ -1030,7 +1029,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
|
||||
|
||||
|
||||
public IBinding consumeEnumerator(boolean hasInitializer) {
|
||||
public IBinding consumeEnumerator() {
|
||||
if(DEBUG) DebugUtil.printMethodTrace();
|
||||
|
||||
IToken token = parser.getLeftIToken();
|
||||
|
@ -1206,7 +1205,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
public void consumeExpressionConstant(int kind) {
|
||||
if(DEBUG) DebugUtil.printMethodTrace();
|
||||
|
||||
|
@ -1407,7 +1406,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
}
|
||||
|
||||
|
||||
public void consumeExpressionUnaryOperator(int operator) {
|
||||
public void consumeExpressionUnaryOperator() {
|
||||
if(DEBUG) DebugUtil.printMethodTrace();
|
||||
|
||||
// TODO: this is lazy, need to check the actual rules for types and operators
|
||||
|
|
|
@ -15,6 +15,7 @@ import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.*;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
|
||||
|
@ -84,26 +85,26 @@ class DeclSpec {
|
|||
if(type != null)
|
||||
return type;
|
||||
if(tokenKindMap.isEmpty()) // there are no type tokens, so it must be implicit int
|
||||
return new C99BasicType(ICBasicType.t_int);
|
||||
return new C99BasicType(IBasicType.t_int);
|
||||
|
||||
C99BasicType basicType = new C99BasicType();
|
||||
|
||||
for(int kind : tokenKindMap.keySet()) {
|
||||
switch(kind) {
|
||||
case TK_void:
|
||||
basicType.setType(ICBasicType.t_void);
|
||||
basicType.setType(IBasicType.t_void);
|
||||
break;
|
||||
case TK_char:
|
||||
basicType.setType(ICBasicType.t_char);
|
||||
basicType.setType(IBasicType.t_char);
|
||||
break;
|
||||
case TK_int:
|
||||
basicType.setType(ICBasicType.t_int);
|
||||
basicType.setType(IBasicType.t_int);
|
||||
break;
|
||||
case TK_float:
|
||||
basicType.setType(ICBasicType.t_float);
|
||||
basicType.setType(IBasicType.t_float);
|
||||
break;
|
||||
case TK_double:
|
||||
basicType.setType(ICBasicType.t_double);
|
||||
basicType.setType(IBasicType.t_double);
|
||||
break;
|
||||
case TK_long:
|
||||
boolean isLongLong = count(TK_long) > 1;
|
||||
|
@ -137,7 +138,6 @@ class DeclSpec {
|
|||
|
||||
if(isConst || isRestrict || isVolatile)
|
||||
return new C99QualifierType(basicType, isConst, isVolatile, isRestrict);
|
||||
else
|
||||
return basicType;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage implements
|
|||
protected abstract ParserLanguage getParserLanguageForPreprocessor();
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IPDOMLinkageFactory.class)
|
||||
|
@ -117,7 +118,7 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage implements
|
|||
ParserLanguage pl = getParserLanguageForPreprocessor();
|
||||
IScanner preprocessor = new CPreprocessor(reader, scanInfo, pl, log, config, fileCreator);
|
||||
preprocessor.setScanComments((options & OPTION_ADD_COMMENTS) != 0);
|
||||
preprocessor.setComputeImageLocations((options & AbstractLanguage.OPTION_NO_IMAGE_LOCATIONS) == 0);
|
||||
preprocessor.setComputeImageLocations((options & ILanguage.OPTION_NO_IMAGE_LOCATIONS) == 0);
|
||||
|
||||
IParser parser = getParser();
|
||||
IASTTranslationUnit tu = createASTTranslationUnit(index, preprocessor);
|
||||
|
@ -143,6 +144,7 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage implements
|
|||
}
|
||||
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
public IASTCompletionNode getCompletionNode(CodeReader reader,
|
||||
IScannerInfo scanInfo, ICodeReaderFactory fileCreator,
|
||||
IIndex index, IParserLogService log, int offset) throws CoreException {
|
||||
|
|
|
@ -92,7 +92,7 @@ public class LPGTokenAdapter implements lpg.lpgjavaruntime.IToken {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public String getValue(char[] arg0) {
|
||||
public String getValue(@SuppressWarnings("unused") char[] arg0) {
|
||||
return toString();
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class LPGTokenAdapter implements lpg.lpgjavaruntime.IToken {
|
|||
this.adjunctIndex = adjunctIndex;
|
||||
}
|
||||
|
||||
public void setEndOffset(int arg0) {
|
||||
public void setEndOffset(@SuppressWarnings("unused") int arg0) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class LPGTokenAdapter implements lpg.lpgjavaruntime.IToken {
|
|||
this.kind = kind;
|
||||
}
|
||||
|
||||
public void setStartOffset(int arg0) {
|
||||
public void setStartOffset(@SuppressWarnings("unused") int arg0) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.lrparser.IParser;
|
||||
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.util.DebugUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
||||
|
@ -1442,7 +1443,7 @@ public abstract class BuildASTParserAction {
|
|||
|
||||
|
||||
private void consumeProblem(IASTProblemHolder problemHolder) {
|
||||
IASTProblem problem = nodeFactory.newProblem(IASTProblem.SYNTAX_ERROR, new char[0], true);
|
||||
IASTProblem problem = nodeFactory.newProblem(IProblem.SYNTAX_ERROR, new char[0], true);
|
||||
problemHolder.setProblem(problem);
|
||||
setOffsetAndLength(problem);
|
||||
setOffsetAndLength((ASTNode)problemHolder);
|
||||
|
|
|
@ -210,6 +210,9 @@ public class C99ASTNodeFactory implements IC99ASTNodeFactory {
|
|||
return new CASTTypeIdInitializerExpression(typeId, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operator
|
||||
*/
|
||||
public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) {
|
||||
return new CASTCastExpression(typeId, operand);
|
||||
}
|
||||
|
|
|
@ -760,7 +760,7 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
|||
|
||||
IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
|
||||
|
||||
IASTDeclaration[] declarations = (IASTDeclaration[]) astStack.topScope().toArray(new IASTDeclaration[0]);
|
||||
IASTDeclaration[] declarations = astStack.topScope().toArray(new IASTDeclaration[0]);
|
||||
astStack.closeScope();
|
||||
|
||||
ICASTKnRFunctionDeclarator decl = (ICASTKnRFunctionDeclarator) astStack.pop();
|
||||
|
|
|
@ -104,6 +104,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
|||
*
|
||||
* @author Mike Kucera
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class CPPBuildASTParserAction extends BuildASTParserAction {
|
||||
|
||||
|
||||
|
@ -394,7 +395,7 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
}
|
||||
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
|
||||
private static OverloadableOperator getOverloadableOperator(List<IToken> tokens) {
|
||||
if(tokens.size() == 1) {
|
||||
// TODO this is a hack that I did to save time
|
||||
|
@ -486,7 +487,7 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
* | '::' operator_function_id
|
||||
* | '::' template_id
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
|
||||
public void consumeGlobalQualifiedId() {
|
||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||
|
||||
|
@ -735,7 +736,6 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
*
|
||||
* @param names List of name nodes in reverse order
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
private IASTName createQualifiedName(LinkedList<IASTName> names, int startOffset, int endOffset, boolean startsWithColonColon, boolean endsWithColonColon) {
|
||||
if(!endsWithColonColon && !startsWithColonColon && names.size() == 1)
|
||||
return names.getFirst(); // its actually an unqualified name
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CASTTranslationUnit;
|
|||
*
|
||||
* @author Mike Kucera
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class C99Language extends BaseExtensibleLanguage {
|
||||
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.core.lrparser"; //$NON-NLS-1$
|
||||
|
@ -57,7 +58,7 @@ public class C99Language extends BaseExtensibleLanguage {
|
|||
return TOKEN_MAP;
|
||||
}
|
||||
|
||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
|
||||
public IContributedModelBuilder createModelBuilder(@SuppressWarnings("unused") ITranslationUnit tu) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -93,7 +94,6 @@ public class C99Language extends BaseExtensibleLanguage {
|
|||
/**
|
||||
* Gets the translation unit object and sets the index and the location resolver.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
@Override
|
||||
protected IASTTranslationUnit createASTTranslationUnit(IIndex index, IScanner preprocessor) {
|
||||
IASTTranslationUnit tu = C99ASTNodeFactory.DEFAULT_INSTANCE.newTranslationUnit();
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
|||
*
|
||||
* @author Mike Kucera
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class ISOCPPLanguage extends BaseExtensibleLanguage {
|
||||
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.core.lrparser"; //$NON-NLS-1$
|
||||
|
@ -57,7 +58,7 @@ public class ISOCPPLanguage extends BaseExtensibleLanguage {
|
|||
return TOKEN_MAP;
|
||||
}
|
||||
|
||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
|
||||
public IContributedModelBuilder createModelBuilder(@SuppressWarnings("unused") ITranslationUnit tu) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -93,7 +94,6 @@ public class ISOCPPLanguage extends BaseExtensibleLanguage {
|
|||
/**
|
||||
* Gets the translation unit object and sets the index and the location resolver.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
@Override
|
||||
protected IASTTranslationUnit createASTTranslationUnit(IIndex index, IScanner preprocessor) {
|
||||
IASTTranslationUnit tu = CPPASTNodeFactory.DEFAULT_INSTANCE.newTranslationUnit();
|
||||
|
|
|
@ -161,6 +161,7 @@ public abstract class AbstractTrialUndoActionProvider<ACT, RULE_DATA> extends Pr
|
|||
public static class DeclaredAction<ACT, RULE_DATA> extends Action<ACT, RULE_DATA> {
|
||||
protected boolean hasUndo = false;
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public boolean doTrial(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
|
||||
return true;
|
||||
}
|
||||
|
@ -172,6 +173,7 @@ public abstract class AbstractTrialUndoActionProvider<ACT, RULE_DATA> extends Pr
|
|||
*/
|
||||
static final class NullAction<ACT, RULE_DATA> extends Action<ACT, RULE_DATA> {
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void doFinal(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -180,16 +182,19 @@ public abstract class AbstractTrialUndoActionProvider<ACT, RULE_DATA> extends Pr
|
|||
|
||||
static final class BadAction<ACT, RULE_DATA> extends Action<ACT, RULE_DATA> {
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void doFinal(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
|
||||
throw new Error(new BadActionException());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public boolean doTrial(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
|
||||
throw new Error(new BadActionException());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void doUndo(ITrialUndoActionProvider<RULE_DATA> provider, ACT action) {
|
||||
throw new Error(new BadActionException());
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ class ParserState {
|
|||
/**
|
||||
* Trial actions that have been executed but not yet committed.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public LinkedList pendingCommits;
|
||||
|
||||
public ConfigurationStack configurationStack;
|
||||
|
|
Loading…
Add table
Reference in a new issue