mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Fix warnings
This commit is contained in:
parent
0c5bdcfb6c
commit
a3e0775ca4
6 changed files with 68 additions and 61 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 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
|
||||
|
@ -74,7 +74,6 @@ public abstract class CodeFormatter {
|
|||
*
|
||||
* @param kind Use to specify the kind of the code snippet to format. It can be any of these:
|
||||
* K_EXPRESSION, K_STATEMENTS, K_CLASS_BODY_DECLARATIONS, K_TRANSLATION_UNIT, K_UNKNOWN
|
||||
* @param file - file associated with this source (null if no file is associated)
|
||||
* @param source the document to format
|
||||
* @param offset the given offset to start recording the edits (inclusive).
|
||||
* @param length the given length to stop recording the edits (exclusive).
|
||||
|
@ -92,7 +91,7 @@ public abstract class CodeFormatter {
|
|||
/**
|
||||
* @param options - general formatter options
|
||||
*/
|
||||
public abstract void setOptions(Map options);
|
||||
public abstract void setOptions(Map<String, ?> options);
|
||||
|
||||
/**
|
||||
* Answers the string that corresponds to the indentation to the given indentation level or an empty string
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2008 QNX Software Systems 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
|
||||
|
@ -13,6 +13,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.formatter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -38,7 +39,7 @@ import org.eclipse.text.edits.TextEdit;
|
|||
public class CCodeFormatter extends CodeFormatter {
|
||||
|
||||
private DefaultCodeFormatterOptions preferences;
|
||||
private Map options;
|
||||
private Map<String, ?> options;
|
||||
|
||||
public CCodeFormatter() {
|
||||
this(DefaultCodeFormatterOptions.getDefaultSettings());
|
||||
|
@ -48,14 +49,14 @@ public class CCodeFormatter extends CodeFormatter {
|
|||
this(preferences, null);
|
||||
}
|
||||
|
||||
public CCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions, Map options) {
|
||||
public CCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions, Map<String, ?> options) {
|
||||
setOptions(options);
|
||||
if (defaultCodeFormatterOptions != null) {
|
||||
preferences.set(defaultCodeFormatterOptions.getMap());
|
||||
}
|
||||
}
|
||||
|
||||
public CCodeFormatter(Map options) {
|
||||
public CCodeFormatter(Map<String, ?> options) {
|
||||
this(null, options);
|
||||
}
|
||||
|
||||
|
@ -102,10 +103,17 @@ public class CCodeFormatter extends CodeFormatter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setOptions(Map options) {
|
||||
public void setOptions(Map<String, ?> options) {
|
||||
if (options != null) {
|
||||
this.options= options;
|
||||
preferences= new DefaultCodeFormatterOptions(options);
|
||||
Map<String, String> formatterPrefs= new HashMap<String, String>(options.size());
|
||||
for (String key : options.keySet()) {
|
||||
Object value= options.get(key);
|
||||
if (value instanceof String) {
|
||||
formatterPrefs.put(key, (String) value);
|
||||
}
|
||||
}
|
||||
preferences= new DefaultCodeFormatterOptions(formatterPrefs);
|
||||
} else {
|
||||
this.options= CCorePlugin.getOptions();
|
||||
preferences= DefaultCodeFormatterOptions.getDefaultSettings();
|
||||
|
@ -149,7 +157,7 @@ public class CCodeFormatter extends CodeFormatter {
|
|||
} catch (CoreException exc) {
|
||||
throw new AbortFormatting(exc);
|
||||
}
|
||||
CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length);
|
||||
CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(this.preferences, offset, length);
|
||||
edit= codeFormatter.format(source, ast);
|
||||
IStatus status= codeFormatter.getStatus();
|
||||
if (!status.isOK()) {
|
||||
|
@ -174,7 +182,7 @@ public class CCodeFormatter extends CodeFormatter {
|
|||
IASTTranslationUnit ast;
|
||||
try {
|
||||
ast= language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, null, ParserUtil.getParserLogService());
|
||||
CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length);
|
||||
CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(this.preferences, offset, length);
|
||||
edit= codeFormatter.format(source, ast);
|
||||
} catch (CoreException exc) {
|
||||
throw new AbortFormatting(exc);
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -202,7 +201,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
private MultiStatus fStatus;
|
||||
|
||||
|
||||
public CodeFormatterVisitor(DefaultCodeFormatterOptions preferences, Map<String, String> settings, int offset, int length) {
|
||||
public CodeFormatterVisitor(DefaultCodeFormatterOptions preferences, int offset, int length) {
|
||||
localScanner = new Scanner() {
|
||||
@Override
|
||||
public Token nextToken() {
|
||||
|
@ -434,11 +433,11 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
}
|
||||
// declarator
|
||||
final IASTDeclarator declarator= node.getDeclarator();
|
||||
if (declarator != null) {
|
||||
boolean needSpace= declarator.getPointerOperators().length > 0 && scribe.printComment();
|
||||
if (needSpace) {
|
||||
scribe.space();
|
||||
}
|
||||
if (declarator != null) {
|
||||
declarator.accept(this);
|
||||
}
|
||||
} finally {
|
||||
|
@ -662,11 +661,11 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
}
|
||||
// declarator
|
||||
final IASTDeclarator declarator= node.getAbstractDeclarator();
|
||||
if (declarator != null) {
|
||||
boolean needSpace= declarator.getPointerOperators().length > 0 && scribe.printComment();
|
||||
if (needSpace) {
|
||||
scribe.space();
|
||||
}
|
||||
if (declarator != null) {
|
||||
declarator.accept(this);
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 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
|
||||
|
@ -294,6 +294,7 @@ public class Alignment {
|
|||
}
|
||||
return wasSplit = true;
|
||||
}
|
||||
break;
|
||||
/* # aligned fragment
|
||||
* foo(#AAAAA,
|
||||
* #BBBBB,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 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
|
||||
|
@ -19,7 +19,7 @@ import java.util.Stack;
|
|||
public class ScannerContext {
|
||||
private Reader fReader;
|
||||
private int fOffset;
|
||||
private Stack fUndo = new Stack();
|
||||
private Stack<Integer> fUndo = new Stack<Integer>();
|
||||
|
||||
public ScannerContext() {
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class ScannerContext {
|
|||
* @return int
|
||||
*/
|
||||
public final int popUndo() {
|
||||
return ((Integer)fUndo.pop()).intValue();
|
||||
return fUndo.pop().intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 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
|
||||
|
@ -25,7 +25,7 @@ import java.util.HashMap;
|
|||
public class SimpleScanner {
|
||||
|
||||
private static final int EOFCHAR= -1;
|
||||
protected static HashMap fgKeywords= new HashMap();
|
||||
protected static HashMap<String, Integer> fgKeywords= new HashMap<String, Integer>();
|
||||
|
||||
protected Token fCurrentToken;
|
||||
protected ScannerContext fContext;
|
||||
|
|
Loading…
Add table
Reference in a new issue