From b17c2cd9dc2736623f5c0f7f20c3f82d701de1f1 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Wed, 18 Jan 2006 08:53:11 +0000 Subject: [PATCH 01/16] migrated plugin from 3.0 to 3.1 --- .../externaltools/ExternalToolsPlugin.java | 15 +++++++++------ net.sourceforge.phpeclipse/plugin.xml | 2 +- .../internal/ui/text/BufferedDocumentScanner.java | 16 ++++++++-------- .../sourceforge/phpeclipse/PHPeclipsePlugin.java | 5 ++--- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpeclipse/externaltools/ExternalToolsPlugin.java b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpeclipse/externaltools/ExternalToolsPlugin.java index c392571..b805a73 100644 --- a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpeclipse/externaltools/ExternalToolsPlugin.java +++ b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpeclipse/externaltools/ExternalToolsPlugin.java @@ -39,6 +39,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; /** * External tools plug-in class @@ -270,10 +271,11 @@ public final class ExternalToolsPlugin extends AbstractUIPlugin { } /** - * @see org.eclipse.core.runtime.Plugin#startup() + * @throws Exception + * @see org.eclipse.core.runtime.Plugin#start(BundleContext context) */ - public void startup() throws CoreException { - // super.startup(); + public void start(BundleContext context) throws Exception { + super.start(context); getStandardDisplay().asyncExec(new Runnable() { public void run() { //initialize the variable context manager @@ -283,11 +285,12 @@ public final class ExternalToolsPlugin extends AbstractUIPlugin { } /** - * @see org.eclipse.core.runtime.Plugin#shutdown() + * @throws Exception + * @see org.eclipse.core.runtime.Plugin#stop(BundleContext context) */ - public void shutdown() throws CoreException { - // super.shutdown(); + public void stop(BundleContext context) throws Exception { ColorManager.getDefault().dispose(); + super.stop(context); } /** diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 873b7db..c747152 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -15,7 +15,7 @@ - + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java index 57812ba..b4fe57d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java @@ -1,10 +1,10 @@ /******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * 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 *******************************************************************************/ @@ -19,7 +19,7 @@ import org.eclipse.jface.text.rules.ICharacterScanner; /** - * A buffered document scanner. The buffer always contains a section + * A buffered document scanner. The buffer always contains a section * of a fixed size of the document to be scanned. */ @@ -43,11 +43,11 @@ public final class BufferedDocumentScanner implements ICharacterScanner { /** The offset of the scanner within the buffer. */ private int fOffset; - + /** * Creates a new buffered document scanner. * The buffer size is set to the given number of characters. - * + * * @param size the buffer size */ public BufferedDocumentScanner(int size) { @@ -63,7 +63,7 @@ public final class BufferedDocumentScanner implements ICharacterScanner { private final void updateBuffer(int offset) { fBufferOffset= offset; - + if (fBufferOffset + fBuffer.length > fRangeOffset + fRangeLength) fBufferLength= fRangeLength - (fBufferOffset - fRangeOffset); else @@ -117,7 +117,7 @@ public final class BufferedDocumentScanner implements ICharacterScanner { return fBuffer[fOffset++]; } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Offset:"+fOffset); - System.out.println("Buffer:"+fBuffer); + System.out.println("Buffer:"+fBuffer.toString()); throw e; } } @@ -134,7 +134,7 @@ public final class BufferedDocumentScanner implements ICharacterScanner { updateBuffer(fBufferOffset - fBuffer.length); fOffset= fBuffer.length - 1; } - } else { + } else { --fOffset; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 46e566a..6eeecfb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -73,7 +73,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; @@ -300,8 +299,8 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon /** * The constructor. */ - public PHPeclipsePlugin(IPluginDescriptor descriptor) { - super(descriptor); + public PHPeclipsePlugin() { + super(); plugin = this; // externalTools = new ExternalToolsPlugin(); -- 1.7.1 From f38d99512df3679a7b20b8ba581116833609c5c2 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Wed, 18 Jan 2006 08:55:23 +0000 Subject: [PATCH 02/16] new SF update site --- net.sourceforge.phpeclipse.updatesite/.project | 17 +++++++++++++++++ net.sourceforge.phpeclipse.updatesite/readme.txt | 21 +++++++++++++++++++++ net.sourceforge.phpeclipse.updatesite/site.xml | 22 ++++++++++++++++++++++ 3 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 net.sourceforge.phpeclipse.updatesite/.project create mode 100644 net.sourceforge.phpeclipse.updatesite/readme.txt create mode 100644 net.sourceforge.phpeclipse.updatesite/site.xml diff --git a/net.sourceforge.phpeclipse.updatesite/.project b/net.sourceforge.phpeclipse.updatesite/.project new file mode 100644 index 0000000..d0ff4e7 --- /dev/null +++ b/net.sourceforge.phpeclipse.updatesite/.project @@ -0,0 +1,17 @@ + + + net.sourceforge.phpeclipse.updatesite + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/net.sourceforge.phpeclipse.updatesite/readme.txt b/net.sourceforge.phpeclipse.updatesite/readme.txt new file mode 100644 index 0000000..ea5b36d --- /dev/null +++ b/net.sourceforge.phpeclipse.updatesite/readme.txt @@ -0,0 +1,21 @@ +Short description of how to create an update site refresh: + +* update feature version, force feature version into plugins (synchronize) +* add feature to update site category "PHPEclipse x.y" +* build feature from update site editor, you should now have the newly versioned jar files in sub folders +* modify feature url in site.xml to point to http://osdn.dl.sourceforge.net/sourceforge/phpeclipse/net.sourceforge.phpeclipse.feature_x.y.z.jar +* rename the newly created file features/net.sourceforge.phpeclipse_x.y.z.jar into features/net.sourceforge.phpeclipse.feature_x.y.z.jar (notice the additional .feature in between). + This is to avoid file name clashes with the plugin file name as all files go into a single directory afterwards +* for each plugin add the following line to the site.xml: + +* upload all new feature and plugin jars to Sourceforge (as flat file list) +* in Sourceforge File Release Manager, create a new active release in hidden package "PHPeclipse update site" +* add all uploaded jars to this release, set their file descriptions +* upload site.xml via SCP or SFTP to htdocs/update/releases +* take a fresh Eclipse runtime and verify by installing from update site + +differences for creating a CVS update site package: +* in feature.xml and site.xml use this update site url: http://phpeclipse.sourceforge.net/update/cvs/ +* replace the category "Eclipse x.y" by category "CVS version" in the site.xml +* create the file release in the package "PHPeclipse CVS update site" on Sourceforge instead +* upload site.xml to htdocs/update/cvs instead \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.updatesite/site.xml b/net.sourceforge.phpeclipse.updatesite/site.xml new file mode 100644 index 0000000..80c58f7 --- /dev/null +++ b/net.sourceforge.phpeclipse.updatesite/site.xml @@ -0,0 +1,22 @@ + + + + PHPeclipse update site + + + + + + + + + + + + + + + + + + -- 1.7.1 From 7e8aeff02e82f20020d7dec7c4c72d949d5412be Mon Sep 17 00:00:00 2001 From: axelcl Date: Wed, 18 Jan 2006 20:36:28 +0000 Subject: [PATCH 03/16] Refactoringaction: net.sourceforge.phpdt.ltk.ui.actions.RenameLocalVariable This refactoring replaces any $-variable inside a function or method declaration The action can detect the scope of a PHP function or class method. This refactoring replaces variables inside double quoted strings. This refactoring replaces a variable in a preceding PHPDoc comment. This refactoring replaces a variable in a line or block comment. This refactoring doesn't look for global variables inside the function or method. This refactoring doesn't look correctly for "self::" and "$this" tokens inside the function or method. --- net.sourceforge.phpeclipse/plugin.xml | 8 +- .../phpdt/ltk/core/RenameIdentifierInfo.java | 30 ++ .../ltk/core/RenameLocalVariableDelegate.java | 332 +++++++++++-------- .../src/net/sourceforge/phpdt/ltk/ui/UITexts.java | 7 + .../phpdt/ltk/ui/actions/RenameLocalVariable.java | 14 +- .../sourceforge/phpdt/ltk/ui/uitexts.properties | 5 +- .../ltk/ui/wizards/RenameLocalVariablePage.java | 317 +++++++++++-------- .../ltk/ui/wizards/RenameLocalVariableWizard.java | 5 +- 8 files changed, 433 insertions(+), 285 deletions(-) diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index c747152..dd4922d 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -762,22 +762,22 @@ id="net.sourceforge.phpeclipse.actions.PHPOpenDeclarationEditorAction"> - + --> diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierInfo.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierInfo.java index 60a9457..6951116 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierInfo.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierInfo.java @@ -36,6 +36,12 @@ public class RenameIdentifierInfo { // projects than the current one private boolean allProjects; + private boolean renameDQString; + + private boolean renamePHPdoc; + + private boolean renameOtherComments; + private SourceMethod method; public int getOffset() { @@ -93,4 +99,28 @@ public class RenameIdentifierInfo { public void setMethod(SourceMethod method) { this.method = method; } + + public boolean isRenameDQString() { + return renameDQString; + } + + public void setRenameDQString(boolean renameDQString) { + this.renameDQString = renameDQString; + } + + public boolean isRenameOtherComments() { + return renameOtherComments; + } + + public void setRenameOtherComments(boolean renameOtherComments) { + this.renameOtherComments = renameOtherComments; + } + + public boolean isRenamePHPdoc() { + return renamePHPdoc; + } + + public void setRenamePHPdoc(boolean renamePHPdoc) { + this.renamePHPdoc = renamePHPdoc; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameLocalVariableDelegate.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameLocalVariableDelegate.java index dfa9ce1..077d3bb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameLocalVariableDelegate.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameLocalVariableDelegate.java @@ -35,145 +35,197 @@ import org.eclipse.ltk.core.refactoring.participants.ValidateEditChecker; */ public class RenameLocalVariableDelegate extends RenameIdentifierDelegate { - public RenameLocalVariableDelegate(final RenameIdentifierInfo info) { - super(info); - } - - RefactoringStatus checkInitialConditions() { - RefactoringStatus result = new RefactoringStatus(); - IFile sourceFile = info.getSourceFile(); - if (sourceFile == null || !sourceFile.exists()) { - result.addFatalError(CoreTexts.renamePropertyDelegate_noSourceFile); - } else if (info.getSourceFile().isReadOnly()) { - result.addFatalError(CoreTexts.renamePropertyDelegate_roFile); - } else if (isEmpty(info.getOldName())) { - // || !isPropertyKey( info.getSourceFile(), info.getOldName() ) ) { - result.addFatalError(CoreTexts.renamePropertyDelegate_noPHPKey); - } - return result; - } - - RefactoringStatus checkFinalConditions(final IProgressMonitor pm, final CheckConditionsContext ctxt) { - RefactoringStatus result = new RefactoringStatus(); - pm.beginTask(CoreTexts.renamePropertyDelegate_checking, 100); - // do something long-running here: traverse the entire project (or even - // workspace) to look for all *.p files with the same bundle - // base name - IFile file = info.getSourceFile(); - IProject project = file.getProject(); - try { - SourceMethod method = info.getMethod(); - ISourceRange range = method.getSourceRange(); - if (project.isNatureEnabled(PHPeclipsePlugin.PHP_NATURE_ID)) { - determineMethodOffsets(file, range.getOffset(), range.getLength(), result); - } - } catch (CoreException e) { - String msg = "Project: " + project.getLocation().toOSString() + " CoreException " + e.getMessage(); - result.addError(msg); - } catch (Exception e) { - String msg = "Project: " + project.getLocation().toOSString() + " Exception " + e.getMessage(); - result.addError(msg); - } - - pm.worked(50); - - if (ctxt != null) { - IFile[] files = new IFile[phpFiles.size()]; - phpFiles.keySet().toArray(files); - IConditionChecker checker = ctxt.getChecker(ValidateEditChecker.class); - ValidateEditChecker editChecker = (ValidateEditChecker) checker; - editChecker.addFiles(files); - } - pm.done(); - return result; - } - - protected void createChange(final IProgressMonitor pm, final CompositeChange rootChange) { - try { - pm.beginTask(CoreTexts.renamePropertyDelegate_collectingChanges, 100); - // all files in the same bundle - rootChange.addAll(createChangesForContainer(pm)); - } finally { - pm.done(); - } - } - - // finds the offsets of the identifier to rename - // usually, this would be the job of a proper parser; - // using a primitive brute-force approach here - private void determineMethodOffsets(final IFile file, int offset, int length, final RefactoringStatus status) { - ArrayList matches = new ArrayList(); - try { - String content = readFileContent(file, status); - String methodString = content.substring(offset, offset + length); - Scanner scanner = new Scanner(true, false); - scanner.setSource(methodString.toCharArray()); - scanner.setPHPMode(true); - String wordStr = info.getOldName(); - char[] word = wordStr.toCharArray(); - - int fToken = ITerminalSymbols.TokenNameEOF; - String dqStr; - int dqOffset; - int index; - try { - fToken = scanner.getNextToken(); - while (fToken != ITerminalSymbols.TokenNameEOF) { - if (fToken == ITerminalSymbols.TokenNameVariable) { - if (scanner.equalsCurrentTokenSource(word)) { - // the current variable token is equal to the given word - matches.add(Integer.valueOf(scanner.getCurrentTokenStartPosition() + offset)); - } - } else if (fToken == ITerminalSymbols.TokenNameStringDoubleQuote) { - // determine the word in double quoted strings: - dqStr = new String(scanner.getCurrentTokenSource()); - dqOffset = scanner.getCurrentTokenStartPosition(); - index = -1; - while ((index = dqStr.indexOf(wordStr, index + 1)) >= 0) { - matches.add(Integer.valueOf(offset + dqOffset + index)); - } - } - fToken = scanner.getNextToken(); - } - - } catch (InvalidInputException e) { - String msg = "File: " + file.getLocation().toOSString() + " InvalidInputException " + e.getMessage(); - status.addError(msg); - } catch (SyntaxError e) { - String msg = "File: " + file.getLocation().toOSString() + " SyntaxError " + e.getMessage(); - status.addError(msg); - } - - } catch (Exception e) { - String msg = "File: " + file.getLocation().toOSString() + " Exception " + e.getMessage(); - status.addError(msg); - } - if (matches.size() > 0) { - phpFiles.put(file, matches); - } - } - - private String readFileContent(final IFile file, final RefactoringStatus refStatus) { - String result = null; - try { - InputStream is = file.getContents(); - byte[] buf = new byte[1024]; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - int len = is.read(buf); - while (len > 0) { - bos.write(buf, 0, len); - len = is.read(buf); - } - is.close(); - result = new String(bos.toByteArray()); - } catch (Exception ex) { - String msg = ex.toString(); - refStatus.addFatalError(msg); - String pluginId = PHPeclipsePlugin.getPluginId(); - IStatus status = new Status(IStatus.ERROR, pluginId, 0, msg, ex); - PHPeclipsePlugin.getDefault().getLog().log(status); - } - return result; - } + public RenameLocalVariableDelegate(final RenameIdentifierInfo info) { + super(info); + } + + RefactoringStatus checkInitialConditions() { + RefactoringStatus result = new RefactoringStatus(); + IFile sourceFile = info.getSourceFile(); + if (sourceFile == null || !sourceFile.exists()) { + result.addFatalError(CoreTexts.renamePropertyDelegate_noSourceFile); + } else if (info.getSourceFile().isReadOnly()) { + result.addFatalError(CoreTexts.renamePropertyDelegate_roFile); + } else if (isEmpty(info.getOldName())) { + // || !isPropertyKey( info.getSourceFile(), info.getOldName() ) ) { + result.addFatalError(CoreTexts.renamePropertyDelegate_noPHPKey); + } + return result; + } + + RefactoringStatus checkFinalConditions(final IProgressMonitor pm, final CheckConditionsContext ctxt) { + RefactoringStatus result = new RefactoringStatus(); + pm.beginTask(CoreTexts.renamePropertyDelegate_checking, 100); + // do something long-running here: traverse the entire project (or even + // workspace) to look for all *.p files with the same bundle + // base name + IFile file = info.getSourceFile(); + IProject project = file.getProject(); + try { + SourceMethod method = info.getMethod(); + ISourceRange range = method.getSourceRange(); + if (project.isNatureEnabled(PHPeclipsePlugin.PHP_NATURE_ID)) { + determineMethodOffsets(file, range.getOffset(), range.getLength(), result); + } + } catch (CoreException e) { + String msg = "Project: " + project.getLocation().toOSString() + " CoreException " + e.getMessage(); + result.addError(msg); + } catch (Exception e) { + String msg = "Project: " + project.getLocation().toOSString() + " Exception " + e.getMessage(); + result.addError(msg); + } + + pm.worked(50); + + if (ctxt != null) { + IFile[] files = new IFile[phpFiles.size()]; + phpFiles.keySet().toArray(files); + IConditionChecker checker = ctxt.getChecker(ValidateEditChecker.class); + ValidateEditChecker editChecker = (ValidateEditChecker) checker; + editChecker.addFiles(files); + } + pm.done(); + return result; + } + + protected void createChange(final IProgressMonitor pm, final CompositeChange rootChange) { + try { + pm.beginTask(CoreTexts.renamePropertyDelegate_collectingChanges, 100); + // all files in the same bundle + rootChange.addAll(createChangesForContainer(pm)); + } finally { + pm.done(); + } + } + + private void determineMethodOffsets(final IFile file, int offset, int length, final RefactoringStatus status) { + ArrayList matches = new ArrayList(); + try { + String content = readFileContent(file, status); + + // + // Find a PHPdoc directly before the method + // + Scanner firstScanner = new Scanner(true, false); + firstScanner.setSource(content.toCharArray()); + int fToken = ITerminalSymbols.TokenNameEOF; + int start = 0; + int phpdocStart = -1; + try { + fToken = firstScanner.getNextToken(); + while (fToken != ITerminalSymbols.TokenNameEOF && start < offset) { + if (fToken == ITerminalSymbols.TokenNameCOMMENT_PHPDOC) { + phpdocStart = firstScanner.getCurrentTokenStartPosition(); + } else { + phpdocStart = -1; + } + fToken = firstScanner.getNextToken(); + start = firstScanner.getCurrentTokenStartPosition(); + } + + } catch (InvalidInputException e) { + String msg = "File: " + file.getLocation().toOSString() + " InvalidInputException " + e.getMessage(); + status.addError(msg); + } catch (SyntaxError e) { + String msg = "File: " + file.getLocation().toOSString() + " SyntaxError " + e.getMessage(); + status.addError(msg); + } + + // + // Find matches for the word in the PHPdoc+method declaration + // + if (phpdocStart >= 0 && phpdocStart < offset) { + length += offset - phpdocStart; + offset = phpdocStart; + } + String methodString = content.substring(offset, offset + length); + Scanner secondScanner = new Scanner(true, false); + secondScanner.setSource(methodString.toCharArray()); + secondScanner.setPHPMode(true); + String wordStr = info.getOldName(); + boolean renameDQString = info.isRenameDQString(); + boolean renamePHPdoc = info.isRenamePHPdoc(); + boolean renameOtherComments = info.isRenameOtherComments(); + char[] word = wordStr.toCharArray(); + + fToken = ITerminalSymbols.TokenNameEOF; + // double quoted string + String tokenString; + // double quoted string offset + int tokenOffset; + int index; + try { + fToken = secondScanner.getNextToken(); + while (fToken != ITerminalSymbols.TokenNameEOF) { + if (fToken == ITerminalSymbols.TokenNameVariable) { + if (secondScanner.equalsCurrentTokenSource(word)) { + // the current variable token is equal to the given word + matches.add(Integer.valueOf(secondScanner.getCurrentTokenStartPosition() + offset)); + } + } else if (fToken == ITerminalSymbols.TokenNameStringDoubleQuote && renameDQString) { + // determine the word in double quoted strings: + tokenString = new String(secondScanner.getCurrentTokenSource()); + tokenOffset = secondScanner.getCurrentTokenStartPosition(); + index = -1; + while ((index = tokenString.indexOf(wordStr, index + 1)) >= 0) { + matches.add(Integer.valueOf(offset + tokenOffset + index)); + } + } else if (fToken == ITerminalSymbols.TokenNameCOMMENT_PHPDOC && renamePHPdoc) { + tokenString = new String(secondScanner.getCurrentTokenSource()); + tokenOffset = secondScanner.getCurrentTokenStartPosition(); + index = -1; + while ((index = tokenString.indexOf(wordStr, index + 1)) >= 0) { + matches.add(Integer.valueOf(offset + tokenOffset + index)); + } + } else if ( (fToken == ITerminalSymbols.TokenNameCOMMENT_BLOCK || fToken == ITerminalSymbols.TokenNameCOMMENT_LINE) && renameOtherComments) { + tokenString = new String(secondScanner.getCurrentTokenSource()); + tokenOffset = secondScanner.getCurrentTokenStartPosition(); + index = -1; + while ((index = tokenString.indexOf(wordStr, index + 1)) >= 0) { + matches.add(Integer.valueOf(offset + tokenOffset + index)); + } + } + fToken = secondScanner.getNextToken(); + } + + } catch (InvalidInputException e) { + String msg = "File: " + file.getLocation().toOSString() + " InvalidInputException " + e.getMessage(); + status.addError(msg); + } catch (SyntaxError e) { + String msg = "File: " + file.getLocation().toOSString() + " SyntaxError " + e.getMessage(); + status.addError(msg); + } + + } catch (Exception e) { + String msg = "File: " + file.getLocation().toOSString() + " Exception " + e.getMessage(); + status.addError(msg); + } + if (matches.size() > 0) { + phpFiles.put(file, matches); + } + } + + private String readFileContent(final IFile file, final RefactoringStatus refStatus) { + String result = null; + try { + InputStream is = file.getContents(); + byte[] buf = new byte[1024]; + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + int len = is.read(buf); + while (len > 0) { + bos.write(buf, 0, len); + len = is.read(buf); + } + is.close(); + result = new String(bos.toByteArray()); + } catch (Exception ex) { + String msg = ex.toString(); + refStatus.addFatalError(msg); + String pluginId = PHPeclipsePlugin.getPluginId(); + IStatus status = new Status(IStatus.ERROR, pluginId, 0, msg, ex); + PHPeclipsePlugin.getDefault().getLog().log(status); + } + return result; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/UITexts.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/UITexts.java index a70f518..adac1e0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/UITexts.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/UITexts.java @@ -33,4 +33,11 @@ public class UITexts { public static String renameLocalVariable_refuseDlg_title; public static String renameLocalVariable_refuseDlg_message; + + public static String renameLocalVariable_cbDQStrings; + + public static String renameLocalVariable_cbPHPdoc; + + public static String renameLocalVariable_cbOtherDoc; + } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/actions/RenameLocalVariable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/actions/RenameLocalVariable.java index 9bc7415..0b1a91c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/actions/RenameLocalVariable.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/actions/RenameLocalVariable.java @@ -51,9 +51,6 @@ public class RenameLocalVariable implements IEditorActionDelegate { private RenameIdentifierInfo info = new RenameIdentifierInfo(); - // interface methods of IEditorActionDelegate - // /////////////////////////////////////////// - public void setActiveEditor(final IAction action, final IEditorPart targetEditor) { this.targetEditor = targetEditor; onPHPFile = false; @@ -86,17 +83,17 @@ public class RenameLocalVariable implements IEditorActionDelegate { SourceMethod method = (SourceMethod) findEnclosingElement(point.x, unit, IJavaElement.METHOD); if (word == null || word.charAt(0) != '$' || method == null || !(method instanceof SourceMethod)) { refuseLocalVariable(); + } else { + applySelection((ITextSelection) selection, word, point, method); + if (saveAll()) { + openWizard(); + } } - applySelection((ITextSelection) selection, word, point, method); - } catch (BadLocationException e) { } } } } - if (saveAll()) { - openWizard(); - } } } } @@ -148,6 +145,7 @@ public class RenameLocalVariable implements IEditorActionDelegate { String message = UITexts.renameLocalVariable_refuseDlg_message; MessageDialog.openInformation(getShell(), title, message); } + private void refuse() { String title = UITexts.renameProperty_refuseDlg_title; String message = UITexts.renameProperty_refuseDlg_message; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/uitexts.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/uitexts.properties index 197714f..219e39d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/uitexts.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/uitexts.properties @@ -5,4 +5,7 @@ renamePropertyInputPage_cbUpdateBundle=Update all PHP files in the same project renamePropertyInputPage_cbAllProjects=Update all PHP projects in the workspace (forces preview) renameLocalVariable_refuseDlg_title=Rename Local PHP variable -renameLocalVariable_refuseDlg_message=The selected identifier is no local PHP variable. \ No newline at end of file +renameLocalVariable_refuseDlg_message=The selected identifier is no local PHP variable. +renameLocalVariable_cbDQStrings=Rename variable inside double quoted strings +renameLocalVariable_cbPHPdoc=Rename variable inside PHPdoc comments +renameLocalVariable_cbOtherDoc=Rename variable inside other PHP comments (line or block) \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariablePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariablePage.java index 9a536ce..3da0b98 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariablePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariablePage.java @@ -2,6 +2,7 @@ // See http://leiffrenzel.de package net.sourceforge.phpdt.ltk.ui.wizards; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; import net.sourceforge.phpdt.ltk.core.RenameIdentifierInfo; import net.sourceforge.phpdt.ltk.ui.UITexts; import net.sourceforge.phpeclipse.PHPeclipsePlugin; @@ -12,6 +13,8 @@ import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -19,134 +22,192 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; - -/**

the input page for the Rename Property refactoring, where users can - * control the effects of the refactoring; to be shown in the wizard.

- * - *

We let the user enter the new name for the property, and we let her - * decide whether other property files in the bundle should be affected, and - * whether the operation is supposed to span the entire workspace or only - * the current project.

- * - */ +/** + *

+ * the input page for the Rename Property refactoring, where users can control + * the effects of the refactoring; to be shown in the wizard. + *

+ * + *

+ * We let the user enter the new name for the property, and we let her decide + * whether other property files in the bundle should be affected, and whether + * the operation is supposed to span the entire workspace or only the current + * project. + *

+ * + */ public class RenameLocalVariablePage extends UserInputWizardPage { - private static final String DS_KEY = RenameLocalVariablePage.class.getName(); - private static final String DS_UPDATE_BUNDLE = "UPDATE_BUNDLE"; //$NON-NLS-1$ - private static final String DS_ALL_PROJECTS = "ALL_PROJECTS"; //$NON-NLS-1$ - - private final RenameIdentifierInfo info; - - private IDialogSettings dialogSettings; - private Text txtNewName; - - - public RenameLocalVariablePage( final RenameIdentifierInfo info ) { - super( RenameLocalVariablePage.class.getName() ); - this.info = info; - initDialogSettings(); - } - - - // interface methods of UserInputWizardPage - /////////////////////////////////////////// - - public void createControl( final Composite parent ) { - Composite composite = createRootComposite( parent ); - setControl( composite ); - - createLblNewName( composite ); - createTxtNewName( composite ); - createCbUpdateBundle( composite ); - createCbAllProjects( composite ); - - validate(); - } - - - // UI creation methods - ////////////////////// - - private Composite createRootComposite( final Composite parent ) { - Composite result = new Composite( parent, SWT.NONE ); - GridLayout gridLayout = new GridLayout( 2, false ); - gridLayout.marginWidth = 10; - gridLayout.marginHeight = 10; - result.setLayout( gridLayout ); - initializeDialogUnits( result ); - Dialog.applyDialogFont( result ); - return result; - } - - private void createLblNewName( final Composite composite ) { - Label lblNewName = new Label( composite, SWT.NONE ); - lblNewName.setText( UITexts.renamePropertyInputPage_lblNewName ); - } - - private void createTxtNewName(Composite composite) { - txtNewName = new Text( composite, SWT.BORDER ); - txtNewName.setText( info.getOldName() ); - txtNewName.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); - txtNewName.selectAll(); - txtNewName.addKeyListener( new KeyAdapter() { - public void keyReleased( final KeyEvent e ) { - info.setNewName( txtNewName.getText() ); - validate(); - } - } ); - } - - private void createCbUpdateBundle( final Composite composite ) { - String texts = UITexts.renamePropertyInputPage_cbUpdateBundle; - initUpdateBundleOption(); - } - - private void createCbAllProjects( final Composite composite ) { - String text = UITexts.renamePropertyInputPage_cbAllProjects; - initAllProjectsOption(); - } - - private Button createCheckbox( final Composite composite, - final String text ) { - Button result = new Button( composite, SWT.CHECK ); - result.setText( text ); - - GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 2; - result.setLayoutData( gridData ); - - return result; - } - - - // helping methods - ////////////////// - - private void initDialogSettings() { - IDialogSettings ds = PHPeclipsePlugin.getDefault().getDialogSettings(); - dialogSettings = ds.getSection( DS_KEY ); - if( dialogSettings == null ) { - dialogSettings = ds.addNewSection( DS_KEY ); - // init default values - dialogSettings.put( DS_UPDATE_BUNDLE, true ); - dialogSettings.put( DS_ALL_PROJECTS, false ); - } - } - - private void validate() { - String txt = txtNewName.getText(); - setPageComplete( txt.length() > 0 && !txt.equals( info.getOldName() ) ); - } - - private void initUpdateBundleOption() { -// boolean updateRefs = dialogSettings.getBoolean( DS_UPDATE_BUNDLE ); -// cbUpdateBundle.setSelection( updateRefs ); -// info.setUpdateProject( updateRefs ); - } - - private void initAllProjectsOption() { -// boolean allProjects = dialogSettings.getBoolean( DS_ALL_PROJECTS ); -// cbAllProjects.setSelection( allProjects ); -// info.setAllProjects( allProjects ); - } + private static final String DS_KEY = RenameLocalVariablePage.class.getName(); + + private static final String DS_RENAME_DQ_STRINGS = "RENAME_DQ_STRINGS"; //$NON-NLS-1$ + + private static final String DS_RENAME_PHPDOC = "RENAME_PHPDOC"; //$NON-NLS-1$ + + private static final String DS_RENAME_OTHER_COMMENTS = "RENAME_OTHER_COMMENTS"; //$NON-NLS-1$ + + private final RenameIdentifierInfo info; + + private IDialogSettings dialogSettings; + + private Text txtNewName; + + private Button cbRenameDQStrings; + + private Button cbRenamePHPdoc; + + private Button cbRenameOtherComments; + + public RenameLocalVariablePage(final RenameIdentifierInfo info) { + super(RenameLocalVariablePage.class.getName()); + this.info = info; + initDialogSettings(); + } + + public void createControl(final Composite parent) { + Composite composite = createRootComposite(parent); + setControl(composite); + + createLblNewName(composite); + createTxtNewName(composite); + createCbDQStrings(composite); + createCbPHPdoc(composite); + createCbOtherComments(composite); + + validate(); + + // TODO check if we can leave this step out in the future + getRefactoringWizard().setForcePreviewReview(true); + } + + private Composite createRootComposite(final Composite parent) { + Composite result = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(2, false); + gridLayout.marginWidth = 10; + gridLayout.marginHeight = 10; + result.setLayout(gridLayout); + initializeDialogUnits(result); + Dialog.applyDialogFont(result); + return result; + } + + private void createLblNewName(final Composite composite) { + Label lblNewName = new Label(composite, SWT.NONE); + lblNewName.setText(UITexts.renamePropertyInputPage_lblNewName); + } + + private void createTxtNewName(Composite composite) { + txtNewName = new Text(composite, SWT.BORDER); + txtNewName.setText(info.getOldName()); + txtNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + txtNewName.selectAll(); + txtNewName.addKeyListener(new KeyAdapter() { + public void keyReleased(final KeyEvent e) { + info.setNewName(txtNewName.getText()); + validate(); + } + }); + } + + private void createCbDQStrings(final Composite composite) { + String texts = UITexts.renameLocalVariable_cbDQStrings; + cbRenameDQStrings = createCheckbox(composite, texts); + cbRenameDQStrings.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(final SelectionEvent event) { + boolean selected = cbRenameDQStrings.getSelection(); + dialogSettings.put(DS_RENAME_DQ_STRINGS, selected); + info.setRenameDQString(selected); + } + }); + initDQStringsOption(); + } + + private void createCbPHPdoc(final Composite composite) { + String texts = UITexts.renameLocalVariable_cbPHPdoc; + cbRenamePHPdoc = createCheckbox(composite, texts); + cbRenamePHPdoc.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(final SelectionEvent event) { + boolean selected = cbRenamePHPdoc.getSelection(); + dialogSettings.put(DS_RENAME_PHPDOC, selected); + info.setRenamePHPdoc(selected); + } + }); + initPHPdocOption(); + } + + private void createCbOtherComments(final Composite composite) { + String texts = UITexts.renameLocalVariable_cbOtherDoc; + cbRenameOtherComments = createCheckbox(composite, texts); + cbRenameOtherComments.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(final SelectionEvent event) { + boolean selected = cbRenameOtherComments.getSelection(); + dialogSettings.put(DS_RENAME_OTHER_COMMENTS, selected); + info.setRenameOtherComments(selected); + } + }); + initOtherCommentsOption(); + } + + private Button createCheckbox(final Composite composite, final String text) { + Button result = new Button(composite, SWT.CHECK); + result.setText(text); + + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 2; + result.setLayoutData(gridData); + + return result; + } + + private void initDialogSettings() { + IDialogSettings ds = PHPeclipsePlugin.getDefault().getDialogSettings(); + dialogSettings = ds.getSection(DS_KEY); + if (dialogSettings == null) { + dialogSettings = ds.addNewSection(DS_KEY); + // init default values + dialogSettings.put(DS_RENAME_DQ_STRINGS, true); + dialogSettings.put(DS_RENAME_PHPDOC, true); + dialogSettings.put(DS_RENAME_OTHER_COMMENTS, true); + } + } + + private static boolean isVariable(String txt) { + if (txt.length() <= 1) { + return false; + } + if (txt.charAt(0) != '$') { + return false; + } + for (int i = 1; i < txt.length(); i++) { + if (!Scanner.isPHPIdentifierPart(txt.charAt(i))) { + return false; + } + } + return true; + } + + private void validate() { + String txt = txtNewName.getText(); + Scanner s; + setPageComplete(isVariable(txt) && !txt.equals(info.getOldName())); + } + + private void initDQStringsOption() { + boolean refs = dialogSettings.getBoolean(DS_RENAME_DQ_STRINGS); + cbRenameDQStrings.setSelection(refs); + info.setRenameDQString(refs); + } + + private void initPHPdocOption() { + boolean refs = dialogSettings.getBoolean(DS_RENAME_PHPDOC); + cbRenamePHPdoc.setSelection(refs); + info.setRenamePHPdoc(refs); + } + + private void initOtherCommentsOption() { + boolean refs = dialogSettings.getBoolean(DS_RENAME_OTHER_COMMENTS); + cbRenameOtherComments.setSelection(refs); + info.setRenameOtherComments(refs); + } + } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariableWizard.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariableWizard.java index 6174f21..e3ee6da 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariableWizard.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/ui/wizards/RenameLocalVariableWizard.java @@ -10,7 +10,7 @@ import org.eclipse.ltk.ui.refactoring.RefactoringWizard; /**

The wizard that is shown to the user for entering the necessary - * information for property renaming.

+ * information for property renaming of local PHP variables.

* *

The wizard class is primarily needed for deciding which pages are * shown to the user. The actual user interface creation goes on the @@ -29,9 +29,6 @@ public class RenameLocalVariableWizard extends RefactoringWizard { } - // interface methods of RefactoringWizard - ///////////////////////////////////////// - protected void addUserInputPages() { setDefaultPageTitle( getRefactoring().getName() ); addPage( new RenameLocalVariablePage( info ) ); -- 1.7.1 From 8ff3b3ceb168f0d19cbb00a1b463c3efab574abf Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Thu, 19 Jan 2006 20:22:00 +0000 Subject: [PATCH 04/16] integration of cia.navi.cx --- CVSROOT/checkoutlist | 4 + CVSROOT/ciabot_cvs.pl | 350 +++++++++++++++++++++++++++++++++++++++++++++++++ CVSROOT/loginfo | 3 + 3 files changed, 357 insertions(+), 0 deletions(-) create mode 100644 CVSROOT/ciabot_cvs.pl diff --git a/CVSROOT/checkoutlist b/CVSROOT/checkoutlist index b04b350..994fcdd 100644 --- a/CVSROOT/checkoutlist +++ b/CVSROOT/checkoutlist @@ -11,3 +11,7 @@ # [] # # comment lines begin with '#' +# +# +# bot for cia.navi.cx +ciabot_cvs.pl \ No newline at end of file diff --git a/CVSROOT/ciabot_cvs.pl b/CVSROOT/ciabot_cvs.pl new file mode 100644 index 0000000..7d7630e --- /dev/null +++ b/CVSROOT/ciabot_cvs.pl @@ -0,0 +1,350 @@ +#!/usr/bin/perl -w +# +# ciabot -- Mail a CVS log message to a given address, for the purposes of CIA +# +# Loosely based on cvslog by Russ Allbery +# Copyright 1998 Board of Trustees, Leland Stanford Jr. University +# +# Copyright 2001, 2003, 2004 Petr Baudis +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License version 2, as published by the +# Free Software Foundation. +# +# The master location of this file is +# http://pasky.or.cz/~pasky/dev/cvs/ciabot.pl. +# +# This version has been modified a bit, and is available on CIA's web site: +# http://cia.navi.cx/clients/cvs/ciabot_cvs.pl +# +# This program is designed to run from the loginfo CVS administration file. It +# takes a log message, massaging it and mailing it to the address given below. +# +# Its record in the loginfo file should look like: +# +# ALL /usr/bin/perl $CVSROOT/CVSROOT/ciabot_cvs.pl %{,,,s} $USER project from_email dest_email ignore_regexp +# +# IMPORTANT: The %{,,,s} in loginfo is new, and is required for proper operation. +# +# Make sure that you add the script to 'checkoutlist' before +# committing it. You may need to change /usr/bin/perl to point to your +# system's perl binary. +# +# Note that the last four parameters are optional, you can alternatively +# change the defaults below in the configuration section. +# + +use strict; +use vars qw ($project $from_email $dest_email $rpc_uri $sendmail $sync_delay + $xml_rpc $ignore_regexp $alt_local_message_target); + + +### Configuration + +# Project name (as known to CIA). +# +# NOTE: This shouldn't be a long description of your project. Ideally +# it is a short identifier with no spaces, punctuation, or +# unnecessary capitalization. This will be used in URLs related +# to your project, as an internal identifier, and in IRC messages. +# If you want a longer name shown for your project on the web +# interface, please use the "title" metadata key rather than +# putting that here. +# +$project = 'phpeclipse'; + +# The from address in generated mails. +$from_email = 'bananeweizen@sourceforge.net'; + +# Mail all reports to this address. +$dest_email = 'cia@cia.navi.cx'; + +# If using XML-RPC, connect to this URI. +$rpc_uri = 'http://cia.navi.cx/RPC2'; + +# Path to your USCD sendmail compatible binary (your mailer daemon created this +# program somewhere). +$sendmail = '/usr/sbin/sendmail'; + +# Number of seconds to wait for possible concurrent instances. CVS calls up +# this script for each involved directory separately and this is the sync +# delay. 5s looks as a safe value, but feel free to increase if you are running +# this on a slower (or overloaded) machine or if you have really a lot of +# directories. +# Increasing this could be a very good idea if you're on Sourceforge ;) +$sync_delay = 5; + +# This script can communicate with CIA either by mail or by an XML-RPC +# interface. The XML-RPC interface is faster and more efficient, however you +# need to have RPC::XML perl module installed, and some large CVS hosting sites +# (like Savannah or Sourceforge) might not allow outgoing HTTP connections +# while they allow outgoing mail. Also, this script will hang and eventually +# not deliver the event at all if CIA server happens to be down, which is +# unfortunately not an uncommon condition. +$xml_rpc = 0; + +# You can make this bot to totally ignore events concerning the objects +# specified below. Each object is composed of //, +# therefore file Manifest in root directory of module gentoo will be called +# "gentoo/Manifest", while file src/bfu/inphist.c of module elinks will be +# called "elinks/src/bfu/inphist.c". Easy, isn't it? +# +# This variable should contain regexp, against which will each object be +# checked, and if the regexp is matched, the file is ignored. Therefore ie. to +# ignore all changes in the two files above and everything concerning module +# 'admin', use: +# +# $ignore_regexp = "^(gentoo/Manifest|elinks/src/bfu/inphist.c|admin/)"; +$ignore_regexp = ""; + +# It can be useful to also grab the generated XML message by some other +# programs and ie. autogenerate some content based on it. Here you can specify +# a file to which it will be appended. +$alt_local_message_target = ""; + + + + +### The code itself + +use vars qw ($user $module $tag @files $logmsg $message); + +my @dir; # This array stores all the affected directories +my @dirfiles; # This array is mapped to the @dir array and contains files + # affected in each directory + + +# A nice nonprinting character we can use as a separator relatively safely. +# The commas in loginfo above give us 4 commas and a space between file +# names given to us on the command line. This is the separator used internally. +# Now we can handle filenames containing spaces, and probably anything except +# strings of 4 commas or the ASCII bell character. +# +# This was inspired by the suggestion in: +# http://mail.gnu.org/archive/html/info-cvs/2003-04/msg00267.html +# +$" = "\7"; + +### Input data loading + + +# These arguments are from %s; first the relative path in the repository +# and then the list of files modified. + +@files = split (' ,,,', ($ARGV[0] or '')); +$dir[0] = shift @files or die "$0: no directory specified\n"; +$dirfiles[0] = "@files" or die "$0: no files specified\n"; + + +# Guess module name. + +$module = $dir[0]; $module =~ s#/.*##; + + +# Figure out who is doing the update. + +$user = $ARGV[1]; + + +# Use the optional parameters, if supplied. + +$project = $ARGV[2] if $ARGV[2]; +$from_email = $ARGV[3] if $ARGV[3]; +$dest_email = $ARGV[4] if $ARGV[4]; +$ignore_regexp = $ARGV[5] if $ARGV[5]; + + +# Parse stdin (what's interesting is the tag and log message) + +while () { + $tag = $1 if /^\s*Tag: ([a-zA-Z0-9_-]+)/; + last if /^Log Message/; +} + +$logmsg = ""; +while () { + next unless ($_ and $_ ne "\n" and $_ ne "\r\n"); + s/&/&/g; + s//>/g; + $logmsg .= $_; +} + +### Remove to-be-ignored files + +$dirfiles[0] = join (' ', + grep { + my $f = "$dir[0]/$_"; + $f !~ m/$ignore_regexp/; + } split (/\s+/, $dirfiles[0]) +) if ($ignore_regexp); +exit unless $dirfiles[0]; + + + +### Sync between the multiple instances potentially being ran simultanously + +my $sum; # _VERY_ simple hash of the log message. It is really weak, but I'm + # lazy and it's really sorta exceptional to even get more commits + # running simultanously anyway. +$sum = 0; +map { $sum += ord $_ } split(//, $logmsg); + +my $syncfile; # Name of the file used for syncing +$syncfile = "/tmp/cvscia.$project.$module.$sum"; + + +if (-f $syncfile and -w $syncfile) { + # The synchronization file for this file already exists, so we are not the + # first ones. So let's just dump what we know and exit. + + open(FF, ">>$syncfile") or die "aieee... can't log, can't log! $syncfile blocked!"; + print FF "$dirfiles[0]!@!$dir[0]\n"; + close(FF); + exit; + +} else { + # We are the first one! Thus, we'll fork, exit the original instance, and + # wait a bit with the new one. Then we'll grab what the others collected and + # go on. + + # We don't need to care about permissions since all the instances of the one + # commit will obviously live as the same user. + + # system("touch") in a different way + open(FF, ">>$syncfile") or die "aieee... can't log, can't log! $syncfile blocked!"; + close(FF); + + exit if (fork); + sleep($sync_delay); + + open(FF, $syncfile); + my ($dirnum) = 1; # 0 is the one we got triggerred for + while () { + chomp; + ($dirfiles[$dirnum], $dir[$dirnum]) = split(/!@!/); + $dirnum++; + } + close(FF); + + unlink($syncfile); +} + + + +### Compose the mail message + + +my ($VERSION) = '2.4'; +my ($URL) = 'http://cia.navi.cx/clients/cvs/ciabot_cvs.pl'; +my $ts = time; + +$message = < + + CIA Perl client for CVS + $VERSION + $URL + + + $project + $module +EM +; +$message .= " $tag" if ($tag); +$message .= < + + $ts + + + + $user + +EM +; + +for (my $dirnum = 0; $dirnum < @dir; $dirnum++) { + map { + $_ = $dir[$dirnum] . '/' . $_; + s#^.*?/##; # weed out the module name + s/&/&/g; + s//>/g; + $message .= " $_\n"; + } split($", $dirfiles[$dirnum]); +} + +$message .= < + +$logmsg + + + + +EM +; + + + +### Write the message to an alt-target + +if ($alt_local_message_target and open (ALT, ">>$alt_local_message_target")) { + print ALT $message; + close ALT; +} + + + +### Send out the XML-RPC message + + +if ($xml_rpc) { + # We gotta be careful from now on. We silence all the warnings because + # RPC::XML code is crappy and works with undefs etc. + $^W = 0; + $RPC::XML::ERROR if (0); # silence perl's compile-time warning + + require RPC::XML; + require RPC::XML::Client; + + my $rpc_client = new RPC::XML::Client $rpc_uri; + my $rpc_request = RPC::XML::request->new('hub.deliver', $message); + my $rpc_response = $rpc_client->send_request($rpc_request); + + unless (ref $rpc_response) { + die "XML-RPC Error: $RPC::XML::ERROR\n"; + } + exit; +} + + + +### Send out the mail + + +# Open our mail program + +open (MAIL, "| $sendmail -t -oi -oem") or die "Cannot execute $sendmail : " . ($?>>8); + + +# The mail header + +print MAIL <> 8) . "\n" unless ($? == 0); + +# vi: set sw=2: diff --git a/CVSROOT/loginfo b/CVSROOT/loginfo index ead100d..02c720a 100644 --- a/CVSROOT/loginfo +++ b/CVSROOT/loginfo @@ -25,3 +25,6 @@ # or #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} phpeclipse-commits@lists.sourceforge.net +# +# cia.navi.cx +ALL /usr/bin/perl $CVSROOT/CVSROOT/ciabot_cvs.pl %{,,,s} $USER \ No newline at end of file -- 1.7.1 From fc811a84a94ed26442ed4752c9ee1bdc363486e9 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Thu, 19 Jan 2006 20:25:41 +0000 Subject: [PATCH 05/16] this is a test commit to check the integration of cia.navi.cx --- net.sourceforge.phpeclipse/install.txt | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/net.sourceforge.phpeclipse/install.txt b/net.sourceforge.phpeclipse/install.txt index e210ad8..374e2a3 100644 --- a/net.sourceforge.phpeclipse/install.txt +++ b/net.sourceforge.phpeclipse/install.txt @@ -13,7 +13,7 @@ Contributors: Philippe Lachaise Stefan Langer Bastien Durel - + and others... This Plugin is released under the Common Public License v1.0 which is included @@ -78,7 +78,7 @@ After installation the directorystructure should look as follows (example): | |-- cpl-v10.html // common public licence | - |-- icons // Icons directory + |-- icons // Icons directory 4. Editing PHP @@ -135,3 +135,4 @@ If it is not listed create a new bug report. Be sure to include your system information (e.g. W2K Pentium 4 512 MB RAM), your Eclipse version (e.g. Eclipse 3.0), the version of phpeclipse you are using and a detailed description of the bug and how it can be reproduced. + -- 1.7.1 From 6290a79440336303d070829af68f26a4f094b7ed Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Thu, 19 Jan 2006 22:10:22 +0000 Subject: [PATCH 06/16] customized "about" dialog --- net.sourceforge.phpeclipse/about.ini | 4 ++++ net.sourceforge.phpeclipse/phpeclipse16.gif | Bin 0 -> 889 bytes net.sourceforge.phpeclipse/phpeclipse32.gif | Bin 0 -> 1785 bytes 3 files changed, 4 insertions(+), 0 deletions(-) create mode 100644 net.sourceforge.phpeclipse/about.ini create mode 100644 net.sourceforge.phpeclipse/phpeclipse16.gif create mode 100644 net.sourceforge.phpeclipse/phpeclipse32.gif diff --git a/net.sourceforge.phpeclipse/about.ini b/net.sourceforge.phpeclipse/about.ini new file mode 100644 index 0000000..62c230e --- /dev/null +++ b/net.sourceforge.phpeclipse/about.ini @@ -0,0 +1,4 @@ +aboutText=PHPeclipse - PHP development tools for Eclipse\n\Visit http://www.phpeclipse.de +featureImage=phpeclipse32.gif +windowImage=phpeclipse16.gif +appName=PHPeclipse \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/phpeclipse16.gif b/net.sourceforge.phpeclipse/phpeclipse16.gif new file mode 100644 index 0000000000000000000000000000000000000000..f01f87eab7e821c148b2b9a66a1ef8b2a4137845 GIT binary patch literal 889 zcmV-<1BU!ZNk%w1VGsZi0QUd@0000^Oi<|O>Qqu%SXN-t&)wSC;>yU^#lzL#-sW3c zW=Tj_WMg!Hfu5et zY;1M!EpSz@`ziVxedwrsZiLpvcV1|gRrKitkXMSjDe`RKSbajh*eyN6v zxPpbUhKja#dZ15HX;@lxEiOBMgQ;d|gpZQ3t*^ul4iyv?9cF8eV`z$GXo$|x-knP+mSV{V~rcB^P|q;GkyV{MyYX_bD8!E=19Wo?#UXN_=qrJSYDl$^q|y4$d} z)49LfyTIGW%;v$y-O<+Wi;kVy-0R`w^GsWwQDC7`VWLuDp;Tj|Q(~f1Vxd)Jq*Y|2 zR%N7CWTRVZs##~ISZ1VKYN%Ujs9I>IS!ktMXQf_ktW;u}U2CaZX{K0ZpkZ*ZU~jHo zY^q#pr&?&ES!bajB|2MZqD)taTxp_TY^GaipJZ~aQ(us0b+JNAa$|6+IznRy2n=U* zu3c%JYeTlt;kHLzS#gd%Kq^;Gbu-CJ^;;psW zx4zxI#N)cb-MGHly~EwS!rZ>Z-j9-=Zg6KphJ+g$86F)RBO)P3MnzIlPzeYK&d$!Vva+eEsRacE0|NsA z0RjL2{{R30A^8LW007DWEC2ui01yBW000P90F?#x literal 0 HcmV?d00001 diff --git a/net.sourceforge.phpeclipse/phpeclipse32.gif b/net.sourceforge.phpeclipse/phpeclipse32.gif new file mode 100644 index 0000000000000000000000000000000000000000..3854b8b13fe1617a360e9539418e6bafc0cce80c GIT binary patch literal 1785 zcmbu8_e0W&0>Hlx+7|k8V^*mhwhtoVg z>0X`;Z+M}HH_O{A58=r|dKGyhI6mIR$kRd;q7?0Y1C1=hAh?Sb8;E@n98eqR-w{N-NyN7W`}IcR%R~J8L-B%;pehpX;aTiMvcHIo9|$AzgGhJI z;6{Q2CPPWJVfe>qNOhs1mEpL_5P~#3KpcUWMuxOR227E|_z9%yD8jE{feR54wb8^U z;X#XWgvFRBPDJFrn6r(sk^J}=K}>8r__Y)e9XQ$pxY-1)Y|gto+s{PRioFI^B) zdyA&?&jA1yWjS= z-hO(&{ri9Szkd1i;NaUA;Qzqtv!WaTd;=W*cKrPWpmG3wdu@sm@Aj>Ge7|O=^Hs`$N;@Ylr9w0;ZyC!DJnUoeW>2;4n(;=L{j=y4TL5@ zk-1Y8C%WsVfrE7sD_;PaI(}ik%BpjrMHdRcwzpN-Ab!J@ko%W%I!8teuP0TNd{WXh zbtc`?&|KcI)iOJQV>mv)@R~Jo$}Xr8ZiRH|yEI#4_-Wz%3=fvNH}2VqxL)#IS;URc zHC|#hvqv45Hx@N(I%3+Lt%h6@uoc$+mkzp2W})gv1GXeV_GYo!2})o2XD`(G_-$+E}Bipv1QW_b6h`mwH=j!E{t#=9&#)K3sK+p2&V zv^57&xPdml&%xSNXK+*xmzk_fEGS8Y6;0!K0S#mX2g`xna`P3`y8#6>^sco}fkhN` z?QRZqJm)t>y;CwkF^-)|^y%9iDLU2AddTFFx^TLxO(mIbZ(ULB8Kvzp&%r_& z08wJubdi>)vwlryr1-!n2uxGda$v*d>+ACrwEBc;Rfme!RGFGrhwh0$9bUuKHq{ew zrdcF`#;6!vamKQ}+V!OD=9Kjb+nZRO2uIi8Li`*%R~e~p4-y5v&6!`aCp!L1YyGj)T;6W!i-HV5PY3wElx`6Ex`kaFSr zIBZ+ciF0*N5l)}9Kh7(4l>>DC4SO3Es4|@FCPJVP2%;3WHPA5yoABdJyLQ_MU1zu1 zu~W}owo!9F1lOaw`KWS1I?jaNs-USzx-v{#m{X(i=sl@w_?Yyo5(4v(amZd2!&X74E9nC8y6gY?kW=j1$$Be;9WKVs{gn6Q_EJ4$ Date: Thu, 19 Jan 2006 22:35:12 +0000 Subject: [PATCH 07/16] Added icon phpedit.png from the free icons library at: http://www.famfamfam.com/lab/icons/silk/ --- net.sourceforge.phpeclipse/icons/obj16/phpedit.png | Bin 0 -> 681 bytes net.sourceforge.phpeclipse/plugin.xml | 4 +- .../sourceforge/phpdt/internal/ui/PHPUiImages.java | 98 ++++++++++---------- 3 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 net.sourceforge.phpeclipse/icons/obj16/phpedit.png diff --git a/net.sourceforge.phpeclipse/icons/obj16/phpedit.png b/net.sourceforge.phpeclipse/icons/obj16/phpedit.png new file mode 100644 index 0000000000000000000000000000000000000000..4e9516679aaa8249f08456f13767ec4cc9540777 GIT binary patch literal 681 zcmV;a0#^NrP)Z2q2hdMvws@1>e7a|NrynPcRL_pFe;8|KY=j|F2%X0vqt{+qeH9OJ>fT2{r^E zfEYmrm|J8p-@UufVfyqHdk!DI%fQOY%y9p~Td)_UrTG~wE#w(&tmPP_q(nhs1rH1s z78Y}W0AdUbp2ZF{Bo`>r4U=eU^kJy0-+~c(p&_~q4)%&b);|U@F)^?K00G1TGzaUE?*h7Fsp0=>uzHvk}jKrY|~F}{BN1;!xo?dwkzJ~I8|$8V6+ z;RXN%5Xc1!Knz6%VTiMVfp`7-ORyx!*~sFcfVH<%VPIlnf*Sx3Kp>;4fmjGA>5m?8 zAU`W83c~}`#6*rEJj@V94L|^aqtQQLiun8Y4|3hzU8*l#e#QVyPjCgGDAm=KVlV}2 zHa3=J;OFCjI34H;P%Hoh5ZC}lNaUIV6Us^SsDtGdbO6! --> @@ -370,7 +370,7 @@ Date: Thu, 19 Jan 2006 22:49:55 +0000 Subject: [PATCH 08/16] Added www.phpeclipse.de --- net.sourceforge.phpeclipse/plugin.properties | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net.sourceforge.phpeclipse/plugin.properties b/net.sourceforge.phpeclipse/plugin.properties index 87909f1..449e2fb 100644 --- a/net.sourceforge.phpeclipse/plugin.properties +++ b/net.sourceforge.phpeclipse/plugin.properties @@ -2,7 +2,7 @@ # ######################################### pluginName=PHPEclipse Tools Core -providerName=phpeclipse.de +providerName=www.phpeclipse.de naturePHP.name=PHP Project elementFiltersName=PHPElement Filters phpProblemName=PHP Problem -- 1.7.1 From b8844d88a3fe8c9c80f84fb04d6df9363af3a96b Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Fri, 20 Jan 2006 08:53:10 +0000 Subject: [PATCH 09/16] bugfix 1330522: =0) { + if (getNextChar('M','m')>=0) { + if (getNextChar('L','l')>=0) { + foundXML=true; + } + } + } + if (!foundXML) { + phpMode = true; + } if (phpShortTag) { fFillerToken = TokenNameECHO_INVISIBLE; } return TokenNameINLINE_HTML; } } else { - int test = getNextChar('H', 'h'); - if (test >= 0) { - test = getNextChar('P', 'p'); - if (test >= 0) { + if (getNextChar('H', 'h') >= 0) { + if (getNextChar('P', 'p') >= 0) { // Date: Sat, 21 Jan 2006 11:07:26 +0000 Subject: [PATCH 10/16] remove dependency to internal package --- .../phpeclipse/phpeditor/PHPUnitEditor.java | 3098 ++++++++++---------- 1 files changed, 1549 insertions(+), 1549 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java index aacb78d..153bf6d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java @@ -39,7 +39,6 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.phpeditor.actions.RTrimAction; import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction; -import org.eclipse.core.internal.runtime.ListenerList; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; @@ -74,6 +73,7 @@ import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewerConfiguration; +import org.eclipse.jface.util.ListenerList; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; @@ -117,7 +117,7 @@ import org.eclipse.ui.texteditor.TextOperationAction; public class PHPUnitEditor extends PHPEditor { //implements // IJavaReconcilingListener { interface ITextConverter { - void customizeDocumentCommand(IDocument document, DocumentCommand command); + void customizeDocumentCommand(IDocument document, DocumentCommand command); }; // class AdaptedSourceViewer extends JavaSourceViewer { @@ -265,118 +265,118 @@ public class PHPUnitEditor extends PHPEditor { //implements // }; class AdaptedSourceViewer extends JavaSourceViewer { - private List fTextConverters; - - private boolean fIgnoreTextConverters = false; - - // private JavaCorrectionAssistant fCorrectionAssistant; - - public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, - boolean showAnnotationsOverview, int styles, IPreferenceStore store) { - super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store); - } - - public IContentAssistant getContentAssistant() { - return fContentAssistant; - } - - /* - * @see ITextOperationTarget#doOperation(int) - */ - public void doOperation(int operation) { - - if (getTextWidget() == null) - return; - - switch (operation) { - case CONTENTASSIST_PROPOSALS: - String msg = fContentAssistant.showPossibleCompletions(); - setStatusLineErrorMessage(msg); - return; - // case CORRECTIONASSIST_PROPOSALS: - // msg = fCorrectionAssistant.showPossibleCompletions(); - // setStatusLineErrorMessage(msg); - // return; - case UNDO: - fIgnoreTextConverters = true; - super.doOperation(operation); - fIgnoreTextConverters = false; - return; - case REDO: - fIgnoreTextConverters = true; - super.doOperation(operation); - fIgnoreTextConverters = false; - return; - } - - super.doOperation(operation); - } - - /* - * @see ITextOperationTarget#canDoOperation(int) - */ - public boolean canDoOperation(int operation) { - // if (operation == CORRECTIONASSIST_PROPOSALS) - // return isEditable(); - - return super.canDoOperation(operation); - } - - /* - * @see org.eclipse.jface.text.source.ISourceViewerExtension2#unconfigure() - * @since 3.0 - */ - public void unconfigure() { - // if (fCorrectionAssistant != null) { - // fCorrectionAssistant.uninstall(); - // fCorrectionAssistant = null; - // } - super.unconfigure(); - } - - public void insertTextConverter(ITextConverter textConverter, int index) { - throw new UnsupportedOperationException(); - } - - public void addTextConverter(ITextConverter textConverter) { - if (fTextConverters == null) { - fTextConverters = new ArrayList(1); - fTextConverters.add(textConverter); - } else if (!fTextConverters.contains(textConverter)) - fTextConverters.add(textConverter); - } - - public void removeTextConverter(ITextConverter textConverter) { - if (fTextConverters != null) { - fTextConverters.remove(textConverter); - if (fTextConverters.size() == 0) - fTextConverters = null; - } - } - - /* - * @see TextViewer#customizeDocumentCommand(DocumentCommand) - */ - protected void customizeDocumentCommand(DocumentCommand command) { - super.customizeDocumentCommand(command); - if (!fIgnoreTextConverters && fTextConverters != null) { - for (Iterator e = fTextConverters.iterator(); e.hasNext();) - ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command); - } - } - - // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 - public void updateIndentationPrefixes() { - SourceViewerConfiguration configuration = getSourceViewerConfiguration(); - String[] types = configuration.getConfiguredContentTypes(this); - for (int i = 0; i < types.length; i++) { - String[] prefixes = configuration.getIndentPrefixes(this, types[i]); - if (prefixes != null && prefixes.length > 0) - setIndentPrefixes(prefixes, types[i]); - } - } - - /* + private List fTextConverters; + + private boolean fIgnoreTextConverters = false; + + // private JavaCorrectionAssistant fCorrectionAssistant; + + public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, + boolean showAnnotationsOverview, int styles, IPreferenceStore store) { + super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store); + } + + public IContentAssistant getContentAssistant() { + return fContentAssistant; + } + + /* + * @see ITextOperationTarget#doOperation(int) + */ + public void doOperation(int operation) { + + if (getTextWidget() == null) + return; + + switch (operation) { + case CONTENTASSIST_PROPOSALS: + String msg = fContentAssistant.showPossibleCompletions(); + setStatusLineErrorMessage(msg); + return; + // case CORRECTIONASSIST_PROPOSALS: + // msg = fCorrectionAssistant.showPossibleCompletions(); + // setStatusLineErrorMessage(msg); + // return; + case UNDO: + fIgnoreTextConverters = true; + super.doOperation(operation); + fIgnoreTextConverters = false; + return; + case REDO: + fIgnoreTextConverters = true; + super.doOperation(operation); + fIgnoreTextConverters = false; + return; + } + + super.doOperation(operation); + } + + /* + * @see ITextOperationTarget#canDoOperation(int) + */ + public boolean canDoOperation(int operation) { + // if (operation == CORRECTIONASSIST_PROPOSALS) + // return isEditable(); + + return super.canDoOperation(operation); + } + + /* + * @see org.eclipse.jface.text.source.ISourceViewerExtension2#unconfigure() + * @since 3.0 + */ + public void unconfigure() { + // if (fCorrectionAssistant != null) { + // fCorrectionAssistant.uninstall(); + // fCorrectionAssistant = null; + // } + super.unconfigure(); + } + + public void insertTextConverter(ITextConverter textConverter, int index) { + throw new UnsupportedOperationException(); + } + + public void addTextConverter(ITextConverter textConverter) { + if (fTextConverters == null) { + fTextConverters = new ArrayList(1); + fTextConverters.add(textConverter); + } else if (!fTextConverters.contains(textConverter)) + fTextConverters.add(textConverter); + } + + public void removeTextConverter(ITextConverter textConverter) { + if (fTextConverters != null) { + fTextConverters.remove(textConverter); + if (fTextConverters.size() == 0) + fTextConverters = null; + } + } + + /* + * @see TextViewer#customizeDocumentCommand(DocumentCommand) + */ + protected void customizeDocumentCommand(DocumentCommand command) { + super.customizeDocumentCommand(command); + if (!fIgnoreTextConverters && fTextConverters != null) { + for (Iterator e = fTextConverters.iterator(); e.hasNext();) + ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command); + } + } + + // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 + public void updateIndentationPrefixes() { + SourceViewerConfiguration configuration = getSourceViewerConfiguration(); + String[] types = configuration.getConfiguredContentTypes(this); + for (int i = 0; i < types.length; i++) { + String[] prefixes = configuration.getIndentPrefixes(this, types[i]); + if (prefixes != null && prefixes.length > 0) + setIndentPrefixes(prefixes, types[i]); + } + } + + /* * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper) */ public boolean requestWidgetToken(IWidgetTokenKeeper requester) { @@ -386,7 +386,7 @@ public class PHPUnitEditor extends PHPEditor { //implements return super.requestWidgetToken(requester); } - /* + /* * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, * int) * @since 3.0 @@ -399,40 +399,40 @@ public class PHPUnitEditor extends PHPEditor { //implements return super.requestWidgetToken(requester, priority); } - /* - * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration) - */ - public void configure(SourceViewerConfiguration configuration) { - super.configure(configuration); - // fCorrectionAssistant = new JavaCorrectionAssistant(CompilationUnitEditor.this); - // fCorrectionAssistant.install(this); - IAutoEditStrategy smartSemi = new SmartSemicolonAutoEditStrategy(IPHPPartitions.PHP_PARTITIONING); - prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE); - prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_DQ); - prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_SQ); - prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_HEREDOC); - } - - /* - * @see org.eclipse.jface.text.source.SourceViewer#createFormattingContext() - * @since 3.0 - */ - public IFormattingContext createFormattingContext() { - IFormattingContext context = new CommentFormattingContext(); - - Map preferences; - IJavaElement inputJavaElement = getInputJavaElement(); - IJavaProject javaProject = inputJavaElement != null ? inputJavaElement.getJavaProject() : null; - if (javaProject == null) - preferences = new HashMap(JavaCore.getOptions()); - else - preferences = new HashMap(javaProject.getOptions(true)); - - context.storeToMap(PreferenceConstants.getPreferenceStore(), preferences, false); - context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences); - - return context; - } + /* + * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration) + */ + public void configure(SourceViewerConfiguration configuration) { + super.configure(configuration); + // fCorrectionAssistant = new JavaCorrectionAssistant(CompilationUnitEditor.this); + // fCorrectionAssistant.install(this); + IAutoEditStrategy smartSemi = new SmartSemicolonAutoEditStrategy(IPHPPartitions.PHP_PARTITIONING); + prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE); + prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_DQ); + prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_SQ); + prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_HEREDOC); + } + + /* + * @see org.eclipse.jface.text.source.SourceViewer#createFormattingContext() + * @since 3.0 + */ + public IFormattingContext createFormattingContext() { + IFormattingContext context = new CommentFormattingContext(); + + Map preferences; + IJavaElement inputJavaElement = getInputJavaElement(); + IJavaProject javaProject = inputJavaElement != null ? inputJavaElement.getJavaProject() : null; + if (javaProject == null) + preferences = new HashMap(JavaCore.getOptions()); + else + preferences = new HashMap(javaProject.getOptions(true)); + + context.storeToMap(PreferenceConstants.getPreferenceStore(), preferences, false); + context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences); + + return context; + } } /** @@ -441,107 +441,107 @@ public class PHPUnitEditor extends PHPEditor { //implements * @since 3.0 */ private class RememberedSelection { - /** The remembered selection start. */ - private RememberedOffset fStartOffset = new RememberedOffset(); - - /** The remembered selection end. */ - private RememberedOffset fEndOffset = new RememberedOffset(); - - /** - * Remember current selection. - */ - public void remember() { - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 This method may be called inside an async call posted to the UI thread, - * so protect against intermediate disposal of the editor. - */ - ISourceViewer viewer = getSourceViewer(); - if (viewer != null) { - IRegion selection = getSignedSelection(viewer); - int startOffset = selection.getOffset(); - int endOffset = startOffset + selection.getLength(); - - fStartOffset.setOffset(startOffset); - fEndOffset.setOffset(endOffset); - } - } - - /** - * Restore remembered selection. - */ - public void restore() { - /* - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 This method may be called inside an async call posted to the UI thread, - * so protect against intermediate disposal of the editor. - */ - if (getSourceViewer() == null) - return; - - try { - - int startOffset, endOffset; - int revealStartOffset, revealEndOffset; - if (showsHighlightRangeOnly()) { - IJavaElement newStartElement = fStartOffset.getElement(); - startOffset = fStartOffset.getRememberedOffset(newStartElement); - revealStartOffset = fStartOffset.getRevealOffset(newStartElement, startOffset); - if (revealStartOffset == -1) - startOffset = -1; - - IJavaElement newEndElement = fEndOffset.getElement(); - endOffset = fEndOffset.getRememberedOffset(newEndElement); - revealEndOffset = fEndOffset.getRevealOffset(newEndElement, endOffset); - if (revealEndOffset == -1) - endOffset = -1; - } else { - startOffset = fStartOffset.getOffset(); - revealStartOffset = startOffset; - endOffset = fEndOffset.getOffset(); - revealEndOffset = endOffset; - } - - if (startOffset == -1) { - startOffset = endOffset; // fallback to caret offset - revealStartOffset = revealEndOffset; - } - - if (endOffset == -1) { - endOffset = startOffset; // fallback to other offset - revealEndOffset = revealStartOffset; - } - - IJavaElement element; - if (endOffset == -1) { - // fallback to element selection - element = fEndOffset.getElement(); - if (element == null) - element = fStartOffset.getElement(); - if (element != null) - setSelection(element); - return; - } - - if (isValidSelection(revealStartOffset, revealEndOffset - revealStartOffset) - && isValidSelection(startOffset, endOffset - startOffset)) - selectAndReveal(startOffset, endOffset - startOffset, revealStartOffset, revealEndOffset - revealStartOffset); - } finally { - fStartOffset.clear(); - fEndOffset.clear(); - } - } - - private boolean isValidSelection(int offset, int length) { - IDocumentProvider provider = getDocumentProvider(); - if (provider != null) { - IDocument document = provider.getDocument(getEditorInput()); - if (document != null) { - int end = offset + length; - int documentLength = document.getLength(); - return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength; - } - } - return false; - } + /** The remembered selection start. */ + private RememberedOffset fStartOffset = new RememberedOffset(); + + /** The remembered selection end. */ + private RememberedOffset fEndOffset = new RememberedOffset(); + + /** + * Remember current selection. + */ + public void remember() { + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 This method may be called inside an async call posted to the UI thread, + * so protect against intermediate disposal of the editor. + */ + ISourceViewer viewer = getSourceViewer(); + if (viewer != null) { + IRegion selection = getSignedSelection(viewer); + int startOffset = selection.getOffset(); + int endOffset = startOffset + selection.getLength(); + + fStartOffset.setOffset(startOffset); + fEndOffset.setOffset(endOffset); + } + } + + /** + * Restore remembered selection. + */ + public void restore() { + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 This method may be called inside an async call posted to the UI thread, + * so protect against intermediate disposal of the editor. + */ + if (getSourceViewer() == null) + return; + + try { + + int startOffset, endOffset; + int revealStartOffset, revealEndOffset; + if (showsHighlightRangeOnly()) { + IJavaElement newStartElement = fStartOffset.getElement(); + startOffset = fStartOffset.getRememberedOffset(newStartElement); + revealStartOffset = fStartOffset.getRevealOffset(newStartElement, startOffset); + if (revealStartOffset == -1) + startOffset = -1; + + IJavaElement newEndElement = fEndOffset.getElement(); + endOffset = fEndOffset.getRememberedOffset(newEndElement); + revealEndOffset = fEndOffset.getRevealOffset(newEndElement, endOffset); + if (revealEndOffset == -1) + endOffset = -1; + } else { + startOffset = fStartOffset.getOffset(); + revealStartOffset = startOffset; + endOffset = fEndOffset.getOffset(); + revealEndOffset = endOffset; + } + + if (startOffset == -1) { + startOffset = endOffset; // fallback to caret offset + revealStartOffset = revealEndOffset; + } + + if (endOffset == -1) { + endOffset = startOffset; // fallback to other offset + revealEndOffset = revealStartOffset; + } + + IJavaElement element; + if (endOffset == -1) { + // fallback to element selection + element = fEndOffset.getElement(); + if (element == null) + element = fStartOffset.getElement(); + if (element != null) + setSelection(element); + return; + } + + if (isValidSelection(revealStartOffset, revealEndOffset - revealStartOffset) + && isValidSelection(startOffset, endOffset - startOffset)) + selectAndReveal(startOffset, endOffset - startOffset, revealStartOffset, revealEndOffset - revealStartOffset); + } finally { + fStartOffset.clear(); + fEndOffset.clear(); + } + } + + private boolean isValidSelection(int offset, int length) { + IDocumentProvider provider = getDocumentProvider(); + if (provider != null) { + IDocument document = provider.getDocument(getEditorInput()); + if (document != null) { + int end = offset + length; + int documentLength = document.getLength(); + return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength; + } + } + return false; + } } @@ -551,610 +551,610 @@ public class PHPUnitEditor extends PHPEditor { //implements * @since 3.0 */ private class RememberedOffset { - /** Remembered line for the given offset */ - private int fLine; - - /** Remembered column for the given offset */ - private int fColumn; - - /** Remembered Java element for the given offset */ - private IJavaElement fElement; - - /** Remembered Java element line for the given offset */ - private int fElementLine; - - /** - * Store visual properties of the given offset. - * - * @param offset - * Offset in the document - */ - public void setOffset(int offset) { - try { - IDocument document = getSourceViewer().getDocument(); - fLine = document.getLineOfOffset(offset); - fColumn = offset - document.getLineOffset(fLine); - fElement = getElementAt(offset, true); - - fElementLine = -1; - if (fElement instanceof IMember) { - ISourceRange range = ((IMember) fElement).getNameRange(); - if (range != null) - fElementLine = document.getLineOfOffset(range.getOffset()); - } - if (fElementLine == -1) - fElementLine = document.getLineOfOffset(getOffset(fElement)); - } catch (BadLocationException e) { - // should not happen - PHPeclipsePlugin.log(e); - clear(); - } catch (JavaModelException e) { - // should not happen - PHPeclipsePlugin.log(e.getStatus()); - clear(); - } - } - - /** - * Return offset recomputed from stored visual properties. - * - * @return Offset in the document - */ - public int getOffset() { - IJavaElement newElement = getElement(); - - int offset = getRememberedOffset(newElement); - - if (offset != -1 && !containsOffset(newElement, offset) && (offset == 0 || !containsOffset(newElement, offset - 1))) - return -1; - - return offset; - } - - /** - * Return offset recomputed from stored visual properties. - * - * @param newElement - * Enclosing element - * @return Offset in the document - */ - public int getRememberedOffset(IJavaElement newElement) { - try { - if (newElement == null) - return -1; - - IDocument document = getSourceViewer().getDocument(); - int newElementLine = -1; - if (newElement instanceof IMember) { - ISourceRange range = ((IMember) newElement).getNameRange(); - if (range != null) - newElementLine = document.getLineOfOffset(range.getOffset()); - } - if (newElementLine == -1) - newElementLine = document.getLineOfOffset(getOffset(newElement)); - if (newElementLine == -1) - return -1; - - int newLine = fLine + newElementLine - fElementLine; - if (newLine < 0 || newLine >= document.getNumberOfLines()) - return -1; - int maxColumn = document.getLineLength(newLine); - String lineDelimiter = document.getLineDelimiter(newLine); - if (lineDelimiter != null) - maxColumn = maxColumn - lineDelimiter.length(); - int offset; - if (fColumn > maxColumn) - offset = document.getLineOffset(newLine) + maxColumn; - else - offset = document.getLineOffset(newLine) + fColumn; - - return offset; - } catch (BadLocationException e) { - // should not happen - PHPeclipsePlugin.log(e); - return -1; - } catch (JavaModelException e) { - // should not happen - PHPeclipsePlugin.log(e.getStatus()); - return -1; - } - } - - /** - * Returns the offset used to reveal the given element based on the given selection offset. - * - * @param element - * the element - * @param offset - * the selection offset - * @return the offset to reveal the given element based on the given selection offset - */ - public int getRevealOffset(IJavaElement element, int offset) { - if (element == null || offset == -1) - return -1; - - if (containsOffset(element, offset)) { - if (offset > 0) { - IJavaElement alternateElement = getElementAt(offset, false); - if (element.getHandleIdentifier().equals(alternateElement.getParent().getHandleIdentifier())) - return offset - 1; // Solves test case 2 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3 - } - return offset; - } else if (offset > 0 && containsOffset(element, offset - 1)) - return offset - 1; // Solves test case 1 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3 - - return -1; - } - - /** - * Return Java element recomputed from stored visual properties. - * - * @return Java element - */ - public IJavaElement getElement() { - if (fElement == null) - return null; - - return findElement(fElement); - } - - /** - * Clears the stored position - */ - public void clear() { - fLine = -1; - fColumn = -1; - fElement = null; - fElementLine = -1; - } - - /** - * Does the given Java element contain the given offset? - * - * @param element - * Java element - * @param offset - * Offset - * @return true iff the Java element contains the offset - */ - private boolean containsOffset(IJavaElement element, int offset) { - int elementOffset = getOffset(element); - int elementLength = getLength(element); - return (elementOffset > -1 && elementLength > -1) ? (offset >= elementOffset && offset < elementOffset + elementLength) - : false; - } - - /** - * Returns the offset of the given Java element. - * - * @param element - * Java element - * @return Offset of the given Java element - */ - private int getOffset(IJavaElement element) { - if (element instanceof ISourceReference) { - ISourceReference sr = (ISourceReference) element; - try { - ISourceRange srcRange = sr.getSourceRange(); - if (srcRange != null) - return srcRange.getOffset(); - } catch (JavaModelException e) { - } - } - return -1; - } - - /** - * Returns the length of the given Java element. - * - * @param element - * Java element - * @return Length of the given Java element - */ - private int getLength(IJavaElement element) { - if (element instanceof ISourceReference) { - ISourceReference sr = (ISourceReference) element; - try { - ISourceRange srcRange = sr.getSourceRange(); - if (srcRange != null) - return srcRange.getLength(); - } catch (JavaModelException e) { - } - } - return -1; - } - - /** - * Returns the updated java element for the old java element. - * - * @param element - * Old Java element - * @return Updated Java element - */ - private IJavaElement findElement(IJavaElement element) { - - if (element == null) - return null; - - IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); - ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); - - if (unit != null) { - try { - - synchronized (unit) { - // unit.reconcile(ICompilationUnit.NO_AST, false, null, null); - unit.reconcile(); - } - IJavaElement[] findings = unit.findElements(element); - if (findings != null && findings.length > 0) - return findings[0]; - - } catch (JavaModelException x) { - PHPeclipsePlugin.log(x.getStatus()); - // nothing found, be tolerant and go on - } - } - - return null; - } + /** Remembered line for the given offset */ + private int fLine; + + /** Remembered column for the given offset */ + private int fColumn; + + /** Remembered Java element for the given offset */ + private IJavaElement fElement; + + /** Remembered Java element line for the given offset */ + private int fElementLine; + + /** + * Store visual properties of the given offset. + * + * @param offset + * Offset in the document + */ + public void setOffset(int offset) { + try { + IDocument document = getSourceViewer().getDocument(); + fLine = document.getLineOfOffset(offset); + fColumn = offset - document.getLineOffset(fLine); + fElement = getElementAt(offset, true); + + fElementLine = -1; + if (fElement instanceof IMember) { + ISourceRange range = ((IMember) fElement).getNameRange(); + if (range != null) + fElementLine = document.getLineOfOffset(range.getOffset()); + } + if (fElementLine == -1) + fElementLine = document.getLineOfOffset(getOffset(fElement)); + } catch (BadLocationException e) { + // should not happen + PHPeclipsePlugin.log(e); + clear(); + } catch (JavaModelException e) { + // should not happen + PHPeclipsePlugin.log(e.getStatus()); + clear(); + } + } + + /** + * Return offset recomputed from stored visual properties. + * + * @return Offset in the document + */ + public int getOffset() { + IJavaElement newElement = getElement(); + + int offset = getRememberedOffset(newElement); + + if (offset != -1 && !containsOffset(newElement, offset) && (offset == 0 || !containsOffset(newElement, offset - 1))) + return -1; + + return offset; + } + + /** + * Return offset recomputed from stored visual properties. + * + * @param newElement + * Enclosing element + * @return Offset in the document + */ + public int getRememberedOffset(IJavaElement newElement) { + try { + if (newElement == null) + return -1; + + IDocument document = getSourceViewer().getDocument(); + int newElementLine = -1; + if (newElement instanceof IMember) { + ISourceRange range = ((IMember) newElement).getNameRange(); + if (range != null) + newElementLine = document.getLineOfOffset(range.getOffset()); + } + if (newElementLine == -1) + newElementLine = document.getLineOfOffset(getOffset(newElement)); + if (newElementLine == -1) + return -1; + + int newLine = fLine + newElementLine - fElementLine; + if (newLine < 0 || newLine >= document.getNumberOfLines()) + return -1; + int maxColumn = document.getLineLength(newLine); + String lineDelimiter = document.getLineDelimiter(newLine); + if (lineDelimiter != null) + maxColumn = maxColumn - lineDelimiter.length(); + int offset; + if (fColumn > maxColumn) + offset = document.getLineOffset(newLine) + maxColumn; + else + offset = document.getLineOffset(newLine) + fColumn; + + return offset; + } catch (BadLocationException e) { + // should not happen + PHPeclipsePlugin.log(e); + return -1; + } catch (JavaModelException e) { + // should not happen + PHPeclipsePlugin.log(e.getStatus()); + return -1; + } + } + + /** + * Returns the offset used to reveal the given element based on the given selection offset. + * + * @param element + * the element + * @param offset + * the selection offset + * @return the offset to reveal the given element based on the given selection offset + */ + public int getRevealOffset(IJavaElement element, int offset) { + if (element == null || offset == -1) + return -1; + + if (containsOffset(element, offset)) { + if (offset > 0) { + IJavaElement alternateElement = getElementAt(offset, false); + if (element.getHandleIdentifier().equals(alternateElement.getParent().getHandleIdentifier())) + return offset - 1; // Solves test case 2 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3 + } + return offset; + } else if (offset > 0 && containsOffset(element, offset - 1)) + return offset - 1; // Solves test case 1 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3 + + return -1; + } + + /** + * Return Java element recomputed from stored visual properties. + * + * @return Java element + */ + public IJavaElement getElement() { + if (fElement == null) + return null; + + return findElement(fElement); + } + + /** + * Clears the stored position + */ + public void clear() { + fLine = -1; + fColumn = -1; + fElement = null; + fElementLine = -1; + } + + /** + * Does the given Java element contain the given offset? + * + * @param element + * Java element + * @param offset + * Offset + * @return true iff the Java element contains the offset + */ + private boolean containsOffset(IJavaElement element, int offset) { + int elementOffset = getOffset(element); + int elementLength = getLength(element); + return (elementOffset > -1 && elementLength > -1) ? (offset >= elementOffset && offset < elementOffset + elementLength) + : false; + } + + /** + * Returns the offset of the given Java element. + * + * @param element + * Java element + * @return Offset of the given Java element + */ + private int getOffset(IJavaElement element) { + if (element instanceof ISourceReference) { + ISourceReference sr = (ISourceReference) element; + try { + ISourceRange srcRange = sr.getSourceRange(); + if (srcRange != null) + return srcRange.getOffset(); + } catch (JavaModelException e) { + } + } + return -1; + } + + /** + * Returns the length of the given Java element. + * + * @param element + * Java element + * @return Length of the given Java element + */ + private int getLength(IJavaElement element) { + if (element instanceof ISourceReference) { + ISourceReference sr = (ISourceReference) element; + try { + ISourceRange srcRange = sr.getSourceRange(); + if (srcRange != null) + return srcRange.getLength(); + } catch (JavaModelException e) { + } + } + return -1; + } + + /** + * Returns the updated java element for the old java element. + * + * @param element + * Old Java element + * @return Updated Java element + */ + private IJavaElement findElement(IJavaElement element) { + + if (element == null) + return null; + + IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); + ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); + + if (unit != null) { + try { + + synchronized (unit) { + // unit.reconcile(ICompilationUnit.NO_AST, false, null, null); + unit.reconcile(); + } + IJavaElement[] findings = unit.findElements(element); + if (findings != null && findings.length > 0) + return findings[0]; + + } catch (JavaModelException x) { + PHPeclipsePlugin.log(x.getStatus()); + // nothing found, be tolerant and go on + } + } + + return null; + } } static class TabConverter implements ITextConverter { - private int fTabRatio; - - private ILineTracker fLineTracker; - - public TabConverter() { - } - - public void setNumberOfSpacesPerTab(int ratio) { - fTabRatio = ratio; - } - - public void setLineTracker(ILineTracker lineTracker) { - fLineTracker = lineTracker; - } - - private int insertTabString(StringBuffer buffer, int offsetInLine) { - if (fTabRatio == 0) - return 0; - int remainder = offsetInLine % fTabRatio; - remainder = fTabRatio - remainder; - for (int i = 0; i < remainder; i++) - buffer.append(' '); - return remainder; - } - - public void customizeDocumentCommand(IDocument document, DocumentCommand command) { - String text = command.text; - if (text == null) - return; - int index = text.indexOf('\t'); - if (index > -1) { - StringBuffer buffer = new StringBuffer(); - fLineTracker.set(command.text); - int lines = fLineTracker.getNumberOfLines(); - try { - for (int i = 0; i < lines; i++) { - int offset = fLineTracker.getLineOffset(i); - int endOffset = offset + fLineTracker.getLineLength(i); - String line = text.substring(offset, endOffset); - int position = 0; - if (i == 0) { - IRegion firstLine = document.getLineInformationOfOffset(command.offset); - position = command.offset - firstLine.getOffset(); - } - int length = line.length(); - for (int j = 0; j < length; j++) { - char c = line.charAt(j); - if (c == '\t') { - position += insertTabString(buffer, position); - } else { - buffer.append(c); - ++position; - } - } - } - command.text = buffer.toString(); - } catch (BadLocationException x) { - } - } - } + private int fTabRatio; + + private ILineTracker fLineTracker; + + public TabConverter() { + } + + public void setNumberOfSpacesPerTab(int ratio) { + fTabRatio = ratio; + } + + public void setLineTracker(ILineTracker lineTracker) { + fLineTracker = lineTracker; + } + + private int insertTabString(StringBuffer buffer, int offsetInLine) { + if (fTabRatio == 0) + return 0; + int remainder = offsetInLine % fTabRatio; + remainder = fTabRatio - remainder; + for (int i = 0; i < remainder; i++) + buffer.append(' '); + return remainder; + } + + public void customizeDocumentCommand(IDocument document, DocumentCommand command) { + String text = command.text; + if (text == null) + return; + int index = text.indexOf('\t'); + if (index > -1) { + StringBuffer buffer = new StringBuffer(); + fLineTracker.set(command.text); + int lines = fLineTracker.getNumberOfLines(); + try { + for (int i = 0; i < lines; i++) { + int offset = fLineTracker.getLineOffset(i); + int endOffset = offset + fLineTracker.getLineLength(i); + String line = text.substring(offset, endOffset); + int position = 0; + if (i == 0) { + IRegion firstLine = document.getLineInformationOfOffset(command.offset); + position = command.offset - firstLine.getOffset(); + } + int length = line.length(); + for (int j = 0; j < length; j++) { + char c = line.charAt(j); + if (c == '\t') { + position += insertTabString(buffer, position); + } else { + buffer.append(c); + ++position; + } + } + } + command.text = buffer.toString(); + } catch (BadLocationException x) { + } + } + } }; private static class ExitPolicy implements LinkedPositionUI.ExitPolicy { - final char fExitCharacter; - - public ExitPolicy(char exitCharacter) { - fExitCharacter = exitCharacter; - } - - /* - * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager, - * org.eclipse.swt.events.VerifyEvent, int, int) - */ - public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length) { - if (event.character == fExitCharacter) { - if (manager.anyPositionIncludes(offset, length)) - return new ExitFlags(LinkedPositionUI.COMMIT | LinkedPositionUI.UPDATE_CARET, false); - else - return new ExitFlags(LinkedPositionUI.COMMIT, true); - } - switch (event.character) { - case '\b': - if (manager.getFirstPosition().length == 0) - return new ExitFlags(0, false); - else - return null; - case '\n': - case '\r': - return new ExitFlags(LinkedPositionUI.COMMIT, true); - default: - return null; - } - } + final char fExitCharacter; + + public ExitPolicy(char exitCharacter) { + fExitCharacter = exitCharacter; + } + + /* + * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager, + * org.eclipse.swt.events.VerifyEvent, int, int) + */ + public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length) { + if (event.character == fExitCharacter) { + if (manager.anyPositionIncludes(offset, length)) + return new ExitFlags(LinkedPositionUI.COMMIT | LinkedPositionUI.UPDATE_CARET, false); + else + return new ExitFlags(LinkedPositionUI.COMMIT, true); + } + switch (event.character) { + case '\b': + if (manager.getFirstPosition().length == 0) + return new ExitFlags(0, false); + else + return null; + case '\n': + case '\r': + return new ExitFlags(LinkedPositionUI.COMMIT, true); + default: + return null; + } + } } private static class BracketLevel { - int fOffset; + int fOffset; - int fLength; + int fLength; - LinkedPositionManager fManager; + LinkedPositionManager fManager; - LinkedPositionUI fEditor; + LinkedPositionUI fEditor; }; private class BracketInserter implements VerifyKeyListener, LinkedPositionUI.ExitListener { - private boolean fCloseBracketsPHP = true; - - private boolean fCloseStringsPHPDQ = true; - - private boolean fCloseStringsPHPSQ = true; - - private boolean fCloseBracketsHTML = true; - - private boolean fCloseStringsHTML = true; - - private int fOffset; - - private int fLength; - - public void setCloseBracketsPHPEnabled(boolean enabled) { - fCloseBracketsPHP = enabled; - } - - public void setCloseStringsPHPDQEnabled(boolean enabled) { - fCloseStringsPHPDQ = enabled; - } - - public void setCloseStringsPHPSQEnabled(boolean enabled) { - fCloseStringsPHPSQ = enabled; - } - - public void setCloseBracketsHTMLEnabled(boolean enabled) { - fCloseBracketsHTML = enabled; - } - - public void setCloseStringsHTMLEnabled(boolean enabled) { - fCloseStringsHTML = enabled; - } - - private boolean hasIdentifierToTheRight(IDocument document, int offset) { - try { - int end = offset; - IRegion endLine = document.getLineInformationOfOffset(end); - int maxEnd = endLine.getOffset() + endLine.getLength(); - while (end != maxEnd && Character.isWhitespace(document.getChar(end))) - ++end; - return end != maxEnd && Scanner.isPHPIdentifierPart(document.getChar(end)); - } catch (BadLocationException e) { - // be conservative - return true; - } - } - - private boolean hasIdentifierToTheLeft(IDocument document, int offset) { - try { - int start = offset; - IRegion startLine = document.getLineInformationOfOffset(start); - int minStart = startLine.getOffset(); - while (start != minStart && Character.isWhitespace(document.getChar(start - 1))) - --start; - return start != minStart && Scanner.isPHPIdentifierPart(document.getChar(start - 1)); - } catch (BadLocationException e) { - return true; - } - } - - private boolean hasCharacterToTheRight(IDocument document, int offset, char character) { - try { - int end = offset; - IRegion endLine = document.getLineInformationOfOffset(end); - int maxEnd = endLine.getOffset() + endLine.getLength(); - while (end != maxEnd && Character.isWhitespace(document.getChar(end))) - ++end; - return end != maxEnd && document.getChar(end) == character; - } catch (BadLocationException e) { - // be conservative - return true; - } - } - - /* - * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) - */ - public void verifyKey(VerifyEvent event) { - if (!event.doit) - return; - final ISourceViewer sourceViewer = getSourceViewer(); - IDocument document = sourceViewer.getDocument(); - final Point selection = sourceViewer.getSelectedRange(); - final int offset = selection.x; - final int length = selection.y; - try { - ITypedRegion partition = document.getPartition(offset); - String type = partition.getType(); - if (type.equals(IPHPPartitions.PHP_PARTITIONING) || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) { - // you will get IDocument.DEFAULT_CONTENT_TYPE for both PHP and HTML area - switch (event.character) { - case '(': - if (hasCharacterToTheRight(document, offset + length, '(')) - return; - // fall through - case '[': - if (!fCloseBracketsPHP) - return; - if (hasIdentifierToTheRight(document, offset + length)) - return; - // fall through - case '"': - if (event.character == '"') { - if (!fCloseStringsPHPDQ) - return; - // changed for statements like echo "" print "" - // if (hasIdentifierToTheLeft(document, offset) - // || - // hasIdentifierToTheRight(document, offset + - // length)) - if (hasIdentifierToTheRight(document, offset + length)) - return; - } - // ITypedRegion partition= - // document.getPartition(offset); - // if (! - // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) - // && - // (partition.getOffset() != offset)) - // return; - final char characterDQ = event.character; - final char closingCharacterDQ = getPeerCharacter(characterDQ); - final StringBuffer bufferDQ = new StringBuffer(); - bufferDQ.append(characterDQ); - bufferDQ.append(closingCharacterDQ); - document.replace(offset, length, bufferDQ.toString()); - LinkedPositionManager managerDQ = new LinkedPositionManager(document); - managerDQ.addPosition(offset + 1, 0); - fOffset = offset; - fLength = 2; - LinkedPositionUI editorDQ = new LinkedPositionUI(sourceViewer, managerDQ); - editorDQ.setCancelListener(this); - editorDQ.setExitPolicy(new ExitPolicy(closingCharacterDQ)); - editorDQ.setFinalCaretOffset(offset + 2); - editorDQ.enter(); - IRegion newSelectionDQ = editorDQ.getSelectedRegion(); - sourceViewer.setSelectedRange(newSelectionDQ.getOffset(), newSelectionDQ.getLength()); - event.doit = false; - break; - // fall through - case '\'': - if (event.character == '\'') { - if (!fCloseStringsPHPSQ) - return; - // changed for statements like echo "" print "" - // if (hasIdentifierToTheLeft(document, offset) - // || - // hasIdentifierToTheRight(document, offset + - // length)) - if (hasIdentifierToTheRight(document, offset + length)) - return; - } - // ITypedRegion partition= - // document.getPartition(offset); - // if (! - // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) - // && - // (partition.getOffset() != offset)) - // return; - final char characterSQ = event.character; - final char closingCharacterSQ = getPeerCharacter(characterSQ); - final StringBuffer bufferSQ = new StringBuffer(); - bufferSQ.append(characterSQ); - bufferSQ.append(closingCharacterSQ); - document.replace(offset, length, bufferSQ.toString()); - LinkedPositionManager managerSQ = new LinkedPositionManager(document); - managerSQ.addPosition(offset + 1, 0); - fOffset = offset; - fLength = 2; - LinkedPositionUI editorSQ = new LinkedPositionUI(sourceViewer, managerSQ); - editorSQ.setCancelListener(this); - editorSQ.setExitPolicy(new ExitPolicy(closingCharacterSQ)); - editorSQ.setFinalCaretOffset(offset + 2); - editorSQ.enter(); - IRegion newSelectionSQ = editorSQ.getSelectedRegion(); - sourceViewer.setSelectedRange(newSelectionSQ.getOffset(), newSelectionSQ.getLength()); - event.doit = false; - } - } - // } else if (type.equals(IPHPPartitions.HTML)) { - // switch (event.character) { - // case '(': - // if (hasCharacterToTheRight(document, offset + length, '(')) - // return; - // // fall through - // case '[': - // if (!fCloseBracketsHTML) - // return; - // if (hasIdentifierToTheRight(document, offset + length)) - // return; - // // fall through - // case '"': - // if (event.character == '"') { - // if (!fCloseStringsHTML) - // return; - // if (hasIdentifierToTheLeft(document, offset) - // || hasIdentifierToTheRight(document, offset + length)) - // return; - // } - // // ITypedRegion partition= - // // document.getPartition(offset); - // // if (! - // // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) - // // && - // // (partition.getOffset() != offset)) - // // return; - // final char character = event.character; - // final char closingCharacter = getPeerCharacter(character); - // final StringBuffer buffer = new StringBuffer(); - // buffer.append(character); - // buffer.append(closingCharacter); - // document.replace(offset, length, buffer.toString()); - // LinkedPositionManager manager = new LinkedPositionManager(document); - // manager.addPosition(offset + 1, 0); - // fOffset = offset; - // fLength = 2; - // LinkedPositionUI editor = new LinkedPositionUI(sourceViewer, - // manager); - // editor.setCancelListener(this); - // editor.setExitPolicy(new ExitPolicy(closingCharacter)); - // editor.setFinalCaretOffset(offset + 2); - // editor.enter(); - // IRegion newSelection = editor.getSelectedRegion(); - // sourceViewer.setSelectedRange(newSelection.getOffset(), - // newSelection.getLength()); - // event.doit = false; - // } - // } - } catch (BadLocationException e) { - } - } - - /* - * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean) - */ - public void exit(boolean accept) { - if (accept) - return; - // remove brackets - try { - final ISourceViewer sourceViewer = getSourceViewer(); - IDocument document = sourceViewer.getDocument(); - document.replace(fOffset, fLength, null); - } catch (BadLocationException e) { - } - } + private boolean fCloseBracketsPHP = true; + + private boolean fCloseStringsPHPDQ = true; + + private boolean fCloseStringsPHPSQ = true; + + private boolean fCloseBracketsHTML = true; + + private boolean fCloseStringsHTML = true; + + private int fOffset; + + private int fLength; + + public void setCloseBracketsPHPEnabled(boolean enabled) { + fCloseBracketsPHP = enabled; + } + + public void setCloseStringsPHPDQEnabled(boolean enabled) { + fCloseStringsPHPDQ = enabled; + } + + public void setCloseStringsPHPSQEnabled(boolean enabled) { + fCloseStringsPHPSQ = enabled; + } + + public void setCloseBracketsHTMLEnabled(boolean enabled) { + fCloseBracketsHTML = enabled; + } + + public void setCloseStringsHTMLEnabled(boolean enabled) { + fCloseStringsHTML = enabled; + } + + private boolean hasIdentifierToTheRight(IDocument document, int offset) { + try { + int end = offset; + IRegion endLine = document.getLineInformationOfOffset(end); + int maxEnd = endLine.getOffset() + endLine.getLength(); + while (end != maxEnd && Character.isWhitespace(document.getChar(end))) + ++end; + return end != maxEnd && Scanner.isPHPIdentifierPart(document.getChar(end)); + } catch (BadLocationException e) { + // be conservative + return true; + } + } + + private boolean hasIdentifierToTheLeft(IDocument document, int offset) { + try { + int start = offset; + IRegion startLine = document.getLineInformationOfOffset(start); + int minStart = startLine.getOffset(); + while (start != minStart && Character.isWhitespace(document.getChar(start - 1))) + --start; + return start != minStart && Scanner.isPHPIdentifierPart(document.getChar(start - 1)); + } catch (BadLocationException e) { + return true; + } + } + + private boolean hasCharacterToTheRight(IDocument document, int offset, char character) { + try { + int end = offset; + IRegion endLine = document.getLineInformationOfOffset(end); + int maxEnd = endLine.getOffset() + endLine.getLength(); + while (end != maxEnd && Character.isWhitespace(document.getChar(end))) + ++end; + return end != maxEnd && document.getChar(end) == character; + } catch (BadLocationException e) { + // be conservative + return true; + } + } + + /* + * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) + */ + public void verifyKey(VerifyEvent event) { + if (!event.doit) + return; + final ISourceViewer sourceViewer = getSourceViewer(); + IDocument document = sourceViewer.getDocument(); + final Point selection = sourceViewer.getSelectedRange(); + final int offset = selection.x; + final int length = selection.y; + try { + ITypedRegion partition = document.getPartition(offset); + String type = partition.getType(); + if (type.equals(IPHPPartitions.PHP_PARTITIONING) || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) { + // you will get IDocument.DEFAULT_CONTENT_TYPE for both PHP and HTML area + switch (event.character) { + case '(': + if (hasCharacterToTheRight(document, offset + length, '(')) + return; + // fall through + case '[': + if (!fCloseBracketsPHP) + return; + if (hasIdentifierToTheRight(document, offset + length)) + return; + // fall through + case '"': + if (event.character == '"') { + if (!fCloseStringsPHPDQ) + return; + // changed for statements like echo "" print "" + // if (hasIdentifierToTheLeft(document, offset) + // || + // hasIdentifierToTheRight(document, offset + + // length)) + if (hasIdentifierToTheRight(document, offset + length)) + return; + } + // ITypedRegion partition= + // document.getPartition(offset); + // if (! + // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) + // && + // (partition.getOffset() != offset)) + // return; + final char characterDQ = event.character; + final char closingCharacterDQ = getPeerCharacter(characterDQ); + final StringBuffer bufferDQ = new StringBuffer(); + bufferDQ.append(characterDQ); + bufferDQ.append(closingCharacterDQ); + document.replace(offset, length, bufferDQ.toString()); + LinkedPositionManager managerDQ = new LinkedPositionManager(document); + managerDQ.addPosition(offset + 1, 0); + fOffset = offset; + fLength = 2; + LinkedPositionUI editorDQ = new LinkedPositionUI(sourceViewer, managerDQ); + editorDQ.setCancelListener(this); + editorDQ.setExitPolicy(new ExitPolicy(closingCharacterDQ)); + editorDQ.setFinalCaretOffset(offset + 2); + editorDQ.enter(); + IRegion newSelectionDQ = editorDQ.getSelectedRegion(); + sourceViewer.setSelectedRange(newSelectionDQ.getOffset(), newSelectionDQ.getLength()); + event.doit = false; + break; + // fall through + case '\'': + if (event.character == '\'') { + if (!fCloseStringsPHPSQ) + return; + // changed for statements like echo "" print "" + // if (hasIdentifierToTheLeft(document, offset) + // || + // hasIdentifierToTheRight(document, offset + + // length)) + if (hasIdentifierToTheRight(document, offset + length)) + return; + } + // ITypedRegion partition= + // document.getPartition(offset); + // if (! + // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) + // && + // (partition.getOffset() != offset)) + // return; + final char characterSQ = event.character; + final char closingCharacterSQ = getPeerCharacter(characterSQ); + final StringBuffer bufferSQ = new StringBuffer(); + bufferSQ.append(characterSQ); + bufferSQ.append(closingCharacterSQ); + document.replace(offset, length, bufferSQ.toString()); + LinkedPositionManager managerSQ = new LinkedPositionManager(document); + managerSQ.addPosition(offset + 1, 0); + fOffset = offset; + fLength = 2; + LinkedPositionUI editorSQ = new LinkedPositionUI(sourceViewer, managerSQ); + editorSQ.setCancelListener(this); + editorSQ.setExitPolicy(new ExitPolicy(closingCharacterSQ)); + editorSQ.setFinalCaretOffset(offset + 2); + editorSQ.enter(); + IRegion newSelectionSQ = editorSQ.getSelectedRegion(); + sourceViewer.setSelectedRange(newSelectionSQ.getOffset(), newSelectionSQ.getLength()); + event.doit = false; + } + } + // } else if (type.equals(IPHPPartitions.HTML)) { + // switch (event.character) { + // case '(': + // if (hasCharacterToTheRight(document, offset + length, '(')) + // return; + // // fall through + // case '[': + // if (!fCloseBracketsHTML) + // return; + // if (hasIdentifierToTheRight(document, offset + length)) + // return; + // // fall through + // case '"': + // if (event.character == '"') { + // if (!fCloseStringsHTML) + // return; + // if (hasIdentifierToTheLeft(document, offset) + // || hasIdentifierToTheRight(document, offset + length)) + // return; + // } + // // ITypedRegion partition= + // // document.getPartition(offset); + // // if (! + // // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) + // // && + // // (partition.getOffset() != offset)) + // // return; + // final char character = event.character; + // final char closingCharacter = getPeerCharacter(character); + // final StringBuffer buffer = new StringBuffer(); + // buffer.append(character); + // buffer.append(closingCharacter); + // document.replace(offset, length, buffer.toString()); + // LinkedPositionManager manager = new LinkedPositionManager(document); + // manager.addPosition(offset + 1, 0); + // fOffset = offset; + // fLength = 2; + // LinkedPositionUI editor = new LinkedPositionUI(sourceViewer, + // manager); + // editor.setCancelListener(this); + // editor.setExitPolicy(new ExitPolicy(closingCharacter)); + // editor.setFinalCaretOffset(offset + 2); + // editor.enter(); + // IRegion newSelection = editor.getSelectedRegion(); + // sourceViewer.setSelectedRange(newSelection.getOffset(), + // newSelection.getLength()); + // event.doit = false; + // } + // } + } catch (BadLocationException e) { + } + } + + /* + * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean) + */ + public void exit(boolean accept) { + if (accept) + return; + // remove brackets + try { + final ISourceViewer sourceViewer = getSourceViewer(); + IDocument document = sourceViewer.getDocument(); + document.replace(fOffset, fLength, null); + } catch (BadLocationException e) { + } + } } /** The editor's save policy */ @@ -1402,160 +1402,160 @@ public class PHPUnitEditor extends PHPEditor { //implements private final Object fReconcilerLock = new Object(); public PHPUnitEditor() { - super(); - setDocumentProvider(PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider()); - setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$ - setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$ - setOutlinerContextMenuId("#PHPOutlinerContext"); //$NON-NLS-1$ - // don't set help contextId, we install our own help context - fSavePolicy = null; - fJavaEditorErrorTickUpdater = new JavaEditorErrorTickUpdater(this); + super(); + setDocumentProvider(PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider()); + setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$ + setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$ + setOutlinerContextMenuId("#PHPOutlinerContext"); //$NON-NLS-1$ + // don't set help contextId, we install our own help context + fSavePolicy = null; + fJavaEditorErrorTickUpdater = new JavaEditorErrorTickUpdater(this); } /* * @see AbstractTextEditor#createActions() */ protected void createActions() { - super.createActions(); - Action action; - // Action action= new - // TextOperationAction(PHPEditorMessages.getResourceBundle(), - // "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS); - // //$NON-NLS-1$ - // action.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS); - // setAction("CorrectionAssistProposal", action); //$NON-NLS-1$ - // markAsStateDependentAction("CorrectionAssistProposal", true); - // //$NON-NLS-1$ - //// WorkbenchHelp.setHelp(action, - // IJavaHelpContextIds.QUICK_FIX_ACTION); - action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$ - action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); - setAction("ContentAssistProposal", action); //$NON-NLS-1$ - markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, - // IJavaHelpContextIds.CONTENT_ASSIST_ACTION); - // action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), - // "ContentAssistContextInformation.", this, - // ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$ - // action - // .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION); - // setAction("ContentAssistContextInformation", action); //$NON-NLS-1$ - // markAsStateDependentAction("ContentAssistContextInformation", true); - // //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, - // IJavaHelpContextIds.PARAMETER_HINTS_ACTION); - // action= new - // TextOperationAction(PHPEditorMessages.getResourceBundle(), - // "ContentAssistCompletePrefix.", this, CONTENTASSIST_COMPLETE_PREFIX); - // //$NON-NLS-1$ - // action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_COMPLETE_PREFIX); - // setAction("ContentAssistCompletePrefix", action); //$NON-NLS-1$ - // markAsStateDependentAction("ContentAssistCompletePrefix", true); - // //$NON-NLS-1$ - //// WorkbenchHelp.setHelp(action, - // IJavaHelpContextIds.PARAMETER_HINTS_ACTION); - action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$ - action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT); - setAction("Comment", action); //$NON-NLS-1$ - markAsStateDependentAction("Comment", true); //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION); - action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$ - action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT); - setAction("Uncomment", action); //$NON-NLS-1$ - markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION); - - action = new ToggleCommentAction(PHPEditorMessages.getResourceBundle(), "ToggleComment.", this); //$NON-NLS-1$ - action.setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT); - setAction("ToggleComment", action); //$NON-NLS-1$ - markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$ - //WorkbenchHelp.setHelp(action, - // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION); - configureToggleCommentAction(); - - action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$ - action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT); - setAction("Format", action); //$NON-NLS-1$ - markAsStateDependentAction("Format", true); //$NON-NLS-1$ - markAsSelectionDependentAction("Format", true); //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION); - - // action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(), - // "AddBlockComment.", this); //$NON-NLS-1$ - // action - // .setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT); - // setAction("AddBlockComment", action); //$NON-NLS-1$ - // markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$ - // markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$ - // // WorkbenchHelp.setHelp(action, - // // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION); - // action = new RemoveBlockCommentAction( - // PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$ - // action - // .setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT); - // setAction("RemoveBlockComment", action); //$NON-NLS-1$ - // markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ - // markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, - // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION); - // action= new IndentAction(PHPEditorMessages.getResourceBundle(), - // "Indent.", this, false); //$NON-NLS-1$ - // action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT); - // setAction("Indent", action); //$NON-NLS-1$ - // markAsStateDependentAction("Indent", true); //$NON-NLS-1$ - // markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$ - //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION); - // - // action= new IndentAction(PHPEditorMessages.getResourceBundle(), - // "Indent.", this, true); //$NON-NLS-1$ - // setAction("IndentOnTab", action); //$NON-NLS-1$ - // markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$ - // markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$ - // - - action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$ - action.setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT); - setAction("AddBlockComment", action); //$NON-NLS-1$ - markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$ - markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION); - - action = new RemoveBlockCommentAction(PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$ - action.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT); - setAction("RemoveBlockComment", action); //$NON-NLS-1$ - markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ - markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ - // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION); - - // action= new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, false); //$NON-NLS-1$ - // action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT); - // setAction("Indent", action); //$NON-NLS-1$ - // markAsStateDependentAction("Indent", true); //$NON-NLS-1$ - // markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$ - //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION); - // - action = new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, true); //$NON-NLS-1$ - setAction("IndentOnTab", action); //$NON-NLS-1$ - markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$ - markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$ - - if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) { - // don't replace Shift Right - have to make sure their enablement is - // mutually exclusive - // removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT); - setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$ - } - fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); - // ActionGroup rg= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); - - // fActionGroups.addGroup(rg); - fActionGroups.addGroup(fGenerateActionGroup); - - // We have to keep the context menu group separate to have better control over positioning - fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup - // rg, - // new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT) - }); + super.createActions(); + Action action; + // Action action= new + // TextOperationAction(PHPEditorMessages.getResourceBundle(), + // "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS); + // //$NON-NLS-1$ + // action.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS); + // setAction("CorrectionAssistProposal", action); //$NON-NLS-1$ + // markAsStateDependentAction("CorrectionAssistProposal", true); + // //$NON-NLS-1$ + //// WorkbenchHelp.setHelp(action, + // IJavaHelpContextIds.QUICK_FIX_ACTION); + action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$ + action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); + setAction("ContentAssistProposal", action); //$NON-NLS-1$ + markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, + // IJavaHelpContextIds.CONTENT_ASSIST_ACTION); + // action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), + // "ContentAssistContextInformation.", this, + // ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$ + // action + // .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION); + // setAction("ContentAssistContextInformation", action); //$NON-NLS-1$ + // markAsStateDependentAction("ContentAssistContextInformation", true); + // //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, + // IJavaHelpContextIds.PARAMETER_HINTS_ACTION); + // action= new + // TextOperationAction(PHPEditorMessages.getResourceBundle(), + // "ContentAssistCompletePrefix.", this, CONTENTASSIST_COMPLETE_PREFIX); + // //$NON-NLS-1$ + // action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_COMPLETE_PREFIX); + // setAction("ContentAssistCompletePrefix", action); //$NON-NLS-1$ + // markAsStateDependentAction("ContentAssistCompletePrefix", true); + // //$NON-NLS-1$ + //// WorkbenchHelp.setHelp(action, + // IJavaHelpContextIds.PARAMETER_HINTS_ACTION); + action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$ + action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT); + setAction("Comment", action); //$NON-NLS-1$ + markAsStateDependentAction("Comment", true); //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION); + action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$ + action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT); + setAction("Uncomment", action); //$NON-NLS-1$ + markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION); + + action = new ToggleCommentAction(PHPEditorMessages.getResourceBundle(), "ToggleComment.", this); //$NON-NLS-1$ + action.setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT); + setAction("ToggleComment", action); //$NON-NLS-1$ + markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$ + //WorkbenchHelp.setHelp(action, + // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION); + configureToggleCommentAction(); + + action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$ + action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT); + setAction("Format", action); //$NON-NLS-1$ + markAsStateDependentAction("Format", true); //$NON-NLS-1$ + markAsSelectionDependentAction("Format", true); //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION); + + // action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(), + // "AddBlockComment.", this); //$NON-NLS-1$ + // action + // .setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT); + // setAction("AddBlockComment", action); //$NON-NLS-1$ + // markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$ + // markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$ + // // WorkbenchHelp.setHelp(action, + // // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION); + // action = new RemoveBlockCommentAction( + // PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$ + // action + // .setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT); + // setAction("RemoveBlockComment", action); //$NON-NLS-1$ + // markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ + // markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, + // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION); + // action= new IndentAction(PHPEditorMessages.getResourceBundle(), + // "Indent.", this, false); //$NON-NLS-1$ + // action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT); + // setAction("Indent", action); //$NON-NLS-1$ + // markAsStateDependentAction("Indent", true); //$NON-NLS-1$ + // markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$ + //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION); + // + // action= new IndentAction(PHPEditorMessages.getResourceBundle(), + // "Indent.", this, true); //$NON-NLS-1$ + // setAction("IndentOnTab", action); //$NON-NLS-1$ + // markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$ + // markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$ + // + + action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$ + action.setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT); + setAction("AddBlockComment", action); //$NON-NLS-1$ + markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$ + markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION); + + action = new RemoveBlockCommentAction(PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$ + action.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT); + setAction("RemoveBlockComment", action); //$NON-NLS-1$ + markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ + markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$ + // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION); + + // action= new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, false); //$NON-NLS-1$ + // action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT); + // setAction("Indent", action); //$NON-NLS-1$ + // markAsStateDependentAction("Indent", true); //$NON-NLS-1$ + // markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$ + //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION); + // + action = new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, true); //$NON-NLS-1$ + setAction("IndentOnTab", action); //$NON-NLS-1$ + markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$ + markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$ + + if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) { + // don't replace Shift Right - have to make sure their enablement is + // mutually exclusive + // removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT); + setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$ + } + fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); + // ActionGroup rg= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT); + + // fActionGroups.addGroup(rg); + fActionGroups.addGroup(fGenerateActionGroup); + + // We have to keep the context menu group separate to have better control over positioning + fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup + // rg, + // new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT) + }); } @@ -1563,7 +1563,7 @@ public class PHPUnitEditor extends PHPEditor { //implements * @see JavaEditor#getElementAt(int) */ protected IJavaElement getElementAt(int offset) { - return getElementAt(offset, true); + return getElementAt(offset, true); } /** @@ -1577,98 +1577,98 @@ public class PHPUnitEditor extends PHPEditor { //implements * true if working copy should be reconciled */ protected IJavaElement getElementAt(int offset, boolean reconcile) { - IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); - ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); - if (unit != null) { - try { - if (reconcile) { - synchronized (unit) { - unit.reconcile(); - } - return unit.getElementAt(offset); - } else if (unit.isConsistent()) - return unit.getElementAt(offset); - } catch (JavaModelException x) { - PHPeclipsePlugin.log(x.getStatus()); - // nothing found, be tolerant and go on - } - } - return null; + IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); + ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); + if (unit != null) { + try { + if (reconcile) { + synchronized (unit) { + unit.reconcile(); + } + return unit.getElementAt(offset); + } else if (unit.isConsistent()) + return unit.getElementAt(offset); + } catch (JavaModelException x) { + PHPeclipsePlugin.log(x.getStatus()); + // nothing found, be tolerant and go on + } + } + return null; } /* * @see JavaEditor#getCorrespondingElement(IJavaElement) */ protected IJavaElement getCorrespondingElement(IJavaElement element) { - try { - return EditorUtility.getWorkingCopy(element, true); - } catch (JavaModelException x) { - PHPeclipsePlugin.log(x.getStatus()); - // nothing found, be tolerant and go on - } - return null; + try { + return EditorUtility.getWorkingCopy(element, true); + } catch (JavaModelException x) { + PHPeclipsePlugin.log(x.getStatus()); + // nothing found, be tolerant and go on + } + return null; } public void createPartControl(Composite parent) { - super.createPartControl(parent); - // fPaintManager = new PaintManager(getSourceViewer()); - LinePainter linePainter; - linePainter = new LinePainter(getSourceViewer()); - linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224)); - // fPaintManager.addPainter(linePainter); - // if (isBracketHighlightingEnabled()) - // startBracketHighlighting(); - // if (isLineHighlightingEnabled()) - // startLineHighlighting(); - // if (isPrintMarginVisible()) - // showPrintMargin(); - // Iterator e = ANNOTATION_MAP.keySet().iterator(); - // while (e.hasNext()) { - // AnnotationType type = (AnnotationType) e.next(); - // if (isAnnotationIndicationEnabled(type)) - // startAnnotationIndication(type); - // } - if (isTabConversionEnabled()) - startTabConversion(); - // if (isOverviewRulerVisible()) - // showOverviewRuler(); - // - // Preferences preferences = - // PHPeclipsePlugin.getDefault().getPluginPreferences(); - // preferences.addPropertyChangeListener(fPropertyChangeListener); - IPreferenceStore preferenceStore = getPreferenceStore(); - boolean closeBracketsPHP = preferenceStore.getBoolean(CLOSE_BRACKETS_PHP); - boolean closeStringsPHPDQ = preferenceStore.getBoolean(CLOSE_STRINGS_DQ_PHP); - boolean closeStringsPHPSQ = preferenceStore.getBoolean(CLOSE_STRINGS_SQ_PHP); - boolean closeBracketsHTML = preferenceStore.getBoolean(CLOSE_BRACKETS_HTML); - boolean closeStringsHTML = preferenceStore.getBoolean(CLOSE_STRINGS_HTML); - fBracketInserter.setCloseBracketsPHPEnabled(closeBracketsPHP); - fBracketInserter.setCloseStringsPHPDQEnabled(closeStringsPHPDQ); - fBracketInserter.setCloseStringsPHPSQEnabled(closeStringsPHPSQ); - fBracketInserter.setCloseBracketsHTMLEnabled(closeBracketsHTML); - fBracketInserter.setCloseStringsHTMLEnabled(closeStringsHTML); - ISourceViewer sourceViewer = getSourceViewer(); - if (sourceViewer instanceof ITextViewerExtension) - ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter); + super.createPartControl(parent); + // fPaintManager = new PaintManager(getSourceViewer()); + LinePainter linePainter; + linePainter = new LinePainter(getSourceViewer()); + linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224)); + // fPaintManager.addPainter(linePainter); + // if (isBracketHighlightingEnabled()) + // startBracketHighlighting(); + // if (isLineHighlightingEnabled()) + // startLineHighlighting(); + // if (isPrintMarginVisible()) + // showPrintMargin(); + // Iterator e = ANNOTATION_MAP.keySet().iterator(); + // while (e.hasNext()) { + // AnnotationType type = (AnnotationType) e.next(); + // if (isAnnotationIndicationEnabled(type)) + // startAnnotationIndication(type); + // } + if (isTabConversionEnabled()) + startTabConversion(); + // if (isOverviewRulerVisible()) + // showOverviewRuler(); + // + // Preferences preferences = + // PHPeclipsePlugin.getDefault().getPluginPreferences(); + // preferences.addPropertyChangeListener(fPropertyChangeListener); + IPreferenceStore preferenceStore = getPreferenceStore(); + boolean closeBracketsPHP = preferenceStore.getBoolean(CLOSE_BRACKETS_PHP); + boolean closeStringsPHPDQ = preferenceStore.getBoolean(CLOSE_STRINGS_DQ_PHP); + boolean closeStringsPHPSQ = preferenceStore.getBoolean(CLOSE_STRINGS_SQ_PHP); + boolean closeBracketsHTML = preferenceStore.getBoolean(CLOSE_BRACKETS_HTML); + boolean closeStringsHTML = preferenceStore.getBoolean(CLOSE_STRINGS_HTML); + fBracketInserter.setCloseBracketsPHPEnabled(closeBracketsPHP); + fBracketInserter.setCloseStringsPHPDQEnabled(closeStringsPHPDQ); + fBracketInserter.setCloseStringsPHPSQEnabled(closeStringsPHPSQ); + fBracketInserter.setCloseBracketsHTMLEnabled(closeBracketsHTML); + fBracketInserter.setCloseStringsHTMLEnabled(closeStringsHTML); + ISourceViewer sourceViewer = getSourceViewer(); + if (sourceViewer instanceof ITextViewerExtension) + ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter); } private static char getPeerCharacter(char character) { - switch (character) { - case '(': - return ')'; - case ')': - return '('; - case '[': - return ']'; - case ']': - return '['; - case '"': - return character; - case '\'': - return character; - default: - throw new IllegalArgumentException(); - } + switch (character) { + case '(': + return ')'; + case ')': + return '('; + case '[': + return ']'; + case ']': + return '['; + case '"': + return character; + case '\'': + return character; + default: + throw new IllegalArgumentException(); + } } // private void startBracketHighlighting() { @@ -1741,23 +1741,23 @@ public class PHPUnitEditor extends PHPEditor { //implements // } private int getTabSize() { - Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences(); - return preferences.getInt(CODE_FORMATTER_TAB_SIZE); + Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences(); + return preferences.getInt(CODE_FORMATTER_TAB_SIZE); } private boolean isTabConversionEnabled() { - IPreferenceStore store = getPreferenceStore(); - return store.getBoolean(SPACES_FOR_TABS); + IPreferenceStore store = getPreferenceStore(); + return store.getBoolean(SPACES_FOR_TABS); } private Color getColor(String key) { - RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key); - return getColor(rgb); + RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key); + return getColor(rgb); } private Color getColor(RGB rgb) { - JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools(); - return textTools.getColorManager().getColor(rgb); + JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools(); + return textTools.getColorManager().getColor(rgb); } // private Color getColor(AnnotationType annotationType) { @@ -1768,30 +1768,30 @@ public class PHPUnitEditor extends PHPEditor { //implements // return null; // } public void dispose() { - ISourceViewer sourceViewer = getSourceViewer(); - if (sourceViewer instanceof ITextViewerExtension) - ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter); - // if (fPropertyChangeListener != null) { - // Preferences preferences = - // PHPeclipsePlugin.getDefault().getPluginPreferences(); - // preferences.removePropertyChangeListener(fPropertyChangeListener); - // fPropertyChangeListener = null; - // } - if (fJavaEditorErrorTickUpdater != null) { - fJavaEditorErrorTickUpdater.dispose(); - fJavaEditorErrorTickUpdater = null; - } - // if (fSelectionHistory != null) - // fSelectionHistory.dispose(); - // if (fPaintManager != null) { - // fPaintManager.dispose(); - // fPaintManager = null; - // } - if (fActionGroups != null) { - fActionGroups.dispose(); - fActionGroups = null; - } - super.dispose(); + ISourceViewer sourceViewer = getSourceViewer(); + if (sourceViewer instanceof ITextViewerExtension) + ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter); + // if (fPropertyChangeListener != null) { + // Preferences preferences = + // PHPeclipsePlugin.getDefault().getPluginPreferences(); + // preferences.removePropertyChangeListener(fPropertyChangeListener); + // fPropertyChangeListener = null; + // } + if (fJavaEditorErrorTickUpdater != null) { + fJavaEditorErrorTickUpdater.dispose(); + fJavaEditorErrorTickUpdater = null; + } + // if (fSelectionHistory != null) + // fSelectionHistory.dispose(); + // if (fPaintManager != null) { + // fPaintManager.dispose(); + // fPaintManager = null; + // } + if (fActionGroups != null) { + fActionGroups.dispose(); + fActionGroups = null; + } + super.dispose(); } // protected AnnotationType getAnnotationType(String preferenceKey) { @@ -1812,141 +1812,141 @@ public class PHPUnitEditor extends PHPEditor { //implements * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent) */ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { - try { - AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); - if (asv != null) { - String p = event.getProperty(); - if (CLOSE_BRACKETS_PHP.equals(p)) { - fBracketInserter.setCloseBracketsPHPEnabled(getPreferenceStore().getBoolean(p)); - return; - } - if (CLOSE_STRINGS_DQ_PHP.equals(p)) { - fBracketInserter.setCloseStringsPHPDQEnabled(getPreferenceStore().getBoolean(p)); - return; - } - if (CLOSE_STRINGS_SQ_PHP.equals(p)) { - fBracketInserter.setCloseStringsPHPSQEnabled(getPreferenceStore().getBoolean(p)); - return; - } - if (CLOSE_BRACKETS_HTML.equals(p)) { - fBracketInserter.setCloseBracketsHTMLEnabled(getPreferenceStore().getBoolean(p)); - return; - } - if (CLOSE_STRINGS_HTML.equals(p)) { - fBracketInserter.setCloseStringsHTMLEnabled(getPreferenceStore().getBoolean(p)); - return; - } - if (SPACES_FOR_TABS.equals(p)) { - if (isTabConversionEnabled()) - startTabConversion(); - else - stopTabConversion(); - return; - } - // if (MATCHING_BRACKETS.equals(p)) { - // if (isBracketHighlightingEnabled()) - // startBracketHighlighting(); - // else - // stopBracketHighlighting(); - // return; - // } - // if (MATCHING_BRACKETS_COLOR.equals(p)) { - // if (fBracketPainter != null) - // fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR)); - // return; - // } - // if (CURRENT_LINE.equals(p)) { - // if (isLineHighlightingEnabled()) - // startLineHighlighting(); - // else - // stopLineHighlighting(); - // return; - // } - // if (CURRENT_LINE_COLOR.equals(p)) { - // if (fLinePainter != null) { - // stopLineHighlighting(); - // startLineHighlighting(); - // } - // return; - // } - // if (PRINT_MARGIN.equals(p)) { - // if (isPrintMarginVisible()) - // showPrintMargin(); - // else - // hidePrintMargin(); - // return; - // } - // if (PRINT_MARGIN_COLOR.equals(p)) { - // if (fPrintMarginPainter != null) - // fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR)); - // return; - // } - // if (PRINT_MARGIN_COLUMN.equals(p)) { - // if (fPrintMarginPainter != null) - // fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN)); - // return; - // } - // if (OVERVIEW_RULER.equals(p)) { - // if (isOverviewRulerVisible()) - // showOverviewRuler(); - // else - // hideOverviewRuler(); - // return; - // } - // AnnotationType type = getAnnotationType(p); - // if (type != null) { - // - // AnnotationInfo info = (AnnotationInfo) - // ANNOTATION_MAP.get(type); - // if (info.fColorPreference.equals(p)) { - // Color color = getColor(type); - // if (fProblemPainter != null) { - // fProblemPainter.setColor(type, color); - // fProblemPainter.paint(IPainter.CONFIGURATION); - // } - // setColorInOverviewRuler(type, color); - // return; - // } - // - // if (info.fEditorPreference.equals(p)) { - // if (isAnnotationIndicationEnabled(type)) - // startAnnotationIndication(type); - // else - // stopAnnotationIndication(type); - // return; - // } - // - // if (info.fOverviewRulerPreference.equals(p)) { - // if (isAnnotationIndicationInOverviewRulerEnabled(type)) - // showAnnotationIndicationInOverviewRuler(type, true); - // else - // showAnnotationIndicationInOverviewRuler(type, false); - // return; - // } - // } - IContentAssistant c = asv.getContentAssistant(); - if (c instanceof ContentAssistant) - ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event); - } - } finally { - super.handlePreferenceStoreChanged(event); - } + try { + AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); + if (asv != null) { + String p = event.getProperty(); + if (CLOSE_BRACKETS_PHP.equals(p)) { + fBracketInserter.setCloseBracketsPHPEnabled(getPreferenceStore().getBoolean(p)); + return; + } + if (CLOSE_STRINGS_DQ_PHP.equals(p)) { + fBracketInserter.setCloseStringsPHPDQEnabled(getPreferenceStore().getBoolean(p)); + return; + } + if (CLOSE_STRINGS_SQ_PHP.equals(p)) { + fBracketInserter.setCloseStringsPHPSQEnabled(getPreferenceStore().getBoolean(p)); + return; + } + if (CLOSE_BRACKETS_HTML.equals(p)) { + fBracketInserter.setCloseBracketsHTMLEnabled(getPreferenceStore().getBoolean(p)); + return; + } + if (CLOSE_STRINGS_HTML.equals(p)) { + fBracketInserter.setCloseStringsHTMLEnabled(getPreferenceStore().getBoolean(p)); + return; + } + if (SPACES_FOR_TABS.equals(p)) { + if (isTabConversionEnabled()) + startTabConversion(); + else + stopTabConversion(); + return; + } + // if (MATCHING_BRACKETS.equals(p)) { + // if (isBracketHighlightingEnabled()) + // startBracketHighlighting(); + // else + // stopBracketHighlighting(); + // return; + // } + // if (MATCHING_BRACKETS_COLOR.equals(p)) { + // if (fBracketPainter != null) + // fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR)); + // return; + // } + // if (CURRENT_LINE.equals(p)) { + // if (isLineHighlightingEnabled()) + // startLineHighlighting(); + // else + // stopLineHighlighting(); + // return; + // } + // if (CURRENT_LINE_COLOR.equals(p)) { + // if (fLinePainter != null) { + // stopLineHighlighting(); + // startLineHighlighting(); + // } + // return; + // } + // if (PRINT_MARGIN.equals(p)) { + // if (isPrintMarginVisible()) + // showPrintMargin(); + // else + // hidePrintMargin(); + // return; + // } + // if (PRINT_MARGIN_COLOR.equals(p)) { + // if (fPrintMarginPainter != null) + // fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR)); + // return; + // } + // if (PRINT_MARGIN_COLUMN.equals(p)) { + // if (fPrintMarginPainter != null) + // fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN)); + // return; + // } + // if (OVERVIEW_RULER.equals(p)) { + // if (isOverviewRulerVisible()) + // showOverviewRuler(); + // else + // hideOverviewRuler(); + // return; + // } + // AnnotationType type = getAnnotationType(p); + // if (type != null) { + // + // AnnotationInfo info = (AnnotationInfo) + // ANNOTATION_MAP.get(type); + // if (info.fColorPreference.equals(p)) { + // Color color = getColor(type); + // if (fProblemPainter != null) { + // fProblemPainter.setColor(type, color); + // fProblemPainter.paint(IPainter.CONFIGURATION); + // } + // setColorInOverviewRuler(type, color); + // return; + // } + // + // if (info.fEditorPreference.equals(p)) { + // if (isAnnotationIndicationEnabled(type)) + // startAnnotationIndication(type); + // else + // stopAnnotationIndication(type); + // return; + // } + // + // if (info.fOverviewRulerPreference.equals(p)) { + // if (isAnnotationIndicationInOverviewRulerEnabled(type)) + // showAnnotationIndicationInOverviewRuler(type, true); + // else + // showAnnotationIndicationInOverviewRuler(type, false); + // return; + // } + // } + IContentAssistant c = asv.getContentAssistant(); + if (c instanceof ContentAssistant) + ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event); + } + } finally { + super.handlePreferenceStoreChanged(event); + } } /* * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) */ protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) { - AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); - if (asv != null) { - String p = event.getProperty(); - if (CODE_FORMATTER_TAB_SIZE.equals(p)) { - asv.updateIndentationPrefixes(); - if (fTabConverter != null) - fTabConverter.setNumberOfSpacesPerTab(getTabSize()); - } - } - super.handlePreferencePropertyChanged(event); + AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); + if (asv != null) { + String p = event.getProperty(); + if (CODE_FORMATTER_TAB_SIZE.equals(p)) { + asv.updateIndentationPrefixes(); + if (fTabConverter != null) + fTabConverter.setNumberOfSpacesPerTab(getTabSize()); + } + } + super.handlePreferencePropertyChanged(event); } /** @@ -1974,8 +1974,8 @@ public class PHPUnitEditor extends PHPEditor { //implements * org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int) */ protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, - boolean isOverviewRulerVisible, int styles, IPreferenceStore store) { - return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store); + boolean isOverviewRulerVisible, int styles, IPreferenceStore store) { + return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store); } // protected ISourceViewer createJavaSourceViewer(Composite parent, @@ -1983,44 +1983,44 @@ public class PHPUnitEditor extends PHPEditor { //implements // return new AdaptedSourceViewer(parent, ruler, styles); // } private boolean isValidSelection(int offset, int length) { - IDocumentProvider provider = getDocumentProvider(); - if (provider != null) { - IDocument document = provider.getDocument(getEditorInput()); - if (document != null) { - int end = offset + length; - int documentLength = document.getLength(); - return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength; - } - } - return false; + IDocumentProvider provider = getDocumentProvider(); + if (provider != null) { + IDocument document = provider.getDocument(getEditorInput()); + if (document != null) { + int end = offset + length; + int documentLength = document.getLength(); + return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength; + } + } + return false; } /* * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#getInputElement() */ protected IJavaElement getInputJavaElement() { - return PHPeclipsePlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput()); + return PHPeclipsePlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput()); } /* * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager) */ public void editorContextMenuAboutToShow(IMenuManager menu) { - super.editorContextMenuAboutToShow(menu); - ActionContext context = new ActionContext(getSelectionProvider().getSelection()); - fContextMenuGroup.setContext(context); - fContextMenuGroup.fillContextMenu(menu); - fContextMenuGroup.setContext(null); + super.editorContextMenuAboutToShow(menu); + ActionContext context = new ActionContext(getSelectionProvider().getSelection()); + fContextMenuGroup.setContext(context); + fContextMenuGroup.fillContextMenu(menu); + fContextMenuGroup.setContext(null); } /* * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput) */ protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) { - if (page != null) { - IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); - page.setInput(manager.getWorkingCopy(input)); - } + if (page != null) { + IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); + page.setInput(manager.getWorkingCopy(input)); + } } /* @@ -2048,60 +2048,60 @@ public class PHPUnitEditor extends PHPEditor { //implements */ public void doSave(IProgressMonitor progressMonitor) { - IDocumentProvider p = getDocumentProvider(); - if (p == null) { - // editor has been closed - return; - } - - if (p.isDeleted(getEditorInput())) { - - if (isSaveAsAllowed()) { - - /* - * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. Changed Behavior to make sure that if called - * inside a regular save (because of deletion of input element) there is a way to report back to the caller. - */ - performSaveAs(progressMonitor); - - } else { - - /* - * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there Missing resources. - */ - Shell shell = getSite().getShell(); - MessageDialog - .openError( - shell, - PHPEditorMessages.getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - } else { - if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE)) { - RTrimAction trimAction = new RTrimAction(); - trimAction.setActiveEditor(null, getSite().getPage().getActiveEditor()); - trimAction.run(null); - } - - setStatusLineErrorMessage(null); - - updateState(getEditorInput()); - validateState(getEditorInput()); - - IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); - ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); - - if (unit != null) { - synchronized (unit) { - performSave(false, progressMonitor); - } - } else - performSave(false, progressMonitor); - } + IDocumentProvider p = getDocumentProvider(); + if (p == null) { + // editor has been closed + return; + } + + if (p.isDeleted(getEditorInput())) { + + if (isSaveAsAllowed()) { + + /* + * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. Changed Behavior to make sure that if called + * inside a regular save (because of deletion of input element) there is a way to report back to the caller. + */ + performSaveAs(progressMonitor); + + } else { + + /* + * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there Missing resources. + */ + Shell shell = getSite().getShell(); + MessageDialog + .openError( + shell, + PHPEditorMessages.getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$ + } + + } else { + if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE)) { + RTrimAction trimAction = new RTrimAction(); + trimAction.setActiveEditor(null, getSite().getPage().getActiveEditor()); + trimAction.run(null); + } + + setStatusLineErrorMessage(null); + + updateState(getEditorInput()); + validateState(getEditorInput()); + + IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); + ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); + + if (unit != null) { + synchronized (unit) { + performSave(false, progressMonitor); + } + } else + performSave(false, progressMonitor); + } } public boolean isSaveAsAllowed() { - return true; + return true; } /** @@ -2113,78 +2113,78 @@ public class PHPUnitEditor extends PHPEditor { //implements */ protected void performSaveAs(IProgressMonitor progressMonitor) { - Shell shell = getSite().getShell(); - IEditorInput input = getEditorInput(); - - SaveAsDialog dialog = new SaveAsDialog(shell); - - IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; - if (original != null) - dialog.setOriginalFile(original); - - dialog.create(); - - IDocumentProvider provider = getDocumentProvider(); - if (provider == null) { - // editor has been programmatically closed while the dialog was open - return; - } - - if (provider.isDeleted(input) && original != null) { - String message = PHPEditorMessages.getFormattedString( - "CompilationUnitEditor.warning.save.delete", new Object[] { original.getName() }); //$NON-NLS-1$ - dialog.setErrorMessage(null); - dialog.setMessage(message, IMessageProvider.WARNING); - } - - if (dialog.open() == Window.CANCEL) { - if (progressMonitor != null) - progressMonitor.setCanceled(true); - return; - } - - IPath filePath = dialog.getResult(); - if (filePath == null) { - if (progressMonitor != null) - progressMonitor.setCanceled(true); - return; - } - - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - IFile file = workspaceRoot.getFile(filePath); - final IEditorInput newInput = new FileEditorInput(file); - - boolean success = false; - try { - - provider.aboutToChange(newInput); - getDocumentProvider().saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); - success = true; - - } catch (CoreException x) { - IStatus status = x.getStatus(); - if (status == null || status.getSeverity() != IStatus.CANCEL) - ErrorDialog - .openError( - shell, - PHPEditorMessages.getString("CompilationUnitEditor.error.saving.title2"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), x.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$ - } finally { - provider.changed(newInput); - if (success) - setInput(newInput); - } - - if (progressMonitor != null) - progressMonitor.setCanceled(!success); + Shell shell = getSite().getShell(); + IEditorInput input = getEditorInput(); + + SaveAsDialog dialog = new SaveAsDialog(shell); + + IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; + if (original != null) + dialog.setOriginalFile(original); + + dialog.create(); + + IDocumentProvider provider = getDocumentProvider(); + if (provider == null) { + // editor has been programmatically closed while the dialog was open + return; + } + + if (provider.isDeleted(input) && original != null) { + String message = PHPEditorMessages.getFormattedString( + "CompilationUnitEditor.warning.save.delete", new Object[] { original.getName() }); //$NON-NLS-1$ + dialog.setErrorMessage(null); + dialog.setMessage(message, IMessageProvider.WARNING); + } + + if (dialog.open() == Window.CANCEL) { + if (progressMonitor != null) + progressMonitor.setCanceled(true); + return; + } + + IPath filePath = dialog.getResult(); + if (filePath == null) { + if (progressMonitor != null) + progressMonitor.setCanceled(true); + return; + } + + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IFile file = workspaceRoot.getFile(filePath); + final IEditorInput newInput = new FileEditorInput(file); + + boolean success = false; + try { + + provider.aboutToChange(newInput); + getDocumentProvider().saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); + success = true; + + } catch (CoreException x) { + IStatus status = x.getStatus(); + if (status == null || status.getSeverity() != IStatus.CANCEL) + ErrorDialog + .openError( + shell, + PHPEditorMessages.getString("CompilationUnitEditor.error.saving.title2"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), x.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$ + } finally { + provider.changed(newInput); + if (success) + setInput(newInput); + } + + if (progressMonitor != null) + progressMonitor.setCanceled(!success); } /* * @see AbstractTextEditor#doSetInput(IEditorInput) */ protected void doSetInput(IEditorInput input) throws CoreException { - super.doSetInput(input); - configureTabConverter(); - configureToggleCommentAction(); + super.doSetInput(input); + configureTabConverter(); + configureToggleCommentAction(); } // /* @@ -2226,12 +2226,12 @@ public class PHPUnitEditor extends PHPEditor { //implements * @since 3.0 */ private void configureToggleCommentAction() { - IAction action = getAction("ToggleComment"); //$NON-NLS-1$ - if (action instanceof ToggleCommentAction) { - ISourceViewer sourceViewer = getSourceViewer(); - SourceViewerConfiguration configuration = getSourceViewerConfiguration(); - ((ToggleCommentAction) action).configure(sourceViewer, configuration); - } + IAction action = getAction("ToggleComment"); //$NON-NLS-1$ + if (action instanceof ToggleCommentAction) { + ISourceViewer sourceViewer = getSourceViewer(); + SourceViewerConfiguration configuration = getSourceViewerConfiguration(); + ((ToggleCommentAction) action).configure(sourceViewer, configuration); + } } // private void configureTabConverter() { @@ -2244,77 +2244,77 @@ public class PHPUnitEditor extends PHPEditor { //implements // } // } private void configureTabConverter() { - if (fTabConverter != null) { - IDocumentProvider provider = getDocumentProvider(); - if (provider instanceof ICompilationUnitDocumentProvider) { - ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider; - fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput())); - } - } + if (fTabConverter != null) { + IDocumentProvider provider = getDocumentProvider(); + if (provider instanceof ICompilationUnitDocumentProvider) { + ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider; + fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput())); + } + } } private void startTabConversion() { - if (fTabConverter == null) { - fTabConverter = new TabConverter(); - configureTabConverter(); - fTabConverter.setNumberOfSpacesPerTab(getTabSize()); - AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); - asv.addTextConverter(fTabConverter); - // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 - asv.updateIndentationPrefixes(); - } + if (fTabConverter == null) { + fTabConverter = new TabConverter(); + configureTabConverter(); + fTabConverter.setNumberOfSpacesPerTab(getTabSize()); + AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); + asv.addTextConverter(fTabConverter); + // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 + asv.updateIndentationPrefixes(); + } } private void stopTabConversion() { - if (fTabConverter != null) { - AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); - asv.removeTextConverter(fTabConverter); - // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 - asv.updateIndentationPrefixes(); - fTabConverter = null; - } + if (fTabConverter != null) { + AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer(); + asv.removeTextConverter(fTabConverter); + // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270 + asv.updateIndentationPrefixes(); + fTabConverter = null; + } } /* * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean, org.eclipse.core.runtime.IProgressMonitor) */ protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) { - // IDocumentProvider p = getDocumentProvider(); - // if (p instanceof PHPDocumentProvider) { - // PHPDocumentProvider cp = (PHPDocumentProvider) p; - // cp.setSavePolicy(fSavePolicy); - // } - // try { - // super.performSave(overwrite, progressMonitor); - // } finally { - // if (p instanceof PHPDocumentProvider) { - // PHPDocumentProvider cp = (PHPDocumentProvider) p; - // cp.setSavePolicy(null); - // } - // } - - IDocumentProvider p = getDocumentProvider(); - if (p instanceof ICompilationUnitDocumentProvider) { - ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p; - cp.setSavePolicy(fSavePolicy); - } - try { - super.performSave(overwrite, progressMonitor); - } finally { - if (p instanceof ICompilationUnitDocumentProvider) { - ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p; - cp.setSavePolicy(null); - } - } + // IDocumentProvider p = getDocumentProvider(); + // if (p instanceof PHPDocumentProvider) { + // PHPDocumentProvider cp = (PHPDocumentProvider) p; + // cp.setSavePolicy(fSavePolicy); + // } + // try { + // super.performSave(overwrite, progressMonitor); + // } finally { + // if (p instanceof PHPDocumentProvider) { + // PHPDocumentProvider cp = (PHPDocumentProvider) p; + // cp.setSavePolicy(null); + // } + // } + + IDocumentProvider p = getDocumentProvider(); + if (p instanceof ICompilationUnitDocumentProvider) { + ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p; + cp.setSavePolicy(fSavePolicy); + } + try { + super.performSave(overwrite, progressMonitor); + } finally { + if (p instanceof ICompilationUnitDocumentProvider) { + ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p; + cp.setSavePolicy(null); + } + } } /* * @see AbstractTextEditor#doSaveAs */ public void doSaveAs() { - if (askIfNonWorkbenchEncodingIsOk()) { - super.doSaveAs(); - } + if (askIfNonWorkbenchEncodingIsOk()) { + super.doSaveAs(); + } } /** @@ -2323,26 +2323,26 @@ public class PHPUnitEditor extends PHPEditor { //implements * @return if the user wants to continue */ private boolean askIfNonWorkbenchEncodingIsOk() { - IDocumentProvider provider = getDocumentProvider(); - if (provider instanceof IStorageDocumentProvider) { - IEditorInput input = getEditorInput(); - IStorageDocumentProvider storageProvider = (IStorageDocumentProvider) provider; - String encoding = storageProvider.getEncoding(input); - String defaultEncoding = storageProvider.getDefaultEncoding(); - if (encoding != null && !encoding.equals(defaultEncoding)) { - Shell shell = getSite().getShell(); - String title = PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$ - String msg; - if (input != null) - msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"), - new String[] { input.getName(), encoding }); //$NON-NLS-1$ - else - msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"), - new String[] { encoding }); //$NON-NLS-1$ - return MessageDialog.openQuestion(shell, title, msg); - } - } - return true; + IDocumentProvider provider = getDocumentProvider(); + if (provider instanceof IStorageDocumentProvider) { + IEditorInput input = getEditorInput(); + IStorageDocumentProvider storageProvider = (IStorageDocumentProvider) provider; + String encoding = storageProvider.getEncoding(input); + String defaultEncoding = storageProvider.getDefaultEncoding(); + if (encoding != null && !encoding.equals(defaultEncoding)) { + Shell shell = getSite().getShell(); + String title = PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$ + String msg; + if (input != null) + msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"), + new String[] { input.getName(), encoding }); //$NON-NLS-1$ + else + msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"), + new String[] { encoding }); //$NON-NLS-1$ + return MessageDialog.openQuestion(shell, title, msg); + } + } + return true; } /* @@ -2351,13 +2351,13 @@ public class PHPUnitEditor extends PHPEditor { //implements */ public void aboutToBeReconciled() { - // Notify AST provider - // PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement()); + // Notify AST provider + // PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement()); - // Notify listeners - Object[] listeners = fReconcilingListeners.getListeners(); - for (int i = 0, length = listeners.length; i < length; ++i) - ((IJavaReconcilingListener) listeners[i]).aboutToBeReconciled(); + // Notify listeners + Object[] listeners = fReconcilingListeners.getListeners(); + for (int i = 0, length = listeners.length; i < length; ++i) + ((IJavaReconcilingListener) listeners[i]).aboutToBeReconciled(); } /* @@ -2367,65 +2367,65 @@ public class PHPUnitEditor extends PHPEditor { //implements */ public void reconciled(CompilationUnit ast, boolean forced, IProgressMonitor progressMonitor) { - // Always notify AST provider - // PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast, getInputJavaElement()); - - // Notify listeners - // Object[] listeners = fReconcilingListeners.getListeners(); - // for (int i = 0, length= listeners.length; i < length; ++i) - // ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced, progressMonitor); - - // Update Java Outline page selection - if (!forced && !progressMonitor.isCanceled()) { - Shell shell = getSite().getShell(); - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(new Runnable() { - public void run() { - selectionChanged(); - } - }); - } - } + // Always notify AST provider + // PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast, getInputJavaElement()); + + // Notify listeners + // Object[] listeners = fReconcilingListeners.getListeners(); + // for (int i = 0, length= listeners.length; i < length; ++i) + // ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced, progressMonitor); + + // Update Java Outline page selection + if (!forced && !progressMonitor.isCanceled()) { + Shell shell = getSite().getShell(); + if (shell != null && !shell.isDisposed()) { + shell.getDisplay().asyncExec(new Runnable() { + public void run() { + selectionChanged(); + } + }); + } + } } /** * Returns the updated java element for the old java element. */ private IJavaElement findElement(IJavaElement element) { - if (element == null) - return null; - IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); - ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); - if (unit != null) { - try { - synchronized (unit) { - unit.reconcile(); - } - IJavaElement[] findings = unit.findElements(element); - if (findings != null && findings.length > 0) - return findings[0]; - } catch (JavaModelException x) { - PHPeclipsePlugin.log(x.getStatus()); - // nothing found, be tolerant and go on - } - } - return null; + if (element == null) + return null; + IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager(); + ICompilationUnit unit = manager.getWorkingCopy(getEditorInput()); + if (unit != null) { + try { + synchronized (unit) { + unit.reconcile(); + } + IJavaElement[] findings = unit.findElements(element); + if (findings != null && findings.length > 0) + return findings[0]; + } catch (JavaModelException x) { + PHPeclipsePlugin.log(x.getStatus()); + // nothing found, be tolerant and go on + } + } + return null; } /** * Returns the offset of the given Java element. */ private int getOffset(IJavaElement element) { - if (element instanceof ISourceReference) { - ISourceReference sr = (ISourceReference) element; - try { - ISourceRange srcRange = sr.getSourceRange(); - if (srcRange != null) - return srcRange.getOffset(); - } catch (JavaModelException e) { - } - } - return -1; + if (element instanceof ISourceReference) { + ISourceReference sr = (ISourceReference) element; + try { + ISourceRange srcRange = sr.getSourceRange(); + if (srcRange != null) + return srcRange.getOffset(); + } catch (JavaModelException e) { + } + } + return -1; } /* @@ -2456,12 +2456,12 @@ public class PHPUnitEditor extends PHPEditor { //implements * @see IWorkbenchPage#getActiveEditor(); */ protected final boolean isActiveEditor() { - IWorkbenchWindow window = getSite().getWorkbenchWindow(); - IWorkbenchPage page = window.getActivePage(); - if (page == null) - return false; - IEditorPart activeEditor = page.getActiveEditor(); - return activeEditor != null && activeEditor.equals(this); + IWorkbenchWindow window = getSite().getWorkbenchWindow(); + IWorkbenchPage page = window.getActivePage(); + if (page == null) + return false; + IEditorPart activeEditor = page.getActiveEditor(); + return activeEditor != null && activeEditor.equals(this); } /** @@ -2472,9 +2472,9 @@ public class PHPUnitEditor extends PHPEditor { //implements * @since 3.0 */ final void addReconcileListener(IJavaReconcilingListener listener) { - synchronized (fReconcilingListeners) { - fReconcilingListeners.add(listener); - } + synchronized (fReconcilingListeners) { + fReconcilingListeners.add(listener); + } } /** @@ -2485,28 +2485,28 @@ public class PHPUnitEditor extends PHPEditor { //implements * @since 3.0 */ final void removeReconcileListener(IJavaReconcilingListener listener) { - synchronized (fReconcilingListeners) { - fReconcilingListeners.remove(listener); - } + synchronized (fReconcilingListeners) { + fReconcilingListeners.remove(listener); + } } protected void updateStateDependentActions() { - super.updateStateDependentActions(); - fGenerateActionGroup.editorStateChanged(); + super.updateStateDependentActions(); + fGenerateActionGroup.editorStateChanged(); } /* * @see AbstractTextEditor#rememberSelection() */ protected void rememberSelection() { - fRememberedSelection.remember(); + fRememberedSelection.remember(); } /* * @see AbstractTextEditor#restoreSelection() */ protected void restoreSelection() { - fRememberedSelection.restore(); + fRememberedSelection.restore(); } /* @@ -2514,47 +2514,47 @@ public class PHPUnitEditor extends PHPEditor { //implements */ protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) { - String oldExtension = ""; //$NON-NLS-1$ - if (originalElement instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput) originalElement).getFile(); - if (file != null) { - String ext = file.getFileExtension(); - if (ext != null) - oldExtension = ext; - } - } - - String newExtension = ""; //$NON-NLS-1$ - if (movedElement instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput) movedElement).getFile(); - if (file != null) - newExtension = file.getFileExtension(); - } - - return oldExtension.equals(newExtension); + String oldExtension = ""; //$NON-NLS-1$ + if (originalElement instanceof IFileEditorInput) { + IFile file = ((IFileEditorInput) originalElement).getFile(); + if (file != null) { + String ext = file.getFileExtension(); + if (ext != null) + oldExtension = ext; + } + } + + String newExtension = ""; //$NON-NLS-1$ + if (movedElement instanceof IFileEditorInput) { + IFile file = ((IFileEditorInput) movedElement).getFile(); + if (file != null) + newExtension = file.getFileExtension(); + } + + return oldExtension.equals(newExtension); } /* * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isPrefQuickDiffAlwaysOn() */ protected boolean isPrefQuickDiffAlwaysOn() { - // reestablishes the behaviour from AbstractDecoratedTextEditor which was hacked by JavaEditor - // to disable the change bar for the class file (attached source) java editor. - IPreferenceStore store = getPreferenceStore(); - return store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON); + // reestablishes the behaviour from AbstractDecoratedTextEditor which was hacked by JavaEditor + // to disable the change bar for the class file (attached source) java editor. + IPreferenceStore store = getPreferenceStore(); + return store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON); } /* * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#getAdapter(java.lang.Class) */ public Object getAdapter(Class required) { - if (SmartBackspaceManager.class.equals(required)) { - if (getSourceViewer() instanceof JavaSourceViewer) { - return ((JavaSourceViewer) getSourceViewer()).getBackspaceManager(); - } - } + if (SmartBackspaceManager.class.equals(required)) { + if (getSourceViewer() instanceof JavaSourceViewer) { + return ((JavaSourceViewer) getSourceViewer()).getBackspaceManager(); + } + } - return super.getAdapter(required); + return super.getAdapter(required); } /** @@ -2566,7 +2566,7 @@ public class PHPUnitEditor extends PHPEditor { //implements * @return the lock reconcilers may use to synchronize on */ public Object getReconcilerLock() { - return fReconcilerLock; + return fReconcilerLock; } /* @@ -2575,10 +2575,10 @@ public class PHPUnitEditor extends PHPEditor { //implements * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorSaved() */ protected void editorSaved() { - super.editorSaved(); - ShowExternalPreviewAction a = ShowExternalPreviewAction.getInstance(); - if (a != null) { - a.refresh(ShowExternalPreviewAction.PHP_TYPE); - } + super.editorSaved(); + ShowExternalPreviewAction a = ShowExternalPreviewAction.getInstance(); + if (a != null) { + a.refresh(ShowExternalPreviewAction.PHP_TYPE); + } } } \ No newline at end of file -- 1.7.1 From b91bd2f1baeb2542dadd56e2c636f8c2e8f3d905 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sat, 21 Jan 2006 11:08:04 +0000 Subject: [PATCH 11/16] make compile in 3.2 by removing internal dependency --- .../corext/textmanipulation/MultiTextEdit.java | 32 ++++++++++---------- 1 files changed, 16 insertions(+), 16 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MultiTextEdit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MultiTextEdit.java index ae29be5..a416650 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MultiTextEdit.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MultiTextEdit.java @@ -8,8 +8,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.eclipse.core.internal.utils.Assert; import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.util.Assert; public class MultiTextEdit { @@ -29,11 +29,11 @@ public class MultiTextEdit { fChildren.add(((TextEdit)iter.next()).copy()); } } - + protected List getChildren() { return fChildren; } - + /** * Adds all TextEdits managed by the given multt text edit. * @@ -43,7 +43,7 @@ public class MultiTextEdit { Assert.isNotNull(edit); fChildren.add(edit); } - + /** * Adds a text edit. * @@ -53,7 +53,7 @@ public class MultiTextEdit { Assert.isNotNull(edit); fChildren.add(edit); } - + /** * Returns the children managed by this text edit collection. * @@ -82,19 +82,19 @@ public class MultiTextEdit { editor.add((MultiTextEdit)element); } } - + /** - * Creates and returns a copy of this text edit collection. The copy method should - * be implemented in a way so that the copy can be added to a different - * TextBuffer without causing any harm to the object from which the copy - * has been created. - * - * @return a copy of this object. - */ + * Creates and returns a copy of this text edit collection. The copy method should + * be implemented in a way so that the copy can be added to a different + * TextBuffer without causing any harm to the object from which the copy + * has been created. + * + * @return a copy of this object. + */ public MultiTextEdit copy() throws CoreException { return new MultiTextEdit(fChildren); } - + /** * Returns the TextRange that this text edit is going to * manipulate. If this method is called before the MultiTextEdit @@ -118,7 +118,7 @@ public class MultiTextEdit { } return new TextRange(start, end - start + 1); } - + /** * Returns the element modified by this text edit. The method * may return null if the modification isn't related to a @@ -131,6 +131,6 @@ public class MultiTextEdit { */ public Object getModifiedElement() { return null; - } + } } -- 1.7.1 From 644c196f02ced72571ac81b7d6bce1401599fbcd Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sat, 21 Jan 2006 11:40:33 +0000 Subject: [PATCH 12/16] removing deprecated package declaration --- net.sourceforge.phpeclipse.launching/plugin.xml | 117 +++++++++++------------ 1 files changed, 58 insertions(+), 59 deletions(-) diff --git a/net.sourceforge.phpeclipse.launching/plugin.xml b/net.sourceforge.phpeclipse.launching/plugin.xml index ba24ca5..f237d4f 100644 --- a/net.sourceforge.phpeclipse.launching/plugin.xml +++ b/net.sourceforge.phpeclipse.launching/plugin.xml @@ -8,75 +8,74 @@ class="net.sourceforge.phpdt.internal.launching.PHPLaunchingPlugin"> - - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - + point="org.eclipse.debug.core.launchConfigurationTypes"> + + + + + + + + + + + + + + - + - - + point="org.eclipse.debug.ui.consoleLineTrackers"> + + - + point="org.eclipse.debug.core.sourceLocators"> + - + \ No newline at end of file -- 1.7.1 From 88d6b2dbb42c289d86822e6f96df2a52cb2bf44b Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sat, 21 Jan 2006 11:48:06 +0000 Subject: [PATCH 13/16] removing static project references to avoid confusion on build path --- net.sourceforge.phpeclipse.launching/.project | 3 --- net.sourceforge.phpeclipse.phphelp/.project | 2 -- net.sourceforge.phpeclipse.smarty.ui/.project | 3 --- net.sourceforge.phpeclipse.xml.core/.project | 1 - net.sourceforge.phpeclipse.xml.ui/.project | 3 --- 5 files changed, 0 insertions(+), 12 deletions(-) diff --git a/net.sourceforge.phpeclipse.launching/.project b/net.sourceforge.phpeclipse.launching/.project index 25ad69f..32f6732 100644 --- a/net.sourceforge.phpeclipse.launching/.project +++ b/net.sourceforge.phpeclipse.launching/.project @@ -3,9 +3,6 @@ net.sourceforge.phpeclipse.launching - net.sourceforge.phpeclipse - net.sourceforge.phpeclipse.debug.core - net.sourceforge.phpeclipse.quantum.sql diff --git a/net.sourceforge.phpeclipse.phphelp/.project b/net.sourceforge.phpeclipse.phphelp/.project index 1fc41f3..0023760 100644 --- a/net.sourceforge.phpeclipse.phphelp/.project +++ b/net.sourceforge.phpeclipse.phphelp/.project @@ -3,8 +3,6 @@ net.sourceforge.phpeclipse.phphelp - net.sourceforge.phpeclipse - net.sourceforge.phpeclipse.quantum.sql diff --git a/net.sourceforge.phpeclipse.smarty.ui/.project b/net.sourceforge.phpeclipse.smarty.ui/.project index c1e772b..c0142b9 100644 --- a/net.sourceforge.phpeclipse.smarty.ui/.project +++ b/net.sourceforge.phpeclipse.smarty.ui/.project @@ -3,9 +3,6 @@ net.sourceforge.phpeclipse.smarty.ui - net.sf.wdte.ui - net.sf.wdte.xml.core - net.sf.wdte.xml.ui diff --git a/net.sourceforge.phpeclipse.xml.core/.project b/net.sourceforge.phpeclipse.xml.core/.project index 53683af..751d00e 100644 --- a/net.sourceforge.phpeclipse.xml.core/.project +++ b/net.sourceforge.phpeclipse.xml.core/.project @@ -3,7 +3,6 @@ net.sourceforge.phpeclipse.xml.core - net.sf.wdte.core diff --git a/net.sourceforge.phpeclipse.xml.ui/.project b/net.sourceforge.phpeclipse.xml.ui/.project index 5351da1..f47559d 100644 --- a/net.sourceforge.phpeclipse.xml.ui/.project +++ b/net.sourceforge.phpeclipse.xml.ui/.project @@ -3,9 +3,6 @@ net.sourceforge.phpeclipse.xml.ui - net.sf.wdte.core - net.sf.wdte.ui - net.sf.wdte.xml.core -- 1.7.1 From d4955d9970c1f3d0488a04286d0fb47720e9353e Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sat, 21 Jan 2006 11:57:44 +0000 Subject: [PATCH 14/16] removing even more static project references --- net.sourceforge.phpeclipse.debug.core/.project | 2 -- net.sourceforge.phpeclipse.debug.ui/.project | 4 ---- net.sourceforge.phpeclipse.ui/.project | 1 - 3 files changed, 0 insertions(+), 7 deletions(-) diff --git a/net.sourceforge.phpeclipse.debug.core/.project b/net.sourceforge.phpeclipse.debug.core/.project index 656ea67..df19cb1 100644 --- a/net.sourceforge.phpeclipse.debug.core/.project +++ b/net.sourceforge.phpeclipse.debug.core/.project @@ -3,8 +3,6 @@ net.sourceforge.phpeclipse.debug.core - net.sourceforge.phpeclipse - net.sourceforge.phpeclipse.quantum.sql diff --git a/net.sourceforge.phpeclipse.debug.ui/.project b/net.sourceforge.phpeclipse.debug.ui/.project index f01f1a2..2c41443 100644 --- a/net.sourceforge.phpeclipse.debug.ui/.project +++ b/net.sourceforge.phpeclipse.debug.ui/.project @@ -3,10 +3,6 @@ net.sourceforge.phpeclipse.debug.ui - net.sourceforge.phpeclipse - net.sourceforge.phpeclipse.debug.core - net.sourceforge.phpeclipse.launching - net.sourceforge.phpeclipse.quantum.sql diff --git a/net.sourceforge.phpeclipse.ui/.project b/net.sourceforge.phpeclipse.ui/.project index 17ea460..b58fe04 100644 --- a/net.sourceforge.phpeclipse.ui/.project +++ b/net.sourceforge.phpeclipse.ui/.project @@ -3,7 +3,6 @@ net.sourceforge.phpeclipse.ui - net.sf.wdte.core -- 1.7.1 From 927bc49b15e9a4f10e620801141d341a33c33a73 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sat, 21 Jan 2006 12:58:34 +0000 Subject: [PATCH 15/16] make compilable in 3.2 --- .../phpeclipse/phpeditor/PHPEditor.java | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index 771eea3..e692e83 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -3314,14 +3314,15 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I * true if search direction is forward, * false if backward */ - public void gotoAnnotation(boolean forward) { + public Annotation gotoAnnotation(boolean forward) { ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection(); Position position = new Position(0, 0); + Annotation annotation=null; if (false /* delayed - see bug 18316 */) { - getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position); + annotation=getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position); selectAndReveal(position.getOffset(), position.getLength()); } else /* no delay - see bug 18316 */{ - Annotation annotation = getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position); + annotation = getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position); setStatusLineErrorMessage(null); setStatusLineMessage(null); if (annotation != null) { @@ -3330,6 +3331,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I setStatusLineMessage(annotation.getText()); } } + return annotation; } /** @@ -4948,7 +4950,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I * otherwise * @since 3.0 */ - private boolean isNavigationTarget(Annotation annotation) { + protected boolean isNavigationTarget(Annotation annotation) { Preferences preferences = EditorsUI.getPluginPreferences(); AnnotationPreference preference = getAnnotationPreferenceLookup().getAnnotationPreference(annotation); // See bug 41689 -- 1.7.1 From 531786704ecb306ec642d6de4569e3d7ba108df1 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sun, 22 Jan 2006 08:58:05 +0000 Subject: [PATCH 16/16] reworked all PHP icons to use the official PHP logo. converted file icon to GIF again, because overlays don't work correctly with PNG files --- .../icons/full/obj16/php.gif | Bin 889 -> 209 bytes .../icons/full/obj16/php.png | Bin 0 -> 445 bytes net.sourceforge.phpeclipse.ui/plugin.xml | 13 +- net.sourceforge.phpeclipse/icons/ctool16/php.gif | Bin 889 -> 209 bytes net.sourceforge.phpeclipse/icons/obj16/php.gif | Bin 889 -> 209 bytes net.sourceforge.phpeclipse/icons/obj16/php.png | Bin 0 -> 445 bytes net.sourceforge.phpeclipse/icons/obj16/phpedit.gif | Bin 562 -> 578 bytes net.sourceforge.phpeclipse/icons/obj16/phpedit.png | Bin 681 -> 605 bytes .../icons/obj16/phpedit2.gif | Bin 0 -> 562 bytes net.sourceforge.phpeclipse/icons/ovr16/php_ovr.gif | Bin 0 -> 185 bytes .../icons/ovr16/php_ovr2.gif | Bin 0 -> 177 bytes .../icons/ovr16/php_ovr3.gif | Bin 0 -> 78 bytes net.sourceforge.phpeclipse/plugin.xml | 2472 ++++++++++---------- 13 files changed, 1245 insertions(+), 1240 deletions(-) create mode 100644 net.sourceforge.phpeclipse.ui/icons/full/obj16/php.png create mode 100644 net.sourceforge.phpeclipse/icons/obj16/php.png create mode 100644 net.sourceforge.phpeclipse/icons/obj16/phpedit2.gif create mode 100644 net.sourceforge.phpeclipse/icons/ovr16/php_ovr.gif create mode 100644 net.sourceforge.phpeclipse/icons/ovr16/php_ovr2.gif create mode 100644 net.sourceforge.phpeclipse/icons/ovr16/php_ovr3.gif diff --git a/net.sourceforge.phpeclipse.ui/icons/full/obj16/php.gif b/net.sourceforge.phpeclipse.ui/icons/full/obj16/php.gif index f01f87eab7e821c148b2b9a66a1ef8b2a4137845..3694fbe375fc5026785a8610663f9586d94bef63 100644 GIT binary patch literal 209 zcmZ?wbhEHb6krfwXpvwD44xGdHaj74QD*jvtelml7piq-V>*Ug& tLroqDAq*~MiX0N#J-*Lo_7UTA{xQc)F5h%Vbo=a?1*`VV6JcVo1^~@LTU!7C literal 889 zcmV-<1BU!ZNk%w1VGsZi0QUd@0000^Oi<|O>Qqu%SXN-t&)wSC;>yU^#lzL#-sW3c zW=Tj_WMg!Hfu5et zY;1M!EpSz@`ziVxedwrsZiLpvcV1|gRrKitkXMSjDe`RKSbajh*eyN6v zxPpbUhKja#dZ15HX;@lxEiOBMgQ;d|gpZQ3t*^ul4iyv?9cF8eV`z$GXo$|x-knP+mSV{V~rcB^P|q;GkyV{MyYX_bD8!E=19Wo?#UXN_=qrJSYDl$^q|y4$d} z)49LfyTIGW%;v$y-O<+Wi;kVy-0R`w^GsWwQDC7`VWLuDp;Tj|Q(~f1Vxd)Jq*Y|2 zR%N7CWTRVZs##~ISZ1VKYN%Ujs9I>IS!ktMXQf_ktW;u}U2CaZX{K0ZpkZ*ZU~jHo zY^q#pr&?&ES!bajB|2MZqD)taTxp_TY^GaipJZ~aQ(us0b+JNAa$|6+IznRy2n=U* zu3c%JYeTlt;kHLzS#gd%Kq^;Gbu-CJ^;;psW zx4zxI#N)cb-MGHly~EwS!rZ>Z-j9-=Zg6KphJ+g$86F)RBO)P3MnzIlPzeYK&d$!Vva+eEsRacE0|NsA z0RjL2{{R30A^8LW007DWEC2ui01yBW000P90F?#x diff --git a/net.sourceforge.phpeclipse.ui/icons/full/obj16/php.png b/net.sourceforge.phpeclipse.ui/icons/full/obj16/php.png new file mode 100644 index 0000000000000000000000000000000000000000..d56545c57f2085c6edf11363d2b10e3e3e6bb524 GIT binary patch literal 445 zcmV;u0Yd(XP)fuHJ}00T%L%xJ%ZjsK1w7u^1+WW99o$+1c14CRk2kgftVd-(E>|CZ{{;E`8{=dB z*zFb;f>R6*^blH_R`^`5Fgi3mU(x{~0FzPTD)B(2Tw`l<4zt<7&FvFs=l4X9{1^;+ zg-@rS0YW;!1yFhaAeSouU^Gb-OI0$NJOK52fH-haF4qVKCb8Sh9G~2=vOJ?Gp!R~erqu;G;tQ; --> + icon="icons/full/obj16/php.png" + id="net.sourceforge.phpeclipse.ui.preferences.project.PHPMiscProjectPreferences" + name="PHP Project Settings" + objectClass="org.eclipse.core.resources.IProject"> + id="net.sourceforge.phpeclipse.ui.preferences.PHPPreviewProjectPreferences" + name="PHP Browser Preview" + objectClass="org.eclipse.core.resources.IFile"> - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - + id="phpnature" + name="%naturePHP.name" + point="org.eclipse.core.resources.natures"> + + + + - - - - + id="parserbuilder" + name="PHP Builder" + point="org.eclipse.core.resources.builders"> + + + + @@ -89,8 +89,8 @@ - - + + @@ -139,15 +139,15 @@ - - - - - - - - + point="org.eclipse.team.core.fileTypes"> + + + + + + + + @@ -160,73 +160,73 @@ + point="net.sourceforge.phpeclipse.phpEditorTextHovers"> + class="net.sourceforge.phpdt.internal.ui.text.java.hover.BestMatchHover" + id="net.sourceforge.phpdt.ui.BestMatchHover" + label="%sequentialHover" + description="%sequentialHoverDescription"> + point="net.sourceforge.phpeclipse.phpEditorTextHovers"> + class="net.sourceforge.phpdt.internal.ui.text.java.hover.JavaSourceHover" + id="net.sourceforge.phpdt.ui.JavaSourceHover" + label="%sourceHover" + description="%sourceHoverDescription"> + label="%problemHover" + description="%problemHoverDescription" + class="net.sourceforge.phpdt.internal.ui.text.java.hover.ProblemHover" + id="net.sourceforge.phpdt.ui.ProblemHover"> + class="net.sourceforge.phpdt.internal.ui.text.java.hover.AnnotationHover" + id="net.sourceforge.phpdt.ui.AnnotationHover" + label="%annotationHover" + description="%annotationHoverDescription"> - - + point="org.eclipse.ui.perspectives"> + + - - - - + point="org.eclipse.ui.perspectiveExtensions"> + + + + - - - - - Create a new PHP project. - - + point="org.eclipse.ui.newWizards"> + + + + + Create a new PHP project. + + - - - Create a basic PHP file. - - - - - Create a basic HTML file. - - + + + Create a new PHP project. + + --> + + + Create a basic PHP file. + + + + + Create a basic HTML file. + + - - %ExportWizards.ObfuscatorDescription - - + + %ExportWizards.ObfuscatorDescription + + - - + point="org.eclipse.ui.ide.projectNatureImages"> + + + point="org.eclipse.ui.propertyPages"> - - - - - - - - - - - - - - - - - + objectClass="org.eclipse.core.resources.IProject" + name="%propertyPagePHPProject.name" + class="net.sourceforge.phpeclipse.preferences.PHPProjectPropertyPage" + id="net.sourceforge.phpeclipse.preferences.PHPProjectPropertyPage"> + + + + + + + --> + + + + + + + + + + + + + + + + + - - - + point="org.eclipse.ui.editors"> + + + + name="%phpEditorName" + default="true" + icon="icons/obj16/htmledit.gif" + extensions="htm,html,xhtml" + contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor" + class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor" + symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont" + id="net.sourceforge.phpeclipse.PHPUnitEditor"> + --> + name="%phpEditorName" + default="true" + icon="icons/obj16/htmledit.gif" + extensions="tpl" + contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor" + class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor" + symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont" + id="net.sourceforge.phpeclipse.PHPUnitEditor"> + --> - - - - %phpEditorFontDefintion.description - - + + + + %phpEditorFontDefintion.description + + - - - - - - - - + point="org.eclipse.ui.editors.annotationTypes"> + + + + + + + + - - - - - - - - + point="org.eclipse.ui.editors.markerAnnotationSpecification"> + + + + + + + annotationType="org.eclipse.debug.core.breakpoint" + icon="icons/full/obj16/brkp_obj.gif" + annotationImageProvider="net.sourceforge.phpeclipse.phpeditor.BreakpointImageProvider"> - + + + - + point="org.eclipse.ui.actionSets"> + -

- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - + point="org.eclipse.ui.actionSetPartAssociations"> + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + point="org.eclipse.ui.popupMenus"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + targetID="#PHPEditorContext" + id="net.sourceforge.phpeclipse.actions.popupOpenSQLTable"> + + +
--> + + + + + + + + + + + + + + + - - - - - - + targetID="#PHPEditorContext" + id="net.sourceforge.phpdt.ltk.renamePHPIdentifier"> + + --> + + + + + + - - - - + point="org.eclipse.ui.actionSets"> + + + + - + point="org.eclipse.ui.editorActions"> + - - - - - - + label="%Dummy.label" + class="net.sourceforge.phpeclipse.phpeditor.JavaSelectRulerAction" + actionID="RulerClick" + id="net.sourceforge.phpeclipse.phpeditor.JavaSelectRulerAction"> + + + + + + - - - - + point="org.eclipse.ui.popupMenus"> + + + + - - - - - - + + + + + + - - - - - + + + + + - + - - + point="org.eclipse.ui.commands"> + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + + - - + id="net.sourceforge.phpeclipse.JavaDocumentSetupParticipant" + name="%javaDocumentSetupParticipant" + point="org.eclipse.core.filebuffers.documentSetup"> + + + extensions="html,xml" + class="net.sourceforge.phpeclipse.phpeditor.HTMLDocumentSetupParticipant"> + + + --> - - + id="net.sourceforge.phpeclipse.JavaDocumentFactory" + name="%javaDocumentFactory" + point="org.eclipse.core.filebuffers.documentCreation"> + + + point="org.eclipse.ui.preferencePages"> - - - - + name="PHP" + category="net.sourceforge.phpeclipse.ui.preferencePage" + class="net.sourceforge.phpeclipse.PHPEclipseBasePreferencePage" + id="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage"> + --> + + + + - - - - - - - - - - + name="Members Sort Order" + category="net.sourceforge.phpeclipse.preferences.PHPPreferencePage" + class="net.sourceforge.phpdt.internal.ui.preferences.MembersOrderPreferencePage" + id="net.sourceforge.phpeclipse.preference.MembersOrderPreferencePage"> + + + + + + + + + --> + + + + + + + + + + - - - + name="%templatePageName" + category="net.sourceforge.phpeclipse.preferences.PHPPreferencePage" + class="net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage" + id="net.sourceforge.phpeclipse.preference.TemplatePreferencePage"> + + + --> + + + - + @@ -1268,7 +1272,7 @@ --> - + point="net.sourceforge.phpeclipse.phpElementFilters"> - - + + - - - - - - - - - - + point="org.eclipse.ui.editors.templates"> + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + point="org.eclipse.ui.bindings"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + sequence="" + contextId="net.sourceforge.phpdt.ui.phpEditorScope" + commandId="net.sourceforge.phpdt.ui.edit.text.java.show.next.problem" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> + --> + + + + + + + + -- 1.7.1