diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IPositionTrackerManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IPositionTrackerManager.java index e3fab3d600a..e23f3b15af8 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IPositionTrackerManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IPositionTrackerManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.core; @@ -16,7 +16,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; /** - * An interface to manage the position tracking. It allows for mapping character + * An interface to manage the position tracking. It allows for mapping character * offsets from a file previously stored on disk to the offset in the current document * for the file. * @@ -35,7 +35,7 @@ public interface IPositionTrackerManager { * Returns the position converter suitable for mapping character offsets of the * given translation unit to the current version of it. * - * @param file a file for which the position adapter is requested. + * @param tu a translation unit for which the position adapter is requested. * @param timestamp identifies the version of the file stored on disk. * @return the requested position converter or null. */ @@ -52,11 +52,11 @@ public interface IPositionTrackerManager { /** * Returns the position tracker suitable for mapping character offsets of the - * given external file/timestamp to the current version of it.

+ * given external file/timestamp to the current version of it.

* The method can be used for resources by supplying the full path. However, * it does not work if you supply the location of a resource. * - * @param externalLocationOrFullPath an external location for which the position adapter is requested. + * @param fullPathOrExternalLocation an external location for which the position adapter is requested. * @param timestamp identifies the version of the file stored on disk. * @return the requested position converter or null. */ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ToolFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ToolFactory.java index 697bfd28954..2a279ca5e88 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ToolFactory.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ToolFactory.java @@ -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 @@ -15,6 +15,7 @@ package org.eclipse.cdt.core; import java.util.Map; import org.eclipse.cdt.core.formatter.CodeFormatter; +import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.internal.formatter.CCodeFormatter; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; @@ -27,19 +28,19 @@ import org.eclipse.core.runtime.Platform; public class ToolFactory { /** - * Create an instance of a code formatter. A code formatter implementation can be contributed via the - * extension point "org.eclipse.cdt.core.CodeFormatter". If unable to find a registered extension, the factory + * Create an instance of a code formatter. A code formatter implementation can be contributed via the + * extension point "org.eclipse.cdt.core.CodeFormatter". If unable to find a registered extension, the factory * will default to using the default code formatter. * @param options - the options map to use for formatting with the code formatter. Recognized options - * are documented on DefaultCodeFormatterConstants. If set to null, then use + * are documented on DefaultCodeFormatterConstants. If set to null, then use * the current settings from CCorePlugin.getOptions(). * @return an instance of either a contributed the built-in code formatter * @see CodeFormatter * @see DefaultCodeFormatterConstants * @see CCorePlugin#getOptions() */ - public static CodeFormatter createCodeFormatter(Map options){ - if (options == null) + public static CodeFormatter createCodeFormatter(Map options){ + if (options == null) options = CCorePlugin.getOptions(); String formatterID = (String)options.get(CCorePreferenceConstants.CODE_FORMATTER); String extID = CCorePlugin.FORMATTER_EXTPOINT_ID; @@ -73,15 +74,15 @@ public class ToolFactory { * Create an instance of the built-in code formatter. * * @param options - the options map to use for formatting with the default code formatter. Recognized options - * are documented on DefaultCodeFormatterConstants. If set to null, then use + * are documented on DefaultCodeFormatterConstants. If set to null, then use * the current settings from CCorePlugin.getOptions(). * @return an instance of the built-in code formatter * @see CodeFormatter * @see DefaultCodeFormatterConstants * @see CCorePlugin#getOptions() */ - public static CodeFormatter createDefaultCodeFormatter(Map options){ - if (options == null) + public static CodeFormatter createDefaultCodeFormatter(Map options){ + if (options == null) options = CCorePlugin.getOptions(); return new CCodeFormatter(options); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java index 11cc8ac7ccb..9427ba2ed1d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 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 @@ -52,9 +52,9 @@ public final class IndentManipulation { * @param ch the given character * @return Returns true if this the character is a line delimiter character, false otherwise */ - public static boolean isLineDelimiterChar(char ch) { + public static boolean isLineDelimiterChar(char ch) { return ch == '\n' || ch == '\r'; - } + } /** * Returns the indentation of the given line in indentation units. Odd spaces are @@ -173,7 +173,7 @@ public final class IndentManipulation { /** - * Removes the given number of indentation units from a given line. If the line + * Removes the given number of indentation units from a given line. If the line * has less than the given indent, all the available indentation is removed. * If indentsToRemove <= 0 the line is returned. * @@ -212,7 +212,7 @@ public final class IndentManipulation { } else { // Assert.isTrue(false, "Line does not have requested number of indents"); start= i; - break; + break; } if (spaceEquivalents == spaceEquivalentsToRemove) { start= i + 1; @@ -288,7 +288,7 @@ public final class IndentManipulation { buf.append(line); } else { // no new line after last line buf.append(lineDelim); - buf.append(newIndentString); + buf.append(newIndentString); buf.append(trimIndent(line, indentUnitsToRemove, tabWidth, indentWidth)); } } @@ -326,13 +326,13 @@ public final class IndentManipulation { throw new IllegalArgumentException(); } - ArrayList result= new ArrayList(); + ArrayList result= new ArrayList(); try { ILineTracker tracker= new DefaultLineTracker(); tracker.set(source); int nLines= tracker.getNumberOfLines(); if (nLines == 1) - return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); + return result.toArray(new ReplaceEdit[result.size()]); for (int i= 1; i < nLines; i++) { IRegion region= tracker.getLineInformation(i); int offset= region.getOffset(); @@ -348,7 +348,7 @@ public final class IndentManipulation { } catch (BadLocationException cannotHappen) { // can not happen } - return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); + return result.toArray(new ReplaceEdit[result.size()]); } /* @@ -382,14 +382,14 @@ public final class IndentManipulation { /** * Returns the tab width as configured in the given map. - *

Use {@link org.eclipse.jdt.core.IJavaProject#getOptions(boolean)} to get the most current project options.

+ *

Use {@link org.eclipse.cdt.core.model.ICProject#getOptions(boolean)} to get the most current project options.

* * @param options the map to get the formatter settings from. * * @return the tab width * @exception IllegalArgumentException if the given options is null */ - public static int getTabWidth(Map options) { + public static int getTabWidth(Map options) { if (options == null) { throw new IllegalArgumentException(); } @@ -398,14 +398,14 @@ public final class IndentManipulation { /** * Returns the tab width as configured in the given map. - *

Use {@link org.eclipse.jdt.core.IJavaProject#getOptions(boolean)} to get the most current project options.

+ *

Use {@link org.eclipse.cdt.core.model.ICProject#getOptions(boolean)} to get the most current project options.

* * @param options the map to get the formatter settings from * * @return the indent width * @exception IllegalArgumentException if the given options is null */ - public static int getIndentWidth(Map options) { + public static int getIndentWidth(Map options) { if (options == null) { throw new IllegalArgumentException(); } @@ -417,9 +417,9 @@ public final class IndentManipulation { return tabWidth; } - private static int getIntValue(Map options, String key, int def) { + private static int getIntValue(Map options, String key, int def) { try { - return Integer.parseInt((String) options.get(key)); + return Integer.parseInt(options.get(key)); } catch (NumberFormatException e) { return def; }