mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
framework for code formatter.
This commit is contained in:
parent
05788b2494
commit
ae5688b47e
5 changed files with 27 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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++){
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue