From: khartlage Date: Mon, 24 Mar 2003 19:28:22 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://secure.phpeclipse.com *** empty log message *** --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ToolFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ToolFactory.java index ca6331d..fa0abb3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ToolFactory.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ToolFactory.java @@ -13,10 +13,12 @@ package net.sourceforge.phpdt.core; import java.util.Map; +import net.sourceforge.phpdt.core.compiler.IScanner; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; +import net.sourceforge.phpdt.internal.formatter.CodeFormatter; import net.sourceforge.phpeclipse.PHPCore; import org.eclipse.core.runtime.Plugin; -import net.sourceforge.phpdt.internal.formatter.CodeFormatter; /** * Factory for creating various compiler tools, such as scanners, parsers and compilers. @@ -117,8 +119,8 @@ public class ToolFactory { * @see ToolFactory#createScanner(boolean,boolean,boolean,boolean, boolean) * @see org.phpeclipse.phpdt.core.compiler.IScanner */ -// public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator){ -// return createScanner(tokenizeComments, tokenizeWhiteSpace, assertMode, recordLineSeparator, false); +// public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean recordLineSeparator){ +// return createScanner(tokenizeComments, tokenizeWhiteSpace, recordLineSeparator); // } /** @@ -155,10 +157,10 @@ public class ToolFactory { * @see org.phpeclipse.phpdt.core.compiler.IScanner * @since 2.1 */ -// public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator, boolean strictCommentMode){ -// -// PublicScanner scanner = new PublicScanner(tokenizeComments, tokenizeWhiteSpace, false/*nls*/, assertMode, strictCommentMode /*strict comment*/, null/*taskTags*/, null/*taskPriorities*/); -// scanner.recordLineSeparator = recordLineSeparator; -// return scanner; -// } + public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean recordLineSeparator){ + + Scanner scanner = new Scanner(tokenizeComments, tokenizeWhiteSpace, false/*nls*/); + scanner.recordLineSeparator = recordLineSeparator; + return scanner; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/Assert.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/Assert.java new file mode 100644 index 0000000..c6f4e5c --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/Assert.java @@ -0,0 +1,134 @@ +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ +package net.sourceforge.phpdt.internal.corext; + +//import org.phpeclipse.phpdt.internal.corext.refactoring.RefactoringCoreMessages; + +/** + * Assert is useful for for embedding runtime sanity checks + * in code. The static predicate methods all test a condition and throw some + * type of unchecked exception if the condition does not hold. + *

+ * Assertion failure exceptions, like most runtime exceptions, are + * thrown when something is misbehaving. Assertion failures are invariably + * unspecified behavior; consequently, clients should never rely on + * these being thrown (or not thrown). If you find yourself in the + * position where you need to catch an assertion failure, you have most + * certainly written your program incorrectly. + *

+ *

+ * Note that an assert statement is slated to be added to the + * Java language in JDK 1.4, rending this class obsolete. + *

+ */ +public final class Assert { + + /** + * AssertionFailedException is a runtime exception thrown + * by some of the methods in Assert. + *

+ * This class is not declared public to prevent some misuses; programs that catch + * or otherwise depend on assertion failures are susceptible to unexpected + * breakage when assertions in the code are added or removed. + *

+ */ + private static class AssertionFailedException extends RuntimeException { + + /** + * Constructs a new exception. + */ + public AssertionFailedException() { + } + + /** + * Constructs a new exception with the given message. + */ + public AssertionFailedException(String detail) { + super(detail); + } + } + + /* This class is not intended to be instantiated. */ + private Assert() { + } + + /** + * Asserts that the given object is not null. If this + * is not the case, some kind of unchecked exception is thrown. + *

+ * As a general rule, parameters passed to API methods must not be + * null unless explicitly allowed in the method's + * specification. Similarly, results returned from API methods are never + * null unless explicitly allowed in the method's + * specification. Implementations are encouraged to make regular use of + * Assert.isNotNull to ensure that null + * parameters are detected as early as possible. + *

+ * + * @param object the value to test + */ + public static void isNotNull(Object object) { + // succeed as quickly as possible + if (object != null) { + return; + } + isNotNull(object, ""); //$NON-NLS-1$ + } + + /** + * Asserts that the given object is not null. If this + * is not the case, some kind of unchecked exception is thrown. + * The given message is included in that exception, to aid debugging. + *

+ * As a general rule, parameters passed to API methods must not be + * null unless explicitly allowed in the method's + * specification. Similarly, results returned from API methods are never + * null unless explicitly allowed in the method's + * specification. Implementations are encouraged to make regular use of + * Assert.isNotNull to ensure that null + * parameters are detected as early as possible. + *

+ * + * @param object the value to test + * @param message the message to include in the exception + */ + public static void isNotNull(Object object, String message) { + if (object == null) + throw new AssertionFailedException("nullargument" + message); //$NON-NLS-1$ + } + + /** + * Asserts that the given boolean is true. If this + * is not the case, some kind of unchecked exception is thrown. + * + * @param expression the outcome of the check + * @return true if the check passes (does not return + * if the check fails) + */ + public static boolean isTrue(boolean expression) { + // succeed as quickly as possible + if (expression) { + return true; + } + return isTrue(expression, ""); //$NON-NLS-1$ + } + + /** + * Asserts that the given boolean is true. If this + * is not the case, some kind of unchecked exception is thrown. + * The given message is included in that exception, to aid debugging. + * + * @param expression the outcome of the check + * @param message the message to include in the exception + * @return true if the check passes (does not return + * if the check fails) + */ + public static boolean isTrue(boolean expression, String message) { + if (!expression) + throw new AssertionFailedException("assertion failed" + message); //$NON-NLS-1$ + return expression; + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/CorextMessages.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/CorextMessages.java new file mode 100644 index 0000000..67c52f3 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/CorextMessages.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2002 International Business Machines Corp. 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: + * IBM Corporation - initial API and implementation + ******************************************************************************/ +package net.sourceforge.phpdt.internal.corext; + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class CorextMessages { + + private static final String BUNDLE_NAME= CorextMessages.class.getName(); + + private static final ResourceBundle RESOURCE_BUNDLE = + ResourceBundle.getBundle(BUNDLE_NAME); + + private CorextMessages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } + + public static String getFormattedString(String key, Object arg) { + return getFormattedString(key, new Object[] { arg }); + } + + public static String getFormattedString(String key, Object[] args) { + return MessageFormat.format(getString(key), args); + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/CorextMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/CorextMessages.properties new file mode 100644 index 0000000..4b57453 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/CorextMessages.properties @@ -0,0 +1,7 @@ +Assertnull_argument=null argument +Assertassertion_failed=assertion failed + +Resources.outOfSyncResources= Some resources are out of sync +Resources.outOfSync= Resource ''{0}'' is out of sync with file system. +Resources.modifiedResources= There are modified resources +Resources.fileModified= File ''{0}'' has been modified since the beginning of the operation diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/ValidateEditException.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/ValidateEditException.java new file mode 100644 index 0000000..5143ac6 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/ValidateEditException.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2002 International Business Machines Corp. 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: + * IBM Corporation - initial API and implementation + ******************************************************************************/ +package net.sourceforge.phpdt.internal.corext; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; + +/** + * Exception thrown if a valid edit failed. + */ +public class ValidateEditException extends CoreException { + + public ValidateEditException(IStatus status) { + super(status); + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/SelectionDispatchAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/SelectionDispatchAction.java new file mode 100644 index 0000000..5fa1dba --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/SelectionDispatchAction.java @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright (c) 2002 International Business Machines Corp. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Corporation - initial API and implementation + ******************************************************************************/ +package net.sourceforge.phpdt.internal.ui.actions; + +import org.eclipse.swt.widgets.Shell; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.util.Assert; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; + +import org.eclipse.ui.IWorkbenchSite; + +/** + * Action that dispatches the IAction#run() and the + * ISelectionChangedListener#selectionChanged + * according to the type of the selection. + * + * + * + *

+ * Note: This class is not intended to be subclassed outside the JDT UI plugin. + *

+ * + * @since 2.0 + */ +public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener { + + private IWorkbenchSite fSite; + + /** + * Creates a new action with no text and no image. + *

+ * Configure the action later using the set methods. + *

+ * + * @param site the site this action is working on + */ + protected SelectionDispatchAction(IWorkbenchSite site) { + Assert.isNotNull(site); + fSite= site; + } + + /** + * Returns the site owning this action. + * + * @return the site owning this action + */ + public IWorkbenchSite getSite() { + return fSite; + } + + /** + * Returns the selection provided by the site owning this action. + * + * @return the site's selection + */ + public ISelection getSelection() { + return getSelectionProvider().getSelection(); + } + + /** + * Returns the shell provided by the site owning this action. + * + * @return the site's shell + */ + public Shell getShell() { + return fSite.getShell(); + } + + /** + * Returns the selection provider managed by the site owning this action. + * + * @return the site's selection provider + */ + public ISelectionProvider getSelectionProvider() { + return fSite.getSelectionProvider(); + } + + /** + * Updates the action's enablement state according to the given selection. This + * default implementation calls one of the selectionChanged + * methods depending on the type of the passed selection. + * + * @param selection the selection this action is working on + */ + public void update(ISelection selection) { + dispatchSelectionChanged(selection); + } + + /** + * Notifies this action that the given structured selection has changed. This default + * implementation calls selectionChanged(ISelection selection). + * + * @param selection the new selection + */ + protected void selectionChanged(IStructuredSelection selection) { + selectionChanged((ISelection)selection); + } + + /** + * Executes this actions with the given structured selection. This default implementation + * calls run(ISelection selection). + */ + protected void run(IStructuredSelection selection) { + run((ISelection)selection); + } + + /** + * Notifies this action that the given text selection has changed. This default + * implementation calls selectionChanged(ISelection selection). + * + * @param selection the new selection + */ + protected void selectionChanged(ITextSelection selection) { + selectionChanged((ISelection)selection); + } + + /** + * Executes this actions with the given text selection. This default implementation + * calls run(ISelection selection). + */ + protected void run(ITextSelection selection) { + run((ISelection)selection); + } + + /** + * Notifies this action that the given selection has changed. This default + * implementation sets the action's enablement state to false. + * + * @param selection the new selection + */ + protected void selectionChanged(ISelection selection) { + setEnabled(false); + } + + /** + * Executes this actions with the given selection. This default implementation + * does nothing. + */ + protected void run(ISelection selection) { + } + + /* (non-Javadoc) + * Method declared on IAction. + */ + public void run() { + dispatchRun(getSelection()); + } + + /* (non-Javadoc) + * Method declared on ISelectionChangedListener. + */ + public void selectionChanged(SelectionChangedEvent event) { + dispatchSelectionChanged(event.getSelection()); + } + + private void dispatchSelectionChanged(ISelection selection) { + if (selection instanceof IStructuredSelection) { + selectionChanged((IStructuredSelection)selection); + } else if (selection instanceof ITextSelection) { + selectionChanged((ITextSelection)selection); + } else { + selectionChanged(selection); + } + } + + private void dispatchRun(ISelection selection) { + if (selection instanceof IStructuredSelection) { + run((IStructuredSelection)selection); + } else if (selection instanceof ITextSelection) { + run((ITextSelection)selection); + } else { + run(selection); + } + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java index 0e8d043..bd714b3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java @@ -18,11 +18,14 @@ import net.sourceforge.phpdt.internal.ui.dialog.StatusUtil; import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout; import net.sourceforge.phpeclipse.PHPCore; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -159,7 +162,7 @@ public class CodeFormatterPreferencePage extends PreferencePage implements IWork private IDocument fPreviewDocument; private Text fTabSizeTextBox; - // private SourceViewer fSourceViewer; + // private SourceViewer fSourceViewer; public CodeFormatterPreferencePage() { @@ -282,7 +285,7 @@ public class CodeFormatterPreferencePage extends PreferencePage implements IWork item.setText(PHPUIMessages.getString("CodeFormatterPreferencePage.tab.style.tabtitle")); //$NON-NLS-1$ item.setControl(styleComposite); - // fSourceViewer= createPreview(parent); +// fSourceViewer= createPreview(parent); updatePreview();