diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index a964906208e..fbef74e3fc4 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,10 @@ +2004-11-05 Alain Magloire + More framework for the formatter. + * src/org/eclipse/cdt/core/ToolFactory.java + * src/org/eclipse/cdt/core/CCorePlugin.java + * src/org/eclipse/cdt/core/formatter/CodeFormatter.java + * src/org/eclipse/cdt/core/formatter/CodeFormatterConstants.java + 2004-11-01 Alain Magloire Change to the errorParserManager, ... finally diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index e53e0459f20..6fbfd7bcc67 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -81,7 +81,12 @@ public class CCorePlugin extends Plugin { // Build Model Interface Discovery public final static String BUILD_SCANNER_INFO_SIMPLE_ID = "ScannerInfoProvider"; //$NON-NLS-1$ public final static String BUILD_SCANNER_INFO_UNIQ_ID = PLUGIN_ID + "." + BUILD_SCANNER_INFO_SIMPLE_ID; //$NON-NLS-1$ - + + /** + * Name of the extension point for contributing a source code formatter + */ + public static final String FORMATTER_EXTPOINT_ID = "CodeFormatter" ; //$NON-NLS-1$ + /** * Possible configurable option value for TRANSLATION_TASK_PRIORITIES. * @see #getDefaultOptions 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 81a4d98c716..51d6f891756 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 @@ -18,7 +18,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; /** @@ -38,9 +37,8 @@ public class ToolFactory { if (options == null) options = CCorePlugin.getOptions(); String formatterID = (String)options.get(CCorePreferenceConstants.CODE_FORMATTER); - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extension = Platform.getExtensionRegistry(). - getExtensionPoint(CCorePlugin.PLUGIN_ID, "CodeFormatter"); + String extID = CCorePlugin.FORMATTER_EXTPOINT_ID; + IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, extID); if (extension != null) { IExtension[] extensions = extension.getExtensions(); for(int i = 0; i < extensions.length; i++){ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java index 9add11618bc..a8c284eed97 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java @@ -58,7 +58,7 @@ 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_COMPILATION_UNIT, K_UNKNOWN * @param file - file associated with this source (null if no file is associated) - * @param document the document to format + * @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). * @param indentationLevel the initial indentation level, used @@ -70,7 +70,7 @@ public abstract class CodeFormatter { * @throws IllegalArgumentException if offset is lower than 0, length is lower than 0 or * length is greater than source length. */ - public abstract TextEdit format(int kind, IDocument document, int offset, int length, int indentationLevel, String lineSeparator); + public abstract TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator); /** * @param options - general formatter options diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatterConstants.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatterConstants.java index e80a775f53c..ad6df809b5b 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatterConstants.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatterConstants.java @@ -1,18 +1,18 @@ -/* - * Created on Sep 5, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ +/******************************************************************************* + * Copyright (c) 2000, 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.core.formatter; import org.eclipse.cdt.core.CCorePlugin; /** - * @author Alex Chapiro - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public class CodeFormatterConstants {