From b1567eb6fa61a048ecca820929e7c9f0215ef6e4 Mon Sep 17 00:00:00 2001 From: khartlage Date: Tue, 15 Jun 2004 20:42:31 +0000 Subject: [PATCH] RC2 compatibility --- net.sourceforge.phpeclipse/.project | 2 - net.sourceforge.phpeclipse/plugin.xml | 19 +- .../phpdt/core/ISourceManipulation.java | 1 - .../src/net/sourceforge/phpdt/core/IType.java | 1 - .../src/net/sourceforge/phpdt/core/JavaCore.java | 8190 +++++++++++--------- .../phpdt/core/compiler/ITerminalSymbols.java | 4 +- .../phpdt/core/dom/CompilationUnit.java | 10 - .../sourceforge/phpdt/core/jdom/DOMFactory.java | 2 +- .../phpdt/corext/refactoring/nls/NLSElement.java | 107 + .../phpdt/corext/refactoring/nls/NLSLine.java | 73 + .../internal/model/ExternalToolsImages.java | 19 +- .../internal/model/ExternalToolsPlugin.java | 4 +- .../registry/ExternalToolVariableRegistry.java | 5 +- .../phpdt/internal/compiler/Compiler.java | 1 + .../phpdt/internal/compiler/codegen/Label.java | 2 - .../phpdt/internal/compiler/lookup/BlockScope.java | 3 - .../compiler/lookup/CompilationUnitScope.java | 1 - .../internal/compiler/lookup/MethodScope.java | 1 - .../phpdt/internal/compiler/parser/Parser.java | 8 +- .../internal/compiler/parser/RecoveredElement.java | 1 - .../phpdt/internal/compiler/parser/Scanner.java | 10 +- .../internal/compiler/problem/ProblemReporter.java | 2 - .../internal/core/BecomeWorkingCopyOperation.java | 3 +- .../phpdt/internal/core/ClasspathEntry.java | 1 - .../internal/core/CommitWorkingCopyOperation.java | 6 +- .../phpdt/internal/core/CompilationUnit.java | 3 +- .../core/CompilationUnitProblemFinder.java | 1 - .../core/CompilationUnitStructureRequestor.java | 1 - .../core/CopyResourceElementsOperation.java | 3 +- .../internal/core/CreateElementInCUOperation.java | 8 +- .../core/CreatePackageDeclarationOperation.java | 3 - .../phpdt/internal/core/DeltaProcessingState.java | 17 - .../phpdt/internal/core/DeltaProcessor.java | 11 +- .../phpdt/internal/core/ImportContainer.java | 2 +- .../phpdt/internal/core/ImportDeclaration.java | 4 +- .../phpdt/internal/core/JavaElement.java | 5 +- .../phpdt/internal/core/JavaElementDelta.java | 2 - .../phpdt/internal/core/JavaModelInfo.java | 2 + .../phpdt/internal/core/JavaModelManager.java | 5 +- .../phpdt/internal/core/JavaModelOperation.java | 8 +- .../phpdt/internal/core/JavaProject.java | 28 +- .../internal/core/JavaProjectElementInfo.java | 1 + .../sourceforge/phpdt/internal/core/Member.java | 4 - .../phpdt/internal/core/MemberElementInfo.java | 2 + .../phpdt/internal/core/MultiOperation.java | 2 - .../phpdt/internal/core/NameLookup.java | 4 +- .../sourceforge/phpdt/internal/core/Openable.java | 6 +- .../phpdt/internal/core/PackageDeclaration.java | 3 - .../phpdt/internal/core/PackageFragment.java | 6 +- .../phpdt/internal/core/PackageFragmentRoot.java | 11 +- .../core/ReconcileWorkingCopyOperation.java | 2 - .../phpdt/internal/core/SetClasspathOperation.java | 9 - .../phpdt/internal/core/SourceField.java | 4 +- .../phpdt/internal/core/SourceMethod.java | 7 +- .../phpdt/internal/core/SourceRefElement.java | 7 +- .../phpdt/internal/core/SourceType.java | 7 +- .../core/builder/AbstractImageBuilder.java | 4 +- .../internal/core/builder/BatchImageBuilder.java | 5 - .../internal/core/builder/ClasspathDirectory.java | 1 - .../internal/core/builder/ClasspathLocation.java | 1 - .../core/builder/IncrementalImageBuilder.java | 47 +- .../phpdt/internal/core/builder/PHPBuilder.java | 6 +- .../phpdt/internal/core/builder/State.java | 6 - .../phpdt/internal/core/builder/WorkQueue.java | 2 +- .../internal/core/jdom/AbstractDOMBuilder.java | 4 +- .../phpdt/internal/core/jdom/DOMField.java | 1 + .../phpdt/internal/core/jdom/DOMImport.java | 1 - .../phpdt/internal/core/jdom/DOMInitializer.java | 1 - .../sourceforge/phpdt/internal/core/util/Util.java | 22 +- .../phpdt/internal/core/util/messages.properties | 308 + .../phpdt/internal/formatter/CodeFormatter.java | 2 +- .../internal/ui/JavaElementAdapterFactory.java | 17 +- .../internal/ui/JavaPluginImages_DeleteIt.java | 424 - .../sourceforge/phpdt/internal/ui/PHPUiImages.java | 44 +- .../ui/actions/WorkbenchRunnableAdapter.java | 4 +- .../ui/preferences/CompilerConfigurationBlock.java | 27 +- .../ui/preferences/MockupPreferenceStore.java | 273 + .../ui/preferences/OptionsConfigurationBlock.java | 190 +- .../ui/preferences/PHPEditorPreferencePage.java | 2 + .../ui/preferences/SpellingConfigurationBlock.java | 445 ++ .../ui/preferences/SpellingPreferencePage.java | 102 + .../ui/preferences/TodoTaskConfigurationBlock.java | 4 +- .../ui/text/CompositeReconcilingStrategy.java | 118 + .../internal/ui/text/java/IInvocationContext.java | 64 + .../java/hover/JavaEditorTextHoverDescriptor.java | 71 +- .../internal/ui/text/link/LinkedPositionUI.java | 2 - .../internal/ui/text/phpdoc/IHtmlTagConstants.java | 38 + .../ui/text/phpdoc/IJavaDocTagConstants.java | 56 + .../internal/ui/text/spelling/AddWordProposal.java | 108 + .../ui/text/spelling/ChangeCaseProposal.java | 51 + .../ui/text/spelling/HtmlTagDictionary.java | 59 + .../ui/text/spelling/JavaDocTagDictionary.java | 63 + .../ui/text/spelling/SpellCheckEngine.java | 338 + .../ui/text/spelling/SpellCheckIterator.java | 378 + .../ui/text/spelling/SpellReconcileDictionary.java | 52 + .../ui/text/spelling/SpellReconcileStrategy.java | 382 + .../ui/text/spelling/TaskTagDictionary.java | 91 + .../ui/text/spelling/WordCorrectionProposal.java | 182 + .../ui/text/spelling/WordIgnoreProposal.java | 107 + .../spelling/engine/AbstractSpellDictionary.java | 433 ++ .../engine/DefaultPhoneticDistanceAlgorithm.java | 103 + .../engine/DefaultPhoneticHashProvider.java | 683 ++ .../text/spelling/engine/DefaultSpellChecker.java | 350 + .../engine/IPhoneticDistanceAlgorithm.java | 31 + .../spelling/engine/IPhoneticHashProvider.java | 36 + .../ui/text/spelling/engine/ISpellCheckEngine.java | 87 + .../text/spelling/engine/ISpellCheckIterator.java | 43 + .../spelling/engine/ISpellCheckPreferenceKeys.java | 107 + .../ui/text/spelling/engine/ISpellChecker.java | 117 + .../ui/text/spelling/engine/ISpellDictionary.java | 72 + .../ui/text/spelling/engine/ISpellEvent.java | 64 + .../text/spelling/engine/ISpellEventListener.java | 29 + .../engine/LocaleSensitiveSpellDictionary.java | 61 + .../spelling/engine/PersistentSpellDictionary.java | 72 + .../text/spelling/engine/RankedWordProposal.java | 102 + .../ui/text/spelling/engine/SpellEvent.java | 109 + .../internal/ui/text/spelling/engine/package.html | 84 + .../phpdt/internal/ui/text/spelling/package.html | 70 + .../ui/text/template/DeclarationProposal.java | 2 + .../sourceforge/phpdt/ui/PreferenceConstants.java | 35 +- .../phpeclipse/PHPPerspectiveFactory.java | 19 +- .../sourceforge/phpeclipse/PHPeclipsePlugin.java | 1118 ++- .../phpeclipse/actions/IncludesScanner.java | 154 + .../actions/PHPOpenAllIncludesEditorAction.java | 212 + .../phpeclipse/builder/IdentifierIndexManager.java | 48 +- .../internal/compiler/ast/AND_AND_Expression.java | 1 - .../obfuscator/ObfuscatorPass1Exporter.java | 2 +- .../obfuscator/ObfuscatorPass2Exporter.java | 2 +- .../phpeclipse/obfuscator/PHPIdentifier.java | 34 +- .../phpeditor/BreakpointImageProvider.java | 7 +- .../CompilationUnitEditorActionContributor.java | 2 - .../phpeclipse/phpeditor/CustomBufferFactory.java | 6 +- .../phpeclipse/phpeditor/IJavaAnnotation.java | 4 +- .../phpeditor/JavaAnnotationImageProvider.java | 14 +- .../phpeclipse/phpeditor/JavaDocumentFactory.java | 1 - .../phpeclipse/phpeditor/JavaOutlinePage.java | 2 +- .../phpeditor/JavaSelectMarkerRulerAction2.java | 1 - .../phpeclipse/phpeditor/JavaSourceViewer.java | 7 +- .../phpeclipse/phpeditor/PHPAnnotationHover.java | 2 +- .../phpeclipse/phpeditor/PHPDocumentProvider.java | 16 +- .../phpeditor/PHPSourceViewerConfiguration.java | 2 +- .../phpeclipse/phpeditor/PHPSyntaxRdr.java | 2 - .../phpeclipse/phpeditor/PHPTextHover.java | 2 + .../phpeclipse/phpeditor/PHPUnitEditor.java | 9 - .../phpeditor/ShowExternalPreviewAction.java | 3 +- .../phpeclipse/phpeditor/WorkingCopyManager.java | 11 +- .../phpeditor/php/PHPCompletionProcessor.java | 26 +- 147 files changed, 12115 insertions(+), 5039 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSElement.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSLine.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/messages.properties delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaPluginImages_DeleteIt.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/MockupPreferenceStore.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingConfigurationBlock.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingPreferencePage.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/CompositeReconcilingStrategy.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/IInvocationContext.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IHtmlTagConstants.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IJavaDocTagConstants.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/AddWordProposal.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/ChangeCaseProposal.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/HtmlTagDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/JavaDocTagDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckEngine.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckIterator.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileStrategy.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/TaskTagDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordCorrectionProposal.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordIgnoreProposal.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckPreferenceKeys.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellChecker.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEvent.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEventListener.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/RankedWordProposal.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/SpellEvent.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/package.html create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/package.html create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java diff --git a/net.sourceforge.phpeclipse/.project b/net.sourceforge.phpeclipse/.project index f592e9e..f3add24 100644 --- a/net.sourceforge.phpeclipse/.project +++ b/net.sourceforge.phpeclipse/.project @@ -3,7 +3,6 @@ net.sourceforge.phpeclipse - net.sourceforge.phpeclipse net.sourceforge.phpeclipse.quantum.sql @@ -28,4 +27,3 @@ org.eclipse.pde.PluginNature - diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 2605ebe..055ac93 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -1,6 +1,5 @@ - - @@ -862,6 +861,16 @@ + + + + --> + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ISourceManipulation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ISourceManipulation.java index 449f6bb..554bbf9 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ISourceManipulation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ISourceManipulation.java @@ -10,7 +10,6 @@ *******************************************************************************/ package net.sourceforge.phpdt.core; -import org.eclipse.core.runtime.IProgressMonitor; /** * Common protocol for Java elements that support source code manipulations such diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IType.java index 9ba334d..5feecce 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IType.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IType.java @@ -10,7 +10,6 @@ *******************************************************************************/ package net.sourceforge.phpdt.core; -import org.eclipse.core.runtime.IProgressMonitor; /** * Represents either a source type in a compilation unit (either a top-level diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/JavaCore.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/JavaCore.java index 109c863..e47f5c4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/JavaCore.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/JavaCore.java @@ -39,3838 +39,4510 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import net.sourceforge.phpdt.internal.core.util.Util; import org.osgi.framework.BundleContext; public class JavaCore { -// public static HashSet OptionNames = new HashSet(20); - /** - * The plug-in identifier of the Java core support - * (value "net.sourceforge.phpeclipse") - */ -// public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core"; //$NON-NLS-1$ + // public static HashSet OptionNames = new HashSet(20); + /** + * The plug-in identifier of the Java core support (value + * "net.sourceforge.phpeclipse") + */ + // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core"; + // //$NON-NLS-1$ public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID; - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + + ".formatter.newline.openingBrace"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + + ".formatter.newline.controlStatement"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + + ".formatter.newline.elseIf"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + + ".formatter.newline.emptyBlock"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + + ".formatter.newline.clearAll"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + + ".formatter.lineSplit"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + + ".formatter.style.assignment"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + + ".formatter.tabulation.char"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + + ".formatter.tabulation.size"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String INSERT = "insert"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String NORMAL = "normal"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String COMPACT = "compact"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String TAB = "tab"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String SPACE = "space"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String ENABLED = "enabled"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String DISABLED = "disabled"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CLEAN = "clean"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_TASK_TAGS = PLUGIN_ID + + ".compiler.taskTags"; //$NON-NLS-1$ + + /** + * Name of the handle id attribute in a Java marker. + */ + protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$ + + // *************** Possible IDs for configurable options. + // ******************** + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions() + */ + public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + + ".compiler.debug.localVariable"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions() + */ + public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + + ".compiler.debug.lineNumber"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + + ".compiler.debug.sourceFile"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_PHP_VAR_DEPRECATED = PLUGIN_ID + + ".compiler.problem.phpVarDeprecatedWarning"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + + ".compiler.problem.unreachableCode"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + + ".compiler.problem.invalidImport"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + + ".compiler.problem.deprecation"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + + ".compiler.problem.unusedLocal"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + + ".compiler.problem.unusedParameter"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + + ".compiler.problem.unusedImport"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String COMPILER_COMPLIANCE = PLUGIN_ID + + ".compiler.compliance"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + + ".compiler.taskPriorities"; //$NON-NLS-1$ + + /** + * Possible configurable option value for COMPILER_TASK_PRIORITIES. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$ + + /** + * Possible configurable option value for COMPILER_TASK_PRIORITIES. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$ + + /** + * Possible configurable option value for COMPILER_TASK_PRIORITIES. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + */ + public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + + ".computeJavaBuildOrder"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + + ".builder.duplicateResourceTask"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + + ".builder.cleanOutputFolder"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + + ".incompleteClasspath"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + + ".circularClasspath"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + + ".builder.invalidClasspath"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + + ".classpath.exclusionPatterns"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + + ".classpath.multipleOutputLocations"; //$NON-NLS-1$ + + /** + * Default task tag + * + * @since 2.1 + */ + public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$ + + /** + * Default task priority + * + * @since 2.1 + */ + public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$ + + /** + * Possible configurable option ID + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + + ".formatter.space.castexpression"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + + ".codeComplete.visibilityCheck"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + + ".codeComplete.localPrefixes"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + + ".codeComplete.localSuffixes"; //$NON-NLS-1$ + + /** + * Possible configurable option ID. + * + * @see #getDefaultOptions + * @since 2.1 + */ + public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$ + + // *************** Possible values for configurable options. + // ******************** + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String GENERATE = "generate"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String PRESERVE = "preserve"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + public static final String ABORT = "abort"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String ERROR = "error"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String WARNING = "warning"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String IGNORE = "ignore"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + */ + public static final String COMPUTE = "compute"; //$NON-NLS-1$ + + /** + * Possible configurable option value. + * + * @see #getDefaultOptions + * @since 2.0 + */ + + /** + * Returns a table of all known configurable options with their default + * values. These options allow to configure the behaviour of the underlying + * components. The client may safely use the result as a template that they + * can modify and then pass to setOptions. + * + * Helper constants have been defined on JavaCore for each of the option ID + * and their possible constant values. + * + * Note: more options might be added in further releases. + * + *
+	 * 
+	 *  RECOGNIZED OPTIONS:
+	 *  COMPILER / Generating Local Variable Debug Attribute
+	 *     When generated, this attribute will enable local variable names 
+	 *     to be displayed in debugger, only in place where variables are 
+	 *     definitely assigned (.class file is then bigger)
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
+	 *      - possible values:   { "generate", "do not generate" }
+	 *      - default:           "generate"
+	 * 
+	 *  COMPILER / Generating Line Number Debug Attribute 
+	 *     When generated, this attribute will enable source code highlighting in debugger 
+	 *     (.class file is then bigger).
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
+	 *      - possible values:   { "generate", "do not generate" }
+	 *      - default:           "generate"
+	 *     
+	 *  COMPILER / Generating Source Debug Attribute 
+	 *     When generated, this attribute will enable the debugger to present the 
+	 *     corresponding source code.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
+	 *      - possible values:   { "generate", "do not generate" }
+	 *      - default:           "generate"
+	 *     
+	 *  COMPILER / Preserving Unused Local Variables
+	 *     Unless requested to preserve unused local variables (i.e. never read), the 
+	 *     compiler will optimize them out, potentially altering debugging
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
+	 *      - possible values:   { "preserve", "optimize out" }
+	 *      - default:           "preserve"
+	 *  
+	 *  COMPILER / Defining Target Java Platform
+	 *     For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
+	 *     Note that "1.4" target require to toggle compliance mode to "1.4" too.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
+	 *      - possible values:   { "1.1", "1.2", "1.3", "1.4" }
+	 *      - default:           "1.1"
+	 * 
+	 *  COMPILER / Reporting Unreachable Code
+	 *     Unreachable code can optionally be reported as an error, warning or simply 
+	 *     ignored. The bytecode generation will always optimized it out.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "error"
+	 * 
+	 *  COMPILER / Reporting Invalid Import
+	 *     An import statement that cannot be resolved might optionally be reported 
+	 *     as an error, as a warning or ignored.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "error"
+	 * 
+	 *  COMPILER / Reporting Attempt to Override Package-Default Method
+	 *     A package default method is not visible in a different package, and thus 
+	 *     cannot be overridden. When enabling this option, the compiler will signal 
+	 *     such scenarii either as an error or a warning.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Method With Constructor Name
+	 *     Naming a method with a constructor name is generally considered poor 
+	 *     style programming. When enabling this option, the compiler will signal such 
+	 *     scenarii either as an error or a warning.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Deprecation
+	 *     When enabled, the compiler will signal use of deprecated API either as an 
+	 *     error or a warning.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Deprecation Inside Deprecated Code
+	 *     When enabled, the compiler will signal use of deprecated API inside deprecated code.
+	 *     The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 * 
+	 *  COMPILER / Reporting Hidden Catch Block
+	 *     Locally to a try statement, some catch blocks may hide others , e.g.
+	 *       try {  throw new java.io.CharConversionException();
+	 *       } catch (java.io.CharConversionException e) {
+	 *       } catch (java.io.IOException e) {}. 
+	 *     When enabling this option, the compiler will issue an error or a warning for hidden 
+	 *     catch blocks corresponding to checked exceptions
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Unused Local
+	 *     When enabled, the compiler will issue an error or a warning for unused local 
+	 *     variables (i.e. variables never read from)
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 * 
+	 *  COMPILER / Reporting Unused Parameter
+	 *     When enabled, the compiler will issue an error or a warning for unused method 
+	 *     parameters (i.e. parameters never read from)
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 * 
+	 *  COMPILER / Reporting Unused Import
+	 *     When enabled, the compiler will issue an error or a warning for unused import 
+	 *     reference 
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Synthetic Access Emulation
+	 *     When enabled, the compiler will issue an error or a warning whenever it emulates 
+	 *     access to a non-accessible member of an enclosing type. Such access can have
+	 *     performance implications.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 * 
+	 *  COMPILER / Reporting Non-Externalized String Literal
+	 *     When enabled, the compiler will issue an error or a warning for non externalized 
+	 *     String literal (i.e. non tagged with //$NON-NLS-<n>$). 
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 *  
+	 *  COMPILER / Reporting Usage of 'assert' Identifier
+	 *     When enabled, the compiler will issue an error or a warning whenever 'assert' is 
+	 *     used as an identifier (reserved keyword in 1.4)
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 *  
+	 *  COMPILER / Reporting Usage of expression receiver on static invocation/field access
+	 *     When enabled, the compiler will issue an error or a warning whenever a static field
+	 *     or method is accessed with an expression receiver.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 *  
+	 *  COMPILER / Reporting Assignment with no effect
+	 *     When enabled, the compiler will issue an error or a warning whenever an assignment
+	 *     has no effect (e.g 'x = x').
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 *  
+	 *  COMPILER / Setting Source Compatibility Mode
+	 *     Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
+	 *     reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
+	 *    level should be set to "1.4" and the compliance mode should be "1.4".
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.source"
+	 *      - possible values:   { "1.3", "1.4" }
+	 *      - default:           "1.3"
+	 *  
+	 *  COMPILER / Setting Compliance Level
+	 *     Select the compliance level for the compiler. In "1.3" mode, source and target settings
+	 *     should not go beyond "1.3" level.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.compliance"
+	 *      - possible values:   { "1.3", "1.4" }
+	 *      - default:           "1.3"
+	 *  
+	 *  COMPILER / Maximum number of problems reported per compilation unit
+	 *     Specify the maximum number of problems reported on each compilation unit.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
+	 *      - possible values:	"<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
+	 *      - default:           "100"
+	 *  
+	 *  COMPILER / Define the Automatic Task Tags
+	 *     When the tag is non empty, the compiler will issue a task marker whenever it encounters
+	 *     one of the corresponding tag inside any comment in Java source code.
+	 *     Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.taskTags"
+	 *      - possible values:   { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card 
+	 *      - default:           ""
+	 *  COMPILER / Define the Automatic Task Priorities
+	 *     In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
+	 *     of the task markers issued by the compiler.
+	 *     If the default is specified, the priority of each task marker is "NORMAL".
+	 *      - option id:         "org.phpeclipse.phpdt.core.compiler.taskPriorities"
+	 *      - possible values:   { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
+	 *      - default:           ""
+	 *  
+	 *  BUILDER / Specifying Filters for Resource Copying Control
+	 *     Allow to specify some filters to control the resource copy process.
+	 *      - option id:         "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
+	 *      - possible values:   { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
+	 *        or the name of a folder which ends with '/'
+	 *      - default:           ""
+	 *  
+	 *  BUILDER / Abort if Invalid Classpath
+	 *     Allow to toggle the builder to abort if the classpath is invalid
+	 *      - option id:         "org.phpeclipse.phpdt.core.builder.invalidClasspath"
+	 *      - possible values:   { "abort", "ignore" }
+	 *      - default:           "ignore"
+	 *  
+	 *  BUILDER / Cleaning Output Folder(s)
+	 *     Indicate whether the JavaBuilder is allowed to clean the output folders
+	 *     when performing full build operations.
+	 *      - option id:         "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
+	 *      - possible values:   { "clean", "ignore" }
+	 *      - default:           "clean"
+	 *  
+	 *  JAVACORE / Computing Project Build Order
+	 *     Indicate whether JavaCore should enforce the project build order to be based on
+	 *     the classpath prerequisite chain. When requesting to compute, this takes over
+	 *     the platform default order (based on project references).
+	 *      - option id:         "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
+	 *      - possible values:   { "compute", "ignore" }
+	 *      - default:           "ignore"	 
+	 *  
+	 *  JAVACORE / Specify Default Source Encoding Format
+	 *     Get the encoding format for compiled sources. This setting is read-only, it is equivalent
+	 *     to 'ResourcesPlugin.getEncoding()'.
+	 *      - option id:         "org.phpeclipse.phpdt.core.encoding"
+	 *      - possible values:   { any of the supported encoding name}.
+	 *      - default:           <platform default>
+	 *  
+	 *  JAVACORE / Reporting Incomplete Classpath
+	 *     An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
+	 *      - option id:         "org.phpeclipse.phpdt.core.incompleteClasspath"
+	 *      - possible values:   { "error", "warning"}
+	 *      - default:           "error"
+	 *  
+	 *  JAVACORE / Reporting Classpath Cycle
+	 *     A project is involved in a cycle.
+	 *      - option id:         "org.phpeclipse.phpdt.core.circularClasspath"
+	 *      - possible values:   { "error", "warning" }
+	 *      - default:           "error"
+	 *  
+	 * 	FORMATTER / Inserting New Line Before Opening Brace
+	 *     When Insert, a new line is inserted before an opening brace, otherwise nothing
+	 *     is inserted
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "do not insert"
+	 *  
+	 * 	FORMATTER / Inserting New Line Inside Control Statement
+	 *     When Insert, a new line is inserted between } and following else, catch, finally
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "do not insert"
+	 *  
+	 * 	FORMATTER / Clearing Blank Lines
+	 *     When Clear all, all blank lines are removed. When Preserve one, only one is kept
+	 *     and all others removed.
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
+	 *      - possible values:   { "clear all", "preserve one" }
+	 *      - default:           "preserve one"
+	 *  
+	 * 	FORMATTER / Inserting New Line Between Else/If 
+	 *     When Insert, a blank line is inserted between an else and an if when they are 
+	 *     contiguous. When choosing to not insert, else-if will be kept on the same
+	 *     line when possible.
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "do not insert"
+	 *  
+	 * 	FORMATTER / Inserting New Line In Empty Block
+	 *     When insert, a line break is inserted between contiguous { and }, if } is not followed
+	 *     by a keyword.
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "insert"
+	 *  
+	 * 	FORMATTER / Splitting Lines Exceeding Length
+	 *     Enable splitting of long lines (exceeding the configurable length). Length of 0 will
+	 *     disable line splitting
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.lineSplit"
+	 *      - possible values:	"<n>", where n is zero or a positive integer
+	 *      - default:           "80"
+	 *  
+	 * 	FORMATTER / Compacting Assignment
+	 *     Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
+	 *     is inserted before the assignment operator
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.style.assignment"
+	 *      - possible values:   { "compact", "normal" }
+	 *      - default:           "normal"
+	 *  
+	 * 	FORMATTER / Defining Indentation Character
+	 *     Either choose to indent with tab characters or spaces
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.tabulation.char"
+	 *      - possible values:   { "tab", "space" }
+	 *      - default:           "tab"
+	 *  
+	 * 	FORMATTER / Defining Space Indentation Length
+	 *     When using spaces, set the amount of space characters to use for each 
+	 *     indentation mark.
+	 *      - option id:         "org.phpeclipse.phpdt.core.formatter.tabulation.size"
+	 *      - possible values:	"<n>", where n is a positive integer
+	 *      - default:           "4"
+	 *  
+	 * 	CODEASSIST / Activate Visibility Sensitive Completion
+	 *     When active, completion doesn't show that you can not see
+	 *     (e.g. you can not see private methods of a super class).
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 *  
+	 * 	CODEASSIST / Automatic Qualification of Implicit Members
+	 *     When active, completion automatically qualifies completion on implicit
+	 *     field references and message expressions.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Field Name
+	 *     When the prefixes is non empty, completion for field name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Static Field Name
+	 *     When the prefixes is non empty, completion for static field name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Local Variable Name
+	 *     When the prefixes is non empty, completion for local variable name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Argument Name
+	 *     When the prefixes is non empty, completion for argument name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Field Name
+	 *     When the suffixes is non empty, completion for field name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Static Field Name
+	 *     When the suffixes is non empty, completion for static field name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Local Variable Name
+	 *     When the suffixes is non empty, completion for local variable name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Argument Name
+	 *     When the suffixes is non empty, completion for argument name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  </pre>
+	 *  
+	 *  @return a mutable table containing the default settings of all known options
+	 *    (key type: 
+	 * 
+	 * String
+	 * 
+	 * ; value type: 
+	 * 
+	 * String
+	 * 
+	 * )
+	 *  @see #setOptions
+	 * 
+	 */
+	//  public static Hashtable getDefaultOptions() {
+	//
+	//    Hashtable defaultOptions = new Hashtable(10);
+	//
+	//    // see #initializeDefaultPluginPreferences() for changing default
+	// settings
+	//    Preferences preferences = getPlugin().getPluginPreferences();
+	//    HashSet optionNames = OptionNames;
+	//
+	//    // get preferences set to their default
+	//    String[] defaultPropertyNames = preferences.defaultPropertyNames();
+	//    for (int i = 0; i < defaultPropertyNames.length; i++) {
+	//      String propertyName = defaultPropertyNames[i];
+	//      if (optionNames.contains(propertyName)) {
+	//        defaultOptions.put(propertyName,
+	// preferences.getDefaultString(propertyName));
+	//      }
+	//    }
+	//    // get preferences not set to their default
+	//    String[] propertyNames = preferences.propertyNames();
+	//    for (int i = 0; i < propertyNames.length; i++) {
+	//      String propertyName = propertyNames[i];
+	//      if (optionNames.contains(propertyName)) {
+	//        defaultOptions.put(propertyName,
+	// preferences.getDefaultString(propertyName));
+	//      }
+	//    }
+	//    // get encoding through resource plugin
+	//    defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
+	//
+	//    return defaultOptions;
+	//  }
+	/**
+	 * Helper method for returning one option value only. Equivalent to
+	 * (String)JavaCore.getOptions().get(optionName) Note that it
+	 * may answer null if this option does not exist.
+	 * 

+ * For a complete description of the configurable options, see + * getDefaultOptions. + *

+ * + * @param optionName + * the name of an option + * @return the String value of a given option + * @see JavaCore#getDefaultOptions + * @since 2.0 + */ + // public static String getOption(String optionName) { + // + // if (CORE_ENCODING.equals(optionName)) { + // return ResourcesPlugin.getEncoding(); + // } + // if (OptionNames.contains(optionName)) { + // Preferences preferences = getPlugin().getPluginPreferences(); + // return preferences.getString(optionName).trim(); + // } + // return null; + // } + /** + * Returns the table of the current options. Initially, all options have + * their default values, and this method returns a table that includes all + * known options. + *

+ * For a complete description of the configurable options, see + * getDefaultOptions. + *

+ * + * @return table of current settings of all options (key type: + * String; value type: String) + * @see JavaCore#getDefaultOptions + */ + // public static Hashtable getOptions() { + // + // Hashtable options = new Hashtable(10); + // + // // see #initializeDefaultPluginPreferences() for changing default + // settings + // Plugin plugin = getPlugin(); + // if (plugin != null) { + // Preferences preferences = getPlugin().getPluginPreferences(); + // HashSet optionNames = OptionNames; + // + // // get preferences set to their default + // String[] defaultPropertyNames = preferences.defaultPropertyNames(); + // for (int i = 0; i < defaultPropertyNames.length; i++) { + // String propertyName = defaultPropertyNames[i]; + // if (optionNames.contains(propertyName)) { + // options.put(propertyName, preferences.getDefaultString(propertyName)); + // } + // } + // // get preferences not set to their default + // String[] propertyNames = preferences.propertyNames(); + // for (int i = 0; i < propertyNames.length; i++) { + // String propertyName = propertyNames[i]; + // if (optionNames.contains(propertyName)) { + // options.put(propertyName, preferences.getString(propertyName).trim()); + // } + // } + // // get encoding through resource plugin + // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); + // } + // return options; + // } + /** + * Sets the current table of options. All and only the options explicitly + * included in the given table are remembered; all previous option settings + * are forgotten, including ones not explicitly mentioned. + *

+ * For a complete description of the configurable options, see + * getDefaultOptions. + *

+ * + * @param newOptions + * the new options (key type: String; value type: + * String), or null to reset all + * options to their default values + * @see JavaCore#getDefaultOptions + */ + // public static void setOptions(Hashtable newOptions) { + // + // // see #initializeDefaultPluginPreferences() for changing default + // settings + // Preferences preferences = getPlugin().getPluginPreferences(); + // + // if (newOptions == null) { + // newOptions = getDefaultOptions(); + // } + // Enumeration keys = newOptions.keys(); + // while (keys.hasMoreElements()) { + // String key = (String) keys.nextElement(); + // if (!OptionNames.contains(key)) + // continue; // unrecognized option + // if (key.equals(CORE_ENCODING)) + // continue; // skipped, contributed by resource prefs + // String value = (String) newOptions.get(key); + // preferences.setValue(key, value); + // } + // + // // persist options + // getPlugin().savePluginPreferences(); + // } + public static IProject[] getPHPProjects() { + List phpProjectsList = new ArrayList(); + IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace() + .getRoot().getProjects(); + + for (int i = 0; i < workspaceProjects.length; i++) { + IProject iProject = workspaceProjects[i]; + if (isPHPProject(iProject)) + phpProjectsList.add(iProject); + } + + IProject[] phpProjects = new IProject[phpProjectsList.size()]; + return (IProject[]) phpProjectsList.toArray(phpProjects); + } + + // public static PHPProject getPHPProject(String name) { + // IProject aProject = + // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name); + // if (isPHPProject(aProject)) { + // PHPProject thePHPProject = new PHPProject(); + // thePHPProject.setProject(aProject); + // return thePHPProject; + // } + // return null; + // } + + public static boolean isPHPProject(IProject aProject) { + try { + return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID); + } catch (CoreException e) { + } + + return false; + } + + // public static PHPFile create(IFile aFile) { + // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension())) + // return new PHPFile(aFile); + // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension())) + // return new PHPFile(aFile); + // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension())) + // return new PHPFile(aFile); + // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension())) + // return new PHPFile(aFile); + // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension())) + // return new PHPFile(aFile); + // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension())) + // return new PHPFile(aFile); + // + // return null; + // } + + // public static PHPProject create(IProject aProject) { + // + // try { + // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) { + // PHPProject project = new PHPProject(); + // project.setProject(aProject); + // return project; + // } + // } catch (CoreException e) { + // System.err.println("Exception occurred in PHPCore#create(IProject): " + + // e.toString()); + // } + // + // return null; + // } + + public static void addPHPNature(IProject project, IProgressMonitor monitor) + throws CoreException { + if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) { + IProjectDescription description = project.getDescription(); + String[] prevNatures = description.getNatureIds(); + String[] newNatures = new String[prevNatures.length + 1]; + System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); + newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID; + description.setNatureIds(newNatures); + project.setDescription(description, monitor); + } + } + + /** + * Returns the single instance of the PHP core plug-in runtime class. + * + * @return the single instance of the PHP core plug-in runtime class + */ + public static Plugin getPlugin() { + return PHPeclipsePlugin.getDefault(); + } + + /** + * Runs the given action as an atomic Java model operation. + *

+ * After running a method that modifies java elements, registered listeners + * receive after-the-fact notification of what just transpired, in the form + * of a element changed event. This method allows clients to call a number + * of methods that modify java elements and only have element changed event + * notifications reported at the end of the entire batch. + *

+ *

+ * If this method is called outside the dynamic scope of another such call, + * this method runs the action and then reports a single element changed + * event describing the net effect of all changes done to java elements by + * the action. + *

+ *

+ * If this method is called in the dynamic scope of another such call, this + * method simply runs the action. + *

+ * + * @param action + * the action to perform + * @param monitor + * a progress monitor, or null if progress + * reporting and cancellation are not desired + * @exception CoreException + * if the operation failed. + * @since 2.1 + */ + // public static void run(IWorkspaceRunnable action, IProgressMonitor + // monitor) throws CoreException { + // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor); + // } + /** + * Runs the given action as an atomic Java model operation. + *

+ * After running a method that modifies java elements, registered listeners + * receive after-the-fact notification of what just transpired, in the form + * of a element changed event. This method allows clients to call a number + * of methods that modify java elements and only have element changed event + * notifications reported at the end of the entire batch. + *

+ *

+ * If this method is called outside the dynamic scope of another such call, + * this method runs the action and then reports a single element changed + * event describing the net effect of all changes done to java elements by + * the action. + *

+ *

+ * If this method is called in the dynamic scope of another such call, this + * method simply runs the action. + *

+ *

+ * The supplied scheduling rule is used to determine whether this operation + * can be run simultaneously with workspace changes in other threads. See + * IWorkspace.run(...) for more details. + *

+ * + * @param action + * the action to perform + * @param rule + * the scheduling rule to use when running this operation, or + * null if there are no scheduling restrictions + * for this operation. + * @param monitor + * a progress monitor, or null if progress + * reporting and cancellation are not desired + * @exception CoreException + * if the operation failed. + * @since 3.0 + */ + // public static void run(IWorkspaceRunnable action, ISchedulingRule rule, + // IProgressMonitor monitor) throws CoreException { + // IWorkspace workspace = ResourcesPlugin.getWorkspace(); + // if (workspace.isTreeLocked()) { + // new BatchOperation(action).run(monitor); + // } else { + // // use IWorkspace.run(...) to ensure that a build will be done in + // autobuild mode + // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, + // monitor); + // } + // } + + /** + * Adds the given listener for changes to Java elements. Has no effect if an + * identical listener is already registered. + * + * This listener will only be notified during the POST_CHANGE resource + * change notification and any reconcile operation (POST_RECONCILE). For + * finer control of the notification, use + * addElementChangedListener(IElementChangedListener,int), + * which allows to specify a different eventMask. + * + * @see ElementChangedEvent + * @param listener + * the listener + */ + public static void addElementChangedListener( + IElementChangedListener listener) { + addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE + | ElementChangedEvent.POST_RECONCILE); + } + + /** + * Adds the given listener for changes to Java elements. Has no effect if an + * identical listener is already registered. After completion of this + * method, the given listener will be registered for exactly the specified + * events. If they were previously registered for other events, they will be + * deregistered. + *

+ * Once registered, a listener starts receiving notification of changes to + * java elements in the model. The listener continues to receive + * notifications until it is replaced or removed. + *

+ *

+ * Listeners can listen for several types of event as defined in + * ElementChangeEvent. Clients are free to register for any + * number of event types however if they register for more than one, it is + * their responsibility to ensure they correctly handle the case where the + * same java element change shows up in multiple notifications. Clients are + * guaranteed to receive only the events for which they are registered. + *

+ * + * @param listener + * the listener + * @param eventMask + * the bit-wise OR of all event types of interest to the listener + * @see IElementChangedListener + * @see ElementChangedEvent + * @see #removeElementChangedListener(IElementChangedListener) + * @since 2.0 + */ + public static void addElementChangedListener( + IElementChangedListener listener, int eventMask) { + JavaModelManager.getJavaModelManager().addElementChangedListener( + listener, eventMask); + } + + /** + * Configures the given marker attribute map for the given Java element. + * Used for markers, which denote a Java element rather than a resource. + * + * @param attributes + * the mutable marker attribute map (key type: + * String, value type: String) + * @param element + * the Java element for which the marker needs to be configured + */ + public static void addJavaElementMarkerAttributes(Map attributes, + IJavaElement element) { + // if (element instanceof IMember) + // element = ((IMember) element).getClassFile(); + if (attributes != null && element != null) + attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier()); + } + + /** + * Configures the given marker for the given Java element. Used for markers, + * which denote a Java element rather than a resource. + * + * @param marker + * the marker to be configured + * @param element + * the Java element for which the marker needs to be configured + * @exception CoreException + * if the IMarker.setAttribute on the marker + * fails + */ + public void configureJavaElementMarker(IMarker marker, IJavaElement element) + throws CoreException { + // if (element instanceof IMember) + // element = ((IMember) element).getClassFile(); + if (marker != null && element != null) + marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier()); + } + + /** + * Returns the Java model element corresponding to the given handle + * identifier generated by IJavaElement.getHandleIdentifier(), + * or null if unable to create the associated element. + */ + public static IJavaElement create(String handleIdentifier) { + if (handleIdentifier == null) { + return null; + } + try { + return JavaModelManager.getJavaModelManager().getHandleFromMemento( + handleIdentifier); + } catch (JavaModelException e) { + return null; + } + } + + /** + * Returns the Java element corresponding to the given file, or + * null if unable to associate the given file with a Java + * element. + * + *

+ * The file must be one of: + *

    + *
  • a .java file - the element returned is the + * corresponding ICompilationUnit
  • + *
  • a .class file - the element returned is the + * corresponding IClassFile
  • + *
  • a .jar file - the element returned is the + * corresponding IPackageFragmentRoot
  • + *
+ *

+ * Creating a Java element has the side effect of creating and opening all + * of the element's parents if they are not yet open. + * + * @param the + * given file + * @return the Java element corresponding to the given file, or + * null if unable to associate the given file with a + * Java element + */ + public static IJavaElement create(IFile file) { + return JavaModelManager.create(file, null); + } + + /** + * Returns the package fragment or package fragment root corresponding to + * the given folder, or null if unable to associate the given + * folder with a Java element. + *

+ * Note that a package fragment root is returned rather than a default + * package. + *

+ * Creating a Java element has the side effect of creating and opening all + * of the element's parents if they are not yet open. + * + * @param the + * given folder + * @return the package fragment or package fragment root corresponding to + * the given folder, or null if unable to associate + * the given folder with a Java element + */ + public static IJavaElement create(IFolder folder) { + return JavaModelManager.create(folder, null); + } + + /** + * Returns the Java project corresponding to the given project. + *

+ * Creating a Java Project has the side effect of creating and opening all + * of the project's parents if they are not yet open. + *

+ * Note that no check is done at this time on the existence or the java + * nature of this project. + * + * @param project + * the given project + * @return the Java project corresponding to the given project, null if the + * given project is null + */ + public static IJavaProject create(IProject project) { + if (project == null) { + return null; + } + JavaModel javaModel = JavaModelManager.getJavaModelManager() + .getJavaModel(); + return javaModel.getJavaProject(project); + } + + /** + * Returns the Java element corresponding to the given resource, or + * null if unable to associate the given resource with a Java + * element. + *

+ * The resource must be one of: + *

    + *
  • a project - the element returned is the corresponding + * IJavaProject
  • + *
  • a .java file - the element returned is the + * corresponding ICompilationUnit
  • + *
  • a .class file - the element returned is the + * corresponding IClassFile
  • + *
  • a .jar file - the element returned is the + * corresponding IPackageFragmentRoot
  • + *
  • a folder - the element returned is the corresponding + * IPackageFragmentRoot or IPackageFragment + *
  • + *
  • the workspace root resource - the element returned is the + * IJavaModel
  • + *
+ *

+ * Creating a Java element has the side effect of creating and opening all + * of the element's parents if they are not yet open. + * + * @param resource + * the given resource + * @return the Java element corresponding to the given resource, or + * null if unable to associate the given resource + * with a Java element + */ + public static IJavaElement create(IResource resource) { + return JavaModelManager.create(resource, null); + } + + /** + * Returns the Java model. + * + * @param root + * the given root + * @return the Java model, or null if the root is null + */ + public static IJavaModel create(IWorkspaceRoot root) { + if (root == null) { + return null; + } + return JavaModelManager.getJavaModelManager().getJavaModel(); + } + + /** + * Creates and returns a class file element for the given + * .class file. Returns null if unable to + * recognize the class file. + * + * @param file + * the given .class file + * @return a class file element for the given .class file, or + * null if unable to recognize the class file + */ + //public static IClassFile createClassFileFrom(IFile file) { + // return JavaModelManager.createClassFileFrom(file, null); + //} + /** + * Creates and returns a compilation unit element for the given + * .java file. Returns null if unable to + * recognize the compilation unit. + * + * @param file + * the given .java file + * @return a compilation unit element for the given .java + * file, or null if unable to recognize the + * compilation unit + */ + public static ICompilationUnit createCompilationUnitFrom(IFile file) { + return JavaModelManager.createCompilationUnitFrom(file, null); + } + + /** + * Creates and returns a handle for the given JAR file. The Java model + * associated with the JAR's project may be created as a side effect. + * + * @param file + * the given JAR file + * @return a handle for the given JAR file, or null if unable + * to create a JAR package fragment root. (for example, if the JAR + * file represents a non-Java resource) + */ + //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile + // file) { + // return JavaModelManager.createJarPackageFragmentRootFrom(file, null); + //} + /** + * Answers the project specific value for a given classpath container. In + * case this container path could not be resolved, then will answer + * null. Both the container path and the project context are + * supposed to be non-null. + *

+ * The containerPath is a formed by a first ID segment followed with extra + * segments, which can be used as additional hints for resolution. If no + * container was ever recorded for this container path onto this project + * (using setClasspathContainer, then a + * ClasspathContainerInitializer will be activated if any was + * registered for this container ID onto the extension point + * "org.eclipse.jdt.core.classpathContainerInitializer". + *

+ * There is no assumption that the returned container must answer the exact + * same containerPath when requested + * IClasspathContainer#getPath. Indeed, the containerPath is + * just an indication for resolving it to an actual container object. + *

+ * Classpath container values are persisted locally to the workspace, but + * are not preserved from a session to another. It is thus highly + * recommended to register a ClasspathContainerInitializer + * for each referenced container (through the extension point + * "org.eclipse.jdt.core.ClasspathContainerInitializer"). + *

+ * + * @param containerPath + * the name of the container, which needs to be resolved + * @param project + * a specific project in which the container is being resolved + * @return the corresponding classpath container or null if + * unable to find one. + * + * @exception JavaModelException + * if an exception occurred while resolving the container, or + * if the resolved container contains illegal entries + * (contains CPE_CONTAINER entries or null entries). + * + * @see ClasspathContainerInitializer + * @see IClasspathContainer + * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], + * IProgressMonitor) + * @since 2.0 + */ + //public static IClasspathContainer getClasspathContainer(final IPath + // containerPath, final IJavaProject project) throws JavaModelException { + // + // IClasspathContainer container = JavaModelManager.containerGet(project, + // containerPath); + // if (container == JavaModelManager.ContainerInitializationInProgress) + // return null; // break cycle + // + // if (container == null){ + // final ClasspathContainerInitializer initializer = + // JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); + // if (initializer != null){ + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPContainer INIT - triggering initialization of: + // ["+project.getElementName()+"] " + containerPath + " using initializer: + // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ + // new Exception("FAKE exception for dumping current CPContainer + // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack + // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + // } + // JavaModelManager.containerPut(project, containerPath, + // JavaModelManager.ContainerInitializationInProgress); // avoid + // initialization cycles + // boolean ok = false; + // try { + // // wrap initializer call with Safe runnable in case initializer would be + // causing some grief + // Platform.run(new ISafeRunnable() { + // public void handleException(Throwable exception) { + // Util.log(exception, "Exception occurred in classpath container + // initializer: "+initializer); //$NON-NLS-1$ + // } + // public void run() throws Exception { + // initializer.initialize(containerPath, project); + // } + // }); + // + // // retrieve value (if initialization was successful) + // container = JavaModelManager.containerGet(project, containerPath); + // if (container == JavaModelManager.ContainerInitializationInProgress) + // return null; // break cycle + // ok = true; + // } finally { + // if (!ok) JavaModelManager.containerPut(project, containerPath, null); // + // flush cache + // } + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.print("CPContainer INIT - after resolution: + // ["+project.getElementName()+"] " + containerPath + " --> "); + // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$ + // if (container != null){ + // System.out.print("container: "+container.getDescription()+" {"); + // //$NON-NLS-2$//$NON-NLS-1$ + // IClasspathEntry[] entries = container.getClasspathEntries(); + // if (entries != null){ + // for (int i = 0; i < entries.length; i++){ + // if (i > 0) System.out.println(", ");//$NON-NLS-1$ + // System.out.println(entries[i]); + // } + // } + // System.out.println("}");//$NON-NLS-1$ + // } else { + // System.out.println("{unbound}");//$NON-NLS-1$ + // } + // } + // } else { + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPContainer INIT - no initializer found for: + // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$ + // //$NON-NLS-2$ + // } + // } + // } + // return container; + //} + /** + * Helper method finding the classpath container initializer registered for + * a given classpath container ID or null if none was found + * while iterating over the contributions to extension point to the + * extension point "org.eclipse.jdt.core.classpathContainerInitializer". + *

+ * A containerID is the first segment of any container path, used to + * identify the registered container initializer. + *

+ * + * @param String - + * a containerID identifying a registered initializer + * @return ClasspathContainerInitializer - the registered classpath + * container initializer or null if none was found. + * @since 2.1 + */ + //public static ClasspathContainerInitializer + // getClasspathContainerInitializer(String containerID){ + // + // Plugin jdtCorePlugin = JavaCore.getPlugin(); + // if (jdtCorePlugin == null) return null; + // + // IExtensionPoint extension = + // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID); + // if (extension != null) { + // IExtension[] extensions = extension.getExtensions(); + // for(int i = 0; i < extensions.length; i++){ + // IConfigurationElement [] configElements = + // extensions[i].getConfigurationElements(); + // for(int j = 0; j < configElements.length; j++){ + // String initializerID = configElements[j].getAttribute("id"); + // //$NON-NLS-1$ + // if (initializerID != null && initializerID.equals(containerID)){ + // if (JavaModelManager.CP_RESOLVE_VERBOSE) { + // System.out.println("CPContainer INIT - found initializer: "+containerID + // +" --> " + + // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ + // } + // try { + // Object execExt = configElements[j].createExecutableExtension("class"); + // //$NON-NLS-1$ + // if (execExt instanceof ClasspathContainerInitializer){ + // return (ClasspathContainerInitializer)execExt; + // } + // } catch(CoreException e) { + // } + // } + // } + // } + // } + // return null; + //} + /** + * Returns the path held in the given classpath variable. Returns null + * if unable to bind. + *

+ * Classpath variable values are persisted locally to the workspace, and are + * preserved from session to session. + *

+ * Note that classpath variables can be contributed registered initializers + * for, using the extension point + * "org.eclipse.jdt.core.classpathVariableInitializer". If an initializer is + * registered for a variable, its persisted value will be ignored: its + * initializer will thus get the opportunity to rebind the variable + * differently on each session. + * + * @param variableName + * the name of the classpath variable + * @return the path, or null if none + * @see #setClasspathVariable + */ + public static IPath getClasspathVariable(final String variableName) { + + IPath variablePath = JavaModelManager.variableGet(variableName); + if (variablePath == JavaModelManager.VariableInitializationInProgress) + return null; // break cycle + + if (variablePath != null) { + return variablePath; + } + + // even if persisted value exists, initializer is given priority, only + // if no initializer is found the persisted value is reused + // final ClasspathVariableInitializer initializer = + // PHPCore.getClasspathVariableInitializer(variableName); + // if (initializer != null){ + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPVariable INIT - triggering initialization of: " + // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$ + // //$NON-NLS-2$ + // new Exception("FAKE exception for dumping current CPVariable + // ("+variableName+ ")INIT invocation stack trace").printStackTrace(); + // //$NON-NLS-1$//$NON-NLS-2$ + // } + // JavaModelManager.variablePut(variableName, + // JavaModelManager.VariableInitializationInProgress); // avoid + // initialization cycles + // boolean ok = false; + // try { + // // wrap initializer call with Safe runnable in case initializer would + // be causing some grief + // Platform.run(new ISafeRunnable() { + // public void handleException(Throwable exception) { + // Util.log(exception, "Exception occurred in classpath variable + // initializer: "+initializer+" while initializing variable: + // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$ + // } + // public void run() throws Exception { + // initializer.initialize(variableName); + // } + // }); + // variablePath = (IPath) JavaModelManager.variableGet(variableName); // + // initializer should have performed side-effect + // if (variablePath == + // JavaModelManager.VariableInitializationInProgress) return null; // + // break cycle (initializer did not init or reentering call) + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPVariable INIT - after initialization: " + + // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$ + // } + // ok = true; + // } finally { + // if (!ok) JavaModelManager.variablePut(variableName, null); // flush + // cache + // } + // } else { + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPVariable INIT - no initializer found for: " + + // variableName); //$NON-NLS-1$ + // } + // } + return variablePath; + } + + /** + * Helper method finding the classpath variable initializer registered for a + * given classpath variable name or null if none was found + * while iterating over the contributions to extension point to the + * extension point "org.eclipse.jdt.core.classpathVariableInitializer". + *

+ * + * @param the + * given variable + * @return ClasspathVariableInitializer - the registered classpath variable + * initializer or null if none was found. + * @since 2.1 + */ + public static ClasspathVariableInitializer getClasspathVariableInitializer( + String variable) { + + Plugin jdtCorePlugin = JavaCore.getPlugin(); + if (jdtCorePlugin == null) + return null; + + // IExtensionPoint extension = + // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID); + // if (extension != null) { + // IExtension[] extensions = extension.getExtensions(); + // for(int i = 0; i < extensions.length; i++){ + // IConfigurationElement [] configElements = + // extensions[i].getConfigurationElements(); + // for(int j = 0; j < configElements.length; j++){ + // try { + // String varAttribute = configElements[j].getAttribute("variable"); + // //$NON-NLS-1$ + // if (variable.equals(varAttribute)) { + // if (JavaModelManager.CP_RESOLVE_VERBOSE) { + // System.out.println("CPVariable INIT - found initializer: "+variable+" + // --> " + + // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ + // } + // Object execExt = + // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$ + // if (execExt instanceof ClasspathVariableInitializer){ + // return (ClasspathVariableInitializer)execExt; + // } + // } + // } catch(CoreException e){ + // } + // } + // } + // } + return null; + } + + /** + * Returns the names of all known classpath variables. + *

+ * Classpath variable values are persisted locally to the workspace, and are + * preserved from session to session. + *

+ * + * @return the list of classpath variable names + * @see #setClasspathVariable + */ + //public static String[] getClasspathVariableNames() { + // return JavaModelManager.variableNames(); + //} + /** + * Returns a table of all known configurable options with their default + * values. These options allow to configure the behaviour of the underlying + * components. The client may safely use the result as a template that they + * can modify and then pass to setOptions. + * + * Helper constants have been defined on JavaCore for each of the option ID + * and their possible constant values. + * + * Note: more options might be added in further releases. + * + *

+	 * 
+	 *  RECOGNIZED OPTIONS:
+	 *  COMPILER / Generating Local Variable Debug Attribute
+	 *     When generated, this attribute will enable local variable names 
+	 *     to be displayed in debugger, only in place where variables are 
+	 *     definitely assigned (.class file is then bigger)
+	 *      - option id:         "org.eclipse.jdt.core.compiler.debug.localVariable"
+	 *      - possible values:   { "generate", "do not generate" }
+	 *      - default:           "generate"
+	 * 
+	 *  COMPILER / Generating Line Number Debug Attribute 
+	 *     When generated, this attribute will enable source code highlighting in debugger 
+	 *     (.class file is then bigger).
+	 *      - option id:         "org.eclipse.jdt.core.compiler.debug.lineNumber"
+	 *      - possible values:   { "generate", "do not generate" }
+	 *      - default:           "generate"
+	 *     
+	 *  COMPILER / Generating Source Debug Attribute 
+	 *     When generated, this attribute will enable the debugger to present the 
+	 *     corresponding source code.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.debug.sourceFile"
+	 *      - possible values:   { "generate", "do not generate" }
+	 *      - default:           "generate"
+	 *     
+	 *  COMPILER / Preserving Unused Local Variables
+	 *     Unless requested to preserve unused local variables (that is, never read), the 
+	 *     compiler will optimize them out, potentially altering debugging
+	 *      - option id:         "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
+	 *      - possible values:   { "preserve", "optimize out" }
+	 *      - default:           "preserve"
+	 *  
+	 *  COMPILER / Defining Target Java Platform
+	 *     For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
+	 *     Note that "1.4" target require to toggle compliance mode to "1.4" too.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
+	 *      - possible values:   { "1.1", "1.2", "1.3", "1.4" }
+	 *      - default:           "1.1"
+	 * 
+	 *  COMPILER / Reporting Unreachable Code
+	 *     Unreachable code can optionally be reported as an error, warning or simply 
+	 *     ignored. The bytecode generation will always optimized it out.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.unreachableCode"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "error"
+	 * 
+	 *  COMPILER / Reporting Invalid Import
+	 *     An import statement that cannot be resolved might optionally be reported 
+	 *     as an error, as a warning or ignored.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.invalidImport"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "error"
+	 * 
+	 *  COMPILER / Reporting Attempt to Override Package-Default Method
+	 *     A package default method is not visible in a different package, and thus 
+	 *     cannot be overridden. When enabling this option, the compiler will signal 
+	 *     such scenarii either as an error or a warning.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Method With Constructor Name
+	 *     Naming a method with a constructor name is generally considered poor 
+	 *     style programming. When enabling this option, the compiler will signal such 
+	 *     scenarii either as an error or a warning.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Deprecation
+	 *     When enabled, the compiler will signal use of deprecated API either as an 
+	 *     error or a warning.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.deprecation"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Deprecation Inside Deprecated Code
+	 *     When enabled, the compiler will signal use of deprecated API inside deprecated code.
+	 *     The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 * 
+	 *  COMPILER / Reporting Hidden Catch Block
+	 *     Locally to a try statement, some catch blocks may hide others . For example,
+	 *       try {  throw new java.io.CharConversionException();
+	 *       } catch (java.io.CharConversionException e) {
+	 *       } catch (java.io.IOException e) {}. 
+	 *     When enabling this option, the compiler will issue an error or a warning for hidden 
+	 *     catch blocks corresponding to checked exceptions
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Unused Local
+	 *     When enabled, the compiler will issue an error or a warning for unused local 
+	 *     variables (that is, variables never read from)
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.unusedLocal"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 * 
+	 *  COMPILER / Reporting Unused Parameter
+	 *     When enabled, the compiler will issue an error or a warning for unused method 
+	 *     parameters (that is, parameters never read from)
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameter"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 * 
+	 *  COMPILER / Reporting Unused Parameter if Implementing Abstract Method
+	 *     When enabled, the compiler will signal unused parameters in abstract method implementations.
+	 *     The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 * 
+	 *  COMPILER / Reporting Unused Parameter if Overriding Concrete Method
+	 *     When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
+	 *     The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 * 
+	 *  COMPILER / Reporting Unused Import
+	 *     When enabled, the compiler will issue an error or a warning for unused import 
+	 *     reference 
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.unusedImport"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Reporting Unused Private Members
+	 *     When enabled, the compiler will issue an error or a warning whenever a private 
+	 *     method or field is declared but never used within the same unit.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 * 
+	 *  COMPILER / Reporting Synthetic Access Emulation
+	 *     When enabled, the compiler will issue an error or a warning whenever it emulates 
+	 *     access to a non-accessible member of an enclosing type. Such access can have
+	 *     performance implications.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 * 
+	 *  COMPILER / Reporting Non-Externalized String Literal
+	 *     When enabled, the compiler will issue an error or a warning for non externalized 
+	 *     String literal (that is, not tagged with //$NON-NLS-<n>$). 
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 *  
+	 *  COMPILER / Reporting Usage of 'assert' Identifier
+	 *     When enabled, the compiler will issue an error or a warning whenever 'assert' is 
+	 *     used as an identifier (reserved keyword in 1.4)
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "ignore"
+	 *  
+	 *  COMPILER / Reporting Non-Static Reference to a Static Member
+	 *     When enabled, the compiler will issue an error or a warning whenever a static field
+	 *     or method is accessed with an expression receiver. A reference to a static member should
+	 *     be qualified with a type name.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 *  
+	 *  COMPILER / Reporting Assignment with no Effect
+	 *     When enabled, the compiler will issue an error or a warning whenever an assignment
+	 *     has no effect (e.g 'x = x').
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 *  
+	 *  COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
+	 *     When enabled, the compiler will issue an error or a warning whenever an interface
+	 *     defines a method incompatible with a non-inherited Object method. Until this conflict
+	 *     is resolved, such an interface cannot be implemented, For example, 
+	 *       interface I { 
+	 *          int clone();
+	 *       } 
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 *  
+	 *  COMPILER / Reporting Usage of char[] Expressions in String Concatenations
+	 *     When enabled, the compiler will issue an error or a warning whenever a char[] expression
+	 *     is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
+	 *      - option id:         "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
+	 *      - possible values:   { "error", "warning", "ignore" }
+	 *      - default:           "warning"
+	 * 
+	 *  COMPILER / Setting Source Compatibility Mode
+	 *     Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
+	 *     reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
+	 *    level should be set to "1.4" and the compliance mode should be "1.4".
+	 *      - option id:         "org.eclipse.jdt.core.compiler.source"
+	 *      - possible values:   { "1.3", "1.4" }
+	 *      - default:           "1.3"
+	 *  
+	 *  COMPILER / Setting Compliance Level
+	 *     Select the compliance level for the compiler. In "1.3" mode, source and target settings
+	 *     should not go beyond "1.3" level.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.compliance"
+	 *      - possible values:   { "1.3", "1.4" }
+	 *      - default:           "1.3"
+	 *  
+	 *  COMPILER / Maximum number of problems reported per compilation unit
+	 *     Specify the maximum number of problems reported on each compilation unit.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
+	 *      - possible values:	"<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
+	 *      - default:           "100"
+	 *  
+	 *  COMPILER / Define the Automatic Task Tags
+	 *     When the tag list is not empty, the compiler will issue a task marker whenever it encounters
+	 *     one of the corresponding tag inside any comment in Java source code.
+	 *     Generated task messages will include the tag, and range until the next line separator or comment ending.
+	 *     Note that tasks messages are trimmed.
+	 *      - option id:         "org.eclipse.jdt.core.compiler.taskTags"
+	 *      - possible values:   { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces 
+	 *      - default:           ""
+	 *  
+	 *  COMPILER / Define the Automatic Task Priorities
+	 *     In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
+	 *     of the task markers issued by the compiler.
+	 *     If the default is specified, the priority of each task marker is "NORMAL".
+	 *      - option id:         "org.eclipse.jdt.core.compiler.taskPriorities"
+	 *      - possible values:   { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
+	 *      - default:           ""
+	 * 
+	 *  BUILDER / Specifying Filters for Resource Copying Control
+	 *     Allow to specify some filters to control the resource copy process.
+	 *      - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
+	 *      - possible values:   { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
+	 *        or the name of a folder which ends with '/'
+	 *      - default:           ""
+	 *  
+	 *  BUILDER / Abort if Invalid Classpath
+	 *     Allow to toggle the builder to abort if the classpath is invalid
+	 *      - option id:         "org.eclipse.jdt.core.builder.invalidClasspath"
+	 *      - possible values:   { "abort", "ignore" }
+	 *      - default:           "abort"
+	 *  
+	 *  BUILDER / Cleaning Output Folder(s)
+	 *     Indicate whether the JavaBuilder is allowed to clean the output folders
+	 *     when performing full build operations.
+	 *      - option id:         "org.eclipse.jdt.core.builder.cleanOutputFolder"
+	 *      - possible values:   { "clean", "ignore" }
+	 *      - default:           "clean"
+	 *  
+	 *  BUILDER / Reporting Duplicate Resources
+	 *     Indicate the severity of the problem reported when more than one occurrence
+	 *     of a resource is to be copied into the output location.
+	 *      - option id:         "org.eclipse.jdt.core.builder.duplicateResourceTask"
+	 *      - possible values:   { "error", "warning" }
+	 *      - default:           "warning"
+	 *  
+	 *  JAVACORE / Computing Project Build Order
+	 *     Indicate whether JavaCore should enforce the project build order to be based on
+	 *     the classpath prerequisite chain. When requesting to compute, this takes over
+	 *     the platform default order (based on project references).
+	 *      - option id:         "org.eclipse.jdt.core.computeJavaBuildOrder"
+	 *      - possible values:   { "compute", "ignore" }
+	 *      - default:           "ignore"	 
+	 *  
+	 *  JAVACORE / Specify Default Source Encoding Format
+	 *     Get the encoding format for compiled sources. This setting is read-only, it is equivalent
+	 *     to 'ResourcesPlugin.getEncoding()'.
+	 *      - option id:         "org.eclipse.jdt.core.encoding"
+	 *      - possible values:   { any of the supported encoding name}.
+	 *      - default:           <platform default>
+	 *  
+	 *  JAVACORE / Reporting Incomplete Classpath
+	 *     Indicate the severity of the problem reported when an entry on the classpath does not exist, 
+	 *     is not legite or is not visible (for example, a referenced project is closed).
+	 *      - option id:         "org.eclipse.jdt.core.incompleteClasspath"
+	 *      - possible values:   { "error", "warning"}
+	 *      - default:           "error"
+	 *  
+	 *  JAVACORE / Reporting Classpath Cycle
+	 *     Indicate the severity of the problem reported when a project is involved in a cycle.
+	 *      - option id:         "org.eclipse.jdt.core.circularClasspath"
+	 *      - possible values:   { "error", "warning" }
+	 *      - default:           "error"
+	 *  
+	 *  JAVACORE / Enabling Usage of Classpath Exclusion Patterns
+	 *     When disabled, no entry on a project classpath can be associated with
+	 *     an exclusion pattern.
+	 *      - option id:         "org.eclipse.jdt.core.classpath.exclusionPatterns"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "enabled"
+	 *  
+	 *  JAVACORE / Enabling Usage of Classpath Multiple Output Locations
+	 *     When disabled, no entry on a project classpath can be associated with
+	 *     a specific output location, preventing thus usage of multiple output locations.
+	 *      - option id:         "org.eclipse.jdt.core.classpath.multipleOutputLocations"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "enabled"
+	 *  
+	 * 	FORMATTER / Inserting New Line Before Opening Brace
+	 *     When Insert, a new line is inserted before an opening brace, otherwise nothing
+	 *     is inserted
+	 *      - option id:         "org.eclipse.jdt.core.formatter.newline.openingBrace"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "do not insert"
+	 *  
+	 * 	FORMATTER / Inserting New Line Inside Control Statement
+	 *     When Insert, a new line is inserted between } and following else, catch, finally
+	 *      - option id:         "org.eclipse.jdt.core.formatter.newline.controlStatement"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "do not insert"
+	 *  
+	 * 	FORMATTER / Clearing Blank Lines
+	 *     When Clear all, all blank lines are removed. When Preserve one, only one is kept
+	 *     and all others removed.
+	 *      - option id:         "org.eclipse.jdt.core.formatter.newline.clearAll"
+	 *      - possible values:   { "clear all", "preserve one" }
+	 *      - default:           "preserve one"
+	 *  
+	 * 	FORMATTER / Inserting New Line Between Else/If 
+	 *     When Insert, a blank line is inserted between an else and an if when they are 
+	 *     contiguous. When choosing to not insert, else-if will be kept on the same
+	 *     line when possible.
+	 *      - option id:         "org.eclipse.jdt.core.formatter.newline.elseIf"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "do not insert"
+	 *  
+	 * 	FORMATTER / Inserting New Line In Empty Block
+	 *     When insert, a line break is inserted between contiguous { and }, if } is not followed
+	 *     by a keyword.
+	 *      - option id:         "org.eclipse.jdt.core.formatter.newline.emptyBlock"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "insert"
+	 *  
+	 * 	FORMATTER / Splitting Lines Exceeding Length
+	 *     Enable splitting of long lines (exceeding the configurable length). Length of 0 will
+	 *     disable line splitting
+	 *      - option id:         "org.eclipse.jdt.core.formatter.lineSplit"
+	 *      - possible values:	"<n>", where n is zero or a positive integer
+	 *      - default:           "80"
+	 *  
+	 * 	FORMATTER / Compacting Assignment
+	 *     Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
+	 *     is inserted before the assignment operator
+	 *      - option id:         "org.eclipse.jdt.core.formatter.style.assignment"
+	 *      - possible values:   { "compact", "normal" }
+	 *      - default:           "normal"
+	 *  
+	 * 	FORMATTER / Defining Indentation Character
+	 *     Either choose to indent with tab characters or spaces
+	 *      - option id:         "org.eclipse.jdt.core.formatter.tabulation.char"
+	 *      - possible values:   { "tab", "space" }
+	 *      - default:           "tab"
+	 *  
+	 * 	FORMATTER / Defining Space Indentation Length
+	 *     When using spaces, set the amount of space characters to use for each 
+	 *     indentation mark.
+	 *      - option id:         "org.eclipse.jdt.core.formatter.tabulation.size"
+	 *      - possible values:	"<n>", where n is a positive integer
+	 *      - default:           "4"
+	 *  
+	 * 	FORMATTER / Inserting space in cast expression
+	 *     When Insert, a space is added between the type and the expression in a cast expression.
+	 *      - option id:         "org.eclipse.jdt.core.formatter.space.castexpression"
+	 *      - possible values:   { "insert", "do not insert" }
+	 *      - default:           "insert"
+	 *  
+	 * 	CODEASSIST / Activate Visibility Sensitive Completion
+	 *     When active, completion doesn't show that you can not see
+	 *     (for example, you can not see private methods of a super class).
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.visibilityCheck"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 *  
+	 * 	CODEASSIST / Automatic Qualification of Implicit Members
+	 *     When active, completion automatically qualifies completion on implicit
+	 *     field references and message expressions.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
+	 *      - possible values:   { "enabled", "disabled" }
+	 *      - default:           "disabled"
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Field Name
+	 *     When the prefixes is non empty, completion for field name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Static Field Name
+	 *     When the prefixes is non empty, completion for static field name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Local Variable Name
+	 *     When the prefixes is non empty, completion for local variable name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.localPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Prefixes for Argument Name
+	 *     When the prefixes is non empty, completion for argument name will begin with
+	 *     one of the proposed prefixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
+	 *      - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Field Name
+	 *     When the suffixes is non empty, completion for field name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Static Field Name
+	 *     When the suffixes is non empty, completion for static field name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Local Variable Name
+	 *     When the suffixes is non empty, completion for local variable name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.localSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  
+	 *   CODEASSIST / Define the Suffixes for Argument Name
+	 *     When the suffixes is non empty, completion for argument name will end with
+	 *     one of the proposed suffixes.
+	 *      - option id:         "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
+	 *      - possible values:   { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card 
+	 *      - default:           ""
+	 *  </pre>
+	 *  
+	 *  @return a mutable table containing the default settings of all known options
+	 *    (key type: 
+	 * 
+	 * String
+	 * 
+	 * ; value type: 
+	 * 
+	 * String
+	 * 
+	 * )
+	 *  @see #setOptions
+	 * 
+	 */
+	public static Hashtable getDefaultOptions() {
+
+		Hashtable defaultOptions = new Hashtable(10);
+
+		// see #initializeDefaultPluginPreferences() for changing default
+		// settings
+		Preferences preferences = getPlugin().getPluginPreferences();
+		HashSet optionNames = JavaModelManager.OptionNames;
+
+		// get preferences set to their default
+		String[] defaultPropertyNames = preferences.defaultPropertyNames();
+		for (int i = 0; i < defaultPropertyNames.length; i++) {
+			String propertyName = defaultPropertyNames[i];
+			if (optionNames.contains(propertyName)) {
+				defaultOptions.put(propertyName, preferences
+						.getDefaultString(propertyName));
+			}
+		}
+		// get preferences not set to their default
+		String[] propertyNames = preferences.propertyNames();
+		for (int i = 0; i < propertyNames.length; i++) {
+			String propertyName = propertyNames[i];
+			if (optionNames.contains(propertyName)) {
+				defaultOptions.put(propertyName, preferences
+						.getDefaultString(propertyName));
+			}
+		}
+		// get encoding through resource plugin
+		defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
+
+		return defaultOptions;
+	}
+
+	/**
+	 * Returns the single instance of the Java core plug-in runtime class.
+	 * Equivalent to (JavaCore) getPlugin().
+	 * 
+	 * @return the single instance of the Java core plug-in runtime class
+	 */
+	public static PHPeclipsePlugin getJavaCore() {
+		return (PHPeclipsePlugin) getPlugin();
+	}
+
+	/**
+	 * Helper method for returning one option value only. Equivalent to
+	 * (String)JavaCore.getOptions().get(optionName) Note that it
+	 * may answer null if this option does not exist.
+	 * 

+ * For a complete description of the configurable options, see + * getDefaultOptions. + *

+ * + * @param optionName + * the name of an option + * @return the String value of a given option + * @see JavaCore#getDefaultOptions + * @since 2.0 + */ + public static String getOption(String optionName) { + + if (CORE_ENCODING.equals(optionName)) { + return ResourcesPlugin.getEncoding(); + } + if (JavaModelManager.OptionNames.contains(optionName)) { + Preferences preferences = getPlugin().getPluginPreferences(); + return preferences.getString(optionName).trim(); + } + return null; + } + + /** + * Returns the table of the current options. Initially, all options have + * their default values, and this method returns a table that includes all + * known options. + *

+ * For a complete description of the configurable options, see + * getDefaultOptions. + *

+ * + * @return table of current settings of all options (key type: + * String; value type: String) + * @see JavaCore#getDefaultOptions + */ + public static Hashtable getOptions() { + + Hashtable options = new Hashtable(10); + + // see #initializeDefaultPluginPreferences() for changing default + // settings + Plugin plugin = getPlugin(); + if (plugin != null) { + Preferences preferences = getPlugin().getPluginPreferences(); + HashSet optionNames = JavaModelManager.OptionNames; + + // get preferences set to their default + String[] defaultPropertyNames = preferences.defaultPropertyNames(); + for (int i = 0; i < defaultPropertyNames.length; i++) { + String propertyName = defaultPropertyNames[i]; + if (optionNames.contains(propertyName)) { + options.put(propertyName, preferences + .getDefaultString(propertyName)); + } + } + // get preferences not set to their default + String[] propertyNames = preferences.propertyNames(); + for (int i = 0; i < propertyNames.length; i++) { + String propertyName = propertyNames[i]; + if (optionNames.contains(propertyName)) { + options.put(propertyName, preferences.getString( + propertyName).trim()); + } + } + // get encoding through resource plugin + options.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); + } + return options; + } + + /** + * This is a helper method, which returns the resolved classpath entry + * denoted by a given entry (if it is a variable entry). It is obtained by + * resolving the variable reference in the first segment. Returns null + * if unable to resolve using the following algorithm: + *
    + *
  • if variable segment cannot be resolved, returns null + *
  • + *
  • finds a project, JAR or binary folder in the workspace at the + * resolved path location
  • + *
  • if none finds an external JAR file or folder outside the workspace + * at the resolved path location
  • + *
  • if none returns null
  • + *
+ *

+ * Variable source attachment path and root path are also resolved and + * recorded in the resulting classpath entry. + *

+ * NOTE: This helper method does not handle classpath containers, for which + * should rather be used JavaCore#getClasspathContainer(IPath, + * IJavaProject). + *

+ * + * @param entry + * the given variable entry + * @return the resolved library or project classpath entry, or null + * if the given variable entry could not be resolved to a + * valid classpath entry + */ + public static IClasspathEntry getResolvedClasspathEntry( + IClasspathEntry entry) { + + if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) + return entry; + + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath()); + if (resolvedPath == null) + return null; + + Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false); + if (target == null) + return null; + + // inside the workspace + if (target instanceof IResource) { + IResource resolvedResource = (IResource) target; + if (resolvedResource != null) { + switch (resolvedResource.getType()) { + + case IResource.PROJECT: + // internal project + return JavaCore.newProjectEntry(resolvedPath, entry + .isExported()); + + case IResource.FILE: + // if (Util.isArchiveFileName(resolvedResource.getName())) { + // // internal binary archive + // return JavaCore.newLibraryEntry( + // resolvedPath, + // getResolvedVariablePath(entry.getSourceAttachmentPath()), + // getResolvedVariablePath(entry.getSourceAttachmentRootPath()), + // entry.isExported()); + // } + break; + + case IResource.FOLDER: + // internal binary folder + // return JavaCore.newLibraryEntry( + // resolvedPath, + // getResolvedVariablePath(entry.getSourceAttachmentPath()), + // getResolvedVariablePath(entry.getSourceAttachmentRootPath()), + // entry.isExported()); + break; + } + } + } + // outside the workspace + if (target instanceof File) { + File externalFile = (File) target; + if (externalFile.isFile()) { + String fileName = externalFile.getName().toLowerCase(); + // if (fileName.endsWith(".jar" //$NON-NLS-1$ + // ) || fileName.endsWith(".zip" //$NON-NLS-1$ + // )) { // external binary archive + // return JavaCore.newLibraryEntry( + // resolvedPath, + // getResolvedVariablePath(entry.getSourceAttachmentPath()), + // getResolvedVariablePath(entry.getSourceAttachmentRootPath()), + // entry.isExported()); + // } + } else { // external binary folder + if (resolvedPath.isAbsolute()) { + // return JavaCore.newLibraryEntry( + // resolvedPath, + // getResolvedVariablePath(entry.getSourceAttachmentPath()), + // getResolvedVariablePath(entry.getSourceAttachmentRootPath()), + // entry.isExported()); + } + } + } + return null; + } + + /** + * Resolve a variable path (helper method). + * + * @param variablePath + * the given variable path + * @return the resolved variable path or null if none + */ + public static IPath getResolvedVariablePath(IPath variablePath) { + + if (variablePath == null) + return null; + int count = variablePath.segmentCount(); + if (count == 0) + return null; + + // lookup variable + String variableName = variablePath.segment(0); + IPath resolvedPath = JavaCore.getClasspathVariable(variableName); + if (resolvedPath == null) + return null; + + // append path suffix + if (count > 1) { + resolvedPath = resolvedPath.append(variablePath + .removeFirstSegments(1)); + } + return resolvedPath; + } + + /** + * Answers the shared working copies currently registered for this buffer + * factory. Working copies can be shared by several clients using the same + * buffer factory,see IWorkingCopy.getSharedWorkingCopy. + * + * @param factory + * the given buffer factory + * @return the list of shared working copies for a given buffer factory + * @see IWorkingCopy + * @since 2.0 + */ + public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) { + + // if factory is null, default factory must be used + if (factory == null) + factory = BufferManager.getDefaultBufferManager() + .getDefaultBufferFactory(); + Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies; + + Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory); + if (perFactoryWorkingCopies == null) + return JavaModelManager.NoWorkingCopy; + Collection copies = perFactoryWorkingCopies.values(); + IWorkingCopy[] result = new IWorkingCopy[copies.size()]; + copies.toArray(result); + return result; + } + + /** + * Initializes the default preferences settings for this plug-in. + */ + public static void initializeDefaultPluginPreferences() { + + Preferences preferences = PHPeclipsePlugin.getDefault() + .getPluginPreferences(); + HashSet optionNames = JavaModelManager.OptionNames; + + // Compiler settings + preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE); + optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR); + + preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE); + optionNames.add(COMPILER_LINE_NUMBER_ATTR); + + preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE); + optionNames.add(COMPILER_SOURCE_FILE_ATTR); + + preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE); + optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL); + + preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1); + optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM); + + preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING); + optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED); + + preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR); + optionNames.add(COMPILER_PB_UNREACHABLE_CODE); + + preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR); + optionNames.add(COMPILER_PB_INVALID_IMPORT); + + preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, + WARNING); + optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD); + + preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, + WARNING); + optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME); + + preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING); + optionNames.add(COMPILER_PB_DEPRECATION); + + preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, + DISABLED); + optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE); + + preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING); + optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK); + + preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE); + optionNames.add(COMPILER_PB_UNUSED_LOCAL); + + preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE); + optionNames.add(COMPILER_PB_UNUSED_PARAMETER); + + preferences.setDefault( + COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, + DISABLED); + optionNames + .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT); + + preferences + .setDefault( + COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, + DISABLED); + optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE); + + preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING); + optionNames.add(COMPILER_PB_UNUSED_IMPORT); + + preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE); + optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER); + + preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE); + optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION); + + preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE); + optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL); + + preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE); + optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER); + + preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING); + optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER); + + preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING); + optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT); + + preferences.setDefault( + COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, + WARNING); + optionNames + .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD); + + preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, + WARNING); + optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION); + + preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$ + optionNames.add(COMPILER_TASK_TAGS); + + preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$ + optionNames.add(COMPILER_TASK_PRIORITIES); + + preferences.setDefault(COMPILER_SOURCE, VERSION_1_3); + optionNames.add(COMPILER_SOURCE); + + preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3); + optionNames.add(COMPILER_COMPLIANCE); + + preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$ + optionNames.add(COMPILER_PB_MAX_PER_UNIT); + + // Builder settings + preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$ + optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER); + + preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT); + optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH); + + preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING); + optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE); + + preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN); + optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER); + + // JavaCore settings + preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE); + optionNames.add(CORE_JAVA_BUILD_ORDER); + + preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR); + optionNames.add(CORE_CIRCULAR_CLASSPATH); + + preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR); + optionNames.add(CORE_INCOMPLETE_CLASSPATH); + + preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, + ENABLED); + optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS); + + preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, + ENABLED); + optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS); + + // encoding setting comes from resource plug-in + optionNames.add(CORE_ENCODING); + + // Formatter settings + preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT); + optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE); + + preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT); + optionNames.add(FORMATTER_NEWLINE_CONTROL); + + preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE); + optionNames.add(FORMATTER_CLEAR_BLANK_LINES); + + preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT); + optionNames.add(FORMATTER_NEWLINE_ELSE_IF); + + preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT); + optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK); + + preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$ + optionNames.add(FORMATTER_LINE_SPLIT); + + preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL); + optionNames.add(FORMATTER_COMPACT_ASSIGNMENT); + + preferences.setDefault(FORMATTER_TAB_CHAR, TAB); + optionNames.add(FORMATTER_TAB_CHAR); + + preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ + optionNames.add(FORMATTER_TAB_SIZE); + + preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$ + optionNames.add(FORMATTER_SPACE_CASTEXPRESSION); + + // CodeAssist settings + preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$ + optionNames.add(CODEASSIST_VISIBILITY_CHECK); + + preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$ + optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION); + + preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_FIELD_PREFIXES); + + preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES); + + preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_LOCAL_PREFIXES); + + preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_ARGUMENT_PREFIXES); + + preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_FIELD_SUFFIXES); + + preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES); + + preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_LOCAL_SUFFIXES); + + preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$ + optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES); + } + + /** + * Returns whether the given marker references the given Java element. Used + * for markers, which denote a Java element rather than a resource. + * + * @param element + * the element + * @param marker + * the marker + * @return true if the marker references the element, false + * otherwise + * @exception CoreException + * if the IMarker.getAttribute on the marker + * fails + */ + public static boolean isReferencedBy(IJavaElement element, IMarker marker) + throws CoreException { + + // only match units or classfiles + if (element instanceof IMember) { + IMember member = (IMember) element; + if (member.isBinary()) { + element = null; //member.getClassFile(); + } else { + element = member.getCompilationUnit(); + } + } + if (element == null) + return false; + if (marker == null) + return false; + + String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID); + if (markerHandleId == null) + return false; + + IJavaElement markerElement = JavaCore.create(markerHandleId); + // while (true){ + if (element.equals(markerElement)) + return true; // external elements may still be equal with different + // handleIDs. + + // cycle through enclosing types in case marker is associated with a + // classfile (15568) + // if (markerElement instanceof IClassFile){ + // IType enclosingType = + // ((IClassFile)markerElement).getType().getDeclaringType(); + // if (enclosingType != null){ + // markerElement = enclosingType.getClassFile(); // retry with immediate + // enclosing classfile + // continue; + // } + // } + // break; + // } + return false; + } + + /** + * Returns whether the given marker delta references the given Java element. + * Used for markers deltas, which denote a Java element rather than a + * resource. + * + * @param element + * the element + * @param markerDelta + * the marker delta + * @return true if the marker delta references the element + * @exception CoreException + * if the IMarkerDelta.getAttribute on the + * marker delta fails + */ + public static boolean isReferencedBy(IJavaElement element, + IMarkerDelta markerDelta) throws CoreException { + + // only match units or classfiles + if (element instanceof IMember) { + IMember member = (IMember) element; + if (member.isBinary()) { + element = null; //member.getClassFile(); + } else { + element = member.getCompilationUnit(); + } + } + if (element == null) + return false; + if (markerDelta == null) + return false; + + String markerDeltarHandleId = (String) markerDelta + .getAttribute(ATT_HANDLE_ID); + if (markerDeltarHandleId == null) + return false; + + IJavaElement markerElement = JavaCore.create(markerDeltarHandleId); + // while (true){ + if (element.equals(markerElement)) + return true; // external elements may still be equal with different + // handleIDs. + + // cycle through enclosing types in case marker is associated with a + // classfile (15568) + // if (markerElement instanceof IClassFile){ + // IType enclosingType = + // ((IClassFile)markerElement).getType().getDeclaringType(); + // if (enclosingType != null){ + // markerElement = enclosingType.getClassFile(); // retry with immediate + // enclosing classfile + // continue; + // } + // } + // break; + // } + return false; + } + + /** + * Creates and returns a new classpath entry of kind + * CPE_CONTAINER for the given path. The path of the + * container will be used during resolution so as to map this container + * entry to a set of other classpath entries the container is acting for. + *

+ * A container entry allows to express indirect references to a set of + * libraries, projects and variable entries, which can be interpreted + * differently for each Java project where it is used. A classpath container + * entry can be resolved using + * JavaCore.getResolvedClasspathContainer, and updated with + * JavaCore.classpathContainerChanged + *

+ * A container is exclusively resolved by a + * ClasspathContainerInitializer registered onto the + * extension point "org.eclipse.jdt.core.classpathContainerInitializer". + *

+ * A container path must be formed of at least one segment, where: + *

    + *
  • the first segment is a unique ID identifying the target container, + * there must be a container initializer registered onto this ID through the + * extension point "org.eclipse.jdt.core.classpathContainerInitializer". + *
  • + *
  • the remaining segments will be passed onto the initializer, and can + * be used as additional hints during the initialization phase.
  • + *
+ *

+ * Example of an ClasspathContainerInitializer for a classpath container + * denoting a default JDK container: + * + * containerEntry = JavaCore.newContainerEntry(new + * Path("MyProvidedJDK/default")); + * + * + * + *

+ * Note that this operation does not attempt to validate classpath + * containers or access the resources at the given paths. + *

+ * The resulting entry is not exported to dependent projects. This method is + * equivalent to newContainerEntry(-,false). + *

+ * + * @param containerPath + * the path identifying the container, it must be formed of two + * segments + * @return a new container classpath entry + * + * @see JavaCore#getClasspathContainer(IPath, IJavaProject) + * @see JavaCore#newContainerEntry(IPath, boolean) + * @since 2.0 + */ + public static IClasspathEntry newContainerEntry(IPath containerPath) { + + return newContainerEntry(containerPath, false); + } /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions + * Creates and returns a new classpath entry of kind + * CPE_CONTAINER for the given path. The path of the + * container will be used during resolution so as to map this container + * entry to a set of other classpath entries the container is acting for. + *

+ * A container entry allows to express indirect references to a set of + * libraries, projects and variable entries, which can be interpreted + * differently for each Java project where it is used. A classpath container + * entry can be resolved using + * JavaCore.getResolvedClasspathContainer, and updated with + * JavaCore.classpathContainerChanged + *

+ * A container is exclusively resolved by a + * ClasspathContainerInitializer registered onto the + * extension point "org.eclipse.jdt.core.classpathContainerInitializer". + *

+ * A container path must be formed of at least one segment, where: + *

    + *
  • the first segment is a unique ID identifying the target container, + * there must be a container initializer registered onto this ID through the + * extension point "org.eclipse.jdt.core.classpathContainerInitializer". + *
  • + *
  • the remaining segments will be passed onto the initializer, and can + * be used as additional hints during the initialization phase.
  • + *
+ *

+ * Example of an ClasspathContainerInitializer for a classpath container + * denoting a default JDK container: + * + * containerEntry = JavaCore.newContainerEntry(new + * Path("MyProvidedJDK/default")); + * + * + * + *

+ * Note that this operation does not attempt to validate classpath + * containers or access the resources at the given paths. + *

+ * + * @param containerPath + * the path identifying the container, it must be formed of at + * least one segment (ID+hints) + * @param isExported + * a boolean indicating whether this entry is contributed to + * dependent projects in addition to the output location + * @return a new container classpath entry + * + * @see JavaCore#getClasspathContainer(IPath, IJavaProject) + * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], + * IClasspathContainer[], IProgressMonitor) + * @see JavaCore#newContainerEntry(IPath, boolean) * @since 2.0 */ - public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; //$NON-NLS-1$ + public static IClasspathEntry newContainerEntry(IPath containerPath, + boolean isExported) { + + if (containerPath == null || containerPath.segmentCount() < 1) { + Assert + .isTrue( + false, + "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$ + } + return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, + IClasspathEntry.CPE_CONTAINER, containerPath, + ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment + null, // source attachment root + null, // specific output folder + isExported); + } + /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 + * Creates and returns a new non-exported classpath entry of kind + * CPE_LIBRARY for the JAR or folder identified by the given + * absolute path. This specifies that all package fragments within the root + * will have children of type IClassFile. + *

+ * A library entry is used to denote a prerequisite JAR or root folder + * containing binaries. The target JAR or folder can either be defined + * internally to the workspace (absolute path relative to the workspace + * root) or externally to the workspace (absolute path in the file system). + *

+ * e.g. Here are some examples of binary path usage + *

    + *
  • "c:/jdk1.2.2/jre/lib/rt.jar" - reference to an + * external JAR
  • + *
  • "/Project/someLib.jar" - reference to an internal JAR + *
  • + *
  • "c:/classes/" - reference to an external binary + * folder
  • + *
+ * Note that this operation does not attempt to validate or access the + * resources at the given paths. + *

+ * The resulting entry is not exported to dependent projects. This method is + * equivalent to newLibraryEntry(-,-,-,false). + *

+ * + * @param path + * the absolute path of the binary archive + * @param sourceAttachmentPath + * the absolute path of the corresponding source archive or + * folder, or null if none + * @param sourceAttachmentRootPath + * the location of the root within the source archive or folder + * or null if this location should be + * automatically detected. + * @return a new library classpath entry + * + * @see #newLibraryEntry(IPath, IPath, IPath, boolean) */ - public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$ + //public static IClasspathEntry newLibraryEntry( + // IPath path, + // IPath sourceAttachmentPath, + // IPath sourceAttachmentRootPath) { + // + // return newLibraryEntry(path, sourceAttachmentPath, + // sourceAttachmentRootPath, false); + //} /** - * Possible configurable option ID. - * @see #getDefaultOptions + * Creates and returns a new classpath entry of kind + * CPE_LIBRARY for the JAR or folder identified by the given + * absolute path. This specifies that all package fragments within the root + * will have children of type IClassFile. + *

+ * A library entry is used to denote a prerequisite JAR or root folder + * containing binaries. The target JAR or folder can either be defined + * internally to the workspace (absolute path relative to the workspace + * root) or externally to the workspace (absolute path in the file system). + *

+ * e.g. Here are some examples of binary path usage + *

    + *
  • "c:/jdk1.2.2/jre/lib/rt.jar" - reference to an + * external JAR
  • + *
  • "/Project/someLib.jar" - reference to an internal JAR + *
  • + *
  • "c:/classes/" - reference to an external binary + * folder
  • + *
+ * Note that this operation does not attempt to validate or access the + * resources at the given paths. + *

+ * + * @param path + * the absolute path of the binary archive + * @param sourceAttachmentPath + * the absolute path of the corresponding source archive or + * folder, or null if none + * @param sourceAttachmentRootPath + * the location of the root within the source archive or folder + * or null if this location should be + * automatically detected. + * @param isExported + * indicates whether this entry is contributed to dependent + * projects in addition to the output location + * @return a new library classpath entry * @since 2.0 */ - public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$ + //public static IClasspathEntry newLibraryEntry( + // IPath path, + // IPath sourceAttachmentPath, + // IPath sourceAttachmentRootPath, + // boolean isExported) { + // + // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry + // must be absolute"); //$NON-NLS-1$ + // + // return new ClasspathEntry( + // IPackageFragmentRoot.K_BINARY, + // IClasspathEntry.CPE_LIBRARY, + // JavaProject.canonicalizedPath(path), + // ClasspathEntry.NO_EXCLUSION_PATTERNS, + // sourceAttachmentPath, + // sourceAttachmentRootPath, + // null, // specific output folder + // isExported); + //} /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Creates and returns a new non-exported classpath entry of kind + * CPE_PROJECT for the project identified by the given + * absolute path. + *

+ * A project entry is used to denote a prerequisite project on a classpath. + * The referenced project will be contributed as a whole, either as sources + * (in the Java Model, it contributes all its package fragment roots) or as + * binaries (when building, it contributes its whole output location). + *

+ * A project reference allows to indirect through another project, + * independently from its internal layout. + *

+ * The prerequisite project is referred to using an absolute path relative + * to the workspace root. + *

+ * The resulting entry is not exported to dependent projects. This method is + * equivalent to newProjectEntry(_,false). + *

+ * + * @param path + * the absolute path of the binary archive + * @return a new project classpath entry + * + * @see JavaCore#newProjectEntry(IPath, boolean) */ - public static final String INSERT = "insert"; //$NON-NLS-1$ + public static IClasspathEntry newProjectEntry(IPath path) { + return newProjectEntry(path, false); + } + /** - * Possible configurable option value. - * @see #getDefaultOptions + * Creates and returns a new classpath entry of kind + * CPE_PROJECT for the project identified by the given + * absolute path. + *

+ * A project entry is used to denote a prerequisite project on a classpath. + * The referenced project will be contributed as a whole, either as sources + * (in the Java Model, it contributes all its package fragment roots) or as + * binaries (when building, it contributes its whole output location). + *

+ * A project reference allows to indirect through another project, + * independently from its internal layout. + *

+ * The prerequisite project is referred to using an absolute path relative + * to the workspace root. + *

+ * + * @param path + * the absolute path of the prerequisite project + * @param isExported + * indicates whether this entry is contributed to dependent + * projects in addition to the output location + * @return a new project classpath entry * @since 2.0 */ - public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$ + public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) { + + if (!path.isAbsolute()) + Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ + + return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, + IClasspathEntry.CPE_PROJECT, path, + ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment + null, // source attachment root + null, // specific output folder + isExported); + } /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Returns a new empty region. + * + * @return a new empty region */ - public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$ + public static IRegion newRegion() { + return new Region(); + } + /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Creates and returns a new classpath entry of kind CPE_SOURCE + * for the project's source folder identified by the given absolute + * workspace-relative path. This specifies that all package fragments within + * the root will have children of type ICompilationUnit. + *

+ * The source folder is referred to using an absolute path relative to the + * workspace root, e.g. /Project/src. A project's source + * folders are located with that project. That is, a source classpath entry + * specifying the path /P1/src is only usable for project + * P1. + *

+ *

+ * The source classpath entry created by this method includes all source + * files below the given workspace-relative path. To selectively exclude + * some of these source files, use the factory method + * JavaCore.newSourceEntry(IPath,IPath[]) instead. + *

+ *

+ * Note that all sources/binaries inside a project are contributed as a + * whole through a project entry (see JavaCore.newProjectEntry). + * Particular source entries cannot be selectively exported. + *

+ * + * @param path + * the absolute workspace-relative path of a source folder + * @return a new source classpath entry with not exclusion patterns + * + * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[]) */ - public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$ + public static IClasspathEntry newSourceEntry(IPath path) { + + return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /* + * output + * location + */); + } + /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Creates and returns a new classpath entry of kind CPE_SOURCE + * for the project's source folder identified by the given absolute + * workspace-relative path but excluding all source files with paths + * matching any of the given patterns. This specifies that all package + * fragments within the root will have children of type + * ICompilationUnit. + *

+ * The source folder is referred to using an absolute path relative to the + * workspace root, e.g. /Project/src. A project's source + * folders are located with that project. That is, a source classpath entry + * specifying the path /P1/src is only usable for project + * P1. + *

+ *

+ * The source classpath entry created by this method includes all source + * files below the given workspace-relative path except for those matched by + * one (or more) of the given exclusion patterns. Each exclusion pattern is + * represented by a relative path, which is interpreted as relative to the + * source folder. For example, if the source folder path is + * /Project/src and the exclusion pattern is + * com/xyz/tests/**, then source files like + * /Project/src/com/xyz/Foo.java and + * /Project/src/com/xyz/utils/Bar.java would be included, + * whereas /Project/src/com/xyz/tests/T1.java and + * /Project/src/com/xyz/tests/quick/T2.java would be + * excluded. Exclusion patterns can contain can contain '**', '*' or '?' + * wildcards; see IClasspathEntry.getExclusionPatterns for + * the full description of the syntax and semantics of exclusion patterns. + *

+ * If the empty list of exclusion patterns is specified, the source folder + * will automatically include all resources located inside the source + * folder. In that case, the result is entirely equivalent to using the + * factory method JavaCore.newSourceEntry(IPath). + *

+ *

+ * Note that all sources/binaries inside a project are contributed as a + * whole through a project entry (see JavaCore.newProjectEntry). + * Particular source entries cannot be selectively exported. + *

+ * + * @param path + * the absolute workspace-relative path of a source folder + * @param exclusionPatterns + * the possibly empty list of exclusion patterns represented as + * relative paths + * @return a new source classpath entry with the given exclusion patterns + * @see #newSourceEntry(org.eclipse.core.runtime.IPath) + * @see IClasspathEntry#getExclusionPatterns + * + * @since 2.1 */ - public static final String NORMAL = "normal"; //$NON-NLS-1$ + public static IClasspathEntry newSourceEntry(IPath path, + IPath[] exclusionPatterns) { + + return newSourceEntry(path, exclusionPatterns, null /* output location */); + } + /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Creates and returns a new classpath entry of kind CPE_SOURCE + * for the project's source folder identified by the given absolute + * workspace-relative path but excluding all source files with paths + * matching any of the given patterns, and associated with a specific output + * location (that is, ".class" files are not going to the project default + * output location). All package fragments within the root will have + * children of type ICompilationUnit. + *

+ * The source folder is referred to using an absolute path relative to the + * workspace root, e.g. /Project/src. A project's source + * folders are located with that project. That is, a source classpath entry + * specifying the path /P1/src is only usable for project + * P1. + *

+ *

+ * The source classpath entry created by this method includes all source + * files below the given workspace-relative path except for those matched by + * one (or more) of the given exclusion patterns. Each exclusion pattern is + * represented by a relative path, which is interpreted as relative to the + * source folder. For example, if the source folder path is + * /Project/src and the exclusion pattern is + * com/xyz/tests/**, then source files like + * /Project/src/com/xyz/Foo.java and + * /Project/src/com/xyz/utils/Bar.java would be included, + * whereas /Project/src/com/xyz/tests/T1.java and + * /Project/src/com/xyz/tests/quick/T2.java would be + * excluded. Exclusion patterns can contain can contain '**', '*' or '?' + * wildcards; see IClasspathEntry.getExclusionPatterns for + * the full description of the syntax and semantics of exclusion patterns. + *

+ * If the empty list of exclusion patterns is specified, the source folder + * will automatically include all resources located inside the source + * folder. In that case, the result is entirely equivalent to using the + * factory method JavaCore.newSourceEntry(IPath). + *

+ *

+ * Additionally, a source entry can be associated with a specific output + * location. By doing so, the Java builder will ensure that the generated + * ".class" files will be issued inside this output location, as opposed to + * be generated into the project default output location (when output + * location is null). Note that multiple source entries may + * target the same output location. The output location is referred to using + * an absolute path relative to the workspace root, e.g. + * "/Project/bin", it must be located inside the same + * project as the source folder. + *

+ *

+ * Also note that all sources/binaries inside a project are contributed as a + * whole through a project entry (see JavaCore.newProjectEntry). + * Particular source entries cannot be selectively exported. + *

+ * + * @param path + * the absolute workspace-relative path of a source folder + * @param exclusionPatterns + * the possibly empty list of exclusion patterns represented as + * relative paths + * @param outputLocation + * the specific output location for this source entry ( + * null if using project default ouput location) + * @return a new source classpath entry with the given exclusion patterns + * @see #newSourceEntry(org.eclipse.core.runtime.IPath) + * @see IClasspathEntry#getExclusionPatterns + * @see IClasspathEntry#getOutputLocation() + * + * @since 2.1 */ - public static final String COMPACT = "compact"; //$NON-NLS-1$ + public static IClasspathEntry newSourceEntry(IPath path, + IPath[] exclusionPatterns, IPath specificOutputLocation) { + + if (!path.isAbsolute()) + Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ + if (exclusionPatterns == null) + Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$ + + return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, + IClasspathEntry.CPE_SOURCE, path, exclusionPatterns, null, // source + // attachment + null, // source attachment root + specificOutputLocation, // custom output location + false); + } + /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Creates and returns a new non-exported classpath entry of kind + * CPE_VARIABLE for the given path. The first segment of the + * path is the name of a classpath variable. The trailing segments of the + * path will be appended to resolved variable path. + *

+ * A variable entry allows to express indirect references on a classpath to + * other projects or libraries, depending on what the classpath variable is + * referring. + *

+ * It is possible to register an automatic initializer ( + * ClasspathVariableInitializer), which will be invoked + * through the extension point + * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a + * classpath variable entry may either correspond to a project or a library + * entry. + *

+ * e.g. Here are some examples of variable path usage + *

    + *
  • "JDTCORE" where variable JDTCORE is bound to + * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the + * library "c:\jars\jdtcore.jar"
  • + *
  • "JDTCORE" where variable JDTCORE is bound to + * "/Project_JDTCORE". The resolved classpath entry is denoting the project + * "/Project_JDTCORE"
  • + *
  • "PLUGINS/com.example/example.jar" where variable + * PLUGINS is bound to "c:/eclipse/plugins". The resolved + * classpath entry is denoting the library + * "c:/eclipse/plugins/com.example/example.jar"
  • + *
+ * Note that this operation does not attempt to validate classpath variables + * or access the resources at the given paths. + *

+ * The resulting entry is not exported to dependent projects. This method is + * equivalent to newVariableEntry(-,-,-,false). + *

+ * + * @param variablePath + * the path of the binary archive; first segment is the name of a + * classpath variable + * @param variableSourceAttachmentPath + * the path of the corresponding source archive, or + * null if none; if present, the first segment is + * the name of a classpath variable (not necessarily the same + * variable as the one that begins variablePath) + * @param sourceAttachmentRootPath + * the location of the root within the source archive or + * null if archivePath is also + * null + * @return a new library classpath entry + * + * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean) */ - public static final String TAB = "tab"; //$NON-NLS-1$ + //public static IClasspathEntry newVariableEntry( + // IPath variablePath, + // IPath variableSourceAttachmentPath, + // IPath sourceAttachmentRootPath) { + // + // return newVariableEntry(variablePath, variableSourceAttachmentPath, + // sourceAttachmentRootPath, false); + //} /** - * Possible configurable option value. - * @see #getDefaultOptions + * Creates and returns a new non-exported classpath entry of kind + * CPE_VARIABLE for the given path. The first segment of the + * path is the name of a classpath variable. The trailing segments of the + * path will be appended to resolved variable path. + *

+ * A variable entry allows to express indirect references on a classpath to + * other projects or libraries, depending on what the classpath variable is + * referring. + *

+ * It is possible to register an automatic initializer ( + * ClasspathVariableInitializer), which will be invoked + * through the extension point + * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a + * classpath variable entry may either correspond to a project or a library + * entry. + *

+ * e.g. Here are some examples of variable path usage + *

    + *
  • "JDTCORE" where variable JDTCORE is bound to + * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the + * library "c:\jars\jdtcore.jar"
  • + *
  • "JDTCORE" where variable JDTCORE is bound to + * "/Project_JDTCORE". The resolved classpath entry is denoting the project + * "/Project_JDTCORE"
  • + *
  • "PLUGINS/com.example/example.jar" where variable + * PLUGINS is bound to "c:/eclipse/plugins". The resolved + * classpath entry is denoting the library + * "c:/eclipse/plugins/com.example/example.jar"
  • + *
+ * Note that this operation does not attempt to validate classpath variables + * or access the resources at the given paths. + *

+ * + * @param variablePath + * the path of the binary archive; first segment is the name of a + * classpath variable + * @param variableSourceAttachmentPath + * the path of the corresponding source archive, or + * null if none; if present, the first segment is + * the name of a classpath variable (not necessarily the same + * variable as the one that begins variablePath) + * @param sourceAttachmentRootPath + * the location of the root within the source archive or + * null if archivePath is also + * null + * @param isExported + * indicates whether this entry is contributed to dependent + * projects in addition to the output location + * @return a new variable classpath entry * @since 2.0 */ - public static final String SPACE = "space"; //$NON-NLS-1$ + //public static IClasspathEntry newVariableEntry( + // IPath variablePath, + // IPath variableSourceAttachmentPath, + // IPath variableSourceAttachmentRootPath, + // boolean isExported) { + // + // if (variablePath == null || variablePath.segmentCount() < 1) { + // Assert.isTrue( + // false, + // "Illegal classpath variable path: \'" + + // variablePath.makeRelative().toString() + "\', must have at least one + // segment"); //$NON-NLS-1$//$NON-NLS-2$ + // } + // + // return new ClasspathEntry( + // IPackageFragmentRoot.K_SOURCE, + // IClasspathEntry.CPE_VARIABLE, + // variablePath, + // ClasspathEntry.NO_EXCLUSION_PATTERNS, + // variableSourceAttachmentPath, // source attachment + // variableSourceAttachmentRootPath, // source attachment root + // null, // specific output folder + // isExported); + //} /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Removed the given classpath variable. Does nothing if no value was set + * for this classpath variable. + *

+ * This functionality cannot be used while the resource tree is locked. + *

+ * Classpath variable values are persisted locally to the workspace, and are + * preserved from session to session. + *

+ * + * @param variableName + * the name of the classpath variable + * @see #setClasspathVariable + * + * @deprecated - use version with extra IProgressMonitor */ - public static final String ENABLED = "enabled"; //$NON-NLS-1$ + //public static void removeClasspathVariable(String variableName) { + // removeClasspathVariable(variableName, null); + //} /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 + * Removed the given classpath variable. Does nothing if no value was set + * for this classpath variable. + *

+ * This functionality cannot be used while the resource tree is locked. + *

+ * Classpath variable values are persisted locally to the workspace, and are + * preserved from session to session. + *

+ * + * @param variableName + * the name of the classpath variable + * @param monitor + * the progress monitor to report progress + * @see #setClasspathVariable */ - public static final String DISABLED = "disabled"; //$NON-NLS-1$ + //public static void removeClasspathVariable( + // String variableName, + // IProgressMonitor monitor) { + // + // try { + // updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, + // monitor); + // } catch (JavaModelException e) { + // } + //} /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.1 + * Removes the given element changed listener. Has no affect if an identical + * listener is not registered. + * + * @param listener + * the listener */ - public static final String CLEAN = "clean"; //$NON-NLS-1$ + public static void removeElementChangedListener( + IElementChangedListener listener) { + JavaModelManager.getJavaModelManager().removeElementChangedListener( + listener); + } /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_TASK_TAGS = PLUGIN_ID + ".compiler.taskTags"; //$NON-NLS-1$ - - /** - * Name of the handle id attribute in a Java marker. - */ - protected static final String ATT_HANDLE_ID = - "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId" ; //$NON-NLS-1$ - - // *************** Possible IDs for configurable options. ******************** - - /** - * Possible configurable option ID. - * @see #getDefaultOptions() - */ - public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions() - */ - public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$ - - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_PHP_VAR_DEPRECATED = PLUGIN_ID + ".compiler.problem.phpVarDeprecatedWarning"; //$NON-NLS-1$ - - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$ - - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String COMPILER_COMPLIANCE = PLUGIN_ID + ".compiler.compliance"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; //$NON-NLS-1$ - /** - * Possible configurable option value for COMPILER_TASK_PRIORITIES. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$ - /** - * Possible configurable option value for COMPILER_TASK_PRIORITIES. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$ - /** - * Possible configurable option value for COMPILER_TASK_PRIORITIES. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - */ - public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$ - /** - * Default task tag - * @since 2.1 - */ - public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$ - /** - * Default task priority - * @since 2.1 - */ - public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$ - /** - * Possible configurable option ID - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + ".codeComplete.visibilityCheck"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; //$NON-NLS-1$ - /** - * Possible configurable option ID. - * @see #getDefaultOptions - * @since 2.1 - */ - public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$ - - // *************** Possible values for configurable options. ******************** - - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String GENERATE = "generate"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String PRESERVE = "preserve"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 - */ - public static final String ABORT = "abort"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String ERROR = "error"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String WARNING = "warning"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String IGNORE = "ignore"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - */ - public static final String COMPUTE = "compute"; //$NON-NLS-1$ - /** - * Possible configurable option value. - * @see #getDefaultOptions - * @since 2.0 - */ - - - /** - * Returns a table of all known configurable options with their default values. - * These options allow to configure the behaviour of the underlying components. - * The client may safely use the result as a template that they can modify and - * then pass to setOptions. - * - * Helper constants have been defined on JavaCore for each of the option ID and - * their possible constant values. - * - * Note: more options might be added in further releases. - *

-   * RECOGNIZED OPTIONS:
-   * COMPILER / Generating Local Variable Debug Attribute
-   *    When generated, this attribute will enable local variable names 
-   *    to be displayed in debugger, only in place where variables are 
-   *    definitely assigned (.class file is then bigger)
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
-   *     - possible values:   { "generate", "do not generate" }
-   *     - default:           "generate"
-   *
-   * COMPILER / Generating Line Number Debug Attribute 
-   *    When generated, this attribute will enable source code highlighting in debugger 
-   *    (.class file is then bigger).
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
-   *     - possible values:   { "generate", "do not generate" }
-   *     - default:           "generate"
-   *    
-   * COMPILER / Generating Source Debug Attribute 
-   *    When generated, this attribute will enable the debugger to present the 
-   *    corresponding source code.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
-   *     - possible values:   { "generate", "do not generate" }
-   *     - default:           "generate"
-   *    
-   * COMPILER / Preserving Unused Local Variables
-   *    Unless requested to preserve unused local variables (i.e. never read), the 
-   *    compiler will optimize them out, potentially altering debugging
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
-   *     - possible values:   { "preserve", "optimize out" }
-   *     - default:           "preserve"
-   * 
-   * COMPILER / Defining Target Java Platform
-   *    For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
-   *    Note that "1.4" target require to toggle compliance mode to "1.4" too.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
-   *     - possible values:   { "1.1", "1.2", "1.3", "1.4" }
-   *     - default:           "1.1"
-   *
-   * COMPILER / Reporting Unreachable Code
-   *    Unreachable code can optionally be reported as an error, warning or simply 
-   *    ignored. The bytecode generation will always optimized it out.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "error"
-   *
-   * COMPILER / Reporting Invalid Import
-   *    An import statement that cannot be resolved might optionally be reported 
-   *    as an error, as a warning or ignored.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "error"
-   *
-   * COMPILER / Reporting Attempt to Override Package-Default Method
-   *    A package default method is not visible in a different package, and thus 
-   *    cannot be overridden. When enabling this option, the compiler will signal 
-   *    such scenarii either as an error or a warning.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "warning"
-   *
-   * COMPILER / Reporting Method With Constructor Name
-   *    Naming a method with a constructor name is generally considered poor 
-   *    style programming. When enabling this option, the compiler will signal such 
-   *    scenarii either as an error or a warning.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "warning"
-   *
-   * COMPILER / Reporting Deprecation
-   *    When enabled, the compiler will signal use of deprecated API either as an 
-   *    error or a warning.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "warning"
-   *
-   * COMPILER / Reporting Deprecation Inside Deprecated Code
-   *    When enabled, the compiler will signal use of deprecated API inside deprecated code.
-   *    The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
-   *     - possible values:   { "enabled", "disabled" }
-   *     - default:           "disabled"
-   *
-   * COMPILER / Reporting Hidden Catch Block
-   *    Locally to a try statement, some catch blocks may hide others , e.g.
-   *      try {  throw new java.io.CharConversionException();
-   *      } catch (java.io.CharConversionException e) {
-   *      } catch (java.io.IOException e) {}. 
-   *    When enabling this option, the compiler will issue an error or a warning for hidden 
-   *    catch blocks corresponding to checked exceptions
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "warning"
-   *
-   * COMPILER / Reporting Unused Local
-   *    When enabled, the compiler will issue an error or a warning for unused local 
-   *    variables (i.e. variables never read from)
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "ignore"
-   *
-   * COMPILER / Reporting Unused Parameter
-   *    When enabled, the compiler will issue an error or a warning for unused method 
-   *    parameters (i.e. parameters never read from)
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "ignore"
-   *
-   * COMPILER / Reporting Unused Import
-   *    When enabled, the compiler will issue an error or a warning for unused import 
-   *    reference 
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "warning"
-   *
-   * COMPILER / Reporting Synthetic Access Emulation
-   *    When enabled, the compiler will issue an error or a warning whenever it emulates 
-   *    access to a non-accessible member of an enclosing type. Such access can have
-   *    performance implications.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "ignore"
-   *
-   * COMPILER / Reporting Non-Externalized String Literal
-   *    When enabled, the compiler will issue an error or a warning for non externalized 
-   *    String literal (i.e. non tagged with //$NON-NLS-$). 
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "ignore"
-   * 
-   * COMPILER / Reporting Usage of 'assert' Identifier
-   *    When enabled, the compiler will issue an error or a warning whenever 'assert' is 
-   *    used as an identifier (reserved keyword in 1.4)
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "ignore"
-   * 
-   * COMPILER / Reporting Usage of expression receiver on static invocation/field access
-   *    When enabled, the compiler will issue an error or a warning whenever a static field
-   *    or method is accessed with an expression receiver.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "warning"
-   * 
-   * COMPILER / Reporting Assignment with no effect
-   *    When enabled, the compiler will issue an error or a warning whenever an assignment
-   *    has no effect (e.g 'x = x').
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
-   *     - possible values:   { "error", "warning", "ignore" }
-   *     - default:           "warning"
-   * 
-   * COMPILER / Setting Source Compatibility Mode
-   *    Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
-   *    reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
-   *   level should be set to "1.4" and the compliance mode should be "1.4".
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.source"
-   *     - possible values:   { "1.3", "1.4" }
-   *     - default:           "1.3"
-   * 
-   * COMPILER / Setting Compliance Level
-   *    Select the compliance level for the compiler. In "1.3" mode, source and target settings
-   *    should not go beyond "1.3" level.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.compliance"
-   *     - possible values:   { "1.3", "1.4" }
-   *     - default:           "1.3"
-   * 
-   * COMPILER / Maximum number of problems reported per compilation unit
-   *    Specify the maximum number of problems reported on each compilation unit.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
-   *     - possible values:	"" where  is zero or a positive integer (if zero then all problems are reported).
-   *     - default:           "100"
-   * 
-   * COMPILER / Define the Automatic Task Tags
-   *    When the tag is non empty, the compiler will issue a task marker whenever it encounters
-   *    one of the corresponding tag inside any comment in Java source code.
-   *    Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.taskTags"
-   *     - possible values:   { "[,]*" } where  is a String without any wild-card 
-   *     - default:           ""
-   * COMPILER / Define the Automatic Task Priorities
-   *    In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
-   *    of the task markers issued by the compiler.
-   *    If the default is specified, the priority of each task marker is "NORMAL".
-   *     - option id:         "org.phpeclipse.phpdt.core.compiler.taskPriorities"
-   *     - possible values:   { "[,]*" } where  is one of "HIGH", "NORMAL" or "LOW"
-   *     - default:           ""
-   * 
-   * BUILDER / Specifying Filters for Resource Copying Control
-   *    Allow to specify some filters to control the resource copy process.
-   *     - option id:         "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
-   *     - possible values:   { "[,]* } where  is a file name pattern (* and ? wild-cards allowed)
-   *       or the name of a folder which ends with '/'
-   *     - default:           ""
-   * 
-   * BUILDER / Abort if Invalid Classpath
-   *    Allow to toggle the builder to abort if the classpath is invalid
-   *     - option id:         "org.phpeclipse.phpdt.core.builder.invalidClasspath"
-   *     - possible values:   { "abort", "ignore" }
-   *     - default:           "ignore"
-   * 
-   * BUILDER / Cleaning Output Folder(s)
-   *    Indicate whether the JavaBuilder is allowed to clean the output folders
-   *    when performing full build operations.
-   *     - option id:         "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
-   *     - possible values:   { "clean", "ignore" }
-   *     - default:           "clean"
-   * 
-   * JAVACORE / Computing Project Build Order
-   *    Indicate whether JavaCore should enforce the project build order to be based on
-   *    the classpath prerequisite chain. When requesting to compute, this takes over
-   *    the platform default order (based on project references).
-   *     - option id:         "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
-   *     - possible values:   { "compute", "ignore" }
-   *     - default:           "ignore"	 
-   * 
-   * JAVACORE / Specify Default Source Encoding Format
-   *    Get the encoding format for compiled sources. This setting is read-only, it is equivalent
-   *    to 'ResourcesPlugin.getEncoding()'.
-   *     - option id:         "org.phpeclipse.phpdt.core.encoding"
-   *     - possible values:   { any of the supported encoding name}.
-   *     - default:           
-   * 
-   * JAVACORE / Reporting Incomplete Classpath
-   *    An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
-   *     - option id:         "org.phpeclipse.phpdt.core.incompleteClasspath"
-   *     - possible values:   { "error", "warning"}
-   *     - default:           "error"
-   * 
-   * JAVACORE / Reporting Classpath Cycle
-   *    A project is involved in a cycle.
-   *     - option id:         "org.phpeclipse.phpdt.core.circularClasspath"
-   *     - possible values:   { "error", "warning" }
-   *     - default:           "error"
-   * 
-   *	FORMATTER / Inserting New Line Before Opening Brace
-   *    When Insert, a new line is inserted before an opening brace, otherwise nothing
-   *    is inserted
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
-   *     - possible values:   { "insert", "do not insert" }
-   *     - default:           "do not insert"
-   * 
-   *	FORMATTER / Inserting New Line Inside Control Statement
-   *    When Insert, a new line is inserted between } and following else, catch, finally
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
-   *     - possible values:   { "insert", "do not insert" }
-   *     - default:           "do not insert"
-   * 
-   *	FORMATTER / Clearing Blank Lines
-   *    When Clear all, all blank lines are removed. When Preserve one, only one is kept
-   *    and all others removed.
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
-   *     - possible values:   { "clear all", "preserve one" }
-   *     - default:           "preserve one"
-   * 
-   *	FORMATTER / Inserting New Line Between Else/If 
-   *    When Insert, a blank line is inserted between an else and an if when they are 
-   *    contiguous. When choosing to not insert, else-if will be kept on the same
-   *    line when possible.
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
-   *     - possible values:   { "insert", "do not insert" }
-   *     - default:           "do not insert"
-   * 
-   *	FORMATTER / Inserting New Line In Empty Block
-   *    When insert, a line break is inserted between contiguous { and }, if } is not followed
-   *    by a keyword.
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
-   *     - possible values:   { "insert", "do not insert" }
-   *     - default:           "insert"
-   * 
-   *	FORMATTER / Splitting Lines Exceeding Length
-   *    Enable splitting of long lines (exceeding the configurable length). Length of 0 will
-   *    disable line splitting
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.lineSplit"
-   *     - possible values:	"", where n is zero or a positive integer
-   *     - default:           "80"
-   * 
-   *	FORMATTER / Compacting Assignment
-   *    Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
-   *    is inserted before the assignment operator
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.style.assignment"
-   *     - possible values:   { "compact", "normal" }
-   *     - default:           "normal"
-   * 
-   *	FORMATTER / Defining Indentation Character
-   *    Either choose to indent with tab characters or spaces
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.tabulation.char"
-   *     - possible values:   { "tab", "space" }
-   *     - default:           "tab"
-   * 
-   *	FORMATTER / Defining Space Indentation Length
-   *    When using spaces, set the amount of space characters to use for each 
-   *    indentation mark.
-   *     - option id:         "org.phpeclipse.phpdt.core.formatter.tabulation.size"
-   *     - possible values:	"", where n is a positive integer
-   *     - default:           "4"
-   * 
-   *	CODEASSIST / Activate Visibility Sensitive Completion
-   *    When active, completion doesn't show that you can not see
-   *    (e.g. you can not see private methods of a super class).
-   *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
-   *     - possible values:   { "enabled", "disabled" }
-   *     - default:           "disabled"
-   * 
-   *	CODEASSIST / Automatic Qualification of Implicit Members
-   *    When active, completion automatically qualifies completion on implicit
-   *    field references and message expressions.
-   *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
-   *     - possible values:   { "enabled", "disabled" }
-   *     - default:           "disabled"
-   * 
-   *  CODEASSIST / Define the Prefixes for Field Name
-   *    When the prefixes is non empty, completion for field name will begin with
-   *    one of the proposed prefixes.
-   *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
-   *     - possible values:   { "[,]*" } where  is a String without any wild-card 
-   *     - default:           ""
-   * 
-   *  CODEASSIST / Define the Prefixes for Static Field Name
-   *    When the prefixes is non empty, completion for static field name will begin with
-   *    one of the proposed prefixes.
-   *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
-   *     - possible values:   { "[,]*" } where  is a String without any wild-card 
-   *     - default:           ""
-   * 
-   *  CODEASSIST / Define the Prefixes for Local Variable Name
-   *    When the prefixes is non empty, completion for local variable name will begin with
-   *    one of the proposed prefixes.
-   *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
-   *     - possible values:   { "[,]*" } where  is a String without any wild-card 
-   *     - default:           ""
-   * 
-   *  CODEASSIST / Define the Prefixes for Argument Name
-   *    When the prefixes is non empty, completion for argument name will begin with
-   *    one of the proposed prefixes.
-   *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
-   *     - possible values:   { "[,]*" } where  is a String without any wild-card 
-   *     - default:           ""
-   * 
-   *  CODEASSIST / Define the Suffixes for Field Name
-   *    When the suffixes is non empty, completion for field name will end with
-   *    one of the proposed suffixes.
-   *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
-   *     - possible values:   { "[,]*" } where  is a String without any wild-card 
-   *     - default:           ""
+   * Bind a container reference path to some actual containers (
+   * IClasspathContainer). This API must be invoked whenever
+   * changes in container need to be reflected onto the JavaModel. Containers
+   * can have distinct values in different projects, therefore this API
+   * considers a set of projects with their respective containers.
+   * 

+ * containerPath is the path under which these values can be + * referenced through container classpath entries ( + * IClasspathEntry#CPE_CONTAINER). A container path is + * formed by a first ID segment followed with extra segments, which can be + * used as additional hints for the resolution. The container ID is used to + * identify a ClasspathContainerInitializer registered on the + * extension point "org.eclipse.jdt.core.classpathContainerInitializer". + *

+ * There is no assumption that each individual container value passed in + * argument (respectiveContainers) must answer the exact + * same path when requested IClasspathContainer#getPath. + * Indeed, the containerPath is just an indication for resolving it to an + * actual container object. It can be delegated to a + * ClasspathContainerInitializer, which can be activated + * through the extension point + * "org.eclipse.jdt.core.ClasspathContainerInitializer"). + *

+ * In reaction to changing container values, the JavaModel will be updated + * to reflect the new state of the updated container. + *

+ * This functionality cannot be used while the resource tree is locked. + *

+ * Classpath container values are persisted locally to the workspace, but + * are not preserved from a session to another. It is thus highly + * recommended to register a ClasspathContainerInitializer + * for each referenced container (through the extension point + * "org.eclipse.jdt.core.ClasspathContainerInitializer"). + *

+ * Note: setting a container to null will cause it to be + * lazily resolved again whenever its value is required. In particular, this + * will cause a registered initializer to be invoked again. + *

* - * CODEASSIST / Define the Suffixes for Static Field Name - * When the suffixes is non empty, completion for static field name will end with - * one of the proposed suffixes. - * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes" - * - possible values: { "[,]*" } where is a String without any wild-card - * - default: "" + * @param containerPath - + * the name of the container reference, which is being updated + * @param affectedProjects - + * the set of projects for which this container is being bound + * @param respectiveContainers - + * the set of respective containers for the affected projects + * @param monitor + * a monitor to report progress * - * CODEASSIST / Define the Suffixes for Local Variable Name - * When the suffixes is non empty, completion for local variable name will end with - * one of the proposed suffixes. - * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes" - * - possible values: { "[,]*" } where is a String without any wild-card - * - default: "" + * @see ClasspathContainerInitializer + * @see #getClasspathContainer(IPath, IJavaProject) + * @see IClasspathContainer + * @since 2.0 + */ + //public static void setClasspathContainer(final IPath containerPath, + // IJavaProject[] affectedProjects, IClasspathContainer[] + // respectiveContainers, IProgressMonitor monitor) throws JavaModelException + // { + // + // if (affectedProjects.length != respectiveContainers.length) + // Assert.isTrue(false, "Projects and containers collections should have the + // same size"); //$NON-NLS-1$ + // + // if (monitor != null && monitor.isCanceled()) return; + // + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPContainer SET - setting container: + // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$ + // + (Util.toString(affectedProjects, + // new Util.Displayable(){ + // public String displayString(Object o) { return ((IJavaProject) + // o).getElementName(); } + // })) + // + "} with values: " //$NON-NLS-1$ + // + (Util.toString(respectiveContainers, + // new Util.Displayable(){ + // public String displayString(Object o) { return ((IClasspathContainer) + // o).getDescription(); } + // })) + // ); + // } + // + // final int projectLength = affectedProjects.length; + // final IJavaProject[] modifiedProjects; + // System.arraycopy(affectedProjects, 0, modifiedProjects = new + // IJavaProject[projectLength], 0, projectLength); + // final IClasspathEntry[][] oldResolvedPaths = new + // IClasspathEntry[projectLength][]; + // + // // filter out unmodified project containers + // int remaining = 0; + // for (int i = 0; i < projectLength; i++){ + // + // if (monitor != null && monitor.isCanceled()) return; + // + // IJavaProject affectedProject = affectedProjects[i]; + // IClasspathContainer newContainer = respectiveContainers[i]; + // if (newContainer == null) newContainer = + // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent + // infinite loop + // boolean found = false; + // if (JavaProject.hasJavaNature(affectedProject.getProject())){ + // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath(); + // for (int j = 0, cpLength = rawClasspath.length; j + * This functionality cannot be used while the resource tree is locked. + *

+ * Classpath variable values are persisted locally to the workspace, and are + * preserved from session to session. + *

* - * CODEASSIST / Define the Suffixes for Argument Name - * When the suffixes is non empty, completion for argument name will end with - * one of the proposed suffixes. - * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes" - * - possible values: { "[,]*" } where is a String without any wild-card - * - default: "" - *

+ * @param variableName + * the name of the classpath variable + * @param path + * the path + * @see #getClasspathVariable * - * @return a mutable table containing the default settings of all known options - * (key type: String; value type: String) - * @see #setOptions + * @deprecated - use API with IProgressMonitor */ -// public static Hashtable getDefaultOptions() { -// -// Hashtable defaultOptions = new Hashtable(10); -// -// // see #initializeDefaultPluginPreferences() for changing default settings -// Preferences preferences = getPlugin().getPluginPreferences(); -// HashSet optionNames = OptionNames; -// -// // get preferences set to their default -// String[] defaultPropertyNames = preferences.defaultPropertyNames(); -// for (int i = 0; i < defaultPropertyNames.length; i++) { -// String propertyName = defaultPropertyNames[i]; -// if (optionNames.contains(propertyName)) { -// defaultOptions.put(propertyName, preferences.getDefaultString(propertyName)); -// } -// } -// // get preferences not set to their default -// String[] propertyNames = preferences.propertyNames(); -// for (int i = 0; i < propertyNames.length; i++) { -// String propertyName = propertyNames[i]; -// if (optionNames.contains(propertyName)) { -// defaultOptions.put(propertyName, preferences.getDefaultString(propertyName)); -// } -// } -// // get encoding through resource plugin -// defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); -// -// return defaultOptions; -// } + //public static void setClasspathVariable(String variableName, IPath path) + // throws JavaModelException { + // + // setClasspathVariable(variableName, path, null); + //} /** - * Helper method for returning one option value only. Equivalent to (String)JavaCore.getOptions().get(optionName) - * Note that it may answer null if this option does not exist. + * Sets the value of the given classpath variable. The path must not be + * null. *

- * For a complete description of the configurable options, see getDefaultOptions. - *

+ * This functionality cannot be used while the resource tree is locked. + *

+ * Classpath variable values are persisted locally to the workspace, and are + * preserved from session to session. + *

+ * Updating a variable with the same value has no effect. * - * @param optionName the name of an option - * @return the String value of a given option - * @see JavaCore#getDefaultOptions - * @since 2.0 + * @param variableName + * the name of the classpath variable + * @param path + * the path + * @param monitor + * a monitor to report progress + * @see #getClasspathVariable */ -// public static String getOption(String optionName) { -// -// if (CORE_ENCODING.equals(optionName)) { -// return ResourcesPlugin.getEncoding(); -// } -// if (OptionNames.contains(optionName)) { -// Preferences preferences = getPlugin().getPluginPreferences(); -// return preferences.getString(optionName).trim(); -// } -// return null; -// } - + //public static void setClasspathVariable( + // String variableName, + // IPath path, + // IProgressMonitor monitor) + // throws JavaModelException { + // + // if (path == null) Assert.isTrue(false, "Variable path cannot be null"); + // //$NON-NLS-1$ + // setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, + // monitor); + //} /** - * Returns the table of the current options. Initially, all options have their default values, - * and this method returns a table that includes all known options. + * Sets the values of all the given classpath variables at once. Null paths + * can be used to request corresponding variable removal. *

- * For a complete description of the configurable options, see getDefaultOptions. - *

+ * This functionality cannot be used while the resource tree is locked. + *

+ * Classpath variable values are persisted locally to the workspace, and are + * preserved from session to session. + *

+ * Updating a variable with the same value has no effect. * - * @return table of current settings of all options - * (key type: String; value type: String) - * @see JavaCore#getDefaultOptions + * @param variableNames + * an array of names for the updated classpath variables + * @param paths + * an array of path updates for the modified classpath variables + * (null meaning that the corresponding value will be removed + * @param monitor + * a monitor to report progress + * @see #getClasspathVariable + * @since 2.0 */ -// public static Hashtable getOptions() { -// -// Hashtable options = new Hashtable(10); -// -// // see #initializeDefaultPluginPreferences() for changing default settings -// Plugin plugin = getPlugin(); -// if (plugin != null) { -// Preferences preferences = getPlugin().getPluginPreferences(); -// HashSet optionNames = OptionNames; -// -// // get preferences set to their default -// String[] defaultPropertyNames = preferences.defaultPropertyNames(); -// for (int i = 0; i < defaultPropertyNames.length; i++) { -// String propertyName = defaultPropertyNames[i]; -// if (optionNames.contains(propertyName)) { -// options.put(propertyName, preferences.getDefaultString(propertyName)); -// } -// } -// // get preferences not set to their default -// String[] propertyNames = preferences.propertyNames(); -// for (int i = 0; i < propertyNames.length; i++) { -// String propertyName = propertyNames[i]; -// if (optionNames.contains(propertyName)) { -// options.put(propertyName, preferences.getString(propertyName).trim()); -// } -// } -// // get encoding through resource plugin -// options.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); -// } -// return options; -// } + //public static void setClasspathVariables( + // String[] variableNames, + // IPath[] paths, + // IProgressMonitor monitor) + // throws JavaModelException { + // + // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable + // names and paths collections should have the same size"); //$NON-NLS-1$ + // //TODO: should check that null cannot be used as variable paths + // updateVariableValues(variableNames, paths, monitor); + //} + /* + * (non-Javadoc) Method declared on IExecutableExtension. Record any + * necessary initialization data from the plugin. + */ + public void setInitializationData(IConfigurationElement cfig, + String propertyName, Object data) throws CoreException { + } + /** - * Sets the current table of options. All and only the options explicitly included in the given table - * are remembered; all previous option settings are forgotten, including ones not explicitly - * mentioned. + * Sets the current table of options. All and only the options explicitly + * included in the given table are remembered; all previous option settings + * are forgotten, including ones not explicitly mentioned. *

- * For a complete description of the configurable options, see getDefaultOptions. + * For a complete description of the configurable options, see + * getDefaultOptions. *

* - * @param newOptions the new options (key type: String; value type: String), - * or null to reset all options to their default values + * @param newOptions + * the new options (key type: String; value type: + * String), or null to reset all + * options to their default values * @see JavaCore#getDefaultOptions */ -// public static void setOptions(Hashtable newOptions) { -// -// // see #initializeDefaultPluginPreferences() for changing default settings -// Preferences preferences = getPlugin().getPluginPreferences(); -// -// if (newOptions == null) { -// newOptions = getDefaultOptions(); -// } -// Enumeration keys = newOptions.keys(); -// while (keys.hasMoreElements()) { -// String key = (String) keys.nextElement(); -// if (!OptionNames.contains(key)) -// continue; // unrecognized option -// if (key.equals(CORE_ENCODING)) -// continue; // skipped, contributed by resource prefs -// String value = (String) newOptions.get(key); -// preferences.setValue(key, value); -// } -// -// // persist options -// getPlugin().savePluginPreferences(); -// } - public static IProject[] getPHPProjects() { - List phpProjectsList = new ArrayList(); - IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace().getRoot().getProjects(); - - for (int i = 0; i < workspaceProjects.length; i++) { - IProject iProject = workspaceProjects[i]; - if (isPHPProject(iProject)) - phpProjectsList.add(iProject); - } - - IProject[] phpProjects = new IProject[phpProjectsList.size()]; - return (IProject[]) phpProjectsList.toArray(phpProjects); - } + public static void setOptions(Hashtable newOptions) { -// public static PHPProject getPHPProject(String name) { -// IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(name); -// if (isPHPProject(aProject)) { -// PHPProject thePHPProject = new PHPProject(); -// thePHPProject.setProject(aProject); -// return thePHPProject; -// } -// return null; -// } + // see #initializeDefaultPluginPreferences() for changing default + // settings + Preferences preferences = getPlugin().getPluginPreferences(); - public static boolean isPHPProject(IProject aProject) { - try { - return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID); - } catch (CoreException e) { + if (newOptions == null) { + newOptions = JavaCore.getDefaultOptions(); } - - return false; - } - -// public static PHPFile create(IFile aFile) { -// if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension())) -// return new PHPFile(aFile); -// if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension())) -// return new PHPFile(aFile); -// if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension())) -// return new PHPFile(aFile); -// if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension())) -// return new PHPFile(aFile); -// if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension())) -// return new PHPFile(aFile); -// if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension())) -// return new PHPFile(aFile); -// -// return null; -// } - -// public static PHPProject create(IProject aProject) { -// -// try { -// if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) { -// PHPProject project = new PHPProject(); -// project.setProject(aProject); -// return project; -// } -// } catch (CoreException e) { -// System.err.println("Exception occurred in PHPCore#create(IProject): " + e.toString()); -// } -// -// return null; -// } - - public static void addPHPNature(IProject project, IProgressMonitor monitor) throws CoreException { - if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) { - IProjectDescription description = project.getDescription(); - String[] prevNatures = description.getNatureIds(); - String[] newNatures = new String[prevNatures.length + 1]; - System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); - newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID; - description.setNatureIds(newNatures); - project.setDescription(description, monitor); + Enumeration keys = newOptions.keys(); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + if (!JavaModelManager.OptionNames.contains(key)) + continue; // unrecognized option + if (key.equals(CORE_ENCODING)) + continue; // skipped, contributed by resource prefs + String value = (String) newOptions.get(key); + preferences.setValue(key, value); } + + // persist options + getPlugin().savePluginPreferences(); } /** - * Returns the single instance of the PHP core plug-in runtime class. + * Shutdown the JavaCore plug-in. + *

+ * De-registers the JavaModelManager as a resource changed listener and save + * participant. + *

* - * @return the single instance of the PHP core plug-in runtime class + * @see org.eclipse.core.runtime.Plugin#shutdown() */ - public static Plugin getPlugin() { - return PHPeclipsePlugin.getDefault(); - } - + // moved to PHPeclipsePlugin#shutdown() + //public void shutdown() { + // + // //savePluginPreferences(); + // getPlugin().savePluginPreferences(); + // IWorkspace workspace = ResourcesPlugin.getWorkspace(); + // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor); + // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault()); + // + // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown(); + //} /** - * Initializes the default preferences settings for this plug-in. - */ - + * Initiate the background indexing process. This should be deferred after + * the plugin activation. + */ + //private void startIndexing() { + // + // JavaModelManager.getJavaModelManager().getIndexManager().reset(); + //} /** - * Runs the given action as an atomic Java model operation. - *

- * After running a method that modifies Java elements, - * registered listeners receive after-the-fact notification of - * what just transpired, in the form of a element changed event. - * This method allows clients to call a number of - * methods that modify java elements and only have element - * changed event notifications reported at the end of the entire - * batch. - *

- *

- * If this method is called outside the dynamic scope of another such - * call, this method runs the action and then reports a single - * element changed event describing the net effect of all changes - * done to java elements by the action. - *

- *

- * If this method is called in the dynamic scope of another such - * call, this method simply runs the action. - *

- * - * @param action the action to perform - * @param monitor a progress monitor, or null if progress - * reporting and cancellation are not desired - * @exception CoreException if the operation failed. - * @since 2.1 - */ - public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - if (workspace.isTreeLocked()) { - new BatchOperation(action).run(monitor); - } else { - // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode - workspace.run(new BatchOperation(action), monitor); - } - } - -/** - * Adds the given listener for changes to Java elements. - * Has no effect if an identical listener is already registered. - * - * This listener will only be notified during the POST_CHANGE resource change notification - * and any reconcile operation (POST_RECONCILE). - * For finer control of the notification, use addElementChangedListener(IElementChangedListener,int), - * which allows to specify a different eventMask. - * - * @see ElementChangedEvent - * @param listener the listener - */ -public static void addElementChangedListener(IElementChangedListener listener) { - addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE); -} - -/** - * Adds the given listener for changes to Java elements. - * Has no effect if an identical listener is already registered. - * After completion of this method, the given listener will be registered for exactly - * the specified events. If they were previously registered for other events, they - * will be deregistered. - *

- * Once registered, a listener starts receiving notification of changes to - * java elements in the model. The listener continues to receive - * notifications until it is replaced or removed. - *

- *

- * Listeners can listen for several types of event as defined in ElementChangeEvent. - * Clients are free to register for any number of event types however if they register - * for more than one, it is their responsibility to ensure they correctly handle the - * case where the same java element change shows up in multiple notifications. - * Clients are guaranteed to receive only the events for which they are registered. - *

- * - * @param listener the listener - * @param eventMask the bit-wise OR of all event types of interest to the listener - * @see IElementChangedListener - * @see ElementChangedEvent - * @see #removeElementChangedListener(IElementChangedListener) - * @since 2.0 - */ -public static void addElementChangedListener(IElementChangedListener listener, int eventMask) { - JavaModelManager.getJavaModelManager().addElementChangedListener(listener, eventMask); -} - -/** - * Configures the given marker attribute map for the given Java element. - * Used for markers, which denote a Java element rather than a resource. - * - * @param attributes the mutable marker attribute map (key type: String, - * value type: String) - * @param element the Java element for which the marker needs to be configured - */ -public static void addJavaElementMarkerAttributes( - Map attributes, - IJavaElement element) { -// if (element instanceof IMember) -// element = ((IMember) element).getClassFile(); - if (attributes != null && element != null) - attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier()); -} - -/** - * Configures the given marker for the given Java element. - * Used for markers, which denote a Java element rather than a resource. - * - * @param marker the marker to be configured - * @param element the Java element for which the marker needs to be configured - * @exception CoreException if the IMarker.setAttribute on the marker fails - */ -public void configureJavaElementMarker(IMarker marker, IJavaElement element) - throws CoreException { -// if (element instanceof IMember) -// element = ((IMember) element).getClassFile(); - if (marker != null && element != null) - marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier()); -} - -/** - * Returns the Java model element corresponding to the given handle identifier - * generated by IJavaElement.getHandleIdentifier(), or - * null if unable to create the associated element. - */ -public static IJavaElement create(String handleIdentifier) { - if (handleIdentifier == null) { - return null; - } - try { - return JavaModelManager.getJavaModelManager().getHandleFromMemento(handleIdentifier); - } catch (JavaModelException e) { - return null; - } -} -/** - * Returns the Java element corresponding to the given file, or - * null if unable to associate the given file - * with a Java element. - * - *

The file must be one of:

    - *
  • a .java file - the element returned is the corresponding ICompilationUnit
  • - *
  • a .class file - the element returned is the corresponding IClassFile
  • - *
  • a .jar file - the element returned is the corresponding IPackageFragmentRoot
  • - *
- *

- * Creating a Java element has the side effect of creating and opening all of the - * element's parents if they are not yet open. - * - * @param the given file - * @return the Java element corresponding to the given file, or - * null if unable to associate the given file - * with a Java element - */ -public static IJavaElement create(IFile file) { - return JavaModelManager.create(file, null); -} -/** - * Returns the package fragment or package fragment root corresponding to the given folder, or - * null if unable to associate the given folder with a Java element. - *

- * Note that a package fragment root is returned rather than a default package. - *

- * Creating a Java element has the side effect of creating and opening all of the - * element's parents if they are not yet open. - * - * @param the given folder - * @return the package fragment or package fragment root corresponding to the given folder, or - * null if unable to associate the given folder with a Java element - */ -public static IJavaElement create(IFolder folder) { - return JavaModelManager.create(folder, null); -} -/** - * Returns the Java project corresponding to the given project. - *

- * Creating a Java Project has the side effect of creating and opening all of the - * project's parents if they are not yet open. - *

- * Note that no check is done at this time on the existence or the java nature of this project. - * - * @param project the given project - * @return the Java project corresponding to the given project, null if the given project is null - */ -public static IJavaProject create(IProject project) { - if (project == null) { - return null; - } - JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel(); - return javaModel.getJavaProject(project); -} -/** - * Returns the Java element corresponding to the given resource, or - * null if unable to associate the given resource - * with a Java element. - *

- * The resource must be one of:

    - *
  • a project - the element returned is the corresponding IJavaProject
  • - *
  • a .java file - the element returned is the corresponding ICompilationUnit
  • - *
  • a .class file - the element returned is the corresponding IClassFile
  • - *
  • a .jar file - the element returned is the corresponding IPackageFragmentRoot
  • - *
  • a folder - the element returned is the corresponding IPackageFragmentRoot - * or IPackageFragment
  • - *
  • the workspace root resource - the element returned is the IJavaModel
  • - *
- *

- * Creating a Java element has the side effect of creating and opening all of the - * element's parents if they are not yet open. - * - * @param resource the given resource - * @return the Java element corresponding to the given resource, or - * null if unable to associate the given resource - * with a Java element - */ -public static IJavaElement create(IResource resource) { - return JavaModelManager.create(resource, null); -} -/** - * Returns the Java model. - * - * @param root the given root - * @return the Java model, or null if the root is null - */ -public static IJavaModel create(IWorkspaceRoot root) { - if (root == null) { - return null; - } - return JavaModelManager.getJavaModelManager().getJavaModel(); -} -/** - * Creates and returns a class file element for - * the given .class file. Returns null if unable - * to recognize the class file. - * - * @param file the given .class file - * @return a class file element for the given .class file, or null if unable - * to recognize the class file - */ -//public static IClassFile createClassFileFrom(IFile file) { -// return JavaModelManager.createClassFileFrom(file, null); -//} -/** - * Creates and returns a compilation unit element for - * the given .java file. Returns null if unable - * to recognize the compilation unit. - * - * @param file the given .java file - * @return a compilation unit element for the given .java file, or null if unable - * to recognize the compilation unit - */ -public static ICompilationUnit createCompilationUnitFrom(IFile file) { - return JavaModelManager.createCompilationUnitFrom(file, null); -} -/** - * Creates and returns a handle for the given JAR file. - * The Java model associated with the JAR's project may be - * created as a side effect. - * - * @param file the given JAR file - * @return a handle for the given JAR file, or null if unable to create a JAR package fragment root. - * (for example, if the JAR file represents a non-Java resource) - */ -//public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) { -// return JavaModelManager.createJarPackageFragmentRootFrom(file, null); -//} - -/** - * Answers the project specific value for a given classpath container. - * In case this container path could not be resolved, then will answer null. - * Both the container path and the project context are supposed to be non-null. - *

- * The containerPath is a formed by a first ID segment followed with extra segments, which can be - * used as additional hints for resolution. If no container was ever recorded for this container path - * onto this project (using setClasspathContainer, then a - * ClasspathContainerInitializer will be activated if any was registered for this container - * ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer". - *

- * There is no assumption that the returned container must answer the exact same containerPath - * when requested IClasspathContainer#getPath. - * Indeed, the containerPath is just an indication for resolving it to an actual container object. - *

- * Classpath container values are persisted locally to the workspace, but - * are not preserved from a session to another. It is thus highly recommended to register a - * ClasspathContainerInitializer for each referenced container - * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer"). - *

- * @param containerPath the name of the container, which needs to be resolved - * @param project a specific project in which the container is being resolved - * @return the corresponding classpath container or null if unable to find one. - * - * @exception JavaModelException if an exception occurred while resolving the container, or if the resolved container - * contains illegal entries (contains CPE_CONTAINER entries or null entries). - * - * @see ClasspathContainerInitializer - * @see IClasspathContainer - * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor) - * @since 2.0 - */ -//public static IClasspathContainer getClasspathContainer(final IPath containerPath, final IJavaProject project) throws JavaModelException { -// -// IClasspathContainer container = JavaModelManager.containerGet(project, containerPath); -// if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle -// -// if (container == null){ -// final ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); -// if (initializer != null){ -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPContainer INIT - triggering initialization of: ["+project.getElementName()+"] " + containerPath + " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ -// new Exception("FAKE exception for dumping current CPContainer (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ -// } -// JavaModelManager.containerPut(project, containerPath, JavaModelManager.ContainerInitializationInProgress); // avoid initialization cycles -// boolean ok = false; -// try { -// // wrap initializer call with Safe runnable in case initializer would be causing some grief -// Platform.run(new ISafeRunnable() { -// public void handleException(Throwable exception) { -// Util.log(exception, "Exception occurred in classpath container initializer: "+initializer); //$NON-NLS-1$ -// } -// public void run() throws Exception { -// initializer.initialize(containerPath, project); -// } -// }); -// -// // retrieve value (if initialization was successful) -// container = JavaModelManager.containerGet(project, containerPath); -// if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle -// ok = true; -// } finally { -// if (!ok) JavaModelManager.containerPut(project, containerPath, null); // flush cache -// } -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.print("CPContainer INIT - after resolution: ["+project.getElementName()+"] " + containerPath + " --> "); //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$ -// if (container != null){ -// System.out.print("container: "+container.getDescription()+" {"); //$NON-NLS-2$//$NON-NLS-1$ -// IClasspathEntry[] entries = container.getClasspathEntries(); -// if (entries != null){ -// for (int i = 0; i < entries.length; i++){ -// if (i > 0) System.out.println(", ");//$NON-NLS-1$ -// System.out.println(entries[i]); -// } -// } -// System.out.println("}");//$NON-NLS-1$ -// } else { -// System.out.println("{unbound}");//$NON-NLS-1$ -// } -// } -// } else { -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPContainer INIT - no initializer found for: "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$ -// } -// } -// } -// return container; -//} - -/** - * Helper method finding the classpath container initializer registered for a given classpath container ID - * or null if none was found while iterating over the contributions to extension point to - * the extension point "org.eclipse.jdt.core.classpathContainerInitializer". - *

- * A containerID is the first segment of any container path, used to identify the registered container initializer. - *

- * @param String - a containerID identifying a registered initializer - * @return ClasspathContainerInitializer - the registered classpath container initializer or null if - * none was found. - * @since 2.1 - */ -//public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID){ -// -// Plugin jdtCorePlugin = JavaCore.getPlugin(); -// if (jdtCorePlugin == null) return null; -// -// IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID); -// if (extension != null) { -// IExtension[] extensions = extension.getExtensions(); -// for(int i = 0; i < extensions.length; i++){ -// IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); -// for(int j = 0; j < configElements.length; j++){ -// String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$ -// if (initializerID != null && initializerID.equals(containerID)){ -// if (JavaModelManager.CP_RESOLVE_VERBOSE) { -// System.out.println("CPContainer INIT - found initializer: "+containerID +" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ -// } -// try { -// Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$ -// if (execExt instanceof ClasspathContainerInitializer){ -// return (ClasspathContainerInitializer)execExt; -// } -// } catch(CoreException e) { -// } -// } -// } -// } -// } -// return null; -//} - -/** - * Returns the path held in the given classpath variable. - * Returns null if unable to bind. - *

- * Classpath variable values are persisted locally to the workspace, and - * are preserved from session to session. - *

- * Note that classpath variables can be contributed registered initializers for, - * using the extension point "org.eclipse.jdt.core.classpathVariableInitializer". - * If an initializer is registered for a variable, its persisted value will be ignored: - * its initializer will thus get the opportunity to rebind the variable differently on - * each session. - * - * @param variableName the name of the classpath variable - * @return the path, or null if none - * @see #setClasspathVariable - */ -public static IPath getClasspathVariable(final String variableName) { - - IPath variablePath = JavaModelManager.variableGet(variableName); - if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle - - if (variablePath != null) { - return variablePath; - } + * Startup of the JavaCore plug-in. + *

+ * Registers the JavaModelManager as a resource changed listener and save + * participant. Starts the background indexing, and restore saved classpath + * variable values. + *

+ * + * @see org.eclipse.core.runtime.Plugin#startup() + */ - // even if persisted value exists, initializer is given priority, only if no initializer is found the persisted value is reused -// final ClasspathVariableInitializer initializer = PHPCore.getClasspathVariableInitializer(variableName); -// if (initializer != null){ -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPVariable INIT - triggering initialization of: " + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$ -// new Exception("FAKE exception for dumping current CPVariable ("+variableName+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$ -// } -// JavaModelManager.variablePut(variableName, JavaModelManager.VariableInitializationInProgress); // avoid initialization cycles -// boolean ok = false; -// try { -// // wrap initializer call with Safe runnable in case initializer would be causing some grief -// Platform.run(new ISafeRunnable() { -// public void handleException(Throwable exception) { -// Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer+" while initializing variable: "+variableName); //$NON-NLS-1$ //$NON-NLS-2$ -// } -// public void run() throws Exception { -// initializer.initialize(variableName); -// } -// }); -// variablePath = (IPath) JavaModelManager.variableGet(variableName); // initializer should have performed side-effect -// if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle (initializer did not init or reentering call) -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPVariable INIT - after initialization: " + variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$ -// } -// ok = true; -// } finally { -// if (!ok) JavaModelManager.variablePut(variableName, null); // flush cache -// } -// } else { -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPVariable INIT - no initializer found for: " + variableName); //$NON-NLS-1$ -// } -// } - return variablePath; -} - -/** - * Helper method finding the classpath variable initializer registered for a given classpath variable name - * or null if none was found while iterating over the contributions to extension point to - * the extension point "org.eclipse.jdt.core.classpathVariableInitializer". - *

- * @param the given variable - * @return ClasspathVariableInitializer - the registered classpath variable initializer or null if - * none was found. - * @since 2.1 - */ -public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){ - - Plugin jdtCorePlugin = JavaCore.getPlugin(); - if (jdtCorePlugin == null) return null; - -// IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID); -// if (extension != null) { -// IExtension[] extensions = extension.getExtensions(); -// for(int i = 0; i < extensions.length; i++){ -// IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); -// for(int j = 0; j < configElements.length; j++){ -// try { -// String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$ -// if (variable.equals(varAttribute)) { -// if (JavaModelManager.CP_RESOLVE_VERBOSE) { -// System.out.println("CPVariable INIT - found initializer: "+variable+" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ -// } -// Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$ -// if (execExt instanceof ClasspathVariableInitializer){ -// return (ClasspathVariableInitializer)execExt; -// } -// } -// } catch(CoreException e){ -// } -// } -// } -// } - return null; -} - -/** - * Returns the names of all known classpath variables. - *

- * Classpath variable values are persisted locally to the workspace, and - * are preserved from session to session. - *

- * - * @return the list of classpath variable names - * @see #setClasspathVariable - */ -//public static String[] getClasspathVariableNames() { -// return JavaModelManager.variableNames(); -//} - -/** - * Returns a table of all known configurable options with their default values. - * These options allow to configure the behaviour of the underlying components. - * The client may safely use the result as a template that they can modify and - * then pass to setOptions. - * - * Helper constants have been defined on JavaCore for each of the option ID and - * their possible constant values. - * - * Note: more options might be added in further releases. - *

- * RECOGNIZED OPTIONS:
- * COMPILER / Generating Local Variable Debug Attribute
- *    When generated, this attribute will enable local variable names 
- *    to be displayed in debugger, only in place where variables are 
- *    definitely assigned (.class file is then bigger)
- *     - option id:         "org.eclipse.jdt.core.compiler.debug.localVariable"
- *     - possible values:   { "generate", "do not generate" }
- *     - default:           "generate"
- *
- * COMPILER / Generating Line Number Debug Attribute 
- *    When generated, this attribute will enable source code highlighting in debugger 
- *    (.class file is then bigger).
- *     - option id:         "org.eclipse.jdt.core.compiler.debug.lineNumber"
- *     - possible values:   { "generate", "do not generate" }
- *     - default:           "generate"
- *    
- * COMPILER / Generating Source Debug Attribute 
- *    When generated, this attribute will enable the debugger to present the 
- *    corresponding source code.
- *     - option id:         "org.eclipse.jdt.core.compiler.debug.sourceFile"
- *     - possible values:   { "generate", "do not generate" }
- *     - default:           "generate"
- *    
- * COMPILER / Preserving Unused Local Variables
- *    Unless requested to preserve unused local variables (that is, never read), the 
- *    compiler will optimize them out, potentially altering debugging
- *     - option id:         "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
- *     - possible values:   { "preserve", "optimize out" }
- *     - default:           "preserve"
- * 
- * COMPILER / Defining Target Java Platform
- *    For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
- *    Note that "1.4" target require to toggle compliance mode to "1.4" too.
- *     - option id:         "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
- *     - possible values:   { "1.1", "1.2", "1.3", "1.4" }
- *     - default:           "1.1"
- *
- * COMPILER / Reporting Unreachable Code
- *    Unreachable code can optionally be reported as an error, warning or simply 
- *    ignored. The bytecode generation will always optimized it out.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.unreachableCode"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "error"
- *
- * COMPILER / Reporting Invalid Import
- *    An import statement that cannot be resolved might optionally be reported 
- *    as an error, as a warning or ignored.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.invalidImport"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "error"
- *
- * COMPILER / Reporting Attempt to Override Package-Default Method
- *    A package default method is not visible in a different package, and thus 
- *    cannot be overridden. When enabling this option, the compiler will signal 
- *    such scenarii either as an error or a warning.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- *
- * COMPILER / Reporting Method With Constructor Name
- *    Naming a method with a constructor name is generally considered poor 
- *    style programming. When enabling this option, the compiler will signal such 
- *    scenarii either as an error or a warning.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- *
- * COMPILER / Reporting Deprecation
- *    When enabled, the compiler will signal use of deprecated API either as an 
- *    error or a warning.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.deprecation"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- *
- * COMPILER / Reporting Deprecation Inside Deprecated Code
- *    When enabled, the compiler will signal use of deprecated API inside deprecated code.
- *    The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
- *     - possible values:   { "enabled", "disabled" }
- *     - default:           "disabled"
- *
- * COMPILER / Reporting Hidden Catch Block
- *    Locally to a try statement, some catch blocks may hide others . For example,
- *      try {  throw new java.io.CharConversionException();
- *      } catch (java.io.CharConversionException e) {
- *      } catch (java.io.IOException e) {}. 
- *    When enabling this option, the compiler will issue an error or a warning for hidden 
- *    catch blocks corresponding to checked exceptions
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- *
- * COMPILER / Reporting Unused Local
- *    When enabled, the compiler will issue an error or a warning for unused local 
- *    variables (that is, variables never read from)
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedLocal"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "ignore"
- *
- * COMPILER / Reporting Unused Parameter
- *    When enabled, the compiler will issue an error or a warning for unused method 
- *    parameters (that is, parameters never read from)
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameter"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "ignore"
- *
- * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
- *    When enabled, the compiler will signal unused parameters in abstract method implementations.
- *    The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
- *     - possible values:   { "enabled", "disabled" }
- *     - default:           "disabled"
- *
- * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
- *    When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
- *    The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
- *     - possible values:   { "enabled", "disabled" }
- *     - default:           "disabled"
- *
- * COMPILER / Reporting Unused Import
- *    When enabled, the compiler will issue an error or a warning for unused import 
- *    reference 
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedImport"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- *
- * COMPILER / Reporting Unused Private Members
- *    When enabled, the compiler will issue an error or a warning whenever a private 
- *    method or field is declared but never used within the same unit.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "ignore"
- *
- * COMPILER / Reporting Synthetic Access Emulation
- *    When enabled, the compiler will issue an error or a warning whenever it emulates 
- *    access to a non-accessible member of an enclosing type. Such access can have
- *    performance implications.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "ignore"
- *
- * COMPILER / Reporting Non-Externalized String Literal
- *    When enabled, the compiler will issue an error or a warning for non externalized 
- *    String literal (that is, not tagged with //$NON-NLS-$). 
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "ignore"
- * 
- * COMPILER / Reporting Usage of 'assert' Identifier
- *    When enabled, the compiler will issue an error or a warning whenever 'assert' is 
- *    used as an identifier (reserved keyword in 1.4)
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "ignore"
- * 
- * COMPILER / Reporting Non-Static Reference to a Static Member
- *    When enabled, the compiler will issue an error or a warning whenever a static field
- *    or method is accessed with an expression receiver. A reference to a static member should
- *    be qualified with a type name.
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- * 
- * COMPILER / Reporting Assignment with no Effect
- *    When enabled, the compiler will issue an error or a warning whenever an assignment
- *    has no effect (e.g 'x = x').
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- * 
- * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
- *    When enabled, the compiler will issue an error or a warning whenever an interface
- *    defines a method incompatible with a non-inherited Object method. Until this conflict
- *    is resolved, such an interface cannot be implemented, For example, 
- *      interface I { 
- *         int clone();
- *      } 
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- * 
- * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
- *    When enabled, the compiler will issue an error or a warning whenever a char[] expression
- *    is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
- *     - option id:         "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
- *     - possible values:   { "error", "warning", "ignore" }
- *     - default:           "warning"
- *
- * COMPILER / Setting Source Compatibility Mode
- *    Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
- *    reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
- *   level should be set to "1.4" and the compliance mode should be "1.4".
- *     - option id:         "org.eclipse.jdt.core.compiler.source"
- *     - possible values:   { "1.3", "1.4" }
- *     - default:           "1.3"
- * 
- * COMPILER / Setting Compliance Level
- *    Select the compliance level for the compiler. In "1.3" mode, source and target settings
- *    should not go beyond "1.3" level.
- *     - option id:         "org.eclipse.jdt.core.compiler.compliance"
- *     - possible values:   { "1.3", "1.4" }
- *     - default:           "1.3"
- * 
- * COMPILER / Maximum number of problems reported per compilation unit
- *    Specify the maximum number of problems reported on each compilation unit.
- *     - option id:         "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
- *     - possible values:	"" where  is zero or a positive integer (if zero then all problems are reported).
- *     - default:           "100"
- * 
- * COMPILER / Define the Automatic Task Tags
- *    When the tag list is not empty, the compiler will issue a task marker whenever it encounters
- *    one of the corresponding tag inside any comment in Java source code.
- *    Generated task messages will include the tag, and range until the next line separator or comment ending.
- *    Note that tasks messages are trimmed.
- *     - option id:         "org.eclipse.jdt.core.compiler.taskTags"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card or leading/trailing spaces 
- *     - default:           ""
- * 
- * COMPILER / Define the Automatic Task Priorities
- *    In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
- *    of the task markers issued by the compiler.
- *    If the default is specified, the priority of each task marker is "NORMAL".
- *     - option id:         "org.eclipse.jdt.core.compiler.taskPriorities"
- *     - possible values:   { "[,]*" } where  is one of "HIGH", "NORMAL" or "LOW"
- *     - default:           ""
- *
- * BUILDER / Specifying Filters for Resource Copying Control
- *    Allow to specify some filters to control the resource copy process.
- *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
- *     - possible values:   { "[,]* } where  is a file name pattern (* and ? wild-cards allowed)
- *       or the name of a folder which ends with '/'
- *     - default:           ""
- * 
- * BUILDER / Abort if Invalid Classpath
- *    Allow to toggle the builder to abort if the classpath is invalid
- *     - option id:         "org.eclipse.jdt.core.builder.invalidClasspath"
- *     - possible values:   { "abort", "ignore" }
- *     - default:           "abort"
- * 
- * BUILDER / Cleaning Output Folder(s)
- *    Indicate whether the JavaBuilder is allowed to clean the output folders
- *    when performing full build operations.
- *     - option id:         "org.eclipse.jdt.core.builder.cleanOutputFolder"
- *     - possible values:   { "clean", "ignore" }
- *     - default:           "clean"
- * 
- * BUILDER / Reporting Duplicate Resources
- *    Indicate the severity of the problem reported when more than one occurrence
- *    of a resource is to be copied into the output location.
- *     - option id:         "org.eclipse.jdt.core.builder.duplicateResourceTask"
- *     - possible values:   { "error", "warning" }
- *     - default:           "warning"
- * 
- * JAVACORE / Computing Project Build Order
- *    Indicate whether JavaCore should enforce the project build order to be based on
- *    the classpath prerequisite chain. When requesting to compute, this takes over
- *    the platform default order (based on project references).
- *     - option id:         "org.eclipse.jdt.core.computeJavaBuildOrder"
- *     - possible values:   { "compute", "ignore" }
- *     - default:           "ignore"	 
- * 
- * JAVACORE / Specify Default Source Encoding Format
- *    Get the encoding format for compiled sources. This setting is read-only, it is equivalent
- *    to 'ResourcesPlugin.getEncoding()'.
- *     - option id:         "org.eclipse.jdt.core.encoding"
- *     - possible values:   { any of the supported encoding name}.
- *     - default:           
- * 
- * JAVACORE / Reporting Incomplete Classpath
- *    Indicate the severity of the problem reported when an entry on the classpath does not exist, 
- *    is not legite or is not visible (for example, a referenced project is closed).
- *     - option id:         "org.eclipse.jdt.core.incompleteClasspath"
- *     - possible values:   { "error", "warning"}
- *     - default:           "error"
- * 
- * JAVACORE / Reporting Classpath Cycle
- *    Indicate the severity of the problem reported when a project is involved in a cycle.
- *     - option id:         "org.eclipse.jdt.core.circularClasspath"
- *     - possible values:   { "error", "warning" }
- *     - default:           "error"
- * 
- * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
- *    When disabled, no entry on a project classpath can be associated with
- *    an exclusion pattern.
- *     - option id:         "org.eclipse.jdt.core.classpath.exclusionPatterns"
- *     - possible values:   { "enabled", "disabled" }
- *     - default:           "enabled"
- * 
- * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
- *    When disabled, no entry on a project classpath can be associated with
- *    a specific output location, preventing thus usage of multiple output locations.
- *     - option id:         "org.eclipse.jdt.core.classpath.multipleOutputLocations"
- *     - possible values:   { "enabled", "disabled" }
- *     - default:           "enabled"
- * 
- *	FORMATTER / Inserting New Line Before Opening Brace
- *    When Insert, a new line is inserted before an opening brace, otherwise nothing
- *    is inserted
- *     - option id:         "org.eclipse.jdt.core.formatter.newline.openingBrace"
- *     - possible values:   { "insert", "do not insert" }
- *     - default:           "do not insert"
- * 
- *	FORMATTER / Inserting New Line Inside Control Statement
- *    When Insert, a new line is inserted between } and following else, catch, finally
- *     - option id:         "org.eclipse.jdt.core.formatter.newline.controlStatement"
- *     - possible values:   { "insert", "do not insert" }
- *     - default:           "do not insert"
- * 
- *	FORMATTER / Clearing Blank Lines
- *    When Clear all, all blank lines are removed. When Preserve one, only one is kept
- *    and all others removed.
- *     - option id:         "org.eclipse.jdt.core.formatter.newline.clearAll"
- *     - possible values:   { "clear all", "preserve one" }
- *     - default:           "preserve one"
- * 
- *	FORMATTER / Inserting New Line Between Else/If 
- *    When Insert, a blank line is inserted between an else and an if when they are 
- *    contiguous. When choosing to not insert, else-if will be kept on the same
- *    line when possible.
- *     - option id:         "org.eclipse.jdt.core.formatter.newline.elseIf"
- *     - possible values:   { "insert", "do not insert" }
- *     - default:           "do not insert"
- * 
- *	FORMATTER / Inserting New Line In Empty Block
- *    When insert, a line break is inserted between contiguous { and }, if } is not followed
- *    by a keyword.
- *     - option id:         "org.eclipse.jdt.core.formatter.newline.emptyBlock"
- *     - possible values:   { "insert", "do not insert" }
- *     - default:           "insert"
- * 
- *	FORMATTER / Splitting Lines Exceeding Length
- *    Enable splitting of long lines (exceeding the configurable length). Length of 0 will
- *    disable line splitting
- *     - option id:         "org.eclipse.jdt.core.formatter.lineSplit"
- *     - possible values:	"", where n is zero or a positive integer
- *     - default:           "80"
- * 
- *	FORMATTER / Compacting Assignment
- *    Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
- *    is inserted before the assignment operator
- *     - option id:         "org.eclipse.jdt.core.formatter.style.assignment"
- *     - possible values:   { "compact", "normal" }
- *     - default:           "normal"
- * 
- *	FORMATTER / Defining Indentation Character
- *    Either choose to indent with tab characters or spaces
- *     - option id:         "org.eclipse.jdt.core.formatter.tabulation.char"
- *     - possible values:   { "tab", "space" }
- *     - default:           "tab"
- * 
- *	FORMATTER / Defining Space Indentation Length
- *    When using spaces, set the amount of space characters to use for each 
- *    indentation mark.
- *     - option id:         "org.eclipse.jdt.core.formatter.tabulation.size"
- *     - possible values:	"", where n is a positive integer
- *     - default:           "4"
- * 
- *	FORMATTER / Inserting space in cast expression
- *    When Insert, a space is added between the type and the expression in a cast expression.
- *     - option id:         "org.eclipse.jdt.core.formatter.space.castexpression"
- *     - possible values:   { "insert", "do not insert" }
- *     - default:           "insert"
- * 
- *	CODEASSIST / Activate Visibility Sensitive Completion
- *    When active, completion doesn't show that you can not see
- *    (for example, you can not see private methods of a super class).
- *     - option id:         "org.eclipse.jdt.core.codeComplete.visibilityCheck"
- *     - possible values:   { "enabled", "disabled" }
- *     - default:           "disabled"
- * 
- *	CODEASSIST / Automatic Qualification of Implicit Members
- *    When active, completion automatically qualifies completion on implicit
- *    field references and message expressions.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
- *     - possible values:   { "enabled", "disabled" }
- *     - default:           "disabled"
- * 
- *  CODEASSIST / Define the Prefixes for Field Name
- *    When the prefixes is non empty, completion for field name will begin with
- *    one of the proposed prefixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- *  CODEASSIST / Define the Prefixes for Static Field Name
- *    When the prefixes is non empty, completion for static field name will begin with
- *    one of the proposed prefixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- *  CODEASSIST / Define the Prefixes for Local Variable Name
- *    When the prefixes is non empty, completion for local variable name will begin with
- *    one of the proposed prefixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.localPrefixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- *  CODEASSIST / Define the Prefixes for Argument Name
- *    When the prefixes is non empty, completion for argument name will begin with
- *    one of the proposed prefixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- *  CODEASSIST / Define the Suffixes for Field Name
- *    When the suffixes is non empty, completion for field name will end with
- *    one of the proposed suffixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- *  CODEASSIST / Define the Suffixes for Static Field Name
- *    When the suffixes is non empty, completion for static field name will end with
- *    one of the proposed suffixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- *  CODEASSIST / Define the Suffixes for Local Variable Name
- *    When the suffixes is non empty, completion for local variable name will end with
- *    one of the proposed suffixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.localSuffixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- *  CODEASSIST / Define the Suffixes for Argument Name
- *    When the suffixes is non empty, completion for argument name will end with
- *    one of the proposed suffixes.
- *     - option id:         "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
- *     - possible values:   { "[,]*" } where  is a String without any wild-card 
- *     - default:           ""
- * 
- * - * @return a mutable table containing the default settings of all known options - * (key type: String; value type: String) - * @see #setOptions - */ -public static Hashtable getDefaultOptions(){ - - Hashtable defaultOptions = new Hashtable(10); - - // see #initializeDefaultPluginPreferences() for changing default settings - Preferences preferences = getPlugin().getPluginPreferences(); - HashSet optionNames = JavaModelManager.OptionNames; - - // get preferences set to their default - String[] defaultPropertyNames = preferences.defaultPropertyNames(); - for (int i = 0; i < defaultPropertyNames.length; i++){ - String propertyName = defaultPropertyNames[i]; - if (optionNames.contains(propertyName)) { - defaultOptions.put(propertyName, preferences.getDefaultString(propertyName)); - } - } - // get preferences not set to their default - String[] propertyNames = preferences.propertyNames(); - for (int i = 0; i < propertyNames.length; i++){ - String propertyName = propertyNames[i]; - if (optionNames.contains(propertyName)) { - defaultOptions.put(propertyName, preferences.getDefaultString(propertyName)); - } - } - // get encoding through resource plugin - defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); - - return defaultOptions; -} - -/** - * Returns the single instance of the Java core plug-in runtime class. - * Equivalent to (JavaCore) getPlugin(). - * - * @return the single instance of the Java core plug-in runtime class - */ -public static PHPeclipsePlugin getJavaCore() { - return (PHPeclipsePlugin) getPlugin(); -} - -/** - * Helper method for returning one option value only. Equivalent to (String)JavaCore.getOptions().get(optionName) - * Note that it may answer null if this option does not exist. - *

- * For a complete description of the configurable options, see getDefaultOptions. - *

- * - * @param optionName the name of an option - * @return the String value of a given option - * @see JavaCore#getDefaultOptions - * @since 2.0 - */ -public static String getOption(String optionName) { - - if (CORE_ENCODING.equals(optionName)){ - return ResourcesPlugin.getEncoding(); - } - if (JavaModelManager.OptionNames.contains(optionName)){ - Preferences preferences = getPlugin().getPluginPreferences(); - return preferences.getString(optionName).trim(); - } - return null; -} - -/** - * Returns the table of the current options. Initially, all options have their default values, - * and this method returns a table that includes all known options. - *

- * For a complete description of the configurable options, see getDefaultOptions. - *

- * - * @return table of current settings of all options - * (key type: String; value type: String) - * @see JavaCore#getDefaultOptions - */ -public static Hashtable getOptions() { - - Hashtable options = new Hashtable(10); - - // see #initializeDefaultPluginPreferences() for changing default settings - Plugin plugin = getPlugin(); - if (plugin != null) { - Preferences preferences = getPlugin().getPluginPreferences(); - HashSet optionNames = JavaModelManager.OptionNames; - - // get preferences set to their default - String[] defaultPropertyNames = preferences.defaultPropertyNames(); - for (int i = 0; i < defaultPropertyNames.length; i++){ - String propertyName = defaultPropertyNames[i]; - if (optionNames.contains(propertyName)){ - options.put(propertyName, preferences.getDefaultString(propertyName)); - } - } - // get preferences not set to their default - String[] propertyNames = preferences.propertyNames(); - for (int i = 0; i < propertyNames.length; i++){ - String propertyName = propertyNames[i]; - if (optionNames.contains(propertyName)){ - options.put(propertyName, preferences.getString(propertyName).trim()); - } - } - // get encoding through resource plugin - options.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); - } - return options; -} - -/** - * This is a helper method, which returns the resolved classpath entry denoted - * by a given entry (if it is a variable entry). It is obtained by resolving the variable - * reference in the first segment. Returns null if unable to resolve using - * the following algorithm: - *
    - *
  • if variable segment cannot be resolved, returns null
  • - *
  • finds a project, JAR or binary folder in the workspace at the resolved path location
  • - *
  • if none finds an external JAR file or folder outside the workspace at the resolved path location
  • - *
  • if none returns null
  • - *
- *

- * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry. - *

- * NOTE: This helper method does not handle classpath containers, for which should rather be used - * JavaCore#getClasspathContainer(IPath, IJavaProject). - *

- * - * @param entry the given variable entry - * @return the resolved library or project classpath entry, or null - * if the given variable entry could not be resolved to a valid classpath entry - */ -public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) { - - if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) - return entry; - - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath()); - if (resolvedPath == null) - return null; - - Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false); - if (target == null) - return null; - - // inside the workspace - if (target instanceof IResource) { - IResource resolvedResource = (IResource) target; - if (resolvedResource != null) { - switch (resolvedResource.getType()) { - - case IResource.PROJECT : - // internal project - return JavaCore.newProjectEntry(resolvedPath, entry.isExported()); - - case IResource.FILE : -// if (Util.isArchiveFileName(resolvedResource.getName())) { -// // internal binary archive -// return JavaCore.newLibraryEntry( -// resolvedPath, -// getResolvedVariablePath(entry.getSourceAttachmentPath()), -// getResolvedVariablePath(entry.getSourceAttachmentRootPath()), -// entry.isExported()); -// } - break; - - case IResource.FOLDER : - // internal binary folder -// return JavaCore.newLibraryEntry( -// resolvedPath, -// getResolvedVariablePath(entry.getSourceAttachmentPath()), -// getResolvedVariablePath(entry.getSourceAttachmentRootPath()), -// entry.isExported()); - break; - } - } - } - // outside the workspace - if (target instanceof File) { - File externalFile = (File) target; - if (externalFile.isFile()) { - String fileName = externalFile.getName().toLowerCase(); -// if (fileName.endsWith(".jar" //$NON-NLS-1$ -// ) || fileName.endsWith(".zip" //$NON-NLS-1$ -// )) { // external binary archive -// return JavaCore.newLibraryEntry( -// resolvedPath, -// getResolvedVariablePath(entry.getSourceAttachmentPath()), -// getResolvedVariablePath(entry.getSourceAttachmentRootPath()), -// entry.isExported()); -// } - } else { // external binary folder - if (resolvedPath.isAbsolute()){ -// return JavaCore.newLibraryEntry( -// resolvedPath, -// getResolvedVariablePath(entry.getSourceAttachmentPath()), -// getResolvedVariablePath(entry.getSourceAttachmentRootPath()), -// entry.isExported()); - } - } - } - return null; -} - - -/** - * Resolve a variable path (helper method). - * - * @param variablePath the given variable path - * @return the resolved variable path or null if none - */ -public static IPath getResolvedVariablePath(IPath variablePath) { - - if (variablePath == null) - return null; - int count = variablePath.segmentCount(); - if (count == 0) - return null; - - // lookup variable - String variableName = variablePath.segment(0); - IPath resolvedPath = JavaCore.getClasspathVariable(variableName); - if (resolvedPath == null) - return null; - - // append path suffix - if (count > 1) { - resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1)); - } - return resolvedPath; -} - -/** - * Answers the shared working copies currently registered for this buffer factory. - * Working copies can be shared by several clients using the same buffer factory,see - * IWorkingCopy.getSharedWorkingCopy. - * - * @param factory the given buffer factory - * @return the list of shared working copies for a given buffer factory - * @see IWorkingCopy - * @since 2.0 - */ -public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory){ - - // if factory is null, default factory must be used - if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory(); - Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies; - - Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory); - if (perFactoryWorkingCopies == null) return JavaModelManager.NoWorkingCopy; - Collection copies = perFactoryWorkingCopies.values(); - IWorkingCopy[] result = new IWorkingCopy[copies.size()]; - copies.toArray(result); - return result; -} - -/** - * Initializes the default preferences settings for this plug-in. - */ -public static void initializeDefaultPluginPreferences() { - - Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences(); - HashSet optionNames = JavaModelManager.OptionNames; - - // Compiler settings - preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE); - optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR); - - preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE); - optionNames.add(COMPILER_LINE_NUMBER_ATTR); - - preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE); - optionNames.add(COMPILER_SOURCE_FILE_ATTR); - - preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE); - optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL); - - preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1); - optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM); - - preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING); - optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED); - - preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR); - optionNames.add(COMPILER_PB_UNREACHABLE_CODE); - - preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR); - optionNames.add(COMPILER_PB_INVALID_IMPORT); - - preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING); - optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD); - - preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING); - optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME); - - preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING); - optionNames.add(COMPILER_PB_DEPRECATION); - - preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED); - optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE); - - preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING); - optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK); - - preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE); - optionNames.add(COMPILER_PB_UNUSED_LOCAL); - - preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE); - optionNames.add(COMPILER_PB_UNUSED_PARAMETER); - - preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, DISABLED); - optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT); - - preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, DISABLED); - optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE); - - preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING); - optionNames.add(COMPILER_PB_UNUSED_IMPORT); - - preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE); - optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER); - - preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE); - optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION); - - preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE); - optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL); - - preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE); - optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER); - - preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING); - optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER); - - preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING); - optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT); - - preferences.setDefault(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, WARNING); - optionNames.add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD); - - preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, WARNING); - optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION); - - preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$ - optionNames.add(COMPILER_TASK_TAGS); - - preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$ - optionNames.add(COMPILER_TASK_PRIORITIES); - - preferences.setDefault(COMPILER_SOURCE, VERSION_1_3); - optionNames.add(COMPILER_SOURCE); - - preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3); - optionNames.add(COMPILER_COMPLIANCE); - - preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$ - optionNames.add(COMPILER_PB_MAX_PER_UNIT); - - // Builder settings - preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$ - optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER); - - preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT); - optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH); - - preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING); - optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE); - - preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN); - optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER); - - // JavaCore settings - preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE); - optionNames.add(CORE_JAVA_BUILD_ORDER); - - preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR); - optionNames.add(CORE_CIRCULAR_CLASSPATH); - - preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR); - optionNames.add(CORE_INCOMPLETE_CLASSPATH); - - preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED); - optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS); - - preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED); - optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS); - - // encoding setting comes from resource plug-in - optionNames.add(CORE_ENCODING); - - // Formatter settings - preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT); - optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE); - - preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT); - optionNames.add(FORMATTER_NEWLINE_CONTROL); - - preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE); - optionNames.add(FORMATTER_CLEAR_BLANK_LINES); - - preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT); - optionNames.add(FORMATTER_NEWLINE_ELSE_IF); - - preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT); - optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK); - - preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$ - optionNames.add(FORMATTER_LINE_SPLIT); - - preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL); - optionNames.add(FORMATTER_COMPACT_ASSIGNMENT); - - preferences.setDefault(FORMATTER_TAB_CHAR, TAB); - optionNames.add(FORMATTER_TAB_CHAR); - - preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ - optionNames.add(FORMATTER_TAB_SIZE); - - preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$ - optionNames.add(FORMATTER_SPACE_CASTEXPRESSION); - - // CodeAssist settings - preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$ - optionNames.add(CODEASSIST_VISIBILITY_CHECK); - - preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$ - optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION); - - preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_FIELD_PREFIXES); - - preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES); - - preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_LOCAL_PREFIXES); - - preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_ARGUMENT_PREFIXES); - - preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_FIELD_SUFFIXES); - - preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES); - - preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_LOCAL_SUFFIXES); - - preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$ - optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES); -} - -/** - * Returns whether the given marker references the given Java element. - * Used for markers, which denote a Java element rather than a resource. - * - * @param element the element - * @param marker the marker - * @return true if the marker references the element, false otherwise - * @exception CoreException if the IMarker.getAttribute on the marker fails - */ -public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException { - - // only match units or classfiles - if (element instanceof IMember){ - IMember member = (IMember) element; - if (member.isBinary()){ - element = null; //member.getClassFile(); - } else { - element = member.getCompilationUnit(); - } - } - if (element == null) return false; - if (marker == null) return false; - - String markerHandleId = (String)marker.getAttribute(ATT_HANDLE_ID); - if (markerHandleId == null) return false; - - IJavaElement markerElement = JavaCore.create(markerHandleId); -// while (true){ - if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs. - - // cycle through enclosing types in case marker is associated with a classfile (15568) -// if (markerElement instanceof IClassFile){ -// IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType(); -// if (enclosingType != null){ -// markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile -// continue; -// } -// } -// break; -// } - return false; -} - -/** - * Returns whether the given marker delta references the given Java element. - * Used for markers deltas, which denote a Java element rather than a resource. - * - * @param element the element - * @param markerDelta the marker delta - * @return true if the marker delta references the element - * @exception CoreException if the IMarkerDelta.getAttribute on the marker delta fails - */ -public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException { - - // only match units or classfiles - if (element instanceof IMember){ - IMember member = (IMember) element; - if (member.isBinary()){ - element = null; //member.getClassFile(); - } else { - element = member.getCompilationUnit(); - } - } - if (element == null) return false; - if (markerDelta == null) return false; - - String markerDeltarHandleId = (String)markerDelta.getAttribute(ATT_HANDLE_ID); - if (markerDeltarHandleId == null) return false; - - IJavaElement markerElement = JavaCore.create(markerDeltarHandleId); -// while (true){ - if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs. - - // cycle through enclosing types in case marker is associated with a classfile (15568) -// if (markerElement instanceof IClassFile){ -// IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType(); -// if (enclosingType != null){ -// markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile -// continue; -// } -// } -// break; -// } - return false; -} - -/** - * Creates and returns a new classpath entry of kind CPE_CONTAINER - * for the given path. The path of the container will be used during resolution so as to map this - * container entry to a set of other classpath entries the container is acting for. - *

- * A container entry allows to express indirect references to a set of libraries, projects and variable entries, - * which can be interpreted differently for each Java project where it is used. - * A classpath container entry can be resolved using JavaCore.getResolvedClasspathContainer, - * and updated with JavaCore.classpathContainerChanged - *

- * A container is exclusively resolved by a ClasspathContainerInitializer registered onto the - * extension point "org.eclipse.jdt.core.classpathContainerInitializer". - *

- * A container path must be formed of at least one segment, where:

    - *
  • the first segment is a unique ID identifying the target container, there must be a container initializer registered - * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
  • - *
  • the remaining segments will be passed onto the initializer, and can be used as additional - * hints during the initialization phase.
  • - *
- *

- * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container: - * - * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default")); - * - * - * - *

- * Note that this operation does not attempt to validate classpath containers - * or access the resources at the given paths. - *

- * The resulting entry is not exported to dependent projects. This method is equivalent to - * newContainerEntry(-,false). - *

- * @param containerPath the path identifying the container, it must be formed of two - * segments - * @return a new container classpath entry - * - * @see JavaCore#getClasspathContainer(IPath, IJavaProject) - * @see JavaCore#newContainerEntry(IPath, boolean) - * @since 2.0 - */ -public static IClasspathEntry newContainerEntry(IPath containerPath) { - - return newContainerEntry(containerPath, false); -} - -/** - * Creates and returns a new classpath entry of kind CPE_CONTAINER - * for the given path. The path of the container will be used during resolution so as to map this - * container entry to a set of other classpath entries the container is acting for. - *

- * A container entry allows to express indirect references to a set of libraries, projects and variable entries, - * which can be interpreted differently for each Java project where it is used. - * A classpath container entry can be resolved using JavaCore.getResolvedClasspathContainer, - * and updated with JavaCore.classpathContainerChanged - *

- * A container is exclusively resolved by a ClasspathContainerInitializer registered onto the - * extension point "org.eclipse.jdt.core.classpathContainerInitializer". - *

- * A container path must be formed of at least one segment, where:

    - *
  • the first segment is a unique ID identifying the target container, there must be a container initializer registered - * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
  • - *
  • the remaining segments will be passed onto the initializer, and can be used as additional - * hints during the initialization phase.
  • - *
- *

- * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container: - * - * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default")); - * - * - * - *

- * Note that this operation does not attempt to validate classpath containers - * or access the resources at the given paths. - *

- * @param containerPath the path identifying the container, it must be formed of at least - * one segment (ID+hints) - * @param isExported a boolean indicating whether this entry is contributed to dependent - * projects in addition to the output location - * @return a new container classpath entry - * - * @see JavaCore#getClasspathContainer(IPath, IJavaProject) - * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor) - * @see JavaCore#newContainerEntry(IPath, boolean) - * @since 2.0 - */ -public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) { - - if (containerPath == null || containerPath.segmentCount() < 1) { - Assert.isTrue( - false, - "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$ - } - return new ClasspathEntry( - IPackageFragmentRoot.K_SOURCE, - IClasspathEntry.CPE_CONTAINER, - containerPath, - ClasspathEntry.NO_EXCLUSION_PATTERNS, - null, // source attachment - null, // source attachment root - null, // specific output folder - isExported); -} - -/** - * Creates and returns a new non-exported classpath entry of kind CPE_LIBRARY for the - * JAR or folder identified by the given absolute path. This specifies that all package fragments - * within the root will have children of type IClassFile. - *

- * A library entry is used to denote a prerequisite JAR or root folder containing binaries. - * The target JAR or folder can either be defined internally to the workspace (absolute path relative - * to the workspace root) or externally to the workspace (absolute path in the file system). - *

- * e.g. Here are some examples of binary path usage

    - *
  • "c:/jdk1.2.2/jre/lib/rt.jar" - reference to an external JAR
  • - *
  • "/Project/someLib.jar" - reference to an internal JAR
  • - *
  • "c:/classes/" - reference to an external binary folder
  • - *
- * Note that this operation does not attempt to validate or access the - * resources at the given paths. - *

- * The resulting entry is not exported to dependent projects. This method is equivalent to - * newLibraryEntry(-,-,-,false). - *

- * - * @param path the absolute path of the binary archive - * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, - * or null if none - * @param sourceAttachmentRootPath the location of the root within the source archive or folder - * or null if this location should be automatically detected. - * @return a new library classpath entry - * - * @see #newLibraryEntry(IPath, IPath, IPath, boolean) - */ -//public static IClasspathEntry newLibraryEntry( -// IPath path, -// IPath sourceAttachmentPath, -// IPath sourceAttachmentRootPath) { -// -// return newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, false); -//} - -/** - * Creates and returns a new classpath entry of kind CPE_LIBRARY for the JAR or folder - * identified by the given absolute path. This specifies that all package fragments within the root - * will have children of type IClassFile. - *

- * A library entry is used to denote a prerequisite JAR or root folder containing binaries. - * The target JAR or folder can either be defined internally to the workspace (absolute path relative - * to the workspace root) or externally to the workspace (absolute path in the file system). - *

- * e.g. Here are some examples of binary path usage

    - *
  • "c:/jdk1.2.2/jre/lib/rt.jar" - reference to an external JAR
  • - *
  • "/Project/someLib.jar" - reference to an internal JAR
  • - *
  • "c:/classes/" - reference to an external binary folder
  • - *
- * Note that this operation does not attempt to validate or access the - * resources at the given paths. - *

- * - * @param path the absolute path of the binary archive - * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, - * or null if none - * @param sourceAttachmentRootPath the location of the root within the source archive or folder - * or null if this location should be automatically detected. - * @param isExported indicates whether this entry is contributed to dependent - * projects in addition to the output location - * @return a new library classpath entry - * @since 2.0 - */ -//public static IClasspathEntry newLibraryEntry( -// IPath path, -// IPath sourceAttachmentPath, -// IPath sourceAttachmentRootPath, -// boolean isExported) { -// -// if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ -// -// return new ClasspathEntry( -// IPackageFragmentRoot.K_BINARY, -// IClasspathEntry.CPE_LIBRARY, -// JavaProject.canonicalizedPath(path), -// ClasspathEntry.NO_EXCLUSION_PATTERNS, -// sourceAttachmentPath, -// sourceAttachmentRootPath, -// null, // specific output folder -// isExported); -//} - -/** - * Creates and returns a new non-exported classpath entry of kind CPE_PROJECT - * for the project identified by the given absolute path. - *

- * A project entry is used to denote a prerequisite project on a classpath. - * The referenced project will be contributed as a whole, either as sources (in the Java Model, it - * contributes all its package fragment roots) or as binaries (when building, it contributes its - * whole output location). - *

- * A project reference allows to indirect through another project, independently from its internal layout. - *

- * The prerequisite project is referred to using an absolute path relative to the workspace root. - *

- * The resulting entry is not exported to dependent projects. This method is equivalent to - * newProjectEntry(_,false). - *

- * - * @param path the absolute path of the binary archive - * @return a new project classpath entry - * - * @see JavaCore#newProjectEntry(IPath, boolean) - */ -public static IClasspathEntry newProjectEntry(IPath path) { - return newProjectEntry(path, false); -} - -/** - * Creates and returns a new classpath entry of kind CPE_PROJECT - * for the project identified by the given absolute path. - *

- * A project entry is used to denote a prerequisite project on a classpath. - * The referenced project will be contributed as a whole, either as sources (in the Java Model, it - * contributes all its package fragment roots) or as binaries (when building, it contributes its - * whole output location). - *

- * A project reference allows to indirect through another project, independently from its internal layout. - *

- * The prerequisite project is referred to using an absolute path relative to the workspace root. - *

- * - * @param path the absolute path of the prerequisite project - * @param isExported indicates whether this entry is contributed to dependent - * projects in addition to the output location - * @return a new project classpath entry - * @since 2.0 - */ -public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) { - - if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ - - return new ClasspathEntry( - IPackageFragmentRoot.K_SOURCE, - IClasspathEntry.CPE_PROJECT, - path, - ClasspathEntry.NO_EXCLUSION_PATTERNS, - null, // source attachment - null, // source attachment root - null, // specific output folder - isExported); -} - -/** - * Returns a new empty region. - * - * @return a new empty region - */ -public static IRegion newRegion() { - return new Region(); -} - -/** - * Creates and returns a new classpath entry of kind CPE_SOURCE - * for the project's source folder identified by the given absolute - * workspace-relative path. This specifies that all package fragments - * within the root will have children of type ICompilationUnit. - *

- * The source folder is referred to using an absolute path relative to the - * workspace root, e.g. /Project/src. A project's source - * folders are located with that project. That is, a source classpath - * entry specifying the path /P1/src is only usable for - * project P1. - *

- *

- * The source classpath entry created by this method includes all source - * files below the given workspace-relative path. To selectively exclude - * some of these source files, use the factory method - * JavaCore.newSourceEntry(IPath,IPath[]) instead. - *

- *

- * Note that all sources/binaries inside a project are contributed as a whole through - * a project entry (see JavaCore.newProjectEntry). Particular - * source entries cannot be selectively exported. - *

- * - * @param path the absolute workspace-relative path of a source folder - * @return a new source classpath entry with not exclusion patterns - * - * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[]) - */ -public static IClasspathEntry newSourceEntry(IPath path) { - - return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*output location*/); -} - -/** - * Creates and returns a new classpath entry of kind CPE_SOURCE - * for the project's source folder identified by the given absolute - * workspace-relative path but excluding all source files with paths - * matching any of the given patterns. This specifies that all package - * fragments within the root will have children of type - * ICompilationUnit. - *

- * The source folder is referred to using an absolute path relative to the - * workspace root, e.g. /Project/src. A project's source - * folders are located with that project. That is, a source classpath - * entry specifying the path /P1/src is only usable for - * project P1. - *

- *

- * The source classpath entry created by this method includes all source - * files below the given workspace-relative path except for those matched - * by one (or more) of the given exclusion patterns. Each exclusion pattern - * is represented by a relative path, which is interpreted as relative to - * the source folder. For example, if the source folder path is - * /Project/src and the exclusion pattern is - * com/xyz/tests/**, then source files - * like /Project/src/com/xyz/Foo.java - * and /Project/src/com/xyz/utils/Bar.java would be included, - * whereas /Project/src/com/xyz/tests/T1.java - * and /Project/src/com/xyz/tests/quick/T2.java would be - * excluded. Exclusion patterns can contain can contain '**', '*' or '?' - * wildcards; see IClasspathEntry.getExclusionPatterns - * for the full description of the syntax and semantics of exclusion - * patterns. - *

- * If the empty list of exclusion patterns is specified, the source folder - * will automatically include all resources located inside the source - * folder. In that case, the result is entirely equivalent to using the - * factory method JavaCore.newSourceEntry(IPath). - *

- *

- * Note that all sources/binaries inside a project are contributed as a whole through - * a project entry (see JavaCore.newProjectEntry). Particular - * source entries cannot be selectively exported. - *

- * - * @param path the absolute workspace-relative path of a source folder - * @param exclusionPatterns the possibly empty list of exclusion patterns - * represented as relative paths - * @return a new source classpath entry with the given exclusion patterns - * @see #newSourceEntry(org.eclipse.core.runtime.IPath) - * @see IClasspathEntry#getExclusionPatterns - * - * @since 2.1 - */ -public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) { - - return newSourceEntry(path, exclusionPatterns, null /*output location*/); -} - -/** - * Creates and returns a new classpath entry of kind CPE_SOURCE - * for the project's source folder identified by the given absolute - * workspace-relative path but excluding all source files with paths - * matching any of the given patterns, and associated with a specific output location - * (that is, ".class" files are not going to the project default output location). - * All package fragments within the root will have children of type - * ICompilationUnit. - *

- * The source folder is referred to using an absolute path relative to the - * workspace root, e.g. /Project/src. A project's source - * folders are located with that project. That is, a source classpath - * entry specifying the path /P1/src is only usable for - * project P1. - *

- *

- * The source classpath entry created by this method includes all source - * files below the given workspace-relative path except for those matched - * by one (or more) of the given exclusion patterns. Each exclusion pattern - * is represented by a relative path, which is interpreted as relative to - * the source folder. For example, if the source folder path is - * /Project/src and the exclusion pattern is - * com/xyz/tests/**, then source files - * like /Project/src/com/xyz/Foo.java - * and /Project/src/com/xyz/utils/Bar.java would be included, - * whereas /Project/src/com/xyz/tests/T1.java - * and /Project/src/com/xyz/tests/quick/T2.java would be - * excluded. Exclusion patterns can contain can contain '**', '*' or '?' - * wildcards; see IClasspathEntry.getExclusionPatterns - * for the full description of the syntax and semantics of exclusion - * patterns. - *

- * If the empty list of exclusion patterns is specified, the source folder - * will automatically include all resources located inside the source - * folder. In that case, the result is entirely equivalent to using the - * factory method JavaCore.newSourceEntry(IPath). - *

- *

- * Additionally, a source entry can be associated with a specific output location. - * By doing so, the Java builder will ensure that the generated ".class" files will - * be issued inside this output location, as opposed to be generated into the - * project default output location (when output location is null). - * Note that multiple source entries may target the same output location. - * The output location is referred to using an absolute path relative to the - * workspace root, e.g. "/Project/bin", it must be located inside - * the same project as the source folder. - *

- *

- * Also note that all sources/binaries inside a project are contributed as a whole through - * a project entry (see JavaCore.newProjectEntry). Particular - * source entries cannot be selectively exported. - *

- * - * @param path the absolute workspace-relative path of a source folder - * @param exclusionPatterns the possibly empty list of exclusion patterns - * represented as relative paths - * @param outputLocation the specific output location for this source entry (null if using project default ouput location) - * @return a new source classpath entry with the given exclusion patterns - * @see #newSourceEntry(org.eclipse.core.runtime.IPath) - * @see IClasspathEntry#getExclusionPatterns - * @see IClasspathEntry#getOutputLocation() - * - * @since 2.1 - */ -public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) { - - if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ - if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$ - - return new ClasspathEntry( - IPackageFragmentRoot.K_SOURCE, - IClasspathEntry.CPE_SOURCE, - path, - exclusionPatterns, - null, // source attachment - null, // source attachment root - specificOutputLocation, // custom output location - false); -} - -/** - * Creates and returns a new non-exported classpath entry of kind CPE_VARIABLE - * for the given path. The first segment of the path is the name of a classpath variable. - * The trailing segments of the path will be appended to resolved variable path. - *

- * A variable entry allows to express indirect references on a classpath to other projects or libraries, - * depending on what the classpath variable is referring. - *

- * It is possible to register an automatic initializer (ClasspathVariableInitializer), - * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer". - * After resolution, a classpath variable entry may either correspond to a project or a library entry. - *

- * e.g. Here are some examples of variable path usage

    - *
  • "JDTCORE" where variable JDTCORE is - * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"
  • - *
  • "JDTCORE" where variable JDTCORE is - * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"
  • - *
  • "PLUGINS/com.example/example.jar" where variable PLUGINS - * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"
  • - *
- * Note that this operation does not attempt to validate classpath variables - * or access the resources at the given paths. - *

- * The resulting entry is not exported to dependent projects. This method is equivalent to - * newVariableEntry(-,-,-,false). - *

- * - * @param variablePath the path of the binary archive; first segment is the - * name of a classpath variable - * @param variableSourceAttachmentPath the path of the corresponding source archive, - * or null if none; if present, the first segment is the - * name of a classpath variable (not necessarily the same variable - * as the one that begins variablePath) - * @param sourceAttachmentRootPath the location of the root within the source archive - * or null if archivePath is also null - * @return a new library classpath entry - * - * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean) - */ -//public static IClasspathEntry newVariableEntry( -// IPath variablePath, -// IPath variableSourceAttachmentPath, -// IPath sourceAttachmentRootPath) { -// -// return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false); -//} - -/** - * Creates and returns a new non-exported classpath entry of kind CPE_VARIABLE - * for the given path. The first segment of the path is the name of a classpath variable. - * The trailing segments of the path will be appended to resolved variable path. - *

- * A variable entry allows to express indirect references on a classpath to other projects or libraries, - * depending on what the classpath variable is referring. - *

- * It is possible to register an automatic initializer (ClasspathVariableInitializer), - * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer". - * After resolution, a classpath variable entry may either correspond to a project or a library entry. - *

- * e.g. Here are some examples of variable path usage

    - *
  • "JDTCORE" where variable JDTCORE is - * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"
  • - *
  • "JDTCORE" where variable JDTCORE is - * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"
  • - *
  • "PLUGINS/com.example/example.jar" where variable PLUGINS - * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"
  • - *
- * Note that this operation does not attempt to validate classpath variables - * or access the resources at the given paths. - *

- * - * @param variablePath the path of the binary archive; first segment is the - * name of a classpath variable - * @param variableSourceAttachmentPath the path of the corresponding source archive, - * or null if none; if present, the first segment is the - * name of a classpath variable (not necessarily the same variable - * as the one that begins variablePath) - * @param sourceAttachmentRootPath the location of the root within the source archive - * or null if archivePath is also null - * @param isExported indicates whether this entry is contributed to dependent - * projects in addition to the output location - * @return a new variable classpath entry - * @since 2.0 - */ -//public static IClasspathEntry newVariableEntry( -// IPath variablePath, -// IPath variableSourceAttachmentPath, -// IPath variableSourceAttachmentRootPath, -// boolean isExported) { -// -// if (variablePath == null || variablePath.segmentCount() < 1) { -// Assert.isTrue( -// false, -// "Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$ -// } -// -// return new ClasspathEntry( -// IPackageFragmentRoot.K_SOURCE, -// IClasspathEntry.CPE_VARIABLE, -// variablePath, -// ClasspathEntry.NO_EXCLUSION_PATTERNS, -// variableSourceAttachmentPath, // source attachment -// variableSourceAttachmentRootPath, // source attachment root -// null, // specific output folder -// isExported); -//} - -/** - * Removed the given classpath variable. Does nothing if no value was - * set for this classpath variable. - *

- * This functionality cannot be used while the resource tree is locked. - *

- * Classpath variable values are persisted locally to the workspace, and - * are preserved from session to session. - *

- * - * @param variableName the name of the classpath variable - * @see #setClasspathVariable - * - * @deprecated - use version with extra IProgressMonitor - */ -//public static void removeClasspathVariable(String variableName) { -// removeClasspathVariable(variableName, null); -//} - -/** - * Removed the given classpath variable. Does nothing if no value was - * set for this classpath variable. - *

- * This functionality cannot be used while the resource tree is locked. - *

- * Classpath variable values are persisted locally to the workspace, and - * are preserved from session to session. - *

- * - * @param variableName the name of the classpath variable - * @param monitor the progress monitor to report progress - * @see #setClasspathVariable - */ -//public static void removeClasspathVariable( -// String variableName, -// IProgressMonitor monitor) { -// -// try { -// updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, monitor); -// } catch (JavaModelException e) { -// } -//} - -/** - * Removes the given element changed listener. - * Has no affect if an identical listener is not registered. - * - * @param listener the listener - */ -public static void removeElementChangedListener(IElementChangedListener listener) { - JavaModelManager.getJavaModelManager().removeElementChangedListener(listener); -} - -/** - * Bind a container reference path to some actual containers (IClasspathContainer). - * This API must be invoked whenever changes in container need to be reflected onto the JavaModel. - * Containers can have distinct values in different projects, therefore this API considers a - * set of projects with their respective containers. - *

- * containerPath is the path under which these values can be referenced through - * container classpath entries (IClasspathEntry#CPE_CONTAINER). A container path - * is formed by a first ID segment followed with extra segments, which can be used as additional hints - * for the resolution. The container ID is used to identify a ClasspathContainerInitializer - * registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer". - *

- * There is no assumption that each individual container value passed in argument - * (respectiveContainers) must answer the exact same path when requested - * IClasspathContainer#getPath. - * Indeed, the containerPath is just an indication for resolving it to an actual container object. It can be - * delegated to a ClasspathContainerInitializer, which can be activated through the extension - * point "org.eclipse.jdt.core.ClasspathContainerInitializer"). - *

- * In reaction to changing container values, the JavaModel will be updated to reflect the new - * state of the updated container. - *

- * This functionality cannot be used while the resource tree is locked. - *

- * Classpath container values are persisted locally to the workspace, but - * are not preserved from a session to another. It is thus highly recommended to register a - * ClasspathContainerInitializer for each referenced container - * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer"). - *

- * Note: setting a container to null will cause it to be lazily resolved again whenever - * its value is required. In particular, this will cause a registered initializer to be invoked - * again. - *

- * @param containerPath - the name of the container reference, which is being updated - * @param affectedProjects - the set of projects for which this container is being bound - * @param respectiveContainers - the set of respective containers for the affected projects - * @param monitor a monitor to report progress - * - * @see ClasspathContainerInitializer - * @see #getClasspathContainer(IPath, IJavaProject) - * @see IClasspathContainer - * @since 2.0 - */ -//public static void setClasspathContainer(final IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException { -// -// if (affectedProjects.length != respectiveContainers.length) Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$ -// -// if (monitor != null && monitor.isCanceled()) return; -// -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPContainer SET - setting container: ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$ -// + (Util.toString(affectedProjects, -// new Util.Displayable(){ -// public String displayString(Object o) { return ((IJavaProject) o).getElementName(); } -// })) -// + "} with values: " //$NON-NLS-1$ -// + (Util.toString(respectiveContainers, -// new Util.Displayable(){ -// public String displayString(Object o) { return ((IClasspathContainer) o).getDescription(); } -// })) -// ); -// } -// -// final int projectLength = affectedProjects.length; -// final IJavaProject[] modifiedProjects; -// System.arraycopy(affectedProjects, 0, modifiedProjects = new IJavaProject[projectLength], 0, projectLength); -// final IClasspathEntry[][] oldResolvedPaths = new IClasspathEntry[projectLength][]; -// -// // filter out unmodified project containers -// int remaining = 0; -// for (int i = 0; i < projectLength; i++){ -// -// if (monitor != null && monitor.isCanceled()) return; -// -// IJavaProject affectedProject = affectedProjects[i]; -// IClasspathContainer newContainer = respectiveContainers[i]; -// if (newContainer == null) newContainer = JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent infinite loop -// boolean found = false; -// if (JavaProject.hasJavaNature(affectedProject.getProject())){ -// IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath(); -// for (int j = 0, cpLength = rawClasspath.length; j - * This functionality cannot be used while the resource tree is locked. - *

- * Classpath variable values are persisted locally to the workspace, and - * are preserved from session to session. - *

- * - * @param variableName the name of the classpath variable - * @param path the path - * @see #getClasspathVariable - * - * @deprecated - use API with IProgressMonitor - */ -//public static void setClasspathVariable(String variableName, IPath path) -// throws JavaModelException { -// -// setClasspathVariable(variableName, path, null); -//} - -/** - * Sets the value of the given classpath variable. - * The path must not be null. - *

- * This functionality cannot be used while the resource tree is locked. - *

- * Classpath variable values are persisted locally to the workspace, and - * are preserved from session to session. - *

- * Updating a variable with the same value has no effect. - * - * @param variableName the name of the classpath variable - * @param path the path - * @param monitor a monitor to report progress - * @see #getClasspathVariable - */ -//public static void setClasspathVariable( -// String variableName, -// IPath path, -// IProgressMonitor monitor) -// throws JavaModelException { -// -// if (path == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$ -// setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, monitor); -//} - -/** - * Sets the values of all the given classpath variables at once. - * Null paths can be used to request corresponding variable removal. - *

- * This functionality cannot be used while the resource tree is locked. - *

- * Classpath variable values are persisted locally to the workspace, and - * are preserved from session to session. - *

- * Updating a variable with the same value has no effect. - * - * @param variableNames an array of names for the updated classpath variables - * @param paths an array of path updates for the modified classpath variables (null - * meaning that the corresponding value will be removed - * @param monitor a monitor to report progress - * @see #getClasspathVariable - * @since 2.0 - */ -//public static void setClasspathVariables( -// String[] variableNames, -// IPath[] paths, -// IProgressMonitor monitor) -// throws JavaModelException { -// -// if (variableNames.length != paths.length) Assert.isTrue(false, "Variable names and paths collections should have the same size"); //$NON-NLS-1$ -// //TODO: should check that null cannot be used as variable paths -// updateVariableValues(variableNames, paths, monitor); -//} - -/* (non-Javadoc) - * Method declared on IExecutableExtension. - * Record any necessary initialization data from the plugin. - */ -public void setInitializationData( - IConfigurationElement cfig, - String propertyName, - Object data) - throws CoreException { -} - -/** - * Sets the current table of options. All and only the options explicitly included in the given table - * are remembered; all previous option settings are forgotten, including ones not explicitly - * mentioned. - *

- * For a complete description of the configurable options, see getDefaultOptions. - *

- * - * @param newOptions the new options (key type: String; value type: String), - * or null to reset all options to their default values - * @see JavaCore#getDefaultOptions - */ -public static void setOptions(Hashtable newOptions) { - - // see #initializeDefaultPluginPreferences() for changing default settings - Preferences preferences = getPlugin().getPluginPreferences(); - - if (newOptions == null){ - newOptions = JavaCore.getDefaultOptions(); - } - Enumeration keys = newOptions.keys(); - while (keys.hasMoreElements()){ - String key = (String)keys.nextElement(); - if (!JavaModelManager.OptionNames.contains(key)) continue; // unrecognized option - if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs - String value = (String)newOptions.get(key); - preferences.setValue(key, value); - } - - // persist options - getPlugin().savePluginPreferences(); -} - -/** - * Shutdown the JavaCore plug-in. - *

- * De-registers the JavaModelManager as a resource changed listener and save participant. - *

- * @see org.eclipse.core.runtime.Plugin#shutdown() - */ -// moved to PHPeclipsePlugin#shutdown() -//public void shutdown() { -// -// //savePluginPreferences(); -// getPlugin().savePluginPreferences(); -// IWorkspace workspace = ResourcesPlugin.getWorkspace(); -// workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor); -// workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault()); -// -// ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown(); -//} - -/** - * Initiate the background indexing process. - * This should be deferred after the plugin activation. - */ -//private void startIndexing() { -// -// JavaModelManager.getJavaModelManager().getIndexManager().reset(); -//} - -/** - * Startup of the JavaCore plug-in. - *

- * Registers the JavaModelManager as a resource changed listener and save participant. - * Starts the background indexing, and restore saved classpath variable values. - *

- * @see org.eclipse.core.runtime.Plugin#startup() - */ - -// moved to PHPeclipsePlugin#startup() -//public void startup() { -// -// JavaModelManager manager = JavaModelManager.getJavaModelManager(); -// try { -// manager.configurePluginDebugOptions(); -// -// // request state folder creation (workaround 19885) -// JavaCore.getPlugin().getStateLocation(); -// -// // retrieve variable values -// JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener()); -//// TODO : jsurfer temp-del -//// manager.loadVariablesAndContainers(); -// -// IWorkspace workspace = ResourcesPlugin.getWorkspace(); -// workspace.addResourceChangeListener( -// manager.deltaProcessor, -// IResourceChangeEvent.PRE_AUTO_BUILD -// | IResourceChangeEvent.POST_AUTO_BUILD -// | IResourceChangeEvent.POST_CHANGE -// | IResourceChangeEvent.PRE_DELETE -// | IResourceChangeEvent.PRE_CLOSE); -// -//// startIndexing(); -// workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager); -// -// } catch (CoreException e) { -// } catch (RuntimeException e) { -// manager.shutdown(); -// throw e; -// } -//} - - -/** - * Internal updating of a variable values (null path meaning removal), allowing to change multiple variable values at once. - */ -//private static void updateVariableValues( -// String[] variableNames, -// IPath[] variablePaths, -// IProgressMonitor monitor) throws JavaModelException { -// -// if (monitor != null && monitor.isCanceled()) return; -// -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPVariable SET - setting variables: {" + Util.toString(variableNames) //$NON-NLS-1$ -// + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$ -// } -// -// int varLength = variableNames.length; -// -// // gather classpath information for updating -// final HashMap affectedProjects = new HashMap(5); -// JavaModelManager manager = JavaModelManager.getJavaModelManager(); -// IJavaModel model = manager.getJavaModel(); -// -// // filter out unmodified variables -// int discardCount = 0; -// for (int i = 0; i < varLength; i++){ -// String variableName = variableNames[i]; -// IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if reentering will provide previous session value -// if (oldPath == JavaModelManager.VariableInitializationInProgress){ -// IPath previousPath = (IPath)JavaModelManager.PreviousSessionVariables.get(variableName); -// if (previousPath != null){ -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPVariable INIT - reentering access to variable: " + variableName+ " during its initialization, will see previous value: "+ previousPath); //$NON-NLS-1$ //$NON-NLS-2$ -// } -// JavaModelManager.variablePut(variableName, previousPath); // replace value so reentering calls are seeing old value -// } -// oldPath = null; //33695 - cannot filter out restored variable, must update affected project to reset cached CP -// } -// if (oldPath != null && oldPath.equals(variablePaths[i])){ -// variableNames[i] = null; -// discardCount++; -// } -// } -// if (discardCount > 0){ -// if (discardCount == varLength) return; -// int changedLength = varLength - discardCount; -// String[] changedVariableNames = new String[changedLength]; -// IPath[] changedVariablePaths = new IPath[changedLength]; -// for (int i = 0, index = 0; i < varLength; i++){ -// if (variableNames[i] != null){ -// changedVariableNames[index] = variableNames[i]; -// changedVariablePaths[index] = variablePaths[i]; -// index++; -// } -// } -// variableNames = changedVariableNames; -// variablePaths = changedVariablePaths; -// varLength = changedLength; -// } -// -// if (monitor != null && monitor.isCanceled()) return; -// -// if (model != null) { -// IJavaProject[] projects = model.getJavaProjects(); -// nextProject : for (int i = 0, projectLength = projects.length; i < projectLength; i++){ -// IJavaProject project = projects[i]; -// -// // check to see if any of the modified variables is present on the classpath -// IClasspathEntry[] classpath = project.getRawClasspath(); -// for (int j = 0, cpLength = classpath.length; j < cpLength; j++){ -// -// IClasspathEntry entry = classpath[j]; -// for (int k = 0; k < varLength; k++){ -// -// String variableName = variableNames[k]; -// if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){ -// -// if (variableName.equals(entry.getPath().segment(0))){ -// affectedProjects.put(project, project.getResolvedClasspath(true)); -// continue nextProject; -// } -// IPath sourcePath, sourceRootPath; -// if (((sourcePath = entry.getSourceAttachmentPath()) != null && variableName.equals(sourcePath.segment(0))) -// || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null && variableName.equals(sourceRootPath.segment(0)))) { -// -// affectedProjects.put(project, project.getResolvedClasspath(true)); -// continue nextProject; -// } -// } -// } -// } -// } -// } -// // update variables -// for (int i = 0; i < varLength; i++){ -// JavaModelManager.variablePut(variableNames[i], variablePaths[i]); -// } -// final String[] dbgVariableNames = variableNames; -// -// // update affected project classpaths -// if (!affectedProjects.isEmpty()) { -// try { -// JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run( -// new IWorkspaceRunnable() { -// public void run(IProgressMonitor monitor) throws CoreException { -// // propagate classpath change -// Iterator projectsToUpdate = affectedProjects.keySet().iterator(); -// while (projectsToUpdate.hasNext()) { -// -// if (monitor != null && monitor.isCanceled()) return; -// -// JavaProject project = (JavaProject) projectsToUpdate.next(); + // moved to PHPeclipsePlugin#startup() + //public void startup() { + // + // JavaModelManager manager = JavaModelManager.getJavaModelManager(); + // try { + // manager.configurePluginDebugOptions(); + // + // // request state folder creation (workaround 19885) + // JavaCore.getPlugin().getStateLocation(); + // + // // retrieve variable values + // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new + // JavaModelManager.PluginPreferencesListener()); + //// TODO : jsurfer temp-del + //// manager.loadVariablesAndContainers(); + // + // IWorkspace workspace = ResourcesPlugin.getWorkspace(); + // workspace.addResourceChangeListener( + // manager.deltaProcessor, + // IResourceChangeEvent.PRE_AUTO_BUILD + // | IResourceChangeEvent.POST_AUTO_BUILD + // | IResourceChangeEvent.POST_CHANGE + // | IResourceChangeEvent.PRE_DELETE + // | IResourceChangeEvent.PRE_CLOSE); + // + //// startIndexing(); + // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager); + // + // } catch (CoreException e) { + // } catch (RuntimeException e) { + // manager.shutdown(); + // throw e; + // } + //} + /** + * Internal updating of a variable values (null path meaning removal), + * allowing to change multiple variable values at once. + */ + //private static void updateVariableValues( + // String[] variableNames, + // IPath[] variablePaths, + // IProgressMonitor monitor) throws JavaModelException { + // + // if (monitor != null && monitor.isCanceled()) return; + // + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPVariable SET - setting variables: {" + + // Util.toString(variableNames) //$NON-NLS-1$ + // + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$ + // } + // + // int varLength = variableNames.length; + // + // // gather classpath information for updating + // final HashMap affectedProjects = new HashMap(5); + // JavaModelManager manager = JavaModelManager.getJavaModelManager(); + // IJavaModel model = manager.getJavaModel(); + // + // // filter out unmodified variables + // int discardCount = 0; + // for (int i = 0; i < varLength; i++){ + // String variableName = variableNames[i]; + // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if + // reentering will provide previous session value + // if (oldPath == JavaModelManager.VariableInitializationInProgress){ + // IPath previousPath = + // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName); + // if (previousPath != null){ + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPVariable INIT - reentering access to variable: " + + // variableName+ " during its initialization, will see previous value: "+ + // previousPath); //$NON-NLS-1$ //$NON-NLS-2$ + // } + // JavaModelManager.variablePut(variableName, previousPath); // replace + // value so reentering calls are seeing old value + // } + // oldPath = null; //33695 - cannot filter out restored variable, must + // update affected project to reset cached CP + // } + // if (oldPath != null && oldPath.equals(variablePaths[i])){ + // variableNames[i] = null; + // discardCount++; + // } + // } + // if (discardCount > 0){ + // if (discardCount == varLength) return; + // int changedLength = varLength - discardCount; + // String[] changedVariableNames = new String[changedLength]; + // IPath[] changedVariablePaths = new IPath[changedLength]; + // for (int i = 0, index = 0; i < varLength; i++){ + // if (variableNames[i] != null){ + // changedVariableNames[index] = variableNames[i]; + // changedVariablePaths[index] = variablePaths[i]; + // index++; + // } + // } + // variableNames = changedVariableNames; + // variablePaths = changedVariablePaths; + // varLength = changedLength; + // } + // + // if (monitor != null && monitor.isCanceled()) return; + // + // if (model != null) { + // IJavaProject[] projects = model.getJavaProjects(); + // nextProject : for (int i = 0, projectLength = projects.length; i < + // projectLength; i++){ + // IJavaProject project = projects[i]; + // + // // check to see if any of the modified variables is present on the + // classpath + // IClasspathEntry[] classpath = project.getRawClasspath(); + // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){ + // + // IClasspathEntry entry = classpath[j]; + // for (int k = 0; k < varLength; k++){ + // + // String variableName = variableNames[k]; + // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){ + // + // if (variableName.equals(entry.getPath().segment(0))){ + // affectedProjects.put(project, project.getResolvedClasspath(true)); + // continue nextProject; + // } + // IPath sourcePath, sourceRootPath; + // if (((sourcePath = entry.getSourceAttachmentPath()) != null && + // variableName.equals(sourcePath.segment(0))) + // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null && + // variableName.equals(sourceRootPath.segment(0)))) { + // + // affectedProjects.put(project, project.getResolvedClasspath(true)); + // continue nextProject; + // } + // } + // } + // } + // } + // } + // // update variables + // for (int i = 0; i < varLength; i++){ + // JavaModelManager.variablePut(variableNames[i], variablePaths[i]); + // } + // final String[] dbgVariableNames = variableNames; + // + // // update affected project classpaths + // if (!affectedProjects.isEmpty()) { + // try { + // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run( + // new IWorkspaceRunnable() { + // public void run(IProgressMonitor monitor) throws CoreException { + // // propagate classpath change + // Iterator projectsToUpdate = affectedProjects.keySet().iterator(); + // while (projectsToUpdate.hasNext()) { + // + // if (monitor != null && monitor.isCanceled()) return; + // + // JavaProject project = (JavaProject) projectsToUpdate.next(); + // + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPVariable SET - updating affected project: + // ["+project.getElementName()+"] due to setting variables: "+ + // Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$ + // } + // + // project + // .setRawClasspath( + // project.getRawClasspath(), + // SetClasspathOperation.ReuseOutputLocation, + // null, // don't call beginTask on the monitor (see + // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717) + // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources + // (IClasspathEntry[]) affectedProjects.get(project), + // false, // updating - no validation + // false); // updating - no need to save + // } + // } + // }, + // monitor); + // } catch (CoreException e) { + // if (JavaModelManager.CP_RESOLVE_VERBOSE){ + // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION: + // "+Util.toString(dbgVariableNames)); //$NON-NLS-1$ + // e.printStackTrace(); + // } + // if (e instanceof JavaModelException) { + // throw (JavaModelException)e; + // } else { + // throw new JavaModelException(e); + // } + // } + // } + //} + /* + * (non-Javadoc) Startup the JavaCore plug-in.

Registers the + * JavaModelManager as a resource changed listener and save participant. + * Starts the background indexing, and restore saved classpath variable + * values.

@throws Exception + * + * @see org.eclipse.core.runtime.Plugin#start(BundleContext) + */ + //public static void start(final Plugin plugin, BundleContext context) + // throws Exception { + //// super.start(context); + // + // final JavaModelManager manager = JavaModelManager.getJavaModelManager(); + // try { + // manager.configurePluginDebugOptions(); + // + // // request state folder creation (workaround 19885) + // JavaCore.getPlugin().getStateLocation(); + // + // // retrieve variable values + // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new + // JavaModelManager.PluginPreferencesListener()); + //// manager.loadVariablesAndContainers(); + // + // final IWorkspace workspace = ResourcesPlugin.getWorkspace(); + // workspace.addResourceChangeListener( + // manager.deltaState, + // IResourceChangeEvent.PRE_BUILD + // | IResourceChangeEvent.POST_BUILD + // | IResourceChangeEvent.POST_CHANGE + // | IResourceChangeEvent.PRE_DELETE + // | IResourceChangeEvent.PRE_CLOSE); + // + //// startIndexing(); + // + // // process deltas since last activated in indexer thread so that indexes + // are up-to-date. + // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658 + // Job processSavedState = new Job(Util.bind("savedState.jobName")) { + // //$NON-NLS-1$ + // protected IStatus run(IProgressMonitor monitor) { + // try { + // // add save participant and process delta atomically + // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937 + // workspace.run( + // new IWorkspaceRunnable() { + // public void run(IProgressMonitor progress) throws CoreException { + //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this, + // manager); + // ISavedState savedState = workspace.addSaveParticipant(plugin, manager); + // if (savedState != null) { + // // the event type coming from the saved state is always POST_AUTO_BUILD + // // force it to be POST_CHANGE so that the delta processor can handle it + // manager.deltaState.getDeltaProcessor().overridenEventType = + // IResourceChangeEvent.POST_CHANGE; + // savedState.processResourceChangeEvents(manager.deltaState); + // } + // } + // }, + // monitor); + // } catch (CoreException e) { + // return e.getStatus(); + // } + // return Status.OK_STATUS; + // } + // }; + // processSavedState.setSystem(true); + // processSavedState.setPriority(Job.SHORT); // process asap + // processSavedState.schedule(); + // } catch (RuntimeException e) { + // manager.shutdown(); + // throw e; + // } + //} + /* + * (non-Javadoc) Shutdown the JavaCore plug-in.

De-registers the + * JavaModelManager as a resource changed listener and save participant.

+ * + * @see org.eclipse.core.runtime.Plugin#stop(BundleContext) + */ +// public static void stop(Plugin plugin, BundleContext context) +// throws Exception { +// try { +// plugin.savePluginPreferences(); +// IWorkspace workspace = ResourcesPlugin.getWorkspace(); +// workspace.removeResourceChangeListener(JavaModelManager +// .getJavaModelManager().deltaState); +// workspace.removeSaveParticipant(plugin); // -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPVariable SET - updating affected project: ["+project.getElementName()+"] due to setting variables: "+ Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$ -// } -// -// project -// .setRawClasspath( -// project.getRawClasspath(), -// SetClasspathOperation.ReuseOutputLocation, -// null, // don't call beginTask on the monitor (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717) -// !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources -// (IClasspathEntry[]) affectedProjects.get(project), -// false, // updating - no validation -// false); // updating - no need to save -// } -// } -// }, -// monitor); -// } catch (CoreException e) { -// if (JavaModelManager.CP_RESOLVE_VERBOSE){ -// System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION: "+Util.toString(dbgVariableNames)); //$NON-NLS-1$ -// e.printStackTrace(); -// } -// if (e instanceof JavaModelException) { -// throw (JavaModelException)e; -// } else { -// throw new JavaModelException(e); -// } -// } -// } -//} -/* (non-Javadoc) - * Startup the JavaCore plug-in. - *

- * Registers the JavaModelManager as a resource changed listener and save participant. - * Starts the background indexing, and restore saved classpath variable values. - *

- * @throws Exception - * @see org.eclipse.core.runtime.Plugin#start(BundleContext) - */ -public static void start(final Plugin plugin, BundleContext context) throws Exception { -// super.start(context); - - final JavaModelManager manager = JavaModelManager.getJavaModelManager(); - try { - manager.configurePluginDebugOptions(); - - // request state folder creation (workaround 19885) - JavaCore.getPlugin().getStateLocation(); - - // retrieve variable values - //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener()); -// manager.loadVariablesAndContainers(); - - final IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.addResourceChangeListener( - manager.deltaState, - IResourceChangeEvent.PRE_BUILD - | IResourceChangeEvent.POST_BUILD - | IResourceChangeEvent.POST_CHANGE - | IResourceChangeEvent.PRE_DELETE - | IResourceChangeEvent.PRE_CLOSE); - -// startIndexing(); - - // process deltas since last activated in indexer thread so that indexes are up-to-date. - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658 - Job processSavedState = new Job(Util.bind("savedState.jobName")) { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - try { - // add save participant and process delta atomically - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937 - workspace.run( - new IWorkspaceRunnable() { - public void run(IProgressMonitor progress) throws CoreException { -// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this, manager); - ISavedState savedState = workspace.addSaveParticipant(plugin, manager); - if (savedState != null) { - // the event type coming from the saved state is always POST_AUTO_BUILD - // force it to be POST_CHANGE so that the delta processor can handle it - manager.deltaState.getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE; - savedState.processResourceChangeEvents(manager.deltaState); - } - } - }, - monitor); - } catch (CoreException e) { - return e.getStatus(); - } - return Status.OK_STATUS; - } - }; - processSavedState.setSystem(true); - processSavedState.setPriority(Job.SHORT); // process asap - processSavedState.schedule(); - } catch (RuntimeException e) { - manager.shutdown(); - throw e; - } -} -/* (non-Javadoc) - * Shutdown the JavaCore plug-in. - *

- * De-registers the JavaModelManager as a resource changed listener and save participant. - *

- * @see org.eclipse.core.runtime.Plugin#stop(BundleContext) - */ -public static void stop(Plugin plugin, BundleContext context) throws Exception { - try { - plugin.savePluginPreferences(); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaState); - workspace.removeSaveParticipant(plugin); - - JavaModelManager.getJavaModelManager().shutdown(); - } finally { - // ensure we call super.stop as the last thing -// super.stop(context); - } -} +// JavaModelManager.getJavaModelManager().shutdown(); +// } finally { +// // ensure we call super.stop as the last thing +// // super.stop(context); +// } +// } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java index fb94814..e3d1074 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java @@ -72,7 +72,7 @@ public interface ITerminalSymbols { final static int TokenNameLBRACKET = 132; final static int TokenNameRBRACKET = 133; final static int TokenNameCOMMA = 134; - final static int TokenNameStringLiteral = 136; + final static int TokenNameStringDoubleQuote = 136; final static int TokenNameIdentifier = 138; final static int TokenNameSEMICOLON = 140; final static int TokenNameMINUS_MINUS = 144; @@ -85,7 +85,7 @@ public interface ITerminalSymbols { final static int TokenNameIntegerLiteral = 151; final static int TokenNameDoubleLiteral = 152; final static int TokenNameStringInterpolated = 153; - final static int TokenNameStringConstant = 154; + final static int TokenNameStringSingleQuote = 154; final static int TokenNameLEFT_SHIFT = 155; final static int TokenNameRIGHT_SHIFT = 156; final static int TokenNameEQUAL_EQUAL_EQUAL = 157; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/dom/CompilationUnit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/dom/CompilationUnit.java index 9053d2b..f7a2352 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/dom/CompilationUnit.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/dom/CompilationUnit.java @@ -11,16 +11,6 @@ package net.sourceforge.phpdt.core.dom; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import net.sourceforge.phpdt.core.compiler.IProblem; -import net.sourceforge.phpdt.internal.compiler.parser.Scanner; -import org.eclipse.jface.text.IDocument; -import org.eclipse.text.edits.TextEdit; /** * Java compilation unit AST node type. This is the type of the root of an AST. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/jdom/DOMFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/jdom/DOMFactory.java index fdc8bbd..20ef495 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/jdom/DOMFactory.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/jdom/DOMFactory.java @@ -12,7 +12,7 @@ package net.sourceforge.phpdt.core.jdom; import net.sourceforge.phpdt.internal.core.jdom.DOMBuilder; import net.sourceforge.phpdt.internal.core.jdom.SimpleDOMBuilder; -import net.sourceforge.phpdt.internal.core.util.Util; + /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSElement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSElement.java new file mode 100644 index 0000000..11bbf94 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSElement.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.corext.refactoring.nls; + +import org.eclipse.jface.text.Region; +import org.eclipse.jface.util.Assert; + +public class NLSElement { + + public static final String TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$ + public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length(); + public static final String TAG_POSTFIX= "$"; //$NON-NLS-1$ + public static final int TAG_POSTFIX_LENGTH= TAG_POSTFIX.length(); + + /** The original string denoted by the position */ + private String fValue; + /** The position of the original string */ + private Region fPosition; + + /** Position of the // $NON_NLS_*$ tag */ + private Region fTagPosition; + + /** Index of the Element in an NLSLine */ + private int fIndex; + + /** + * Creates a new NLS element for the given string and position. + */ + public NLSElement(String value, int start, int length, int index) { + fValue= value; + fIndex= index; + Assert.isNotNull(fValue); + fPosition= new Region(start, length); + } + + /** + * Returns the position of the string to be NLSed. + * @return Returns the position of the string to be NLSed + */ + public Region getPosition() { + return fPosition; + } + + /** + * Returns the actual string value. + * @return the actual string value + */ + public String getValue() { + return fValue; + } + + /** + * Sets the actual string value. + */ + public void setValue(String value) { + fValue= value; + } + + /** + * Sets the tag position if one is associated with the NLS element. + */ + public void setTagPosition(int start, int length) { + fTagPosition= new Region(start, length); + } + + /** + * Returns the tag position for this element. The method can return null. + * In this case no tag has been found for this NLS element. + */ + public Region getTagPosition() { + return fTagPosition; + } + + /** + * Returns true if the NLS element has an assicated $NON-NLS-*$ tag. + * Otherwise false is returned. + */ + public boolean hasTag() { + return fTagPosition != null && fTagPosition.getLength() > 0; + } + + public static String createTagText(int index) { + return TAG_PREFIX + index + TAG_POSTFIX; + } + + public String getTagText() { + return TAG_PREFIX + (fIndex + 1) + TAG_POSTFIX; + } + + /* (Non-Javadoc) + * Method declared in Object. + * only for debugging + */ + public String toString() { + return fPosition + ": " + fValue + " Tag position: " + //$NON-NLS-2$ //$NON-NLS-1$ + (hasTag() ? fTagPosition.toString() : "no tag found"); //$NON-NLS-1$ + } +} + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSLine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSLine.java new file mode 100644 index 0000000..92e1df2 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/corext/refactoring/nls/NLSLine.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.corext.refactoring.nls; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.jface.util.Assert; + +public class NLSLine { + + private int fLineNumber; + private List fElements; + + public NLSLine(int lineNumber) { + fLineNumber= lineNumber; + Assert.isTrue(fLineNumber >= 0); + fElements= new ArrayList(); + } + + public int getLineNumber() { + return fLineNumber; + } + + /** + * Adds a NLS element to this line. + */ + public void add(NLSElement element) { + Assert.isNotNull(element); + fElements.add(element); + } + + public NLSElement[] getElements() { + return (NLSElement[]) fElements.toArray(new NLSElement[fElements.size()]); + } + + public NLSElement get(int index) { + return (NLSElement)fElements.get(index); + } + + public boolean exists(int index) { + return index >= 0 && index < fElements.size(); + } + + public int size(){ + return fElements.size(); + } + + /* non javaDoc + * only for debugging + * @see Object#toString() + */ + public String toString() { + StringBuffer result= new StringBuffer(); + result.append("Line: " + fLineNumber + "\n"); //$NON-NLS-2$ //$NON-NLS-1$ + for (Iterator iter= fElements.iterator(); iter.hasNext(); ) { + result.append("\t"); //$NON-NLS-1$ + result.append(iter.next().toString()); + result.append("\n"); //$NON-NLS-1$ + } + return result.toString(); + } +} + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsImages.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsImages.java index f83989e..24abd4b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsImages.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsImages.java @@ -20,6 +20,7 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin; /** * The images provided by the external tools plugin. @@ -42,14 +43,18 @@ public class ExternalToolsImages { /* Declare Common paths */ private static URL ICON_BASE_URL= null; +// static { +// String pathSuffix = "icons/externaltools/full/"; //$NON-NLS-1$ +// +// try { +// ICON_BASE_URL= new URL(PHPeclipsePlugin.getDefault().getDescriptor().getInstallURL(), pathSuffix); +// } catch (MalformedURLException e) { +// // do nothing +// } +// } static { - String pathSuffix = "icons/externaltools/full/"; //$NON-NLS-1$ - - try { - ICON_BASE_URL= new URL(PHPeclipsePlugin.getDefault().getDescriptor().getInstallURL(), pathSuffix); - } catch (MalformedURLException e) { - // do nothing - } + String pathSuffix = "icons/full/"; //$NON-NLS-1$ + ICON_BASE_URL= ExternalToolsPlugin.getDefault().getBundle().getEntry(pathSuffix); } // Use IPath and toOSString to build the names to ensure they have the slashes correct diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsPlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsPlugin.java index a2bc1c0..b4f3b26 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsPlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/model/ExternalToolsPlugin.java @@ -28,6 +28,7 @@ import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.IWorkbenchWindow; +import org.osgi.framework.Bundle; /** * External tools plug-in class @@ -129,7 +130,8 @@ public final class ExternalToolsPlugin { // extends AbstractUIPlugin { */ public ImageDescriptor getImageDescriptor(String path) { try { - URL installURL = PHPeclipsePlugin.getDefault().getDescriptor().getInstallURL(); + Bundle bundle= PHPeclipsePlugin.getDefault().getBundle(); + URL installURL = bundle.getEntry("/"); //$NON-NLS-1$ URL url = new URL(installURL, path); return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/registry/ExternalToolVariableRegistry.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/registry/ExternalToolVariableRegistry.java index a13d06f..978883d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/registry/ExternalToolVariableRegistry.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/registry/ExternalToolVariableRegistry.java @@ -17,7 +17,7 @@ import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IPluginRegistry; +import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; /** @@ -94,7 +94,8 @@ public abstract class ExternalToolVariableRegistry { */ private void loadVariables() { variables = new HashMap(); - IPluginRegistry registry = Platform.getPluginRegistry(); + IExtensionRegistry registry= Platform.getExtensionRegistry(); +// IPluginRegistry registry = Platform.getPluginRegistry(); IExtensionPoint point = registry.getExtensionPoint(IExternalToolConstants.PLUGIN_ID, extensionPointId); if (point != null) { IExtension[] extensions = point.getExtensions(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/Compiler.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/Compiler.java index cbfdcfc..45967fc 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/Compiler.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/Compiler.java @@ -12,6 +12,7 @@ package net.sourceforge.phpdt.internal.compiler; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Map; + import net.sourceforge.phpdt.core.compiler.IProblem; import net.sourceforge.phpdt.internal.compiler.env.IBinaryType; import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/codegen/Label.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/codegen/Label.java index 1179c83..5f8ee65 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/codegen/Label.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/codegen/Label.java @@ -10,8 +10,6 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.codegen; -import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding; -import net.sourceforge.phpdt.internal.compiler.problem.AbortMethod; /** * This type is a port of smalltalks JavaLabel diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/BlockScope.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/BlockScope.java index 35c9d53..429d073 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/BlockScope.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/BlockScope.java @@ -11,11 +11,8 @@ package net.sourceforge.phpdt.internal.compiler.lookup; import net.sourceforge.phpdt.core.compiler.CharOperation; -import net.sourceforge.phpdt.internal.compiler.impl.Constant; import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration; -import net.sourceforge.phpeclipse.internal.compiler.ast.Argument; -import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode; import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/CompilationUnitScope.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/CompilationUnitScope.java index c6dcbb6..8825732 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/CompilationUnitScope.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/CompilationUnitScope.java @@ -19,7 +19,6 @@ import net.sourceforge.phpdt.internal.compiler.util.HashtableOfType; import net.sourceforge.phpdt.internal.compiler.util.ObjectVector; import net.sourceforge.phpdt.internal.compiler.util.SimpleNameVector; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; -import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference; import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration; public class CompilationUnitScope extends Scope { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/MethodScope.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/MethodScope.java index c454db2..4fe05b4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/MethodScope.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/MethodScope.java @@ -15,7 +15,6 @@ import net.sourceforge.phpdt.internal.compiler.flow.UnconditionalFlowInfo; import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext; import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration; -import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode; import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedNameReference; import net.sourceforge.phpeclipse.internal.compiler.ast.SingleNameReference; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index 2ab8088..e99fb28 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -2053,8 +2053,8 @@ public class Parser //extends PHPParserSuperclass break; case TokenNameIntegerLiteral : case TokenNameDoubleLiteral : - case TokenNameStringLiteral : - case TokenNameStringConstant : + case TokenNameStringDoubleQuote : + case TokenNameStringSingleQuote : case TokenNameStringInterpolated : case TokenNameFILE : case TokenNameLINE : @@ -3189,10 +3189,10 @@ public class Parser //extends PHPParserSuperclass case TokenNameDoubleLiteral : getNextToken(); return true; - case TokenNameStringLiteral : + case TokenNameStringDoubleQuote : getNextToken(); return true; - case TokenNameStringConstant : + case TokenNameStringSingleQuote : getNextToken(); return true; case TokenNameStringInterpolated : diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/RecoveredElement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/RecoveredElement.java index 38ba5e5..8290a0c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/RecoveredElement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/RecoveredElement.java @@ -12,7 +12,6 @@ package net.sourceforge.phpdt.internal.compiler.parser; import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode; import net.sourceforge.phpeclipse.internal.compiler.ast.Block; -import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.Statement; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java index af7f65a..c1098d5 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java @@ -1197,7 +1197,7 @@ public class Scanner implements IScanner, ITerminalSymbols { case '\'' : if (tokenizeStrings) { consumeStringConstant(); - return TokenNameStringConstant; + return TokenNameStringSingleQuote; } return TokenNameEncapsedString1; case '"' : @@ -1462,11 +1462,11 @@ public class Scanner implements IScanner, ITerminalSymbols { return TokenNameAT; case '\'' : consumeStringConstant(); - return TokenNameStringConstant; + return TokenNameStringSingleQuote; case '"' : if (tokenizeStrings) { consumeStringLiteral(); - return TokenNameStringLiteral; + return TokenNameStringDoubleQuote; } return TokenNameEncapsedString2; case '`' : @@ -3726,9 +3726,9 @@ public class Scanner implements IScanner, ITerminalSymbols { return "Integer(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ case TokenNameDoubleLiteral : return "Double(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - case TokenNameStringLiteral : + case TokenNameStringDoubleQuote : return "StringLiteral(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - case TokenNameStringConstant : + case TokenNameStringSingleQuote : return "StringConstant(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ case TokenNameStringInterpolated : return "StringInterpolated(" + new String(getCurrentTokenSource()) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java index 9df2dae..c66a8c9 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java @@ -24,7 +24,6 @@ import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding; import net.sourceforge.phpdt.internal.compiler.lookup.MethodBinding; import net.sourceforge.phpdt.internal.compiler.lookup.ProblemMethodBinding; import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons; -import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReferenceBinding; import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding; import net.sourceforge.phpdt.internal.compiler.lookup.SourceTypeBinding; import net.sourceforge.phpdt.internal.compiler.lookup.SyntheticArgumentBinding; @@ -54,7 +53,6 @@ import net.sourceforge.phpeclipse.internal.compiler.ast.ExplicitConstructorCall; import net.sourceforge.phpeclipse.internal.compiler.ast.Expression; import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.FieldReference; -import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference; import net.sourceforge.phpeclipse.internal.compiler.ast.InstanceOfExpression; import net.sourceforge.phpeclipse.internal.compiler.ast.IntLiteral; import net.sourceforge.phpeclipse.internal.compiler.ast.Literal; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BecomeWorkingCopyOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BecomeWorkingCopyOperation.java index 798d0d3..a3150db 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BecomeWorkingCopyOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BecomeWorkingCopyOperation.java @@ -10,8 +10,9 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import net.sourceforge.phpdt.core.*; import net.sourceforge.phpdt.core.IJavaElement; +import net.sourceforge.phpdt.core.IJavaElementDelta; +import net.sourceforge.phpdt.core.IProblemRequestor; import net.sourceforge.phpdt.core.JavaModelException; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ClasspathEntry.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ClasspathEntry.java index d634382..8237f92 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ClasspathEntry.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ClasspathEntry.java @@ -23,7 +23,6 @@ import net.sourceforge.phpdt.internal.corext.Assert; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import net.sourceforge.phpdt.internal.core.XMLWriter; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CommitWorkingCopyOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CommitWorkingCopyOperation.java index b22eede..3c1285c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CommitWorkingCopyOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CommitWorkingCopyOperation.java @@ -19,6 +19,7 @@ import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModelStatus; import net.sourceforge.phpdt.core.IJavaModelStatusConstants; import net.sourceforge.phpdt.core.JavaModelException; +import net.sourceforge.phpdt.internal.core.util.Util; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -26,11 +27,6 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.jobs.ISchedulingRule; -import net.sourceforge.phpdt.internal.core.CompilationUnit; -import net.sourceforge.phpdt.internal.core.JavaElementDeltaBuilder; -import net.sourceforge.phpdt.internal.core.PackageFragmentRoot; -import net.sourceforge.phpdt.internal.core.util.Util; - /** * Commits the contents of a working copy compilation diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java index 72e516f..2fc911b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java @@ -17,7 +17,6 @@ import java.util.Map; import net.sourceforge.phpdt.core.IBuffer; import net.sourceforge.phpdt.core.IBufferFactory; import net.sourceforge.phpdt.core.ICompilationUnit; -import net.sourceforge.phpdt.core.IImportContainer; import net.sourceforge.phpdt.core.IImportDeclaration; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModelStatusConstants; @@ -45,7 +44,7 @@ import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions; import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory; import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; -import net.sourceforge.phpdt.core.*; + import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java index b89c279..cd10093 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitProblemFinder.java @@ -41,7 +41,6 @@ import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.core.runtime.IProgressMonitor; -import net.sourceforge.phpdt.internal.core.JavaModelManager; /** * Responsible for resolving types inside a compilation unit being reconciled, diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitStructureRequestor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitStructureRequestor.java index 2e24f0c..8b9fcb0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitStructureRequestor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnitStructureRequestor.java @@ -16,7 +16,6 @@ import java.util.Stack; import net.sourceforge.phpdt.core.Flags; import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IField; -import net.sourceforge.phpdt.core.IImportContainer; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IMethod; import net.sourceforge.phpdt.core.IType; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CopyResourceElementsOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CopyResourceElementsOperation.java index ddf268c..19b0fe4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CopyResourceElementsOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CopyResourceElementsOperation.java @@ -28,13 +28,12 @@ import net.sourceforge.phpdt.core.IJavaProject; import net.sourceforge.phpdt.core.IPackageFragment; import net.sourceforge.phpdt.core.IPackageFragmentRoot; import net.sourceforge.phpdt.core.IType; -import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.jdom.DOMException; import net.sourceforge.phpdt.core.jdom.DOMFactory; import net.sourceforge.phpdt.core.jdom.IDOMCompilationUnit; import net.sourceforge.phpdt.core.jdom.IDOMNode; -import net.sourceforge.phpdt.core.jdom.IDOMPackage; import net.sourceforge.phpdt.internal.core.util.Util; import org.eclipse.core.resources.IContainer; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreateElementInCUOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreateElementInCUOperation.java index 9793413..28f0900 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreateElementInCUOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreateElementInCUOperation.java @@ -10,10 +10,6 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.runtime.jobs.ISchedulingRule; - import net.sourceforge.phpdt.core.IBuffer; import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IJavaElement; @@ -26,6 +22,10 @@ import net.sourceforge.phpdt.core.jdom.IDOMNode; import net.sourceforge.phpdt.internal.core.jdom.DOMNode; import net.sourceforge.phpdt.internal.core.util.Util; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.jobs.ISchedulingRule; + /** *

This abstract class implements behavior common to CreateElementInCUOperations. * To create a compilation unit, or an element contained in a compilation unit, the diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreatePackageDeclarationOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreatePackageDeclarationOperation.java index 9a55512..9270628 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreatePackageDeclarationOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CreatePackageDeclarationOperation.java @@ -13,7 +13,6 @@ package net.sourceforge.phpdt.internal.core; import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModelStatus; -import net.sourceforge.phpdt.core.IJavaModelStatusConstants; import net.sourceforge.phpdt.core.IPackageDeclaration; import net.sourceforge.phpdt.core.IType; import net.sourceforge.phpdt.core.JavaModelException; @@ -23,8 +22,6 @@ import net.sourceforge.phpdt.core.jdom.IDOMPackage; import net.sourceforge.phpdt.internal.core.jdom.DOMNode; import net.sourceforge.phpdt.internal.core.util.Util; -import org.eclipse.core.runtime.IStatus; - /** *

This operation adds/replaces a package declaration in an existing compilation unit. * If the compilation unit already includes the specified package declaration, diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessingState.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessingState.java index 23c4a00..015593b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessingState.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessingState.java @@ -10,45 +10,28 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; -import java.util.Map; import java.util.Set; import net.sourceforge.phpdt.core.IClasspathEntry; import net.sourceforge.phpdt.core.IElementChangedListener; -import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModel; import net.sourceforge.phpdt.core.IJavaProject; -import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.internal.core.util.Util; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; -import net.sourceforge.phpdt.internal.core.DeltaProcessor; -import net.sourceforge.phpdt.internal.core.JavaModelManager; - -import net.sourceforge.phpdt.core.ElementChangedEvent; -import net.sourceforge.phpdt.core.IJavaElementDelta; -import net.sourceforge.phpdt.internal.core.builder.PHPBuilder; /** * Keep the global states used during Java element delta processing. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessor.java index ae314b3..a4b7bfe 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/DeltaProcessor.java @@ -27,6 +27,7 @@ import net.sourceforge.phpdt.core.IJavaModel; import net.sourceforge.phpdt.core.IJavaProject; import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.core.JavaModelException; +import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil; import net.sourceforge.phpeclipse.PHPeclipsePlugin; @@ -44,12 +45,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.QualifiedName; -import net.sourceforge.phpdt.internal.core.builder.PHPBuilder; - -import net.sourceforge.phpdt.internal.core.DeltaProcessingState; -import net.sourceforge.phpdt.internal.core.JavaElementDelta; -import net.sourceforge.phpdt.internal.core.JavaModelManager; -import net.sourceforge.phpdt.internal.core.util.Util; /** @@ -1797,7 +1792,7 @@ public class DeltaProcessor implements IResourceChangeListener { } return; - case IResourceChangeEvent.PRE_AUTO_BUILD : + case IResourceChangeEvent.PRE_BUILD : // TODO jsurfer temp-del // if(isAffectedBy(delta)) { // avoid populating for SYNC or MARKER deltas // this.checkProjectsBeingAddedOrRemoved(delta); @@ -1818,7 +1813,7 @@ public class DeltaProcessor implements IResourceChangeListener { this.manager.fire(null, ElementChangedEvent.PRE_AUTO_BUILD); break; - case IResourceChangeEvent.POST_AUTO_BUILD : + case IResourceChangeEvent.POST_BUILD : // TODO jsurfer temp-del // JavaBuilder.finishedBuilding(event); break; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportContainer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportContainer.java index bf8495a..54089a2 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportContainer.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportContainer.java @@ -10,10 +10,10 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import net.sourceforge.phpdt.core.*; import net.sourceforge.phpdt.core.IImportContainer; import net.sourceforge.phpdt.core.IImportDeclaration; import net.sourceforge.phpdt.core.IJavaElement; +import net.sourceforge.phpdt.core.IParent; import net.sourceforge.phpdt.core.ISourceRange; import net.sourceforge.phpdt.core.ISourceReference; import net.sourceforge.phpdt.core.JavaModelException; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportDeclaration.java index ff360b3..0bff672 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ImportDeclaration.java @@ -10,10 +10,10 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import net.sourceforge.phpdt.core.*; import net.sourceforge.phpdt.core.IImportDeclaration; +import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.JavaModelException; -import net.sourceforge.phpdt.core.jdom.*; +import net.sourceforge.phpdt.core.jdom.IDOMNode; /** * Handle for an import declaration. Info object is a ImportDeclarationElementInfo. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java index afda75c..6eb79ee 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElement.java @@ -27,6 +27,7 @@ import net.sourceforge.phpdt.core.ISourceReference; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.jdom.IDOMCompilationUnit; import net.sourceforge.phpdt.core.jdom.IDOMNode; +import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpdt.internal.corext.Assert; import org.eclipse.core.resources.IResource; @@ -39,10 +40,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.jobs.ISchedulingRule; -import net.sourceforge.phpdt.internal.core.JavaElementInfo; - -import net.sourceforge.phpdt.internal.core.JavaModelManager; -import net.sourceforge.phpdt.internal.core.util.Util; /** * Root of Java element handle hierarchy. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElementDelta.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElementDelta.java index 166e4d3..9cbedb3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElementDelta.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaElementDelta.java @@ -14,10 +14,8 @@ import java.util.ArrayList; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaElementDelta; -import net.sourceforge.phpdt.core.IJavaProject; import org.eclipse.core.resources.IResourceDelta; -import net.sourceforge.phpdt.internal.core.SimpleDelta; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelInfo.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelInfo.java index b572012..958a178 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelInfo.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelInfo.java @@ -10,6 +10,8 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; +import net.sourceforge.phpdt.core.IJavaModel; + import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java index e87fef2..7a62757 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java @@ -59,7 +59,6 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.IStatus; @@ -69,7 +68,6 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Status; -import net.sourceforge.phpdt.internal.core.BufferManager; import net.sourceforge.phpdt.internal.core.DefaultWorkingCopyOwner; @@ -1201,8 +1199,7 @@ public class JavaModelManager implements ISaveParticipant { */ private File getSerializationFile(IProject project) { if (!project.exists()) return null; - IPluginDescriptor descr= JavaCore.getJavaCore().getDescriptor(); - IPath workingLocation= project.getPluginWorkingLocation(descr); + IPath workingLocation = project.getWorkingLocation(JavaCore.PLUGIN_ID); return workingLocation.append("state.dat").toFile(); //$NON-NLS-1$ } /* diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelOperation.java index a780950..7a01755 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelOperation.java @@ -41,8 +41,6 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; -import net.sourceforge.phpdt.internal.core.DeltaProcessor; -import net.sourceforge.phpdt.internal.core.JavaModelManager; /** @@ -152,14 +150,14 @@ public abstract class JavaModelOperation implements IWorkspaceRunnable, IProgres protected JavaModelOperation(IJavaElement[] elementsToProcess, IJavaElement[] parentElements, boolean force) { fElementsToProcess = elementsToProcess; fParentElements= parentElements; - force= force; + this.force= force; } /** * A common constructor for all Java Model operations. */ protected JavaModelOperation(IJavaElement[] elements, boolean force) { fElementsToProcess = elements; - force= force; + this.force= force; } /** @@ -173,7 +171,7 @@ public abstract class JavaModelOperation implements IWorkspaceRunnable, IProgres */ protected JavaModelOperation(IJavaElement element, boolean force) { fElementsToProcess = new IJavaElement[]{element}; - force= force; + this.force= force; } /* diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProject.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProject.java index 978cb1b..ff47e67 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProject.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProject.java @@ -54,15 +54,6 @@ import net.sourceforge.phpdt.internal.corext.Assert; import net.sourceforge.phpeclipse.LoadPathEntry; import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -80,10 +71,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.QualifiedName; - -import net.sourceforge.phpdt.internal.core.ClasspathEntry; -import net.sourceforge.phpdt.internal.core.XMLWriter; -import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -2088,7 +2075,9 @@ public class JavaProject return this.isOnClasspath(path); } - + private IPath getPluginWorkingLocation() { + return this.project.getWorkingLocation(JavaCore.PLUGIN_ID); + } /* * load preferences from a shareable format (VCM-wise) */ @@ -2097,7 +2086,7 @@ public class JavaProject Preferences preferences = new Preferences(); // File prefFile = getProject().getLocation().append(PREF_FILENAME).toFile(); - IPath projectMetaLocation = getProject().getPluginWorkingLocation(JavaCore.getPlugin().getDescriptor()); + IPath projectMetaLocation = getPluginWorkingLocation(); if (projectMetaLocation != null) { File prefFile = projectMetaLocation.append(PREF_FILENAME).toFile(); if (prefFile.exists()) { // load preferences from file @@ -2289,13 +2278,13 @@ public class JavaProject } } + /** * Save project custom preferences to shareable file (.jprefs) */ private void savePreferences(Preferences preferences) { - IProject project = getProject(); - if (!JavaProject.hasJavaNature(project)) return; // ignore + if (!JavaProject.hasJavaNature(this.project)) return; // ignore if (preferences == null || (!preferences.needsSaving() && preferences.propertyNames().length != 0)) { // nothing to save @@ -2305,8 +2294,8 @@ public class JavaProject // preferences need to be saved // the preferences file is located in the plug-in's state area // at a well-known name (.jprefs) -// File prefFile = getProject().getLocation().append(PREF_FILENAME).toFile(); - File prefFile = project.getPluginWorkingLocation(JavaCore.getPlugin().getDescriptor()).append(PREF_FILENAME).toFile(); +// File prefFile = this.project.getLocation().append(PREF_FILENAME).toFile(); + File prefFile = getPluginWorkingLocation().append(PREF_FILENAME).toFile(); if (preferences.propertyNames().length == 0) { // there are no preference settings // rather than write an empty file, just delete any existing file @@ -2333,7 +2322,6 @@ public class JavaProject } } } - /** * Update the Java command in the build spec (replace existing one if present, * add one first if none). diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProjectElementInfo.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProjectElementInfo.java index 07fbf2f..54c0ca4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProjectElementInfo.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaProjectElementInfo.java @@ -11,6 +11,7 @@ package net.sourceforge.phpdt.internal.core; import net.sourceforge.phpdt.core.IClasspathEntry; +import net.sourceforge.phpdt.core.IJavaProject; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.internal.core.util.Util; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Member.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Member.java index e459a67..eb6d570 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Member.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Member.java @@ -12,8 +12,6 @@ package net.sourceforge.phpdt.internal.core; import java.util.ArrayList; -import net.sourceforge.phpdt.internal.core.JavaElement; - import net.sourceforge.phpdt.core.Flags; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IMember; @@ -24,8 +22,6 @@ import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.Signature; import net.sourceforge.phpdt.core.jdom.IDOMNode; -import com.sun.corba.se.internal.core.Constant; - /** * @see IMember diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MemberElementInfo.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MemberElementInfo.java index 33d7f16..5c7e7f9 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MemberElementInfo.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MemberElementInfo.java @@ -10,6 +10,8 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; +import net.sourceforge.phpdt.internal.compiler.env.IConstants; + /** *Element info for IMember elements. */ diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MultiOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MultiOperation.java index 5fe4c7c..a5b4f45 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MultiOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/MultiOperation.java @@ -20,8 +20,6 @@ import net.sourceforge.phpdt.core.IJavaModelStatusConstants; import net.sourceforge.phpdt.core.IPackageFragment; import net.sourceforge.phpdt.core.JavaModelException; -import org.eclipse.core.runtime.IStatus; - /** * This class is used to perform operations on multiple IJavaElement. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/NameLookup.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/NameLookup.java index 5bdf614..66ec3f7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/NameLookup.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/NameLookup.java @@ -16,15 +16,15 @@ import java.util.HashMap; import java.util.Map; import net.sourceforge.phpdt.core.IClasspathEntry; +import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaProject; import net.sourceforge.phpdt.core.IPackageFragment; import net.sourceforge.phpdt.core.IPackageFragmentRoot; import net.sourceforge.phpdt.core.IType; import net.sourceforge.phpdt.core.IWorkingCopy; -import net.sourceforge.phpdt.core.JavaModelException; -import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.internal.core.util.PerThreadObject; import net.sourceforge.phpdt.internal.core.util.Util; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java index 1fb75fb..4fbafee 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java @@ -24,18 +24,14 @@ import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModelStatusConstants; import net.sourceforge.phpdt.core.IOpenable; import net.sourceforge.phpdt.core.IPackageFragmentRoot; +import net.sourceforge.phpdt.core.IParent; import net.sourceforge.phpdt.core.JavaModelException; -import net.sourceforge.phpdt.internal.codeassist.ISearchableNameEnvironment; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IProgressMonitor; -import net.sourceforge.phpdt.internal.core.JavaElement; - -import net.sourceforge.phpdt.internal.core.JavaModelManager; -import net.sourceforge.phpdt.internal.core.OpenableElementInfo; /** * Abstract class for implementations of java elements which are IOpenable. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageDeclaration.java index 2feda7a..138b007 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageDeclaration.java @@ -11,9 +11,6 @@ package net.sourceforge.phpdt.internal.core; import net.sourceforge.phpdt.core.IJavaElement; -import net.sourceforge.phpdt.internal.core.CompilationUnit; - -import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IPackageDeclaration; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.jdom.IDOMNode; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragment.java index 760e09e..8820a41 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragment.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragment.java @@ -291,7 +291,8 @@ public IPath getPath() { if (root.isArchive()) { return root.getPath(); } else { - return root.getPath().append(this.getElementName().replace('.', '/')); +// return root.getPath().append(this.getElementName().replace('.', '/')); + return root.getPath().append(this.getElementName()); } } /** @@ -306,7 +307,8 @@ public IResource getResource() { if (elementName.length() == 0) { return root.getResource(); } else { - return ((IContainer)root.getResource()).getFolder(new Path(this.getElementName().replace('.', '/'))); +// return ((IContainer)root.getResource()).getFolder(new Path(this.getElementName().replace('.', '/'))); + return ((IContainer)root.getResource()).getFolder(new Path(this.getElementName())); } } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragmentRoot.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragmentRoot.java index f73c8bd..07263dd 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragmentRoot.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/PackageFragmentRoot.java @@ -14,11 +14,11 @@ import java.util.ArrayList; import java.util.Map; import net.sourceforge.phpdt.core.IJavaElement; -import net.sourceforge.phpdt.core.IJavaProject; +import net.sourceforge.phpdt.core.IJavaModelStatusConstants; import net.sourceforge.phpdt.core.IPackageFragment; import net.sourceforge.phpdt.core.IPackageFragmentRoot; -import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.compiler.CharOperation; import net.sourceforge.phpdt.internal.core.util.Util; @@ -30,13 +30,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.QualifiedName; -import net.sourceforge.phpdt.core.IClasspathEntry; -import net.sourceforge.phpdt.core.IJavaModelStatusConstants; -import net.sourceforge.phpdt.internal.core.Openable; -import net.sourceforge.phpdt.internal.core.OpenableElementInfo; - -import net.sourceforge.phpdt.internal.core.JavaProject; -import net.sourceforge.phpdt.internal.core.PackageFragmentRootInfo; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ReconcileWorkingCopyOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ReconcileWorkingCopyOperation.java index cf966f9..126addc 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ReconcileWorkingCopyOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/ReconcileWorkingCopyOperation.java @@ -10,8 +10,6 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import java.util.Map; - import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModelStatus; import net.sourceforge.phpdt.core.IJavaModelStatusConstants; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java index 29c98d5..b57a644 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java @@ -10,12 +10,9 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import java.io.File; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Map; import net.sourceforge.phpdt.core.IClasspathEntry; import net.sourceforge.phpdt.core.IJavaElement; @@ -23,24 +20,18 @@ import net.sourceforge.phpdt.core.IJavaElementDelta; import net.sourceforge.phpdt.core.IJavaModel; import net.sourceforge.phpdt.core.IJavaModelStatus; import net.sourceforge.phpdt.core.IJavaProject; -import net.sourceforge.phpdt.core.IPackageFragment; import net.sourceforge.phpdt.core.IPackageFragmentRoot; import net.sourceforge.phpdt.core.JavaModelException; -import net.sourceforge.phpdt.internal.compiler.util.ObjectVector; import net.sourceforge.phpdt.internal.core.util.Util; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import net.sourceforge.phpdt.internal.core.JavaModelManager; -import net.sourceforge.phpdt.internal.core.JavaProject; /** * This operation sets an IJavaProject's classpath. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceField.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceField.java index b8ea749..1854e1c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceField.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceField.java @@ -10,10 +10,8 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import net.sourceforge.phpdt.core.IJavaElement; -import net.sourceforge.phpdt.internal.core.JavaElement; - import net.sourceforge.phpdt.core.IField; +import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.Signature; import net.sourceforge.phpdt.core.jdom.IDOMNode; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceMethod.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceMethod.java index e4ce741..c1e4ab7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceMethod.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceMethod.java @@ -10,14 +10,9 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import net.sourceforge.phpdt.internal.core.JavaElement; - -import net.sourceforge.phpdt.core.IJavaElement; - import net.sourceforge.phpdt.core.Flags; -import net.sourceforge.phpdt.core.ICompilationUnit; +import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IMethod; -import net.sourceforge.phpdt.core.IType; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.Signature; import net.sourceforge.phpdt.core.jdom.IDOMMethod; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceRefElement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceRefElement.java index e359e6b..9db0a5a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceRefElement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceRefElement.java @@ -16,7 +16,9 @@ import net.sourceforge.phpdt.core.IBuffer; import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaProject; +import net.sourceforge.phpdt.core.IMember; import net.sourceforge.phpdt.core.IOpenable; +import net.sourceforge.phpdt.core.ISourceManipulation; import net.sourceforge.phpdt.core.ISourceRange; import net.sourceforge.phpdt.core.ISourceReference; import net.sourceforge.phpdt.core.JavaModelException; @@ -24,11 +26,6 @@ import net.sourceforge.phpdt.core.JavaModelException; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import net.sourceforge.phpdt.internal.core.JavaElementInfo; -import net.sourceforge.phpdt.internal.core.JavaModelManager; -import net.sourceforge.phpdt.internal.core.Openable; - -import net.sourceforge.phpdt.internal.core.JavaElement; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceType.java index 1655530..8a9c259 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceType.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SourceType.java @@ -12,19 +12,16 @@ package net.sourceforge.phpdt.internal.core; import java.util.ArrayList; -import net.sourceforge.phpdt.internal.core.SourceTypeElementInfo; - -import net.sourceforge.phpdt.internal.core.JavaElement; -import net.sourceforge.phpdt.internal.core.util.Util; - import net.sourceforge.phpdt.core.IField; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IMember; import net.sourceforge.phpdt.core.IMethod; import net.sourceforge.phpdt.core.IPackageFragment; +import net.sourceforge.phpdt.core.IParent; import net.sourceforge.phpdt.core.IType; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.jdom.IDOMNode; +import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpdt.internal.corext.Assert; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java index cf6b24b..f760a22 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java @@ -14,11 +14,11 @@ import java.util.ArrayList; import java.util.Locale; import net.sourceforge.phpdt.core.IJavaModelMarker; -import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.compiler.IProblem; -import net.sourceforge.phpdt.internal.compiler.Compiler; import net.sourceforge.phpdt.internal.compiler.CompilationResult; +import net.sourceforge.phpdt.internal.compiler.Compiler; import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies; import net.sourceforge.phpdt.internal.compiler.ICompilerRequestor; import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/BatchImageBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/BatchImageBuilder.java index aa0de9f..aad863d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/BatchImageBuilder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/BatchImageBuilder.java @@ -13,10 +13,7 @@ package net.sourceforge.phpdt.internal.core.builder; import java.util.ArrayList; import net.sourceforge.phpdt.core.JavaCore; -import net.sourceforge.phpdt.internal.core.JavaModelManager; import net.sourceforge.phpdt.internal.core.util.Util; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -25,8 +22,6 @@ import org.eclipse.core.resources.IResourceProxy; import org.eclipse.core.resources.IResourceProxyVisitor; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import net.sourceforge.phpdt.internal.core.builder.PHPBuilder; -import net.sourceforge.phpdt.internal.core.builder.SourceFile; public class BatchImageBuilder extends AbstractImageBuilder { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathDirectory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathDirectory.java index d27f8c4..901bcd3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathDirectory.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathDirectory.java @@ -12,7 +12,6 @@ package net.sourceforge.phpdt.internal.core.builder; import net.sourceforge.phpdt.internal.compiler.env.NameEnvironmentAnswer; import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable; -import net.sourceforge.phpdt.internal.core.util.Util; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathLocation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathLocation.java index c9bbdad..993422d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathLocation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ClasspathLocation.java @@ -13,7 +13,6 @@ package net.sourceforge.phpdt.internal.core.builder; import net.sourceforge.phpdt.internal.compiler.env.NameEnvironmentAnswer; import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; public abstract class ClasspathLocation { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java index d752767..dc13acf 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java @@ -15,9 +15,6 @@ import net.sourceforge.phpdt.core.compiler.IProblem; import net.sourceforge.phpdt.internal.compiler.CompilationResult; import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable; import net.sourceforge.phpdt.internal.core.util.Util; -import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -394,7 +391,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder { case IResourceDelta.ADDED : IPath addedPackagePath = resource.getFullPath() .removeFirstSegments(segmentCount); - createFolder(addedPackagePath, md.binaryFolder); // ensure package + // createFolder(addedPackagePath, md.binaryFolder); // ensure package // exists in the // output folder // add dependents even when the package thinks it exists to be on @@ -522,41 +519,41 @@ public class IncrementalImageBuilder extends AbstractImageBuilder { // copy all other resource deltas to the output folder IPath resourcePath = resource.getFullPath().removeFirstSegments( segmentCount); - IResource outputFile = md.binaryFolder.getFile(resourcePath); +// IResource outputFile = md.binaryFolder.getFile(resourcePath); switch (sourceDelta.getKind()) { case IResourceDelta.ADDED : - if (outputFile.exists()) { - if (PHPBuilder.DEBUG) - System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$ - outputFile.delete(IResource.FORCE, null); - } +// if (outputFile.exists()) { +// if (PHPBuilder.DEBUG) +// System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$ +// outputFile.delete(IResource.FORCE, null); +// } if (PHPBuilder.DEBUG) System.out.println("Copying added file " + resourcePath); //$NON-NLS-1$ - createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure +// createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure // package // exists // in // the // output // folder - resource.copy(outputFile.getFullPath(), IResource.FORCE, null); - outputFile.setDerived(true); +// resource.copy(outputFile.getFullPath(), IResource.FORCE, null); +// outputFile.setDerived(true); return; case IResourceDelta.REMOVED : - if (outputFile.exists()) { - if (PHPBuilder.DEBUG) - System.out.println("Deleting removed file " + resourcePath); //$NON-NLS-1$ - outputFile.delete(IResource.FORCE, null); - } +// if (outputFile.exists()) { +// if (PHPBuilder.DEBUG) +// System.out.println("Deleting removed file " + resourcePath); //$NON-NLS-1$ +// outputFile.delete(IResource.FORCE, null); +// } return; case IResourceDelta.CHANGED : if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0) return; // skip it since it really isn't changed - if (outputFile.exists()) { - if (PHPBuilder.DEBUG) - System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$ - outputFile.delete(IResource.FORCE, null); - } +// if (outputFile.exists()) { +// if (PHPBuilder.DEBUG) +// System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$ +// outputFile.delete(IResource.FORCE, null); +// } if (PHPBuilder.DEBUG) System.out.println("Copying changed file " + resourcePath); //$NON-NLS-1$ createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure @@ -566,8 +563,8 @@ public class IncrementalImageBuilder extends AbstractImageBuilder { // the // output // folder - resource.copy(outputFile.getFullPath(), IResource.FORCE, null); - outputFile.setDerived(true); +// resource.copy(outputFile.getFullPath(), IResource.FORCE, null); +// outputFile.setDerived(true); } return; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/PHPBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/PHPBuilder.java index 9a161a4..e694619 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/PHPBuilder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/PHPBuilder.java @@ -17,10 +17,11 @@ import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.Map; + import net.sourceforge.phpdt.core.IClasspathEntry; import net.sourceforge.phpdt.core.IJavaModelMarker; -import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.compiler.CharOperation; import net.sourceforge.phpdt.internal.core.JavaModel; import net.sourceforge.phpdt.internal.core.JavaModelManager; @@ -30,8 +31,7 @@ import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; -import net.sourceforge.phpeclipse.phpeditor.PHPParserAction; -//import net.sourceforge.phpeclipse.resourcesview.PHPProject; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/State.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/State.java index 9b0a223..279abb0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/State.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/State.java @@ -13,20 +13,14 @@ package net.sourceforge.phpdt.internal.core.builder; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.util.ArrayList; import java.util.Date; -import net.sourceforge.phpdt.core.compiler.CharOperation; -import net.sourceforge.phpdt.internal.compiler.util.Util; import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable; -import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; public class State { // NOTE: this state cannot contain types that are not defined in this project diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/WorkQueue.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/WorkQueue.java index 8d76a90..04abe87 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/WorkQueue.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/WorkQueue.java @@ -10,7 +10,7 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core.builder; -import java.util.*; +import java.util.ArrayList; public class WorkQueue { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/AbstractDOMBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/AbstractDOMBuilder.java index 40fe1be..2c9a0dd 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/AbstractDOMBuilder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/AbstractDOMBuilder.java @@ -12,10 +12,12 @@ package net.sourceforge.phpdt.internal.core.jdom; import java.util.Stack; -import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; import net.sourceforge.phpdt.core.compiler.IProblem; import net.sourceforge.phpdt.core.jdom.IDOMCompilationUnit; +import net.sourceforge.phpdt.core.jdom.IDOMFactory; import net.sourceforge.phpdt.core.jdom.IDOMNode; +import net.sourceforge.phpdt.internal.compiler.IDocumentElementRequestor; +import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; import net.sourceforge.phpdt.internal.core.util.ReferenceInfoAdapter; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMField.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMField.java index 32ebdb1..6c115e4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMField.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMField.java @@ -16,6 +16,7 @@ import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IType; import net.sourceforge.phpdt.core.jdom.DOMException; import net.sourceforge.phpdt.core.jdom.IDOMField; +import net.sourceforge.phpdt.core.jdom.IDOMMember; import net.sourceforge.phpdt.core.jdom.IDOMNode; import net.sourceforge.phpdt.internal.compiler.util.Util; import net.sourceforge.phpdt.internal.core.util.CharArrayBuffer; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMImport.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMImport.java index 535071b..d835805 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMImport.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMImport.java @@ -13,7 +13,6 @@ package net.sourceforge.phpdt.internal.core.jdom; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.jdom.IDOMImport; import net.sourceforge.phpdt.core.jdom.IDOMNode; -import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; import net.sourceforge.phpdt.internal.compiler.util.Util; import net.sourceforge.phpdt.internal.core.util.CharArrayBuffer; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMInitializer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMInitializer.java index 314ee35..a0d1ad8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMInitializer.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/jdom/DOMInitializer.java @@ -11,7 +11,6 @@ package net.sourceforge.phpdt.internal.core.jdom; import net.sourceforge.phpdt.core.IJavaElement; -import net.sourceforge.phpdt.core.IType; import net.sourceforge.phpdt.core.jdom.IDOMInitializer; import net.sourceforge.phpdt.core.jdom.IDOMNode; import net.sourceforge.phpdt.internal.compiler.util.Util; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/Util.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/Util.java index ea8125b..5ce6748 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/Util.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/Util.java @@ -76,7 +76,7 @@ public class Util { /* Bundle containing messages */ protected static ResourceBundle bundle; - private final static String bundleName = "net.sourceforge.phpdt.internal.core.messages"; //$NON-NLS-1$ + private final static String bundleName = "net.sourceforge.phpdt.internal.core.util.messages"; //$NON-NLS-1$ // public final static char[] SUFFIX_class = ".class".toCharArray(); //$NON-NLS-1$ // public final static char[] SUFFIX_CLASS = ".CLASS".toCharArray(); //$NON-NLS-1$ @@ -824,6 +824,23 @@ public class Util { /* * Add a log entry */ +// public static void log(Throwable e, String message) { +// Throwable nestedException; +// if (e instanceof JavaModelException +// && (nestedException = ((JavaModelException)e).getException()) != null) { +// e = nestedException; +// } +// IStatus status= new Status( +// IStatus.ERROR, +// JavaCore.getPlugin().getDescriptor().getUniqueIdentifier(), +// IStatus.ERROR, +// message, +// e); +// JavaCore.getPlugin().getLog().log(status); +// } + /* + * Add a log entry + */ public static void log(Throwable e, String message) { Throwable nestedException; if (e instanceof JavaModelException @@ -832,13 +849,12 @@ public class Util { } IStatus status= new Status( IStatus.ERROR, - JavaCore.getPlugin().getDescriptor().getUniqueIdentifier(), + JavaCore.PLUGIN_ID, IStatus.ERROR, message, e); JavaCore.getPlugin().getLog().log(status); } - /** * Normalizes the cariage returns in the given text. * They are all changed to use the given buffer's line separator. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/messages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/messages.properties new file mode 100644 index 0000000..587ca3f --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/util/messages.properties @@ -0,0 +1,308 @@ +############################################################################### +# Copyright (c) 2000, 2004 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Common Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/cpl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +### JavaModel messages. + +### hierarchy +hierarchy.nullProject = Project argument cannot be null +hierarchy.nullRegion = Region cannot be null +hierarchy.nullFocusType = Type focus cannot be null +hierarchy.creating = Creating type hierarchy... +hierarchy.creatingOnType = Creating type hierarchy on {0}... + +### java element +element.doesNotExist = {0} does not exist +element.invalidClassFileName = Class file name must end with .class +element.reconciling = Reconciling... +element.attachingSource = Attaching source... +element.invalidType = Type is not one of the defined constants +element.invalidResourceForProject = Illegal argument - must be one of IProject, IFolder, or IFile +element.nullName = Name cannot be null +element.nullType = Type cannot be null +element.illegalParent = Illegal parent argument +sourcetype.invalidName = The source type has an invalid name: {0} + +### java model operations +operation.needElements = Operation requires one or more elements +operation.needName = Operation requires a name +operation.needPath = Operation requires a path +operation.needAbsolutePath = Operation requires an absolute path. Relative path specified was: ''{0}'' +operation.needString = Operation requires a String. +operation.notSupported = Operation not supported for specified element type(s): +operation.cancelled = Operation cancelled +operation.nullContainer = Container cannot be null +operation.nullName = Name cannot be null +operation.copyElementProgress = Copying elements... +operation.moveElementProgress = Moving elements... +operation.renameElementProgress = Renaming elements... +operation.copyResourceProgress = Copying resources... +operation.moveResourceProgress = Moving resources... +operation.renameResourceProgress = Renaming resources... +operation.createUnitProgress = Creating a compilation unit... +operation.createFieldProgress = Creating a field... +operation.createImportsProgress = Creating imports... +operation.createInitializerProgress = Creating an initializer... +operation.createMethodProgress = Creating a method... +operation.createPackageProgress = Creating a package declaration... +operation.createPackageFragmentProgress = Creating package fragment(s)... +operation.createTypeProgress = Creating a type... +operation.deleteElementProgress = Deleting elements... +operation.deleteResourceProgress = Deleting resources... +operation.cannotRenameDefaultPackage = Default package cannot be renamed +operation.pathOutsideProject = Path ''{0}'' must denote location inside project {1} +operation.sortelements = Sorting elements... + +### working copy +workingCopy.commit = Committing working copy... + +### build status messages +build.preparingBuild = Preparing for build +build.readStateProgress = Reading saved built state for project {0} +build.saveStateProgress = Saving built state for project {0} +build.saveStateComplete = Saved in {0} ms +build.readingDelta = Reading resource change information for {0} +build.analyzingDeltas = Analyzing deltas +build.analyzingSources = Analyzing sources +build.cleaningOutput = Cleaning output folder +build.copyingResources = Copying resources to the output folder +build.compiling = Compiling {0} +build.foundHeader = Found +build.fixedHeader = Fixed +build.oneError = 1 error +build.oneWarning = 1 warning +build.multipleErrors = {0} errors +build.multipleWarnings = {0} warnings +build.done = Build done + +### build errors +build.wrongFileFormat = Wrong file format +build.cannotSaveState = Error saving last build state for project {0} +build.cannotSaveStates = Error saving build states +build.initializationError = Builder initialization error +build.serializationError = Builder serialization error + +### build inconsistencies +build.classFileCollision = Class file collision: {0} +build.duplicateClassFile = The type {0} is already defined +build.duplicateResource = The resource is a duplicate of {0} and was not copied to the output folder +build.inconsistentClassFile = A class file was not written. The project may be inconsistent, if so try refreshing this project and building it +build.inconsistentProject = The project was not built due to "{0}". Fix the problem, then try refreshing this project and building it since it may be inconsistent +build.incompleteClassPath = The project was not built since its build path is incomplete. Cannot find the class file for {0}. Fix the build path then try building this project +build.missingSourceFile = The project was not built since the source file {0} could not be read +build.prereqProjectHasClasspathProblems = The project was not built since it depends on {0}, which has build path errors +build.prereqProjectMustBeRebuilt = The project cannot be built until its prerequisite {0} is built. Cleaning and building all projects is recommended +build.abortDueToClasspathProblems = The project cannot be built until build path errors are resolved + +### status +status.cannotUseDeviceOnPath = Operation requires a path with no device. Path specified was: {0} +status.coreException = Core exception +status.defaultPackageReadOnly = Default package is read-only +status.evaluationError = Evaluation error: {0} +status.JDOMError = JDOM error +status.IOException = I/O exception +status.indexOutOfBounds = Index out of bounds +status.invalidContents = Invalid contents specified +status.invalidDestination = Invalid destination: ''{0}'' +status.invalidName = Invalid name specified: {0} +status.invalidPackage = Invalid package: {0} +status.invalidPath = Invalid path: ''{0}'' +status.invalidProject = Invalid project: {0} +status.invalidResource = Invalid resource: {0} +status.invalidResourceType = Invalid resource type for {0} +status.invalidSibling = Invalid sibling: {0} +status.nameCollision = {0} already exists in target +status.noLocalContents = Cannot find local contents for resource: {0} +status.OK = OK +status.readOnly = {0} is read-only +status.targetException = Target exception +status.updateConflict = Update conflict + +### classpath +classpath.buildPath = Build path +classpath.cannotNestEntryInEntry = Cannot nest ''{0}'' inside ''{1}''. To enable the nesting exclude ''{2}'' from ''{1}'' +classpath.cannotNestEntryInLibrary = Cannot nest ''{0}'' inside library ''{1}'' +classpath.cannotNestEntryInOutput = Cannot nest ''{0}'' inside output folder ''{1}'' +classpath.cannotNestOutputInEntry = Cannot nest output folder ''{0}'' inside ''{1}'' +classpath.cannotNestOutputInOutput = Cannot nest output folder ''{0}'' inside output folder ''{1}'' +classpath.cannotReadClasspathFile = Unable to read ''.classpath'' file of project {0} +classpath.cannotReferToItself = Project cannot reference itself: {0} +classpath.cannotUseDistinctSourceFolderAsOutput = Source folder ''{0}'' in project {2} cannot output to distinct source folder ''{1}'' +classpath.cannotUseLibraryAsOutput = Source folder ''{0}'' in project {2} cannot output to library ''{1}'' +classpath.closedProject = Required project: {0} needs to be open +classpath.couldNotWriteClasspathFile = Could not write ''.classpath'' file of project {0}: {1} +classpath.cycle = A cycle was detected in the build path of project: {0} +classpath.duplicateEntryPath = Build path contains duplicate entry: ''{0}'' for project {1} +classpath.illegalContainerPath = Illegal classpath container path: ''{0}'' in project {1}, must have at least one segment (containerID+hints) +classpath.illegalEntryInClasspathFile = Illegal entry in ''.classpath'' of project {0} file: {1} +classpath.illegalLibraryPath = Illegal path for required library: ''{0}'' in project {1} +classpath.illegalLibraryArchive = Illegal type of archive for required library: ''{0}'' in project {1} +classpath.illegalExternalFolder = Required library cannot denote external folder: ''{0}'' for project {1} +classpath.illegalProjectPath = Illegal path for required project: ''{0}'' in project {1} +classpath.illegalSourceFolderPath = Illegal path for required source folder: ''{0}'' in project {1} +classpath.illegalVariablePath = Illegal classpath variable path: ''{0}'' in project {1}, must have at least one segment +classpath.invalidClasspathInClasspathFile = Invalid build path in ''.classpath'' file of project {0}: {1} +classpath.invalidContainer = Invalid classpath container: ''{0}'' in project {1} +classpath.mustEndWithSlash = End exclusion filter ''{0}'' with / to fully exclude ''{1}'' +classpath.unboundContainerPath = Unbound classpath container: ''{0}'' in project {1} +classpath.unboundLibrary = Project {1} is missing required library: ''{0}'' +classpath.unboundProject = Project {1} is missing required PHP project: ''{0}'' +classpath.settingOutputLocationProgress = Setting output location for: ''{0}'' +classpath.settingProgress = Setting classpath for: {0} +classpath.unboundSourceAttachment = Invalid source attachment: ''{0}'' for required library ''{1}'' in project {1} +classpath.unboundSourceFolder = Project {1} is missing required source folder: ''{0}'' +classpath.unboundVariablePath = Unbound classpath variable: ''{0}'' in project {1} +classpath.unknownKind = Unknown kind: ''{0}'' +classpath.xmlFormatError = XML format error in ''.classpath'' file of project {0}: {1} +classpath.disabledInclusionExclusionPatterns = Inclusion or exclusion patterns are disabled in project {1}, cannot selectively include or exclude from entry: ''{0}'' +classpath.disabledMultipleOutputLocations = Multiple output locations are disabled in project {1}, cannot associate entry: ''{0}'' with a specific output +classpath.incompatibleLibraryJDKLevel = Incompatible .class files version in required binaries. Project ''{0}'' is targeting a {1} runtime, but is compiled against ''{2}'' which requires a {3} runtime + +### miscellaneous +file.notFound = File not found: ''{0}'' +file.badFormat = Bad format +path.nullPath = Path cannot be null +path.mustBeAbsolute = Path must be absolute +cache.invalidLoadFactor = Incorrect load factor +savedState.jobName = Processing PHP changes since last activation + +### java conventions +convention.unit.nullName = Compilation unit name must not be null +convention.unit.notJavaName = Compilation unit name must end with .php +convention.classFile.nullName = .class file name must not be null +convention.classFile.notClassFileName = .class file name must end with .class +convention.illegalIdentifier = ''{0}'' is not a valid PHP identifier +convention.import.nullImport = An import declaration must not be null +convention.import.unqualifiedImport = An import declaration must not end with an unqualified * +convention.type.nullName = A PHP type name must not be null +convention.type.nameWithBlanks = A PHP type name must not start or end with a blank +convention.type.dollarName = By convention, PHP type names usually don''t contain the $ character +convention.type.lowercaseName = By convention, PHP type names usually start with an uppercase letter +convention.type.invalidName = The type name ''{0}'' is not a valid identifier +convention.package.nullName = A package name must not be null +convention.package.emptyName = A package name must not be empty +convention.package.dotName = A package name cannot start or end with a dot +convention.package.nameWithBlanks = A package name must not start or end with a blank +convention.package.consecutiveDotsName = A package name must not contain two consecutive dots +convention.package.uppercaseName = By convention, package names usually start with a lowercase letter + +### DOM +dom.cannotDetail = Unable to generate detailed source indexes +dom.nullTypeParameter = Cannot add parameter with null type +dom.nullNameParameter = Cannot add parameter with null name +dom.nullReturnType = Return type cannot be null +dom.nullExceptionType = Cannot add null exception +dom.mismatchArgNamesAndTypes = Types and names must have identical length +dom.addNullChild = Attempt to add null child +dom.addIncompatibleChild = Attempt to add child of incompatible type +dom.addChildWithParent = Attempt to add child that is already parented +dom.unableAddChild = Attempt to add child to node that cannot have children +dom.addAncestorAsChild = Attempt to add ancestor as child +dom.addNullSibling = Attempt to insert null sibling +dom.addSiblingBeforeRoot = Attempt to insert sibling before root node +dom.addIncompatibleSibling = Attempt to insert sibling of incompatible type +dom.addSiblingWithParent = Attempt to insert sibling that is already parented +dom.addAncestorAsSibling = Attempt to insert ancestor as sibling +dom.addNullInterface = Cannot add null interface +dom.nullInterfaces = Illegal to set super interfaces to null + +### correction +correction.nullRequestor = Requestor cannot be null +correction.nullUnit = Compilation unit cannot be null + +### Eclipse Java Core Search messages. + +engine.searching = Searching... +exception.wrongFormat = Wrong format +process.name = PHP indexing +manager.filesToIndex = {0} files to index +manager.indexingInProgress = PHP indexing in progress + +### Disassembler messages + +### disassembler +disassembler.description = Default classfile disassembler +disassembler.opentypedeclaration =\ { +disassembler.closetypedeclaration = } +disassembler.parametername = arg +disassembler.endofmethodheader = ; +disassembler.begincommentline = //\ +disassembler.fieldhasconstant =\ =\ +disassembler.endoffieldheader = ; +disassembler.sourceattributeheader = Compiled from +disassembler.enclosingmethodheader = Enclosing Method: +disassembler.exceptiontableheader = Exception Table: +disassembler.linenumberattributeheader = Line numbers: +disassembler.localvariabletableattributeheader = Local variable table: +disassembler.localvariabletypetableattributeheader = Local variable type table: +disassembler.arraydimensions = [] +disassembler.innerattributesheader = Inner classes: +disassembler.inner_class_info_name = inner class info: +disassembler.outer_class_info_name = outer class info: +disassembler.inner_name = inner name: +disassembler.inner_accessflags = accessflags: +disassembler.genericattributeheader = Attribute:\ +disassembler.genericattributename = Name: +disassembler.genericattributelength =\ Length: +disassembler.signatureattributeheader = Signature:\ +disassembler.identation = \ +disassembler.constantpoolindex =\ # +disassembler.classmemberseparator = . +disassembler.space = \ +disassembler.comma = , +disassembler.openinnerclassentry = [ +disassembler.closeinnerclassentry = ] +disassembler.deprecated =\ (deprecated) + +### classfileformat decoding +classfileformat.versiondetails =\ (version {0} : {1}.{2}, {3}) +classfileformat.methoddescriptor =Method descriptor +classfileformat.fieldddescriptor =Field descriptor +classfileformat.maxStack = Stack: +classfileformat.maxLocals = Locals: +classfileformat.superflagisnotset = no super bit +classfileformat.superflagisset = super bit +classfileformat.clinitname = {} + +### string displayed for each opcode +classformat.invokeinterfacemethod =\ +classformat.invokespecialconstructor =\ +classformat.invokespecialmethod =\ +classformat.invokestaticmethod =\ +classformat.invokevirtualmethod =\ +classformat.getfield = \ +classformat.getstatic = \ +classformat.putstatic =\ +classformat.putfield =\ +classformat.nargs =\ [nargs : +classformat.interfacemethodrefindex = ] # +classfileformat.anyexceptionhandler=any +classfileformat.fielddescriptorindex=# +classfileformat.exceptiontablefrom=[pc: +classfileformat.exceptiontableto=, pc: +classfileformat.exceptiontablegoto=] -> +classfileformat.exceptiontablewhen =\ when : +classfileformat.linenumbertablefrom=[pc: +classfileformat.linenumbertableto=, line: +classfileformat.linenumbertableclose=] +classfileformat.localvariabletablefrom=[pc: +classfileformat.localvariabletableto=, pc: +classfileformat.localvariabletablelocalname=] local: +classfileformat.localvariabletablelocalindex=\ index: +classfileformat.localvariabletablelocaltype=\ type: \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java index 36955ff..7efbade 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java @@ -1277,7 +1277,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { // || token == TokenNameFloatingPointLiteral || token == TokenNameDoubleLiteral // || token == TokenNameCharacterLiteral - || token == TokenNameStringLiteral; + || token == TokenNameStringDoubleQuote; return result; } /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaElementAdapterFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaElementAdapterFactory.java index cebd160..ba91171 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaElementAdapterFactory.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaElementAdapterFactory.java @@ -12,28 +12,21 @@ package net.sourceforge.phpdt.internal.ui; +import net.sourceforge.phpdt.core.ICompilationUnit; +import net.sourceforge.phpdt.core.IJavaElement; +import net.sourceforge.phpdt.core.IPackageFragmentRoot; +import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdapterFactory; - -import org.eclipse.ui.IContainmentAdapter; import org.eclipse.ui.IContributorResourceAdapter; import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.views.properties.FilePropertySource; import org.eclipse.ui.views.properties.IPropertySource; import org.eclipse.ui.views.properties.ResourcePropertySource; -import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter; - -import org.eclipse.search.ui.ISearchPageScoreComputer; - -import net.sourceforge.phpdt.core.ICompilationUnit; -import net.sourceforge.phpdt.core.IJavaElement; -import net.sourceforge.phpdt.core.IPackageFragmentRoot; - -import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil; //import net.sourceforge.phpdt.internal.ui.search.JavaSearchPageScoreComputer; //import net.sourceforge.phpdt.internal.ui.search.SearchUtil; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaPluginImages_DeleteIt.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaPluginImages_DeleteIt.java deleted file mode 100644 index 04543bb..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/JavaPluginImages_DeleteIt.java +++ /dev/null @@ -1,424 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package net.sourceforge.phpdt.internal.ui; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Iterator; - -import net.sourceforge.phpeclipse.PHPeclipsePlugin; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; - - -/** - * Bundle of most images used by the Java plugin. - */ -public class JavaPluginImages_DeleteIt { - - private static final String NAME_PREFIX= "net.sourceforge.phpdt.internal.ui."; //$NON-NLS-1$ - private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length(); - - private static URL fgIconBaseURL= null; - - // Determine display depth. If depth > 4 then we use high color images. Otherwise low color - // images are used - static { -// String pathSuffix= "icons/full/"; //$NON-NLS-1$ - String pathSuffix= "icons/"; //$NON-NLS-1$ - try { - fgIconBaseURL= new URL(PHPeclipsePlugin.getDefault().getDescriptor().getInstallURL(), pathSuffix); - } catch (MalformedURLException e) { - // do nothing - } - } - - // The plugin registry - private static ImageRegistry fgImageRegistry= null; - private static HashMap fgAvoidSWTErrorMap= null; - - /* - * Available cached Images in the Java plugin image registry. - */ - public static final String IMG_MISC_PUBLIC= NAME_PREFIX + "methpub_obj.gif"; //$NON-NLS-1$ - public static final String IMG_MISC_PROTECTED= NAME_PREFIX + "methpro_obj.gif"; //$NON-NLS-1$ - public static final String IMG_MISC_PRIVATE= NAME_PREFIX + "methpri_obj.gif"; //$NON-NLS-1$ - public static final String IMG_MISC_DEFAULT= NAME_PREFIX + "methdef_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_FIELD_PUBLIC= NAME_PREFIX + "field_public_obj.gif"; //$NON-NLS-1$ - public static final String IMG_FIELD_PROTECTED= NAME_PREFIX + "field_protected_obj.gif"; //$NON-NLS-1$ - public static final String IMG_FIELD_PRIVATE= NAME_PREFIX + "field_private_obj.gif"; //$NON-NLS-1$ - public static final String IMG_FIELD_DEFAULT= NAME_PREFIX + "field_default_obj.gif"; //$NON-NLS-1$ - - - public static final String IMG_OBJS_GHOST= NAME_PREFIX + "ghost.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SEARCH_TSK= NAME_PREFIX + "search_tsk.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_PACKDECL= NAME_PREFIX + "packd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_IMPDECL= NAME_PREFIX + "imp_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_IMPCONT= NAME_PREFIX + "impc_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_JSEARCH= NAME_PREFIX + "jsearch_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SEARCH_DECL= NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SEARCH_REF= NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CLASSALT= NAME_PREFIX + "classfo_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CLASS_DEFAULT= NAME_PREFIX + "class_default_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_INTERFACE= NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_INTERFACEALT= NAME_PREFIX + "intf_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_INTERFACE_DEFAULT= NAME_PREFIX + "int_default_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CUNIT= NAME_PREFIX + "jcu_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CUNIT_RESOURCE= NAME_PREFIX + "jcu_resource_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CFILE= NAME_PREFIX + "classf_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CFILECLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CFILEINT= NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_LOGICAL_PACKAGE= NAME_PREFIX + "logical_package_obj.gif";//$NON-NLS-1$ - public static final String IMG_OJS_EMPTY_LOGICAL_PACKAGE= NAME_PREFIX + "empty_logical_package_obj.gif";//$NON-NLS-1$ - public static final String IMG_OBJS_PACKAGE= NAME_PREFIX + "package_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EMPTY_PACK_RESOURCE= NAME_PREFIX + "empty_pack_fldr_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EMPTY_PACKAGE= NAME_PREFIX + "empty_pack_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_PACKFRAG_ROOT= NAME_PREFIX + "packagefolder_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_MISSING_PACKFRAG_ROOT= NAME_PREFIX + "packagefolder_nonexist_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_MISSING_JAR= NAME_PREFIX + "jar_nonexist_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_JAR= NAME_PREFIX + "jar_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EXTJAR= NAME_PREFIX + "jar_l_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_JAR_WSRC= NAME_PREFIX + "jar_src_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EXTJAR_WSRC= NAME_PREFIX + "jar_lsrc_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_ENV_VAR= NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_MISSING_ENV_VAR= NAME_PREFIX + "envvar_nonexist_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_JAVA_MODEL= NAME_PREFIX + "java_model_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_UNKNOWN= NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_JAVADOCTAG= NAME_PREFIX + "jdoc_tag_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_HTMLTAG= NAME_PREFIX + "html_tag_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_EXCEPTION= NAME_PREFIX + "jexception_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_ERROR= NAME_PREFIX + "jrtexception_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_BREAKPOINT_INSTALLED= NAME_PREFIX + "brkpi_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_SNIPPET_EVALUATING= NAME_PREFIX + "jsbook_run_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_REFACTORING_FATAL= NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_REFACTORING_ERROR= NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_REFACTORING_INFO= NAME_PREFIX + "info_obj.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_NLS_TRANSLATE= NAME_PREFIX + "translate.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_NLS_SKIP= NAME_PREFIX + "skip.gif"; //$NON-NLS-1$ - - public static final String IMG_OBJS_SEARCH_READACCESS= NAME_PREFIX + "occ_read.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SEARCH_WRITEACCESS= NAME_PREFIX + "occ_write.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SEARCH_OCCURRENCE= NAME_PREFIX + "occ_match.gif"; //$NON-NLS-1$ - /* - * Set of predefined Image Descriptors. - */ - private static final String T_OBJ= "obj16"; //$NON-NLS-1$ - private static final String T_OVR= "ovr16"; //$NON-NLS-1$ - private static final String T_WIZBAN= "wizban"; //$NON-NLS-1$ - private static final String T_CLCL= "clcl16"; //$NON-NLS-1$ - private static final String T_DLCL= "dlcl16"; //$NON-NLS-1$ - private static final String T_CTOOL= "ctool16"; //$NON-NLS-1$ - private static final String T_CVIEW= "cview16"; //$NON-NLS-1$ - - public static final ImageDescriptor DESC_VIEW_ERRORWARNING_TAB= create(T_CVIEW, "errorwarning_tab.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_VIEW_CLASSFILEGENERATION_TAB= create(T_CVIEW, "classfilegeneration_tab.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_VIEW_JDKCOMPLIANCE_TAB= create(T_CVIEW, "jdkcompliance_tab.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_CLCL_FILTER= create(T_CLCL, "filter_ps.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_CLCL_CODE_ASSIST= create(T_CLCL, "metharg_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_DLCL_CODE_ASSIST= create(T_DLCL, "metharg_obj.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_MISC_PUBLIC= createManaged(T_OBJ, IMG_MISC_PUBLIC); - public static final ImageDescriptor DESC_MISC_PROTECTED= createManaged(T_OBJ, IMG_MISC_PROTECTED); - public static final ImageDescriptor DESC_MISC_PRIVATE= createManaged(T_OBJ, IMG_MISC_PRIVATE); - public static final ImageDescriptor DESC_MISC_DEFAULT= createManaged(T_OBJ, IMG_MISC_DEFAULT); - - public static final ImageDescriptor DESC_FIELD_PUBLIC= createManaged(T_OBJ, IMG_FIELD_PUBLIC); //$NON-NLS-1$ - public static final ImageDescriptor DESC_FIELD_PROTECTED= createManaged(T_OBJ, IMG_FIELD_PROTECTED); //$NON-NLS-1$ - public static final ImageDescriptor DESC_FIELD_PRIVATE= createManaged(T_OBJ, IMG_FIELD_PRIVATE); //$NON-NLS-1$ - public static final ImageDescriptor DESC_FIELD_DEFAULT= createManaged(T_OBJ, IMG_FIELD_DEFAULT); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_MENU_SHIFT_RIGHT= create(T_CTOOL, "shift_r_edit.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_MENU_SHIFT_LEFT= create(T_CTOOL, "shift_l_edit.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_OBJS_GHOST= createManaged(T_OBJ, IMG_OBJS_GHOST); - public static final ImageDescriptor DESC_OBJS_PACKDECL= createManaged(T_OBJ, IMG_OBJS_PACKDECL); - public static final ImageDescriptor DESC_OBJS_IMPDECL= createManaged(T_OBJ, IMG_OBJS_IMPDECL); - public static final ImageDescriptor DESC_OBJS_IMPCONT= createManaged(T_OBJ, IMG_OBJS_IMPCONT); - public static final ImageDescriptor DESC_OBJS_JSEARCH= createManaged(T_OBJ, IMG_OBJS_JSEARCH); - public static final ImageDescriptor DESC_OBJS_SEARCH_DECL= createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL); - public static final ImageDescriptor DESC_OBJS_SEARCH_REF= createManaged(T_OBJ, IMG_OBJS_SEARCH_REF); - public static final ImageDescriptor DESC_OBJS_CUNIT= createManaged(T_OBJ, IMG_OBJS_CUNIT); - public static final ImageDescriptor DESC_OBJS_CUNIT_RESOURCE= createManaged(T_OBJ, IMG_OBJS_CUNIT_RESOURCE); - public static final ImageDescriptor DESC_OBJS_CFILE= createManaged(T_OBJ, IMG_OBJS_CFILE); - public static final ImageDescriptor DESC_OBJS_CFILECLASS= createManaged(T_OBJ, IMG_OBJS_CFILECLASS); - public static final ImageDescriptor DESC_OBJS_CFILEINT= createManaged(T_OBJ, IMG_OBJS_CFILEINT); - public static final ImageDescriptor DESC_OBJS_PACKAGE= createManaged(T_OBJ, IMG_OBJS_PACKAGE); - public static final ImageDescriptor DESC_OBJS_EMPTY_LOGICAL_PACKAGE= createManaged(T_OBJ, IMG_OJS_EMPTY_LOGICAL_PACKAGE); - public static final ImageDescriptor DESC_OBJS_LOGICAL_PACKAGE= createManaged(T_OBJ, IMG_OBJS_LOGICAL_PACKAGE); - public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE_RESOURCES= createManaged(T_OBJ, IMG_OBJS_EMPTY_PACK_RESOURCE); - public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE= createManaged(T_OBJ, IMG_OBJS_EMPTY_PACKAGE); - public static final ImageDescriptor DESC_OBJS_PACKFRAG_ROOT= createManaged(T_OBJ, IMG_OBJS_PACKFRAG_ROOT); - public static final ImageDescriptor DESC_OBJS_MISSING_PACKFRAG_ROOT= createManaged(T_OBJ, IMG_OBJS_MISSING_PACKFRAG_ROOT); - public static final ImageDescriptor DESC_OBJS_JAVA_MODEL= createManaged(T_OBJ, IMG_OBJS_JAVA_MODEL); - - public static final ImageDescriptor DESC_OBJS_CLASS= createManaged(T_OBJ, IMG_OBJS_CLASS); - public static final ImageDescriptor DESC_OBJS_CLASS_DEFAULT= createManaged(T_OBJ, IMG_OBJS_CLASS_DEFAULT); - - public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PUBLIC= create(T_OBJ, "innerclass_public_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_INNER_CLASS_DEFAULT= create(T_OBJ, "innerclass_default_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PROTECTED= create(T_OBJ, "innerclass_protected_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PRIVATE= create(T_OBJ, "innerclass_private_obj.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_OBJS_CLASSALT= createManaged(T_OBJ, IMG_OBJS_CLASSALT); - - public static final ImageDescriptor DESC_OBJS_INTERFACE= createManaged(T_OBJ, IMG_OBJS_INTERFACE); - public static final ImageDescriptor DESC_OBJS_INTERFACE_DEFAULT= createManaged(T_OBJ, IMG_OBJS_INTERFACE_DEFAULT); - - public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PUBLIC= create(T_OBJ, "innerinterface_public_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_DEFAULT= create(T_OBJ, "innerinterface_default_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PROTECTED= create(T_OBJ, "innerinterface_protected_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PRIVATE= create(T_OBJ, "innerinterface_private_obj.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_OBJS_INTERFACEALT= createManaged(T_OBJ, IMG_OBJS_INTERFACEALT); - - public static final ImageDescriptor DESC_OBJS_JAR= createManaged(T_OBJ, IMG_OBJS_JAR); - public static final ImageDescriptor DESC_OBJS_MISSING_JAR= createManaged(T_OBJ, IMG_OBJS_MISSING_JAR); - public static final ImageDescriptor DESC_OBJS_EXTJAR= createManaged(T_OBJ, IMG_OBJS_EXTJAR); - public static final ImageDescriptor DESC_OBJS_JAR_WSRC= createManaged(T_OBJ, IMG_OBJS_JAR_WSRC); - public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC= createManaged(T_OBJ, IMG_OBJS_EXTJAR_WSRC); - public static final ImageDescriptor DESC_OBJS_ENV_VAR= createManaged(T_OBJ, IMG_OBJS_ENV_VAR); - public static final ImageDescriptor DESC_OBJS_MISSING_ENV_VAR= createManaged(T_OBJ, IMG_OBJS_MISSING_ENV_VAR); - - public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY); - - public static final ImageDescriptor DESC_OBJS_JAVADOCTAG= createManaged(T_OBJ, IMG_OBJS_JAVADOCTAG); - public static final ImageDescriptor DESC_OBJS_HTMLTAG= createManaged(T_OBJ, IMG_OBJS_HTMLTAG); - - public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE); - - public static final ImageDescriptor DESC_OBJS_EXCEPTION= createManaged(T_OBJ, IMG_OBJS_EXCEPTION); - public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED= createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_INSTALLED); - public static final ImageDescriptor DESC_OBJS_ERROR= createManaged(T_OBJ, IMG_OBJS_ERROR); - public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM); - public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR); - - public static final ImageDescriptor DESC_OBJS_SNIPPET_EVALUATING= createManaged(T_OBJ, IMG_OBJS_SNIPPET_EVALUATING); - - public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE= create(T_OBJ, "change.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_COMPOSITE_CHANGE= create(T_OBJ, "composite_change.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_CU_CHANGE= create(T_OBJ, "cu_change.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_FILE_CHANGE= create(T_OBJ, "file_change.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_TEXT_EDIT= create(T_OBJ, "text_edit.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB= create(T_OBJ, "exclusion_filter_attrib.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER_ATTRIB= create(T_OBJ, "output_folder_attrib.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= create(T_OBJ, "source_attach_attrib.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_JAVADOC_LOCATION_ATTRIB= create(T_OBJ, "javadoc_location_attrib.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_OBJS_REFACTORING_FATAL= createManaged(T_OBJ, IMG_OBJS_REFACTORING_FATAL); - public static final ImageDescriptor DESC_OBJS_REFACTORING_ERROR= createManaged(T_OBJ, IMG_OBJS_REFACTORING_ERROR); - public static final ImageDescriptor DESC_OBJS_REFACTORING_WARNING= createManaged(T_OBJ, IMG_OBJS_REFACTORING_WARNING); - public static final ImageDescriptor DESC_OBJS_REFACTORING_INFO= createManaged(T_OBJ, IMG_OBJS_REFACTORING_INFO); - - public static final ImageDescriptor DESC_OBJS_NLS_TRANSLATE= createManaged(T_OBJ, IMG_OBJS_NLS_TRANSLATE); - public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE= createManaged(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE); - public static final ImageDescriptor DESC_OBJS_NLS_SKIP= createManaged(T_OBJ, IMG_OBJS_NLS_SKIP); - - public static final ImageDescriptor DESC_OBJS_UNKNOWN= createManaged(T_OBJ, IMG_OBJS_UNKNOWN); - - public static final ImageDescriptor DESC_OBJS_SEARCH_READACCESS= createManaged(T_OBJ, IMG_OBJS_SEARCH_READACCESS); - public static final ImageDescriptor DESC_OBJS_SEARCH_WRITEACCESS= createManaged(T_OBJ, IMG_OBJS_SEARCH_WRITEACCESS); - public static final ImageDescriptor DESC_OBJS_SEARCH_OCCURRENCE= createManaged(T_OBJ, IMG_OBJS_SEARCH_OCCURRENCE); - - public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= create(T_OBJ, "localvariable_obj.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_FINAL= create(T_OVR, "final_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_ABSTRACT= create(T_OVR, "abstract_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_SYNCH= create(T_OVR, "synch_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_RUN= create(T_OVR, "run_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_OVERRIDES= create(T_OVR, "over_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_IMPLEMENTS= create(T_OVR, "implm_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_CONSTRUCTOR= create(T_OVR, "constr_ovr.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OVR_FOCUS= create(T_OVR, "focus_ovr.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= create(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_NEWFIELD= create(T_WIZBAN, "newfield_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_NEWINT= create(T_WIZBAN, "newint_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_NEWJPRJ= create(T_WIZBAN, "newjprj_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR= create(T_WIZBAN, "newsrcfldr_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_NEWMETH= create(T_WIZBAN, "newmeth_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_NEWPACK= create(T_WIZBAN, "newpack_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_NEWSCRAPPAGE= create(T_WIZBAN, "newsbook_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_JAVA_LAUNCH= create(T_WIZBAN, "java_app_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_JAVA_ATTACH= create(T_WIZBAN, "java_attach_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR= create(T_WIZBAN, "refactor_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD= create(T_WIZBAN, "fieldrefact_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD= create(T_WIZBAN, "methrefact_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE= create(T_WIZBAN, "typerefact_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PACKAGE= create(T_WIZBAN, "packrefact_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CODE= create(T_WIZBAN, "coderefact_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CU= create(T_WIZBAN, "compunitrefact_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PULL_UP= create(T_WIZBAN, "pullup_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_JAR_PACKAGER= create(T_WIZBAN, "jar_pack_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_JAVA_WORKINGSET= create(T_WIZBAN, "java_workingset_wiz.gif");//$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_EXPORT_JAVADOC= create(T_WIZBAN, "export_javadoc_wiz.gif");//$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_EXTERNALIZE_STRINGS= create(T_WIZBAN, "extstr_wiz.gif");//$NON-NLS-1$ - public static final ImageDescriptor DESC_WIZBAN_ADD_LIBRARY= create(T_WIZBAN, "addlibrary_wiz.gif");//$NON-NLS-1$ - - - public static final ImageDescriptor DESC_TOOL_DISPLAYSNIPPET= create(T_CTOOL, "disp_sbook.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_RUNSNIPPET= create(T_CTOOL, "run_sbook.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_INSPSNIPPET= create(T_CTOOL, "insp_sbook.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_PACKSNIPPET= create(T_CTOOL, "pack_sbook.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_TERMSNIPPET= create(T_CTOOL, "term_sbook.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_SHOW_EMPTY_PKG= create(T_CTOOL, "show_empty_pkg.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_SHOW_SEGMENTS= create(T_CTOOL, "segment_edit.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_GOTO_NEXT_ERROR= create(T_CTOOL, "next_error_nav.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_GOTO_PREV_ERROR= create(T_CTOOL, "prev_error_nav.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_TOOL_OPENTYPE= create(T_CTOOL, "opentype.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_NEWPROJECT= create(T_CTOOL, "newjprj_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_NEWPACKAGE= create(T_CTOOL, "newpack_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_NEWCLASS= create(T_CTOOL, "newclass_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_NEWINTERFACE= create(T_CTOOL, "newint_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_NEWSNIPPET= create(T_CTOOL, "newsbook_wiz.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_TOOL_NEWPACKROOT= create(T_CTOOL, "newpackfolder_wiz.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor DESC_TOOL_CLASSPATH_ORDER= create(T_OBJ, "cp_order_obj.gif"); //$NON-NLS-1$ - - // Keys for correction proposal. We have to put the image into the registry since "code assist" doesn't - // have a life cycle. So no change to dispose icons. - - public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$ - public static final String IMG_CORRECTION_MOVE= NAME_PREFIX + "correction_move.gif"; //$NON-NLS-1$ - public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$ - public static final String IMG_CORRECTION_DELETE_IMPORT= NAME_PREFIX + "correction_delete_import.gif"; //$NON-NLS-1$ - public static final String IMG_CORRECTION_LOCAL= NAME_PREFIX + "localvariable_obj.gif"; //$NON-NLS-1$ - static { - createManaged(T_OBJ, IMG_CORRECTION_CHANGE); - createManaged(T_OBJ, IMG_CORRECTION_MOVE); - createManaged(T_OBJ, IMG_CORRECTION_RENAME); - createManaged(T_OBJ, IMG_CORRECTION_DELETE_IMPORT); - createManaged(T_OBJ, IMG_CORRECTION_LOCAL); - } - - /** - * Returns the image managed under the given key in this registry. - * - * @param key the image's key - * @return the image managed under the given key - */ - public static Image get(String key) { - return getImageRegistry().get(key); - } - - /** - * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions - * are retrieved from the *tool16 folders. - */ - public static void setToolImageDescriptors(IAction action, String iconName) { - setImageDescriptors(action, "tool16", iconName); //$NON-NLS-1$ - } - - /** - * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions - * are retrieved from the *lcl16 folders. - */ - public static void setLocalImageDescriptors(IAction action, String iconName) { - setImageDescriptors(action, "lcl16", iconName); //$NON-NLS-1$ - } - - /* - * Helper method to access the image registry from the JavaPlugin class. - */ - /* package */ static ImageRegistry getImageRegistry() { - if (fgImageRegistry == null) { - fgImageRegistry= new ImageRegistry(); - for (Iterator iter= fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext();) { - String key= (String) iter.next(); - fgImageRegistry.put(key, (ImageDescriptor) fgAvoidSWTErrorMap.get(key)); - } - fgAvoidSWTErrorMap= null; - } - return fgImageRegistry; - } - - //---- Helper methods to access icons on the file system -------------------------------------- - - private static void setImageDescriptors(IAction action, String type, String relPath) { - - try { - ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("d" + type, relPath)); //$NON-NLS-1$ - if (id != null) - action.setDisabledImageDescriptor(id); - } catch (MalformedURLException e) { - } - - try { - ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("c" + type, relPath)); //$NON-NLS-1$ - if (id != null) - action.setHoverImageDescriptor(id); - } catch (MalformedURLException e) { - } - - action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$ - } - - private static ImageDescriptor createManaged(String prefix, String name) { - try { - ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); - if (fgAvoidSWTErrorMap == null) { - fgAvoidSWTErrorMap= new HashMap(); - } - fgAvoidSWTErrorMap.put(name, result); - if (fgImageRegistry != null) { - PHPeclipsePlugin.log(IStatus.ERROR, "Image registry already defined"); //$NON-NLS-1$ - } - return result; - } catch (MalformedURLException e) { - return ImageDescriptor.getMissingImageDescriptor(); - } - } - - private static ImageDescriptor create(String prefix, String name) { - try { - return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); - } catch (MalformedURLException e) { - return ImageDescriptor.getMissingImageDescriptor(); - } - } - - private static URL makeIconFileURL(String prefix, String name) throws MalformedURLException { - if (fgIconBaseURL == null) - throw new MalformedURLException(); - - StringBuffer buffer= new StringBuffer(prefix); - buffer.append('/'); - buffer.append(name); - return new URL(fgIconBaseURL, buffer.toString()); - } -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/PHPUiImages.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/PHPUiImages.java index e56aeff..ee12ab3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/PHPUiImages.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/PHPUiImages.java @@ -16,23 +16,28 @@ public class PHPUiImages { "net.sourceforge.phpdt.internal.ui."; protected static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length(); - protected static URL iconBaseURL; - + protected static URL fgIconBaseURL; + +// static { +// String pathSuffix = "icons/"; +// try { +// fgIconBaseURL = +// new URL( +// PHPeclipsePlugin +// .getDefault() +// .getDescriptor() +// .getInstallURL(), +// pathSuffix); +// } catch (MalformedURLException e) { +// PHPeclipsePlugin.log(e); +// } +// } + +// Determine display depth. If depth > 4 then we use high color images. Otherwise low color + // images are used static { - String pathSuffix = "icons/"; - try { - iconBaseURL = - new URL( - PHPeclipsePlugin - .getDefault() - .getDescriptor() - .getInstallURL(), - pathSuffix); - } catch (MalformedURLException e) { - PHPeclipsePlugin.log(e); - } + fgIconBaseURL= PHPeclipsePlugin.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$ } - protected static final ImageRegistry IMAGE_REGISTRY = new ImageRegistry(); protected static final String OBJ_PREFIX = "obj16"; @@ -359,12 +364,17 @@ public class PHPUiImages { public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$ public static final String IMG_CORRECTION_DELETE_IMPORT= NAME_PREFIX + "correction_delete_import.gif"; //$NON-NLS-1$ public static final String IMG_CORRECTION_LOCAL= NAME_PREFIX + "localvariable_obj.gif"; //$NON-NLS-1$ + public static final String IMG_CORRECTION_REMOVE= NAME_PREFIX + "remove_correction.gif"; //$NON-NLS-1$ + public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "add_correction.gif"; //$NON-NLS-1$ + static { createManaged(T_OBJ, IMG_CORRECTION_CHANGE); createManaged(T_OBJ, IMG_CORRECTION_MOVE); createManaged(T_OBJ, IMG_CORRECTION_RENAME); createManaged(T_OBJ, IMG_CORRECTION_DELETE_IMPORT); createManaged(T_OBJ, IMG_CORRECTION_LOCAL); + createManaged(T_OBJ, IMG_CORRECTION_REMOVE); + createManaged(T_OBJ, IMG_CORRECTION_ADD); } /** * Returns the image managed under the given key in this registry. @@ -454,12 +464,12 @@ public class PHPUiImages { protected static URL makeIconFileURL(String prefix, String name) throws MalformedURLException { - if (iconBaseURL == null) + if (fgIconBaseURL == null) throw new MalformedURLException(); StringBuffer buffer = new StringBuffer(prefix); buffer.append('/'); buffer.append(name); - return new URL(iconBaseURL, buffer.toString()); + return new URL(fgIconBaseURL, buffer.toString()); } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/WorkbenchRunnableAdapter.java index a062bba..bd68861 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/WorkbenchRunnableAdapter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/WorkbenchRunnableAdapter.java @@ -12,7 +12,7 @@ package net.sourceforge.phpdt.internal.ui.actions; import java.lang.reflect.InvocationTargetException; -import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; @@ -39,7 +39,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress { */ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { - JavaCore.run(fWorkspaceRunnable, monitor); + PHPeclipsePlugin.run(fWorkspaceRunnable, monitor); } catch (OperationCanceledException e) { throw new InterruptedException(e.getMessage()); } catch (CoreException e) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CompilerConfigurationBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CompilerConfigurationBlock.java index 5d64871..4dc5d04 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CompilerConfigurationBlock.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CompilerConfigurationBlock.java @@ -13,11 +13,15 @@ package net.sourceforge.phpdt.internal.ui.preferences; import java.util.ArrayList; import java.util.Map; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; +import net.sourceforge.phpdt.core.IJavaProject; +import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo; +import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil; +import net.sourceforge.phpdt.internal.ui.util.PixelConverter; +import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout; +import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener; +import org.eclipse.core.runtime.IStatus; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -28,15 +32,6 @@ import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; -import net.sourceforge.phpdt.core.IJavaProject; -import net.sourceforge.phpdt.core.JavaCore; - -import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo; -import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil; -import net.sourceforge.phpdt.internal.ui.util.PixelConverter; -import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout; -import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener; - /** */ public class CompilerConfigurationBlock extends OptionsConfigurationBlock { @@ -151,7 +146,7 @@ public class CompilerConfigurationBlock extends OptionsConfigurationBlock { // private IStatus fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus; public CompilerConfigurationBlock(IStatusChangeListener context, IJavaProject project) { - super(context, project); + super(context, project, getKeys()); fComplianceControls= new ArrayList(); @@ -166,7 +161,7 @@ public class CompilerConfigurationBlock extends OptionsConfigurationBlock { } - private final String[] KEYS= new String[] { + private final static String[] KEYS= new String[] { PREF_PB_PHP_VAR_DEPRECATED, // PREF_LOCAL_VARIABLE_ATTR, // PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL, @@ -214,7 +209,7 @@ public class CompilerConfigurationBlock extends OptionsConfigurationBlock { // PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING }; - protected String[] getAllKeys() { + private static String[] getKeys() { return KEYS; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/MockupPreferenceStore.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/MockupPreferenceStore.java new file mode 100644 index 0000000..9ebfdcb --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/MockupPreferenceStore.java @@ -0,0 +1,273 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.preferences; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.ListenerList; +import org.eclipse.jface.util.PropertyChangeEvent; + +/** + * Mockup preference store, for registering listeners and firing events, + * without being an actual store. + *

+ * All methods except firing, adding and removing listeners throw + * an {@link java.lang.UnsupportedOperationException}. + *

+ * + * @since 3.0 + */ +public class MockupPreferenceStore implements IPreferenceStore { + + /** Listeners on this store */ + private ListenerList fListeners= new ListenerList(); + + /** + * {@inheritDoc} + */ + public void addPropertyChangeListener(IPropertyChangeListener listener) { + fListeners.add(listener); + } + + /** + * {@inheritDoc} + */ + public void removePropertyChangeListener(IPropertyChangeListener listener) { + fListeners.remove(listener); + } + + /** + * {@inheritDoc} + */ + public boolean contains(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { + firePropertyChangeEvent(this, name, oldValue, newValue); + } + + /** + * Fires a property change event with the given source, property name, old and new value. Used + * when the event source should be different from this mockup preference store. + * @param source The event source + * @param name The property name + * @param oldValue The property's old value + * @param newValue The property's new value + */ + public void firePropertyChangeEvent(Object source, String name, Object oldValue, Object newValue) { + PropertyChangeEvent event= new PropertyChangeEvent(source, name, oldValue, newValue); + Object[] listeners= fListeners.getListeners(); + for (int i= 0; i < listeners.length; i++) + ((IPropertyChangeListener) listeners[i]).propertyChange(event); + } + + /** + * {@inheritDoc} + */ + public boolean getBoolean(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public boolean getDefaultBoolean(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public double getDefaultDouble(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public float getDefaultFloat(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public int getDefaultInt(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public long getDefaultLong(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public String getDefaultString(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public double getDouble(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public float getFloat(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public int getInt(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public long getLong(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public String getString(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public boolean isDefault(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public boolean needsSaving() { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void putValue(String name, String value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setDefault(String name, double value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setDefault(String name, float value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setDefault(String name, int value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setDefault(String name, long value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setDefault(String name, String defaultObject) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setDefault(String name, boolean value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setToDefault(String name) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setValue(String name, double value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setValue(String name, float value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setValue(String name, int value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setValue(String name, long value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setValue(String name, String value) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public void setValue(String name, boolean value) { + throw new UnsupportedOperationException(); + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/OptionsConfigurationBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/OptionsConfigurationBlock.java index 941b851..2e4ce5d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/OptionsConfigurationBlock.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/OptionsConfigurationBlock.java @@ -10,27 +10,30 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.ui.preferences; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; +import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; +import java.util.Map.Entry; import net.sourceforge.phpdt.core.IJavaProject; import net.sourceforge.phpdt.core.JavaCore; -import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler; import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -48,7 +51,11 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Widget; /** - */ + * Abstract options configuration block providing a general implementation for setting up + * an options configuration page. + * + * @since 2.1 + */ public abstract class OptionsConfigurationBlock { protected static class ControlData { @@ -74,12 +81,14 @@ public abstract class OptionsConfigurationBlock { } public int getSelection(String value) { - for (int i= 0; i < fValues.length; i++) { - if (value.equals(fValues[i])) { - return i; + if (value != null) { + for (int i= 0; i < fValues.length; i++) { + if (value.equals(fValues[i])) { + return i; + } } } - return 0; + return fValues.length -1; // assume the last option is the least severe } } @@ -96,14 +105,17 @@ public abstract class OptionsConfigurationBlock { protected IStatusChangeListener fContext; protected IJavaProject fProject; // project or null + protected String[] fAllKeys; private Shell fShell; - public OptionsConfigurationBlock(IStatusChangeListener context, IJavaProject project) { + public OptionsConfigurationBlock(IStatusChangeListener context, IJavaProject project, String[] allKeys) { fContext= context; fProject= project; + fAllKeys= allKeys; fWorkingValues= getOptions(true); + testIfOptionsComplete(fWorkingValues, allKeys); fCheckBoxes= new ArrayList(); fComboBoxes= new ArrayList(); @@ -111,8 +123,14 @@ public abstract class OptionsConfigurationBlock { fLabels= new HashMap(); } - protected abstract String[] getAllKeys(); - + private void testIfOptionsComplete(Map workingValues, String[] allKeys) { + for (int i= 0; i < allKeys.length; i++) { + if (workingValues.get(allKeys[i]) == null) { + PHPeclipsePlugin.logErrorMessage("preference option missing: " + allKeys[i] + " (" + this.getClass().getName() +')'); //$NON-NLS-1$//$NON-NLS-2$ + } + } + } + protected Map getOptions(boolean inheritJavaCoreOptions) { if (fProject != null) { return fProject.getOptions(inheritJavaCoreOptions); @@ -128,7 +146,7 @@ public abstract class OptionsConfigurationBlock { public final boolean hasProjectSpecificOptions() { if (fProject != null) { Map settings= fProject.getOptions(false); - String[] allKeys= getAllKeys(); + String[] allKeys= fAllKeys; for (int i= 0; i < allKeys.length; i++) { if (settings.get(allKeys[i]) != null) { return true; @@ -140,12 +158,44 @@ public abstract class OptionsConfigurationBlock { protected void setOptions(Map map) { if (fProject != null) { + Map oldOptions= fProject.getOptions(false); fProject.setOptions(map); + firePropertyChangeEvents(oldOptions, map); } else { JavaCore.setOptions((Hashtable) map); } } + /** + * Computes the differences between the given old and new options and fires corresponding + * property change events on the Java plugin's mockup preference store. + * @param oldOptions The old options + * @param newOptions The new options + */ + private void firePropertyChangeEvents(Map oldOptions, Map newOptions) { + oldOptions= new HashMap(oldOptions); + Object source= fProject.getProject(); + MockupPreferenceStore store= PHPeclipsePlugin.getDefault().getMockupPreferenceStore(); + Iterator iter= newOptions.entrySet().iterator(); + while (iter.hasNext()) { + Entry entry= (Entry) iter.next(); + + String name= (String) entry.getKey(); + Object oldValue= oldOptions.get(name); + Object newValue= entry.getValue(); + + if ((oldValue != null && !oldValue.equals(newValue)) || (oldValue == null && newValue != null)) + store.firePropertyChangeEvent(source, name, oldValue, newValue); + oldOptions.remove(name); + } + + iter= oldOptions.entrySet().iterator(); + while (iter.hasNext()) { + Entry entry= (Entry) iter.next(); + store.firePropertyChangeEvent(source, (String) entry.getKey(), entry.getValue(), null); + } + } + protected Shell getShell() { return fShell; } @@ -169,7 +219,7 @@ public abstract class OptionsConfigurationBlock { checkBox.setLayoutData(gd); checkBox.addSelectionListener(getSelectionListener()); - String currValue= (String)fWorkingValues.get(key); + String currValue= (String)fWorkingValues.get(key); checkBox.setSelection(data.getSelection(currValue) == 0); fCheckBoxes.add(checkBox); @@ -250,7 +300,9 @@ public abstract class OptionsConfigurationBlock { fLabels.put(textBox, labelControl); String currValue= (String) fWorkingValues.get(key); - textBox.setText(currValue); + if (currValue != null) { + textBox.setText(currValue); + } textBox.addModifyListener(getTextModifyListener()); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL); @@ -334,7 +386,7 @@ public abstract class OptionsConfigurationBlock { public boolean performOk(boolean enabled) { - String[] allKeys= getAllKeys(); + String[] allKeys= fAllKeys; Map actualOptions= getOptions(false); // preserve other options @@ -345,7 +397,7 @@ public abstract class OptionsConfigurationBlock { String val= null; if (enabled) { val= (String) fWorkingValues.get(key); - if (!val.equals(oldVal)) { + if (val != null && !val.equals(oldVal)) { hasChanges= true; actualOptions.put(key, val); } @@ -372,7 +424,10 @@ public abstract class OptionsConfigurationBlock { } setOptions(actualOptions); if (doBuild) { - doFullBuild(); + boolean res= doFullBuild(); + if (!res) { + return false; + } } } return true; @@ -380,35 +435,41 @@ public abstract class OptionsConfigurationBlock { protected abstract String[] getFullBuildDialogStrings(boolean workspaceSettings); - protected void doFullBuild() { - ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell()); - try { - dialog.run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - monitor.beginTask("", 2); //$NON-NLS-1$ - try { - if (fProject != null) { - monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.buildproject.taskname", fProject.getElementName())); //$NON-NLS-1$ - fProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor,1)); - PHPeclipsePlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor,1)); - } else { - monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.buildall.taskname")); //$NON-NLS-1$ - PHPeclipsePlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor, 2)); - } - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); + protected boolean doFullBuild() { + + Job buildJob = new Job(PreferencesMessages.getString("OptionsConfigurationBlock.job.title")){ //$NON-NLS-1$ + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + try { + if (fProject != null) { + monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.buildproject.taskname", fProject.getElementName())); //$NON-NLS-1$ + fProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor,1)); + PHPeclipsePlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor,1)); + } else { + monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.buildall.taskname")); //$NON-NLS-1$ + PHPeclipsePlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor, 2)); } + } catch (CoreException e) { + return e.getStatus(); + } catch (OperationCanceledException e) { + return Status.CANCEL_STATUS; } - }); - } catch (InterruptedException e) { - // cancelled by user - } catch (InvocationTargetException e) { - String title= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.title"); //$NON-NLS-1$ - String message= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.message"); //$NON-NLS-1$ - ExceptionHandler.handle(e, getShell(), title, message); - } + finally { + monitor.done(); + } + return Status.OK_STATUS; + } + public boolean belongsTo(Object family) { + return ResourcesPlugin.FAMILY_MANUAL_BUILD == family; + } + }; + + buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); + buildJob.setUser(true); + buildJob.schedule(); + return true; } public void performDefaults() { @@ -420,24 +481,35 @@ public abstract class OptionsConfigurationBlock { protected void updateControls() { // update the UI for (int i= fCheckBoxes.size() - 1; i >= 0; i--) { - Button curr= (Button) fCheckBoxes.get(i); - ControlData data= (ControlData) curr.getData(); - - String currValue= (String) fWorkingValues.get(data.getKey()); - curr.setSelection(data.getSelection(currValue) == 0); + updateCheckBox((Button) fCheckBoxes.get(i)); } for (int i= fComboBoxes.size() - 1; i >= 0; i--) { - Combo curr= (Combo) fComboBoxes.get(i); - ControlData data= (ControlData) curr.getData(); - - String currValue= (String) fWorkingValues.get(data.getKey()); - curr.select(data.getSelection(currValue)); + updateCombo((Combo) fComboBoxes.get(i)); } for (int i= fTextBoxes.size() - 1; i >= 0; i--) { - Text curr= (Text) fTextBoxes.get(i); - String key= (String) curr.getData(); - - String currValue= (String) fWorkingValues.get(key); + updateText((Text) fTextBoxes.get(i)); + } + } + + protected void updateCombo(Combo curr) { + ControlData data= (ControlData) curr.getData(); + + String currValue= (String) fWorkingValues.get(data.getKey()); + curr.select(data.getSelection(currValue)); + } + + protected void updateCheckBox(Button curr) { + ControlData data= (ControlData) curr.getData(); + + String currValue= (String) fWorkingValues.get(data.getKey()); + curr.setSelection(data.getSelection(currValue) == 0); + } + + protected void updateText(Text curr) { + String key= (String) curr.getData(); + + String currValue= (String) fWorkingValues.get(key); + if (currValue != null) { curr.setText(currValue); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PHPEditorPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PHPEditorPreferencePage.java index 24fd75f..d0e75ad 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PHPEditorPreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PHPEditorPreferencePage.java @@ -20,6 +20,7 @@ import java.util.Iterator; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; + import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.internal.ui.PHPUIMessages; import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo; @@ -31,6 +32,7 @@ import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration; import net.sourceforge.phpeclipse.preferences.ColorEditor; + import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.preference.IPreferenceStore; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingConfigurationBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingConfigurationBlock.java new file mode 100644 index 0000000..169901a --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingConfigurationBlock.java @@ -0,0 +1,445 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.preferences; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.IStatus; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import org.eclipse.jface.preference.IPreferenceStore; + +import net.sourceforge.phpdt.core.IJavaProject; + +import net.sourceforge.phpdt.ui.PreferenceConstants; + +import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo; +import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil; +import net.sourceforge.phpdt.internal.ui.text.spelling.SpellCheckEngine; +import net.sourceforge.phpdt.internal.ui.util.PixelConverter; +import net.sourceforge.phpdt.internal.ui.util.SWTUtil; +import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener; + +/** + * Options configuration block for spell-check related settings. + * + * @since 3.0 + */ +public class SpellingConfigurationBlock extends OptionsConfigurationBlock { + + /** Preference keys for the preferences in this block */ + private static final String PREF_SPELLING_CHECK_SPELLING= PreferenceConstants.SPELLING_CHECK_SPELLING; + private static final String PREF_SPELLING_IGNORE_DIGITS= PreferenceConstants.SPELLING_IGNORE_DIGITS; + private static final String PREF_SPELLING_IGNORE_MIXED= PreferenceConstants.SPELLING_IGNORE_MIXED; + private static final String PREF_SPELLING_IGNORE_SENTENCE= PreferenceConstants.SPELLING_IGNORE_SENTENCE; + private static final String PREF_SPELLING_IGNORE_UPPER= PreferenceConstants.SPELLING_IGNORE_UPPER; + private static final String PREF_SPELLING_IGNORE_URLS= PreferenceConstants.SPELLING_IGNORE_URLS; + private static final String PREF_SPELLING_LOCALE= PreferenceConstants.SPELLING_LOCALE; + private static final String PREF_SPELLING_PROPOSAL_THRESHOLD= PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD; + private static final String PREF_SPELLING_USER_DICTIONARY= PreferenceConstants.SPELLING_USER_DICTIONARY; + private static final String PREF_SPELLING_ENABLE_CONTENTASSIST= PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST; + + /** + * Creates a selection dependency between a master and a slave control. + * + * @param master + * The master button that controls the state of the slave + * @param slave + * The slave control that is enabled only if the master is + * selected + */ + protected static void createSelectionDependency(final Button master, final Control slave) { + + master.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent event) { + // Do nothing + } + + public void widgetSelected(SelectionEvent event) { + slave.setEnabled(master.getSelection()); + } + }); + slave.setEnabled(master.getSelection()); + } + + /** + * Returns the locale codes for the locale list. + * + * @param locales + * The list of locales + * @return Array of locale codes for the list + */ + protected static String[] getDictionaryCodes(final Set locales) { + + int index= 0; + Locale locale= null; + + final String[] codes= new String[locales.size()]; + for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { + + locale= (Locale)iterator.next(); + codes[index++]= locale.toString(); + } + return codes; + } + + /** + * Returns the display labels for the locale list. + * + * @param locales + * The list of locales + * @return Array of display labels for the list + */ + protected static String[] getDictionaryLabels(final Set locales) { + + int index= 0; + Locale locale= null; + + final String[] labels= new String[locales.size()]; + for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { + + locale= (Locale)iterator.next(); + labels[index++]= locale.getDisplayName(SpellCheckEngine.getDefaultLocale()); + } + return labels; + } + + /** + * Validates that the file with the specified absolute path exists and can + * be opened. + * + * @param path + * The path of the file to validate + * @return true iff the file exists and can be opened, + * false otherwise + */ + protected static IStatus validateAbsoluteFilePath(final String path) { + + final StatusInfo status= new StatusInfo(); + if (path.length() > 0) { + + final File file= new File(path); + if (!file.isFile() || !file.isAbsolute() || !file.exists() || !file.canRead() || !file.canWrite()) + status.setError(PreferencesMessages.getString("SpellingPreferencePage.dictionary.error")); //$NON-NLS-1$ + + } + return status; + } + + /** + * Validates that the specified locale is available. + * + * @param locale + * The locale to validate + * @return The status of the validation + */ + protected static IStatus validateLocale(final String locale) { + + final StatusInfo status= new StatusInfo(IStatus.ERROR, PreferencesMessages.getString("SpellingPreferencePage.locale.error")); //$NON-NLS-1$ + final Set locales= SpellCheckEngine.getAvailableLocales(); + + Locale current= null; + for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { + + current= (Locale)iterator.next(); + if (current.toString().equals(locale)) + return new StatusInfo(); + } + return status; + } + + /** + * Validates that the specified number is positive. + * + * @param number + * The number to validate + * @return The status of the validation + */ + protected static IStatus validatePositiveNumber(final String number) { + + final StatusInfo status= new StatusInfo(); + if (number.length() == 0) { + status.setError(PreferencesMessages.getString("SpellingPreferencePage.empty_threshold")); //$NON-NLS-1$ + } else { + try { + final int value= Integer.parseInt(number); + if (value < 0) { + status.setError(PreferencesMessages.getFormattedString("SpellingPreferencePage.invalid_threshold", number)); //$NON-NLS-1$ + } + } catch (NumberFormatException exception) { + status.setError(PreferencesMessages.getFormattedString("SpellingPreferencePage.invalid_threshold", number)); //$NON-NLS-1$ + } + } + return status; + } + + /** The dictionary path field */ + private Text fDictionaryPath= null; + + /** The status for the workspace dictionary file */ + private IStatus fFileStatus= new StatusInfo(); + + /** The status for the platform locale */ + private IStatus fLocaleStatus= new StatusInfo(); + + /** The status for the proposal threshold */ + private IStatus fThresholdStatus= new StatusInfo(); + + /** + * Creates a new spelling configuration block. + * + * @param context + * The status change listener + * @param project + * The Java project + */ + public SpellingConfigurationBlock(final IStatusChangeListener context, final IJavaProject project) { + super(context, project, getAllKeys()); + + IStatus status= validateAbsoluteFilePath((String)fWorkingValues.get(PREF_SPELLING_USER_DICTIONARY)); + if (status.getSeverity() != IStatus.OK) + fWorkingValues.put(PREF_SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$ + + status= validateLocale((String)fWorkingValues.get(PREF_SPELLING_LOCALE)); + if (status.getSeverity() != IStatus.OK) + fWorkingValues.put(PREF_SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString()); + } + + protected Combo addComboBox(Composite parent, String label, String key, String[] values, String[] valueLabels, int indent) { + ControlData data= new ControlData(key, values); + + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= indent; + + Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP); + labelControl.setText(label); + labelControl.setLayoutData(gd); + + Combo comboBox= new Combo(parent, SWT.READ_ONLY); + comboBox.setItems(valueLabels); + comboBox.setData(data); + gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gd.horizontalSpan= 2; + comboBox.setLayoutData(gd); + comboBox.addSelectionListener(getSelectionListener()); + + fLabels.put(comboBox, labelControl); + + String currValue= (String)fWorkingValues.get(key); + comboBox.select(data.getSelection(currValue)); + + fComboBoxes.add(comboBox); + return comboBox; + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite) + */ + protected Control createContents(final Composite parent) { + + Composite composite= new Composite(parent, SWT.NONE); + GridLayout layout= new GridLayout(); layout.numColumns= 1; + composite.setLayout(layout); + + final PixelConverter converter= new PixelConverter(parent); + + layout= new GridLayout(); + layout.numColumns= 3; + + final String[] trueFalse= new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE }; + + Group user= new Group(composite, SWT.NONE); + user.setText(PreferencesMessages.getString("SpellingPreferencePage.preferences.user")); //$NON-NLS-1$ + user.setLayout(new GridLayout()); + user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + String label= PreferencesMessages.getString("SpellingPreferencePage.enable.label"); //$NON-NLS-1$ + final Button master= addCheckBox(user, label, PREF_SPELLING_CHECK_SPELLING, trueFalse, 0); + + label= PreferencesMessages.getString("SpellingPreferencePage.ignore.digits.label"); //$NON-NLS-1$ + Control slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 20); + createSelectionDependency(master, slave); + + label= PreferencesMessages.getString("SpellingPreferencePage.ignore.mixed.label"); //$NON-NLS-1$ + slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 20); + createSelectionDependency(master, slave); + + label= PreferencesMessages.getString("SpellingPreferencePage.ignore.sentence.label"); //$NON-NLS-1$ + slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 20); + createSelectionDependency(master, slave); + + label= PreferencesMessages.getString("SpellingPreferencePage.ignore.upper.label"); //$NON-NLS-1$ + slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 20); + createSelectionDependency(master, slave); + + label= PreferencesMessages.getString("SpellingPreferencePage.ignore.url.label"); //$NON-NLS-1$ + slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 20); + createSelectionDependency(master, slave); + + final Group engine= new Group(composite, SWT.NONE); + engine.setText(PreferencesMessages.getString("SpellingPreferencePage.preferences.engine")); //$NON-NLS-1$ + layout= new GridLayout(); + layout.numColumns= 4; + engine.setLayout(layout); + engine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + label= PreferencesMessages.getString("SpellingPreferencePage.dictionary.label"); //$NON-NLS-1$ + final Set locales= SpellCheckEngine.getAvailableLocales(); + + Combo combo= addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales), getDictionaryLabels(locales), 0); + combo.setEnabled(locales.size() > 1); + + new Label(engine, SWT.NONE); // placeholder + + label= PreferencesMessages.getString("SpellingPreferencePage.workspace.dictionary.label"); //$NON-NLS-1$ + fDictionaryPath= addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0); + + + Button button= new Button(engine, SWT.PUSH); + button.setText(PreferencesMessages.getString("SpellingPreferencePage.browse.label")); //$NON-NLS-1$ + button.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(final SelectionEvent event) { + handleBrowseButtonSelected(); + } + }); + button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + SWTUtil.setButtonDimensionHint(button); + + layout= new GridLayout(); + layout.numColumns= 3; + + Group advanced= new Group(composite, SWT.NONE); + advanced.setText(PreferencesMessages.getString("SpellingPreferencePage.preferences.advanced")); //$NON-NLS-1$ + layout= new GridLayout(); + layout.numColumns= 3; + advanced.setLayout(layout); + advanced.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + label= PreferencesMessages.getString("SpellingPreferencePage.proposals.threshold"); //$NON-NLS-1$ + Text text= addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0, 0); + text.setTextLimit(3); + GridData data= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + data.widthHint= converter.convertWidthInCharsToPixels(4); + text.setLayoutData(data); + + label= PreferencesMessages.getString("SpellingPreferencePage.enable.contentassist.label"); //$NON-NLS-1$ + addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0); + + return composite; + } + + private static String[] getAllKeys() { + return new String[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_CHECK_SPELLING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST }; + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getDefaultOptions() + */ + protected Map getDefaultOptions() { + + final String[] keys= fAllKeys; + final Map options= new HashMap(); + final IPreferenceStore store= PreferenceConstants.getPreferenceStore(); + + for (int index= 0; index < keys.length; index++) + options.put(keys[index], store.getDefaultString(keys[index])); + + return options; + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean) + */ + protected final String[] getFullBuildDialogStrings(final boolean workspace) { + return null; + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getOptions(boolean) + */ + protected Map getOptions(final boolean inherit) { + + final String[] keys= fAllKeys; + final Map options= new HashMap(); + final IPreferenceStore store= PreferenceConstants.getPreferenceStore(); + + for (int index= 0; index < keys.length; index++) + options.put(keys[index], store.getString(keys[index])); + + return options; + } + + /** + * Handles selections of the browse button. + */ + protected void handleBrowseButtonSelected() { + + final FileDialog dialog= new FileDialog(fDictionaryPath.getShell(), SWT.OPEN); + dialog.setText(PreferencesMessages.getString("SpellingPreferencePage.filedialog.title")); //$NON-NLS-1$ + dialog.setFilterExtensions(new String[] { PreferencesMessages.getString("SpellingPreferencePage.filter.dictionary.extension"), PreferencesMessages.getString("SpellingPreferencePage.filter.all.extension") }); //$NON-NLS-1$ //$NON-NLS-2$ + dialog.setFilterNames(new String[] { PreferencesMessages.getString("SpellingPreferencePage.filter.dictionary.label"), PreferencesMessages.getString("SpellingPreferencePage.filter.all.label") }); //$NON-NLS-1$ //$NON-NLS-2$ + + final String path= dialog.open(); + if (path != null) + fDictionaryPath.setText(path); + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#setOptions(java.util.Map) + */ + protected void setOptions(final Map options) { + + final String[] keys= fAllKeys; + final IPreferenceStore store= PreferenceConstants.getPreferenceStore(); + + for (int index= 0; index < keys.length; index++) + store.setValue(keys[index], (String)fWorkingValues.get(keys[index])); + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String,java.lang.String) + */ + protected void validateSettings(final String key, final String value) { + + if (key == null || PREF_SPELLING_PROPOSAL_THRESHOLD.equals(key)) + fThresholdStatus= validatePositiveNumber((String)fWorkingValues.get(PREF_SPELLING_PROPOSAL_THRESHOLD)); + + if (key == null || PREF_SPELLING_USER_DICTIONARY.equals(key)) + fFileStatus= validateAbsoluteFilePath((String)fWorkingValues.get(PREF_SPELLING_USER_DICTIONARY)); + + if (key == null || PREF_SPELLING_LOCALE.equals(key)) + fLocaleStatus= validateLocale((String)fWorkingValues.get(PREF_SPELLING_LOCALE)); + + fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fLocaleStatus })); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingPreferencePage.java new file mode 100644 index 0000000..3ab69b1 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/SpellingPreferencePage.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.preferences; + +import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds; +import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil; +import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.help.WorkbenchHelp; + +/** + * Preference page for spell checking preferences. + * + * @since 3.0 + */ +public class SpellingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IStatusChangeListener { + + /** The spelling configuration block */ + private final SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(this, null); + + /** + * Creates a new spelling preference page. + */ + public SpellingPreferencePage() { + + setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); + setDescription(PreferencesMessages.getString("SpellingPreferencePage.description")); //$NON-NLS-1$ + setTitle(PreferencesMessages.getString("SpellingPreferencePage.title")); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) + */ + protected Control createContents(final Composite parent) { + + final Control control= fBlock.createContents(parent); + Dialog.applyDialogFont(control); + + return control; + } + + /* + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(final Composite parent) { + super.createControl(parent); + WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE); + } + + /* + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(final IWorkbench workbench) { + // Do nothing + } + + /* + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + */ + protected void performDefaults() { + fBlock.performDefaults(); + + super.performDefaults(); + } + + /* + * @see org.eclipse.jface.preference.IPreferencePage#performOk() + */ + public boolean performOk() { + + if (!fBlock.performOk(true)) + return false; + + return super.performOk(); + } + + /* + * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus) + */ + public void statusChanged(final IStatus status) { + setValid(!status.matches(IStatus.ERROR)); + + StatusUtil.applyToStatusLine(this, status); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TodoTaskConfigurationBlock.java index 5931d52..2a0196c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TodoTaskConfigurationBlock.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TodoTaskConfigurationBlock.java @@ -104,7 +104,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { private ListDialogField fTodoTasksList; public TodoTaskConfigurationBlock(IStatusChangeListener context, IJavaProject project) { - super(context, project); + super(context, project, getKeys()); TaskTagAdapter adapter= new TaskTagAdapter(); String[] buttons= new String[] { @@ -134,7 +134,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { fTaskTagsStatus= new StatusInfo(); } - protected final String[] getAllKeys() { + private final static String[] getKeys() { return new String[] { PREF_COMPILER_TASK_TAGS, PREF_COMPILER_TASK_PRIORITIES }; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/CompositeReconcilingStrategy.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/CompositeReconcilingStrategy.java new file mode 100644 index 0000000..defb19c --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/CompositeReconcilingStrategy.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.internal.ui.text; + +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.reconciler.DirtyRegion; +import org.eclipse.jface.text.reconciler.IReconcilingStrategy; +import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; + +/** + * A reconciling strategy consisting of a sequence of internal reconciling strategies. + * By default, all requests are passed on to the contained strategies. + * + * @since 3.0 + */ +public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension { + + /** The list of internal reconciling strategies. */ + private IReconcilingStrategy[] fStrategies; + + /** + * Creates a new, empty composite reconciling strategy. + */ + public CompositeReconcilingStrategy() { + } + + /** + * Sets the reconciling strategies for this composite strategy. + * + * @param strategies the strategies to be set or null + */ + public void setReconcilingStrategies(IReconcilingStrategy[] strategies) { + fStrategies= strategies; + } + + /** + * Returns the previously set stratgies or null. + * + * @return the contained strategies or null + */ + public IReconcilingStrategy[] getReconcilingStrategies() { + return fStrategies; + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument) + */ + public void setDocument(IDocument document) { + if (fStrategies == null) + return; + + for (int i= 0; i < fStrategies.length; i++) + fStrategies[i].setDocument(document); + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion) + */ + public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { + if (fStrategies == null) + return; + + for (int i= 0; i < fStrategies.length; i++) + fStrategies[i].reconcile(dirtyRegion, subRegion); + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion) + */ + public void reconcile(IRegion partition) { + if (fStrategies == null) + return; + + for (int i= 0; i < fStrategies.length; i++) + fStrategies[i].reconcile(partition); + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) + */ + public void setProgressMonitor(IProgressMonitor monitor) { + if (fStrategies == null) + return; + + for (int i=0; i < fStrategies.length; i++) { + if (fStrategies[i] instanceof IReconcilingStrategyExtension) { + IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i]; + extension.setProgressMonitor(monitor); + } + } + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile() + */ + public void initialReconcile() { + if (fStrategies == null) + return; + + for (int i=0; i < fStrategies.length; i++) { + if (fStrategies[i] instanceof IReconcilingStrategyExtension) { + IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i]; + extension.initialReconcile(); + } + } + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/IInvocationContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/IInvocationContext.java new file mode 100644 index 0000000..fc45294 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/IInvocationContext.java @@ -0,0 +1,64 @@ + /******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.internal.ui.text.java; + +import net.sourceforge.phpdt.core.ICompilationUnit; +import net.sourceforge.phpdt.core.dom.CompilationUnit; + + +/** + * Context information for quick fix and quick assist processors. + *

+ * Note: this interface is not intended to be implemented. + *

+ * + * @since 3.0 + */ +public interface IInvocationContext { + + /** + * @return Returns the current compilation unit. + */ + ICompilationUnit getCompilationUnit(); + + /** + * @return Returns the offset of the current selection + */ + int getSelectionOffset(); + + /** + * @return Returns the length of the current selection + */ + int getSelectionLength(); + + /** + * Returns an AST of the compilation unit, possibly only a partial AST focused on the selection + * offset (see {@link org.eclipse.jdt.core.dom.ASTParser#setFocalPosition(int)}). + * The returned AST is shared and therefore protected and cannot be modified. + * The client must check the AST API level and do nothing if they are given an AST + * they can't handle. (see {@link org.eclipse.jdt.core.dom.AST#apiLevel()}). + * @return Returns the root of the AST corresponding to the current compilation unit. + */ + CompilationUnit getASTRoot(); + + /** + * Convenience method to evaluate the AST node covering the current selection. + * @return Returns the node that covers the location of the problem + */ +// ASTNode getCoveringNode(); + + /** + * Convenience method to evaluate the AST node that is covered by the current selection. + * @return Returns the node that is covered by the location of the problem + */ +// ASTNode getCoveredNode(); + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java index 410463d..e2820e6 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java @@ -25,14 +25,13 @@ import net.sourceforge.phpeclipse.phpeditor.EditorUtility; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IPluginDescriptor; -import org.eclipse.core.runtime.IPluginPrerequisite; -import org.eclipse.core.runtime.IPluginRegistry; +import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.jface.text.Assert; import org.eclipse.swt.SWT; +import org.osgi.framework.Bundle; /** * Describes a Java editor text hover. @@ -59,18 +58,16 @@ public class JavaEditorTextHoverDescriptor implements Comparable { private IConfigurationElement fElement; - /** * Returns all Java editor text hovers contributed to the workbench. */ public static JavaEditorTextHoverDescriptor[] getContributedHovers() { - IPluginRegistry registry= Platform.getPluginRegistry(); + IExtensionRegistry registry= Platform.getExtensionRegistry(); IConfigurationElement[] elements= registry.getConfigurationElementsFor(JAVA_EDITOR_TEXT_HOVER_EXTENSION_POINT); JavaEditorTextHoverDescriptor[] hoverDescs= createDescriptors(elements); initializeFromPreferences(hoverDescs); return hoverDescs; } - /** * Computes the state mask for the given modifier string. * @@ -107,7 +104,8 @@ public class JavaEditorTextHoverDescriptor implements Comparable { * Creates the Java editor text hover. */ public IJavaEditorTextHover createTextHover() { - boolean isHoversPlugInActivated= fElement.getDeclaringExtension().getDeclaringPluginDescriptor().isPluginActivated(); + String pluginId = fElement.getDeclaringExtension().getNamespace(); + boolean isHoversPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE; if (isHoversPlugInActivated || canActivatePlugIn()) { try { return (IJavaEditorTextHover)fElement.createExecutableExtension(CLASS_ATTRIBUTE); @@ -118,7 +116,6 @@ public class JavaEditorTextHoverDescriptor implements Comparable { return null; } - //---- XML Attribute accessors --------------------------------------------- /** @@ -183,35 +180,35 @@ public class JavaEditorTextHoverDescriptor implements Comparable { return Collator.getInstance().compare(getLabel(), ((JavaEditorTextHoverDescriptor)o).getLabel()); } - /** - * @param descriptor a JavaEditorTextHoverDescriptor - * @return true if this contributed hover depends on the other one - */ - public boolean dependsOn(JavaEditorTextHoverDescriptor descriptor) { - if (descriptor == null) - return false; - - IPluginDescriptor thisPluginDescriptor= fElement.getDeclaringExtension().getDeclaringPluginDescriptor(); - IPluginDescriptor otherPluginDescriptor= descriptor.fElement.getDeclaringExtension().getDeclaringPluginDescriptor(); - return dependsOn(thisPluginDescriptor, otherPluginDescriptor); - } - - private boolean dependsOn(IPluginDescriptor descriptor0, IPluginDescriptor descriptor1) { - - IPluginRegistry registry= Platform.getPluginRegistry(); - IPluginPrerequisite[] prerequisites= descriptor0.getPluginPrerequisites(); - - for (int i= 0; i < prerequisites.length; i++) { - IPluginPrerequisite prerequisite= prerequisites[i]; - String id= prerequisite.getUniqueIdentifier(); - IPluginDescriptor descriptor= registry.getPluginDescriptor(id); - - if (descriptor != null && (descriptor.equals(descriptor1) || dependsOn(descriptor, descriptor1))) - return true; - } - - return false; - } +// /** +// * @param descriptor a JavaEditorTextHoverDescriptor +// * @return true if this contributed hover depends on the other one +// */ +// public boolean dependsOn(JavaEditorTextHoverDescriptor descriptor) { +// if (descriptor == null) +// return false; +// +// IPluginDescriptor thisPluginDescriptor= fElement.getDeclaringExtension().getDeclaringPluginDescriptor(); +// IPluginDescriptor otherPluginDescriptor= descriptor.fElement.getDeclaringExtension().getDeclaringPluginDescriptor(); +// return dependsOn(thisPluginDescriptor, otherPluginDescriptor); +// } + +// private boolean dependsOn(IPluginDescriptor descriptor0, IPluginDescriptor descriptor1) { +// +// IPluginRegistry registry= Platform.getPluginRegistry(); +// IPluginPrerequisite[] prerequisites= descriptor0.getPluginPrerequisites(); +// +// for (int i= 0; i < prerequisites.length; i++) { +// IPluginPrerequisite prerequisite= prerequisites[i]; +// String id= prerequisite.getUniqueIdentifier(); +// IPluginDescriptor descriptor= registry.getPluginDescriptor(id); +// +// if (descriptor != null && (descriptor.equals(descriptor1) || dependsOn(descriptor, descriptor1))) +// return true; +// } +// +// return false; +// } private static JavaEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) { List result= new ArrayList(elements.length); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java index 7f455fe..b47befa 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java @@ -37,8 +37,6 @@ import org.eclipse.jface.text.ITextViewerExtension3; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextEvent; -import org.eclipse.jface.text.TextUtilities; -import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IHtmlTagConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IHtmlTagConstants.java new file mode 100644 index 0000000..31f1827 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IHtmlTagConstants.java @@ -0,0 +1,38 @@ +/***************************************************************************** + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *****************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.phpdoc; + +/** + * Html tag constants. + * + * @since 3.0 + */ +public interface IHtmlTagConstants { + + /** Html tag close prefix */ + public static final String HTML_CLOSE_PREFIX= "', ' ', '&', '^', '~', '\"' }; + + /** Html entity codes */ + public static final String[] HTML_ENTITY_CODES= new String[] { "<", ">", " ", "&", "ˆ", "˜", """ }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + + /** Html general tags */ + public static final String[] HTML_GENERAL_TAGS= new String[] { "b", "blockquote", "br", "code", "dd", "dl", "dt", "em", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "i", "li", "nl", "ol", "p", "pre", "q", "td", "th", "tr", "tt", "ul" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ + + /** Html tag postfix */ + public static final char HTML_TAG_POSTFIX= '>'; + + /** Html tag prefix */ + public static final char HTML_TAG_PREFIX= '<'; +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IJavaDocTagConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IJavaDocTagConstants.java new file mode 100644 index 0000000..eeaeda5 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/IJavaDocTagConstants.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *****************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.phpdoc; + +/** + * Javadoc tag constants. + * + * @since 3.0 + */ +public interface IJavaDocTagConstants { + + /** Javadoc break tags */ + public static final String[] JAVADOC_BREAK_TAGS= new String[] { "dd", "dt", "li", "td", "th", "tr", "h1", "h2", "h3", "h4", "h5", "h6", "q" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ + + /** Javadoc single break tag */ + public static final String[] JAVADOC_SINGLE_BREAK_TAG= new String[] { "br" }; //$NON-NLS-1$ + + /** Javadoc code tags */ + public static final String[] JAVADOC_CODE_TAGS= new String[] { "pre" }; //$NON-NLS-1$ + + /** Javadoc general tags */ + public static final String[] JAVADOC_GENERAL_TAGS= new String[] { "@author", "@deprecated", "@docRoot", "@exception", "@inheritDoc", "@link", "@linkplain", "@param", "@return", "@see", "@serial", "@serialData", "@serialField", "@since", "@throws", "@value", "@version" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ + + /** Javadoc immutable tags */ + public static final String[] JAVADOC_IMMUTABLE_TAGS= new String[] { "code", "em", "pre", "q", "tt" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + + /** Javadoc link tags */ + public static final String[] JAVADOC_LINK_TAGS= new String[] { "@docRoot", "@inheritDoc", "@link", "@linkplain" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + + /** Javadoc new line tags */ + public static final String[] JAVADOC_NEWLINE_TAGS= new String[] { "dd", "dt", "li", "td", "th", "tr", "h1", "h2", "h3", "h4", "h5", "h6", "q" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ + + /** Javadoc parameter tags */ + public static final String[] JAVADOC_PARAM_TAGS= new String[] { "@exception", "@param", "@serialField", "@throws" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + + /** Javadoc reference tags */ + public static final String[] JAVADOC_REFERENCE_TAGS= new String[] { "@see" }; //$NON-NLS-1$ + + /** Javadoc root tags */ + public static final String[] JAVADOC_ROOT_TAGS= new String[] { "@author", "@deprecated", "@return", "@see", "@serial", "@serialData", "@since", "@version", "@inheritDoc" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ + + /** Javadoc separator tags */ + public static final String[] JAVADOC_SEPARATOR_TAGS= new String[] { "dl", "hr", "nl", "p", "pre", "ul", "ol" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + + /** Javadoc tag prefix */ + public static final char JAVADOC_TAG_PREFIX= '@'; +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/AddWordProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/AddWordProposal.java new file mode 100644 index 0000000..3619060 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/AddWordProposal.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.text.MessageFormat; + +import net.sourceforge.phpdt.internal.ui.PHPUIMessages; +import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import net.sourceforge.phpdt.internal.ui.text.java.IInvocationContext; +import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckEngine; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellChecker; +import net.sourceforge.phpdt.ui.PreferenceConstants; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; + +/** + * Proposal to add the unknown word to the dictionaries. + * + * @since 3.0 + */ +public class AddWordProposal implements IPHPCompletionProposal { + + /** The invocation context */ + private final IInvocationContext fContext; + + /** The word to add */ + private final String fWord; + + /** + * Creates a new add word proposal + * + * @param word + * The word to add + * @param context + * The invocation context + */ + public AddWordProposal(final String word, final IInvocationContext context) { + fContext= context; + fWord= word; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument) + */ + public final void apply(final IDocument document) { + + final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); + final ISpellChecker checker= engine.createSpellChecker(engine.getLocale(), PreferenceConstants.getPreferenceStore()); + + if (checker != null) + checker.addWord(fWord); + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo() + */ + public String getAdditionalProposalInfo() { + return MessageFormat.format(PHPUIMessages.getString("Spelling.add.info"), new String[] { WordCorrectionProposal.getHtmlRepresentation(fWord)}); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation() + */ + public final IContextInformation getContextInformation() { + return null; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() + */ + public String getDisplayString() { + return MessageFormat.format(PHPUIMessages.getString("Spelling.add.label"), new String[] { fWord }); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage() + */ + public Image getImage() { + return PHPUiImages.get(PHPUiImages.IMG_CORRECTION_ADD); + } + + /* + * @see org.eclipse.jdt.ui.text.java.IJavaCompletionProposal#getRelevance() + */ + public int getRelevance() { + return Integer.MIN_VALUE; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument) + */ + public final Point getSelection(final IDocument document) { + return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength()); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/ChangeCaseProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/ChangeCaseProposal.java new file mode 100644 index 0000000..d83692d --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/ChangeCaseProposal.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.util.Locale; + +import net.sourceforge.phpdt.internal.ui.PHPUIMessages; +import net.sourceforge.phpdt.internal.ui.text.java.IInvocationContext; + + +/** + * Proposal to change the letter case of a word. + * + * @since 3.0 + */ +public class ChangeCaseProposal extends WordCorrectionProposal { + + /** + * Creates a new change case proposal. + * + * @param arguments + * The problem arguments associated with the spelling problem + * @param offset + * The offset in the document where to apply the proposal + * @param length + * The lenght in the document to apply the proposal + * @param context + * The invocation context for this proposal + * @param locale + * The locale to use for the case change + */ + public ChangeCaseProposal(final String[] arguments, final int offset, final int length, final IInvocationContext context, final Locale locale) { + super(Character.isLowerCase(arguments[0].charAt(0)) ? Character.toUpperCase(arguments[0].charAt(0)) + arguments[0].substring(1) : arguments[0], arguments, offset, length, context, Integer.MAX_VALUE); + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() + */ + public String getDisplayString() { + return PHPUIMessages.getString("Spelling.case.label"); //$NON-NLS-1$ + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/HtmlTagDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/HtmlTagDictionary.java new file mode 100644 index 0000000..5e8907f --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/HtmlTagDictionary.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.net.URL; + +import net.sourceforge.phpdt.internal.ui.text.phpdoc.IHtmlTagConstants; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.AbstractSpellDictionary; + + +/** + * Dictionary for html tags. + * + * @since 3.0 + */ +public class HtmlTagDictionary extends AbstractSpellDictionary implements IHtmlTagConstants { + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName() + */ + protected final URL getURL() { + return null; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary#isCorrect(java.lang.String) + */ + public boolean isCorrect(final String word) { + + if (word.charAt(0) == HTML_TAG_PREFIX) + return super.isCorrect(word); + + return false; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.AbstractSpellDictionary#load(java.net.URL) + */ + protected boolean load(final URL url) { + + unload(); + + for (int index= 0; index < HTML_GENERAL_TAGS.length; index++) { + + hashWord(HTML_TAG_PREFIX + HTML_GENERAL_TAGS[index] + HTML_TAG_POSTFIX); + hashWord(HTML_CLOSE_PREFIX + HTML_GENERAL_TAGS[index] + HTML_TAG_POSTFIX); + } + return true; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/JavaDocTagDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/JavaDocTagDictionary.java new file mode 100644 index 0000000..891d87b --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/JavaDocTagDictionary.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.net.URL; + +import net.sourceforge.phpdt.internal.ui.text.phpdoc.IJavaDocTagConstants; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.AbstractSpellDictionary; + + +/** + * Dictionary for Javadoc tags. + * + * @since 3.0 + */ +public class JavaDocTagDictionary extends AbstractSpellDictionary implements IJavaDocTagConstants { + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName() + */ + protected final URL getURL() { + return null; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary#isCorrect(java.lang.String) + */ + public boolean isCorrect(final String word) { + + if (word.charAt(0) == JAVADOC_TAG_PREFIX) + return super.isCorrect(word); + + return false; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.AbstractSpellDictionary#load(java.net.URL) + */ + protected boolean load(final URL url) { + + unload(); + + for (int index= 0; index < JAVADOC_LINK_TAGS.length; index++) + hashWord(JAVADOC_LINK_TAGS[index]); + + for (int index= 0; index < JAVADOC_ROOT_TAGS.length; index++) + hashWord(JAVADOC_ROOT_TAGS[index]); + + for (int index= 0; index < JAVADOC_PARAM_TAGS.length; index++) + hashWord(JAVADOC_PARAM_TAGS[index]); + + return true; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckEngine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckEngine.java new file mode 100644 index 0000000..4215576 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckEngine.java @@ -0,0 +1,338 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.phpdt.internal.ui.PHPUIMessages; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.DefaultSpellChecker; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckEngine; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckPreferenceKeys; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellChecker; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellDictionary; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.PersistentSpellDictionary; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; + + + +/** + * Spell check engine for Java source spell checking. + * + * @since 3.0 + */ +public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListener { + + /** The dictionary location */ + public static final String DICTIONARY_LOCATION= "dictionaries/"; //$NON-NLS-1$ + + /** The singleton spell checker instance */ + private static ISpellChecker fChecker= null; + + /** The singleton engine instance */ + private static ISpellCheckEngine fEngine= null; + + /** + * Returns the available locales for this spell check engine. + * + * @return The available locales for this engine + */ + public static Set getAvailableLocales() { + + URL url= null; + Locale locale= null; + InputStream stream= null; + + final Set result= new HashSet(); + try { + + final URL location= getDictionaryLocation(); + final Locale[] locales= Locale.getAvailableLocales(); + + for (int index= 0; index < locales.length; index++) { + + locale= locales[index]; + url= new URL(location, locale.toString().toLowerCase() + "." + PHPUIMessages.getString("Spelling.dictionary.file.extension")); //$NON-NLS-1$ //$NON-NLS-2$ + + try { + stream= url.openStream(); + if (stream != null) { + try { + result.add(locale); + } finally { + stream.close(); + } + } + } catch (IOException exception) { + // Do nothing + } + } + } catch (MalformedURLException exception) { + // Do nothing + } + result.add(getDefaultLocale()); + + return result; + } + + /** + * Returns the default locale for this engine. + * + * @return The default locale + */ + public static Locale getDefaultLocale() { + return Locale.US; + } + + /** + * Returns the dictionary location. + * + * @throws MalformedURLException + * if the URL could not be created + * @return The dictionary location, or null iff the location + * is not known + */ + public static URL getDictionaryLocation() throws MalformedURLException { + + final PHPeclipsePlugin plugin= PHPeclipsePlugin.getDefault(); + if (plugin != null) + return plugin.getBundle().getEntry("/" + DICTIONARY_LOCATION); //$NON-NLS-1$ + + return null; + } + + /** + * Returns the singleton instance of the spell check engine. + * + * @return The singleton instance of the spell check engine + */ + public static final synchronized ISpellCheckEngine getInstance() { + + if (fEngine == null) + fEngine= new SpellCheckEngine(); + + return fEngine; + } + + /** The registered locale insenitive dictionaries */ + private final Set fGlobalDictionaries= new HashSet(); + + /** The current locale */ + private Locale fLocale= null; + + /** The registered locale sensitive dictionaries */ + private final Map fLocaleDictionaries= new HashMap(); + + /** The preference store where to listen */ + private IPreferenceStore fPreferences= null; + + /** The user dictionary */ + private ISpellDictionary fUserDictionary= null; + + /** + * Creates a new spell check manager. + */ + private SpellCheckEngine() { + + fGlobalDictionaries.add(new TaskTagDictionary()); + fGlobalDictionaries.add(new HtmlTagDictionary()); + fGlobalDictionaries.add(new JavaDocTagDictionary()); + + try { + + Locale locale= null; + final URL location= getDictionaryLocation(); + + for (final Iterator iterator= getAvailableLocales().iterator(); iterator.hasNext();) { + + locale= (Locale)iterator.next(); + fLocaleDictionaries.put(locale, new SpellReconcileDictionary(locale, location)); + } + + } catch (MalformedURLException exception) { + // Do nothing + } + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#createSpellChecker(java.util.Locale,org.eclipse.jface.preference.IPreferenceStore) + */ + public final synchronized ISpellChecker createSpellChecker(final Locale locale, final IPreferenceStore store) { + + if (fLocale != null && fLocale.equals(locale)) + return fChecker; + + if (fChecker == null) { + + fChecker= new DefaultSpellChecker(store); + store.addPropertyChangeListener(this); + + fPreferences= store; + + ISpellDictionary dictionary= null; + for (Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) { + + dictionary= (ISpellDictionary)iterator.next(); + fChecker.addDictionary(dictionary); + } + } + + ISpellDictionary dictionary= null; + if (fLocale != null) { + + dictionary= (ISpellDictionary)fLocaleDictionaries.get(fLocale); + if (dictionary != null) { + + fChecker.removeDictionary(dictionary); + dictionary.unload(); + } + } + fLocale= locale; + + dictionary= (ISpellDictionary)fLocaleDictionaries.get(locale); + if (dictionary == null) { + + if (!getDefaultLocale().equals(locale)) { + + if (fPreferences != null) + fPreferences.removePropertyChangeListener(this); + + fChecker= null; + fLocale= null; + } + + } else + fChecker.addDictionary(dictionary); + + if (fPreferences != null) + propertyChange(new PropertyChangeEvent(this, ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY, null, fPreferences.getString(ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY))); + + return fChecker; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#getLocale() + */ + public final Locale getLocale() { + return fLocale; + } + + /* + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public final void propertyChange(final PropertyChangeEvent event) { + + if (fChecker != null && event.getProperty().equals(ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY)) { + + if (fUserDictionary != null) { + + fChecker.removeDictionary(fUserDictionary); + fUserDictionary= null; + } + + final String file= (String)event.getNewValue(); + if (file.length() > 0) { + + try { + + final URL url= new URL("file", null, file); //$NON-NLS-1$ + InputStream stream= url.openStream(); + if (stream != null) { + try { + fUserDictionary= new PersistentSpellDictionary(url); + fChecker.addDictionary(fUserDictionary); + } finally { + stream.close(); + } + } + } catch (MalformedURLException exception) { + // Do nothing + } catch (IOException exception) { + // Do nothing + } + } + } + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary) + */ + public synchronized final void registerDictionary(final ISpellDictionary dictionary) { + + fGlobalDictionaries.add(dictionary); + + if (fChecker != null) + fChecker.addDictionary(dictionary); + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(java.util.Locale,org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary) + */ + public synchronized final void registerDictionary(final Locale locale, final ISpellDictionary dictionary) { + + fLocaleDictionaries.put(locale, dictionary); + + if (fChecker != null && fLocale != null && fLocale.equals(locale)) + fChecker.addDictionary(dictionary); + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#unload() + */ + public synchronized final void unload() { + + ISpellDictionary dictionary= null; + for (final Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) { + + dictionary= (ISpellDictionary)iterator.next(); + dictionary.unload(); + } + + for (final Iterator iterator= fLocaleDictionaries.values().iterator(); iterator.hasNext();) { + + dictionary= (ISpellDictionary)iterator.next(); + dictionary.unload(); + } + + if (fPreferences != null) + fPreferences.removePropertyChangeListener(this); + + fUserDictionary= null; + fChecker= null; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#unregisterDictionary(org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary) + */ + public synchronized final void unregisterDictionary(final ISpellDictionary dictionary) { + + fGlobalDictionaries.remove(dictionary); + fLocaleDictionaries.values().remove(dictionary); + + if (fChecker != null) + fChecker.removeDictionary(dictionary); + + dictionary.unload(); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckIterator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckIterator.java new file mode 100644 index 0000000..f420cd7 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellCheckIterator.java @@ -0,0 +1,378 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.text.BreakIterator; +import java.util.LinkedList; +import java.util.Locale; + +import net.sourceforge.phpdt.corext.refactoring.nls.NLSElement; +import net.sourceforge.phpdt.internal.ui.text.phpdoc.IHtmlTagConstants; +import net.sourceforge.phpdt.internal.ui.text.phpdoc.IJavaDocTagConstants; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.DefaultSpellChecker; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckIterator; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.TextUtilities; + +/** + * Iterator to spell-check javadoc comment regions. + * + * @since 3.0 + */ +public class SpellCheckIterator implements ISpellCheckIterator, IJavaDocTagConstants, IHtmlTagConstants { + + /** The content of the region */ + private final String fContent; + + /** The line delimiter */ + private final String fDelimiter; + + /** The last token */ + private String fLastToken= null; + + /** The next break */ + private int fNext= 1; + + /** The offset of the region */ + private final int fOffset; + + /** The predecessor break */ + private int fPredecessor; + + /** The previous break */ + private int fPrevious= 0; + + /** The sentence breaks */ + private final LinkedList fSentenceBreaks= new LinkedList(); + + /** Does the current word start a sentence? */ + private boolean fStartsSentence= false; + + /** The successor break */ + private int fSuccessor; + + /** The word iterator */ + private final BreakIterator fWordIterator; + + /** + * Creates a new spell check iterator. + * + * @param document + * The document containing the specified partition + * @param region + * The region to spell-check + * @param locale + * The locale to use for spell-checking + */ + public SpellCheckIterator(final IDocument document, final IRegion region, final Locale locale) { + + fOffset= region.getOffset(); + fWordIterator= BreakIterator.getWordInstance(locale); + fDelimiter= TextUtilities.getDefaultLineDelimiter(document); + + String content; + try { + + content= document.get(region.getOffset(), region.getLength()); + if (content.startsWith(NLSElement.TAG_PREFIX)) + content= ""; //$NON-NLS-1$ + + } catch (Exception exception) { + content= ""; //$NON-NLS-1$ + } + fContent= content; + + fWordIterator.setText(content); + fPredecessor= fWordIterator.first(); + fSuccessor= fWordIterator.next(); + + final BreakIterator iterator= BreakIterator.getSentenceInstance(locale); + iterator.setText(content); + + int offset= iterator.current(); + while (offset != BreakIterator.DONE) { + + fSentenceBreaks.add(new Integer(offset)); + offset= iterator.next(); + } + } + + /* + * @see org.eclipse.spelling.done.ISpellCheckIterator#getBegin() + */ + public final int getBegin() { + return fPrevious + fOffset; + } + + /* + * @see org.eclipse.spelling.done.ISpellCheckIterator#getEnd() + */ + public final int getEnd() { + return fNext + fOffset - 1; + } + + /* + * @see java.util.Iterator#hasNext() + */ + public final boolean hasNext() { + return fSuccessor != BreakIterator.DONE; + } + + /** + * Does the specified token consist of at least one letter and digits only? + * + * @param begin + * The begin index + * @param end + * The end index + * @return true iff the token consists of digits and at + * least one letter only, false otherwise + */ + protected final boolean isAlphaNumeric(final int begin, final int end) { + + char character= 0; + + boolean letter= false; + for (int index= begin; index < end; index++) { + + character= fContent.charAt(index); + if (Character.isLetter(character)) + letter= true; + + if (!Character.isLetterOrDigit(character)) + return false; + } + return letter; + } + + /** + * Was the last token a Javadoc tag tag? + * + * @param tags + * The javadoc tags to check + * @return true iff the last token was a Javadoc tag, false + * otherwise + */ + protected final boolean isJavadocToken(final String[] tags) { + + if (fLastToken != null) { + + for (int index= 0; index < tags.length; index++) { + + if (fLastToken.equals(tags[index])) + return true; + } + } + return false; + } + + /** + * Is the current token a single letter token surrounded by non-whitespace + * characters? + * + * @param begin + * The begin index + * @return true iff the token is a single letter token, + * false otherwise + */ + protected final boolean isSingleLetter(final int begin) { + + if (begin > 0 && begin < fContent.length() - 1) + return Character.isWhitespace(fContent.charAt(begin - 1)) && Character.isLetter(fContent.charAt(begin)) && Character.isWhitespace(fContent.charAt(begin + 1)); + + return false; + } + + /** + * Does the specified token look like an URL? + * + * @param begin + * The begin index + * @return true iff this token look like an URL, false + * otherwise + */ + protected final boolean isUrlToken(final int begin) { + + for (int index= 0; index < DefaultSpellChecker.URL_PREFIXES.length; index++) { + + if (fContent.startsWith(DefaultSpellChecker.URL_PREFIXES[index], begin)) + return true; + } + return false; + } + + /** + * Does the specified token consist of whitespace only? + * + * @param begin + * The begin index + * @param end + * The end index + * @return true iff the token consists of whitespace only, + * false otherwise + */ + protected final boolean isWhitespace(final int begin, final int end) { + + for (int index= begin; index < end; index++) { + + if (!Character.isWhitespace(fContent.charAt(index))) + return false; + } + return true; + } + + /* + * @see java.util.Iterator#next() + */ + public final Object next() { + + String token= nextToken(); + while (token == null && fSuccessor != BreakIterator.DONE) + token= nextToken(); + + fLastToken= token; + + return token; + } + + /** + * Advances the end index to the next word break. + */ + protected final void nextBreak() { + + fNext= fSuccessor; + fPredecessor= fSuccessor; + + fSuccessor= fWordIterator.next(); + } + + /** + * Returns the next sentence break. + * + * @return The next sentence break + */ + protected final int nextSentence() { + return ((Integer) fSentenceBreaks.getFirst()).intValue(); + } + + /** + * Determines the next token to be spell-checked. + * + * @return The next token to be spell-checked, or null iff + * the next token is not a candidate for spell-checking. + */ + protected String nextToken() { + + String token= null; + + fPrevious= fPredecessor; + fStartsSentence= false; + + nextBreak(); + + boolean update= false; + if (fNext - fPrevious > 0) { + + if (fSuccessor != BreakIterator.DONE && fContent.charAt(fPrevious) == JAVADOC_TAG_PREFIX) { + + nextBreak(); + if (Character.isLetter(fContent.charAt(fPrevious + 1))) { + update= true; + token= fContent.substring(fPrevious, fNext); + } else + fPredecessor= fNext; + + } else if (fSuccessor != BreakIterator.DONE && fContent.charAt(fPrevious) == HTML_TAG_PREFIX && (Character.isLetter(fContent.charAt(fNext)) || fContent.charAt(fNext) == '/')) { + + if (fContent.startsWith(HTML_CLOSE_PREFIX, fPrevious)) + nextBreak(); + + nextBreak(); + + if (fSuccessor != BreakIterator.DONE && fContent.charAt(fNext) == HTML_TAG_POSTFIX) { + + nextBreak(); + if (fSuccessor != BreakIterator.DONE) { + update= true; + token= fContent.substring(fPrevious, fNext); + } + } + } else if (!isWhitespace(fPrevious, fNext) && isAlphaNumeric(fPrevious, fNext)) { + + if (isUrlToken(fPrevious)) + skipTokens(fPrevious, ' '); + else if (isJavadocToken(JAVADOC_PARAM_TAGS)) + fLastToken= null; + else if (isJavadocToken(JAVADOC_REFERENCE_TAGS)) { + fLastToken= null; + skipTokens(fPrevious, fDelimiter.charAt(0)); + } else if (fNext - fPrevious > 1 || isSingleLetter(fPrevious)) + token= fContent.substring(fPrevious, fNext); + + update= true; + } + } + + if (update && fSentenceBreaks.size() > 0) { + + if (fPrevious >= nextSentence()) { + + while (fSentenceBreaks.size() > 0 && fPrevious >= nextSentence()) + fSentenceBreaks.removeFirst(); + + fStartsSentence= (fLastToken == null) || (token != null); + } + } + return token; + } + + /* + * @see java.util.Iterator#remove() + */ + public final void remove() { + throw new UnsupportedOperationException(); + } + + /** + * Skip the tokens until the stop character is reached. + * + * @param begin + * The begin index + * @param stop + * The stop character + */ + protected final void skipTokens(final int begin, final char stop) { + + int end= begin; + + while (end < fContent.length() && fContent.charAt(end) != stop) + end++; + + if (end < fContent.length()) { + + fNext= end; + fPredecessor= fNext; + + fSuccessor= fWordIterator.following(fNext); + } else + fSuccessor= BreakIterator.DONE; + } + + /* + * @see org.eclipse.spelling.done.ISpellCheckIterator#startsSentence() + */ + public final boolean startsSentence() { + return fStartsSentence; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileDictionary.java new file mode 100644 index 0000000..b19b0c4 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileDictionary.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.net.URL; +import java.util.Locale; + +import net.sourceforge.phpdt.internal.ui.text.phpdoc.IHtmlTagConstants; +import net.sourceforge.phpdt.internal.ui.text.phpdoc.IJavaDocTagConstants; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.LocaleSensitiveSpellDictionary; + + +/** + * Dictionary used by the spell reconciling strategy. + * + * @since 3.0 + */ +public class SpellReconcileDictionary extends LocaleSensitiveSpellDictionary implements IJavaDocTagConstants, IHtmlTagConstants { + + /** + * Creates a new locale sensitive spell dictionary. + * + * @param locale + * The locale for this dictionary + * @param location + * The location of the locale sensitive dictionaries + */ + public SpellReconcileDictionary(final Locale locale, final URL location) { + super(locale, location); + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary#isCorrect(java.lang.String) + */ + public boolean isCorrect(final String word) { + + final char character= word.charAt(0); + if (character != JAVADOC_TAG_PREFIX && character != HTML_TAG_PREFIX) + return super.isCorrect(word); + + return false; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileStrategy.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileStrategy.java new file mode 100644 index 0000000..b77b767 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/SpellReconcileStrategy.java @@ -0,0 +1,382 @@ +/***************************************************************************** + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *****************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.text.MessageFormat; +import java.util.Locale; + +import net.sourceforge.phpdt.core.IProblemRequestor; +import net.sourceforge.phpdt.core.compiler.IProblem; +import net.sourceforge.phpdt.internal.ui.PHPUIMessages; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckEngine; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckPreferenceKeys; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellChecker; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEventListener; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITypedRegion; +import org.eclipse.jface.text.TextUtilities; +import org.eclipse.jface.text.reconciler.DirtyRegion; +import org.eclipse.jface.text.reconciler.IReconcilingStrategy; +import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; +import org.eclipse.jface.text.source.IAnnotationModel; +import org.eclipse.ui.texteditor.ITextEditor; + +/** + * Reconcile strategy to spell-check comments. + * + * @since 3.0 + */ +public class SpellReconcileStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension, ISpellEventListener { + + /** + * Spelling problem to be accepted by problem requestors. + */ + public class SpellProblem implements IProblem { + + /** The id of the problem */ + public static final int Spelling= 0x80000000; + + /** The end offset of the problem */ + private int fEnd= 0; + + /** The line number of the problem */ + private int fLine= 1; + + /** Was the word found in the dictionary? */ + private boolean fMatch; + + /** Does the word start a new sentence? */ + private boolean fSentence= false; + + /** The start offset of the problem */ + private int fStart= 0; + + /** The word which caused the problem */ + private final String fWord; + + /** + * Creates a new spelling problem + * + * @param word + * The word which caused the problem + */ + protected SpellProblem(final String word) { + fWord= word; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#getArguments() + */ + public String[] getArguments() { + + String prefix= ""; //$NON-NLS-1$ + String postfix= ""; //$NON-NLS-1$ + + try { + + final IRegion line= fDocument.getLineInformationOfOffset(fStart); + + prefix= fDocument.get(line.getOffset(), fStart - line.getOffset()); + postfix= fDocument.get(fEnd + 1, line.getOffset() + line.getLength() - fEnd); + + } catch (BadLocationException exception) { + // Do nothing + } + return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false)}; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#getID() + */ + public int getID() { + return Spelling; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#getMessage() + */ + public String getMessage() { + + if (fSentence && fMatch) + return MessageFormat.format(PHPUIMessages.getString("Spelling.error.case.label"), new String[] { fWord }); //$NON-NLS-1$ + + return MessageFormat.format(PHPUIMessages.getString("Spelling.error.label"), new String[] { fWord }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#getOriginatingFileName() + */ + public char[] getOriginatingFileName() { + return fEditor.getEditorInput().getName().toCharArray(); + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#getSourceEnd() + */ + public final int getSourceEnd() { + return fEnd; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#getSourceLineNumber() + */ + public final int getSourceLineNumber() { + return fLine; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#getSourceStart() + */ + public final int getSourceStart() { + return fStart; + } + + /** + * Was the problem word found in the dictionary? + * + * @return true iff the word was found, false + * otherwise + */ + public final boolean isDictionaryMatch() { + return fMatch; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#isError() + */ + public final boolean isError() { + return false; + } + + /** + * Does the problem word start a new sentence? + * + * @return true iff it starts a new sentence, false + * otherwise + */ + public final boolean isSentenceStart() { + return fSentence; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#isWarning() + */ + public final boolean isWarning() { + return true; + } + + /** + * Sets whether the problem word was found in the dictionary. + * + * @param match + * true iff the word was found, false + * otherwise + */ + public final void setDictionaryMatch(final boolean match) { + fMatch= match; + } + + /** + * Sets whether the problem word starts a new sentence. + * + * @param sentence + * true iff the word starts a new sentence, + * false otherwise. + */ + public final void setSentenceStart(final boolean sentence) { + fSentence= sentence; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#setSourceEnd(int) + */ + public final void setSourceEnd(final int end) { + fEnd= end; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#setSourceLineNumber(int) + */ + public final void setSourceLineNumber(final int line) { + fLine= line; + } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#setSourceStart(int) + */ + public final void setSourceStart(final int start) { + fStart= start; + } + } + + /** The document to operate on */ + private IDocument fDocument= null; + + /** The text editor to operate on */ + private final ITextEditor fEditor; + + /** The current locale */ + private Locale fLocale= SpellCheckEngine.getDefaultLocale(); + + /** The partitioning of the document */ + private final String fPartitioning; + + /** The preference store to use */ + private final IPreferenceStore fPreferences; + + /** The problem requestor */ + private IProblemRequestor fRequestor; + + /** + * Creates a new comment reconcile strategy. + * + * @param editor + * The text editor to operate on + * @param partitioning + * The partitioning of the document + * @param store + * The preference store to get the preferences from + */ + public SpellReconcileStrategy(final ITextEditor editor, final String partitioning, final IPreferenceStore store) { + fEditor= editor; + fPartitioning= partitioning; + fPreferences= store; + + updateProblemRequestor(); + } + + /** + * Returns the current locale of the spell checking preferences. + * + * @return The current locale of the spell checking preferences + */ + public Locale getLocale() { + + final String locale= fPreferences.getString(ISpellCheckPreferenceKeys.SPELLING_LOCALE); + if (locale.equals(fLocale.toString())) + return fLocale; + + if (locale.length() >= 5) + return new Locale(locale.substring(0, 2), locale.substring(3, 5)); + + return SpellCheckEngine.getDefaultLocale(); + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEventListener#handle(org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent) + */ + public void handle(final ISpellEvent event) { + + if (fRequestor != null) { + + final SpellProblem problem= new SpellProblem(event.getWord()); + + problem.setSourceStart(event.getBegin()); + problem.setSourceEnd(event.getEnd()); + problem.setSentenceStart(event.isStart()); + problem.setDictionaryMatch(event.isMatch()); + + try { + problem.setSourceLineNumber(fDocument.getLineOfOffset(event.getBegin()) + 1); + } catch (BadLocationException x) { + // Do nothing + } + + fRequestor.acceptProblem(problem); + } + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile() + */ + public void initialReconcile() { + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion,org.eclipse.jface.text.IRegion) + */ + public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) { + reconcile(subRegion); + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion) + */ + public void reconcile(final IRegion region) { + + if (fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_CHECK_SPELLING) && fRequestor != null) { + + try { + + fRequestor.beginReporting(); + + ITypedRegion partition= null; + final ITypedRegion[] partitions= TextUtilities.computePartitioning(fDocument, fPartitioning, 0, fDocument.getLength(), false); + + final Locale locale= getLocale(); + final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); + + final ISpellChecker checker= engine.createSpellChecker(locale, fPreferences); + if (checker != null) { + try { + checker.addListener(this); + + for (int index= 0; index < partitions.length; index++) { + partition= partitions[index]; + if (!partition.getType().equals(IDocument.DEFAULT_CONTENT_TYPE)) + checker.execute(new SpellCheckIterator(fDocument, partition, locale)); + } + + } finally { + checker.removeListener(this); + } + } + } catch (BadLocationException exception) { + // Do nothing + } finally { + fRequestor.endReporting(); + } + } + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument) + */ + public final void setDocument(final IDocument document) { + fDocument= document; + + updateProblemRequestor(); + } + + /* + * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) + */ + public final void setProgressMonitor(final IProgressMonitor monitor) { + // Do nothing + } + + /** + * Update the problem requestor based on the current editor + * + * @since 3.0 + */ + private void updateProblemRequestor() { + final IAnnotationModel model= fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput()); + fRequestor= (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/TaskTagDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/TaskTagDictionary.java new file mode 100644 index 0000000..92b1ef5 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/TaskTagDictionary.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.net.URL; +import java.util.StringTokenizer; + +import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.AbstractSpellDictionary; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; +import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; + +/** + * Dictionary for task tags. + * + * @since 3.0 + */ +public class TaskTagDictionary extends AbstractSpellDictionary implements IPropertyChangeListener { + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName() + */ + protected final URL getURL() { + return null; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.AbstractSpellDictionary#load(java.net.URL) + */ + protected boolean load(final URL url) { + + final Plugin plugin= JavaCore.getPlugin(); + if (plugin != null) { + + plugin.getPluginPreferences().addPropertyChangeListener(this); + return updateTaskTags(); + } + return false; + } + + /* + * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) + */ + public void propertyChange(final PropertyChangeEvent event) { + + if (JavaCore.COMPILER_TASK_TAGS.equals(event.getProperty())) + updateTaskTags(); + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary#unload() + */ + public void unload() { + + final Plugin plugin= JavaCore.getPlugin(); + if (plugin != null) + plugin.getPluginPreferences().removePropertyChangeListener(this); + + super.unload(); + } + + /** + * Handles the compiler task tags property change event. + */ + protected boolean updateTaskTags() { + + final String tags= JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS); + if (tags != null) { + + unload(); + + final StringTokenizer tokenizer= new StringTokenizer(tags, ","); //$NON-NLS-1$ + while (tokenizer.hasMoreTokens()) + hashWord(tokenizer.nextToken()); + + return true; + } + return false; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordCorrectionProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordCorrectionProposal.java new file mode 100644 index 0000000..6d0d4ad --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordCorrectionProposal.java @@ -0,0 +1,182 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.text.MessageFormat; + +import net.sourceforge.phpdt.internal.ui.PHPUIMessages; +import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import net.sourceforge.phpdt.internal.ui.text.java.IInvocationContext; +import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal; +import net.sourceforge.phpdt.internal.ui.text.phpdoc.IHtmlTagConstants; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; + +/** + * Proposal to correct the incorrectly spelled word. + * + * @since 3.0 + */ +public class WordCorrectionProposal implements IPHPCompletionProposal, IHtmlTagConstants { + + /** + * Returns the html representation of the specified string. + * + * @param string + * The string to return the html representation for + * @return The html representation for the string + */ + public static String getHtmlRepresentation(final String string) { + + final int length= string.length(); + final StringBuffer buffer= new StringBuffer(string); + + for (int offset= length - 1; offset >= 0; offset--) { + + for (int index= 0; index < HTML_ENTITY_CHARACTERS.length; index++) { + + if (string.charAt(offset) == HTML_ENTITY_CHARACTERS[index]) { + + buffer.replace(offset, offset + 1, String.valueOf(HTML_ENTITY_CODES[index])); + break; + } + } + } + return buffer.toString(); + } + + /** The invocation context */ + private final IInvocationContext fContext; + + /** The length in the document */ + private final int fLength; + + /** The line where to apply the correction */ + private final String fLine; + + /** The offset in the document */ + private final int fOffset; + + /** The relevance of this proposal */ + private final int fRelevance; + + /** The word to complete */ + private final String fWord; + + /** + * Creates a new word correction proposal. + * + * @param word + * The corrected word + * @param arguments + * The problem arguments associated with the spelling problem + * @param offset + * The offset in the document where to apply the proposal + * @param length + * The lenght in the document to apply the proposal + * @param context + * The invocation context for this proposal + * @param relevance + * The relevance of this proposal + */ + public WordCorrectionProposal(final String word, final String[] arguments, final int offset, final int length, final IInvocationContext context, final int relevance) { + + fWord= Character.isUpperCase(arguments[0].charAt(0)) ? Character.toUpperCase(word.charAt(0)) + word.substring(1) : word; + + fOffset= offset; + fLength= length; + fContext= context; + fRelevance= relevance; + + final StringBuffer buffer= new StringBuffer(80); + + buffer.append("...
"); //$NON-NLS-1$ + buffer.append(getHtmlRepresentation(arguments[1])); + buffer.append(""); //$NON-NLS-1$ + buffer.append(getHtmlRepresentation(fWord)); + buffer.append(""); //$NON-NLS-1$ + buffer.append(getHtmlRepresentation(arguments[2])); + buffer.append("
..."); //$NON-NLS-1$ + + fLine= buffer.toString(); + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument) + */ + public final void apply(final IDocument document) { + try { + document.replace(fOffset, fLength, fWord); + } catch (BadLocationException exception) { + // Do nothing + } + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo() + */ + public String getAdditionalProposalInfo() { + return fLine; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation() + */ + public final IContextInformation getContextInformation() { + return null; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() + */ + public String getDisplayString() { + return MessageFormat.format(PHPUIMessages.getString("Spelling.correct.label"), new String[] { fWord }); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage() + */ + public Image getImage() { + return PHPUiImages.get(PHPUiImages.IMG_CORRECTION_RENAME); + } + + /* + * @see org.eclipse.jdt.ui.text.java.IJavaCompletionProposal#getRelevance() + */ + public final int getRelevance() { + return fRelevance; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument) + */ + public final Point getSelection(final IDocument document) { + + int offset= fContext.getSelectionOffset(); + int length= fContext.getSelectionLength(); + + final int delta= fWord.length() - fLength; + if (offset <= fOffset && offset + length >= fOffset) + length += delta; + else if (offset > fOffset && offset + length > fOffset + fLength) { + offset += delta; + length -= delta; + } else + length += delta; + + return new Point(offset, length); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordIgnoreProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordIgnoreProposal.java new file mode 100644 index 0000000..a8cfbf0 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/WordIgnoreProposal.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling; + +import java.text.MessageFormat; + +import net.sourceforge.phpdt.internal.ui.PHPUIMessages; +import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import net.sourceforge.phpdt.internal.ui.text.java.IInvocationContext; +import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckEngine; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellChecker; +import net.sourceforge.phpdt.ui.PreferenceConstants; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; + +/** + * Proposal to ignore the word during the current editing session. + * + * @since 3.0 + */ +public class WordIgnoreProposal implements IPHPCompletionProposal { + + /** The invocation context */ + private IInvocationContext fContext; + + /** The word to ignore */ + private String fWord; + + /** + * Creates a new spell ignore proposal. + * + * @param word + * The word to ignore + * @param context + * The invocation context + */ + public WordIgnoreProposal(final String word, final IInvocationContext context) { + fWord= word; + fContext= context; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument) + */ + public final void apply(final IDocument document) { + + final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); + final ISpellChecker checker= engine.createSpellChecker(engine.getLocale(), PreferenceConstants.getPreferenceStore()); + + if (checker != null) + checker.ignoreWord(fWord); + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo() + */ + public String getAdditionalProposalInfo() { + return MessageFormat.format(PHPUIMessages.getString("Spelling.ignore.info"), new String[] { WordCorrectionProposal.getHtmlRepresentation(fWord)}); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation() + */ + public final IContextInformation getContextInformation() { + return null; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() + */ + public String getDisplayString() { + return MessageFormat.format(PHPUIMessages.getString("Spelling.ignore.label"), new String[] { fWord }); //$NON-NLS-1$ + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage() + */ + public Image getImage() { + return PHPUiImages.get(PHPUiImages.IMG_OBJS_NLS_NEVER_TRANSLATE); + } + /* + * @see org.eclipse.jdt.ui.text.java.IJavaCompletionProposal#getRelevance() + */ + public final int getRelevance() { + return Integer.MIN_VALUE + 1; + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument) + */ + public final Point getSelection(final IDocument document) { + return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength()); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java new file mode 100644 index 0000000..d15172a --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java @@ -0,0 +1,433 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Partial implementation of a spell dictionary. + * + * @since 3.0 + */ +public abstract class AbstractSpellDictionary implements ISpellDictionary { + + /** The bucket capacity */ + protected static final int BUCKET_CAPACITY= 4; + + /** The word buffer capacity */ + protected static final int BUFFER_CAPACITY= 32; + + /** The distance threshold */ + protected static final int DISTANCE_THRESHOLD= 160; + + /** The hash capacity */ + protected static final int HASH_CAPACITY= 22 * 1024; + + /** The phonetic distance algorithm */ + private IPhoneticDistanceAlgorithm fDistanceAlgorithm= new DefaultPhoneticDistanceAlgorithm(); + + /** The mapping from phonetic hashes to word lists */ + private final Map fHashBuckets= new HashMap(HASH_CAPACITY); + + /** The phonetic hash provider */ + private IPhoneticHashProvider fHashProvider= new DefaultPhoneticHashProvider(); + + /** Is the dictionary already loaded? */ + private boolean fLoaded= false; + + /** + * Returns all candidates with the same phonetic hash. + * + * @param hash + * The hash to retrieve the candidates of + * @return Array of candidates for the phonetic hash + */ + protected final ArrayList getCandidates(final String hash) { + + ArrayList list= (ArrayList)fHashBuckets.get(hash); + if (list == null) + list= new ArrayList(0); + + return list; + } + + /** + * Returns all candidates that have a phonetic hash within a bounded + * distance to the specified word. + * + * @param word + * The word to find the nearest matches for + * @param sentence + * true iff the proposals start a new sentence, + * false otherwise + * @param hashs + * Array of close hashes to find the matches + * @return Set of ranked words with bounded distance to the specified word + */ + protected final HashSet getCandidates(final String word, final boolean sentence, final ArrayList hashs) { + + int distance= 0; + String hash= null; + + String candidate= null; + List candidates= null; + + final StringBuffer buffer= new StringBuffer(BUFFER_CAPACITY); + final HashSet result= new HashSet(BUCKET_CAPACITY * hashs.size()); + + for (int index= 0; index < hashs.size(); index++) { + + hash= (String)hashs.get(index); + candidates= getCandidates(hash); + + for (int offset= 0; offset < candidates.size(); offset++) { + + candidate= (String)candidates.get(offset); + distance= fDistanceAlgorithm.getDistance(word, candidate); + + if (distance < DISTANCE_THRESHOLD) { + + buffer.setLength(0); + buffer.append(candidate); + + if (sentence) + buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0))); + + result.add(new RankedWordProposal(buffer.toString(), -distance)); + } + } + } + return result; + } + + /** + * Returns all approximations that have a phonetic hash with smallest + * possible distance to the specified word. + * + * @param word + * The word to find the nearest matches for + * @param sentence + * true iff the proposals start a new sentence, + * false otherwise + * @param result + * Set of ranked words with smallest possible distance to the + * specified word + */ + protected final void getCandidates(final String word, final boolean sentence, final HashSet result) { + + int distance= 0; + int minimum= Integer.MAX_VALUE; + + String candidate= null; + StringBuffer buffer= new StringBuffer(BUFFER_CAPACITY); + + final ArrayList candidates= getCandidates(fHashProvider.getHash(word)); + final ArrayList matches= new ArrayList(candidates.size()); + + for (int index= 0; index < candidates.size(); index++) { + + candidate= (String)candidates.get(index); + distance= fDistanceAlgorithm.getDistance(word, candidate); + + if (distance <= minimum) { + + buffer.setLength(0); + buffer.append(candidate); + + if (sentence) + buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0))); + + matches.add(new RankedWordProposal(buffer.toString(), -distance)); + minimum= distance; + } + } + + RankedWordProposal match= null; + + for (int index= 0; index < matches.size(); index++) { + + match= (RankedWordProposal)matches.get(index); + if (match.getRank() == minimum) + result.add(match); + } + } + + /** + * Returns the used phonetic distance algorithm. + * + * @return The phonetic distance algorithm + */ + protected final IPhoneticDistanceAlgorithm getDistanceAlgorithm() { + return fDistanceAlgorithm; + } + + /** + * Returns the used phonetic hash provider. + * + * @return The phonetic hash provider + */ + protected final IPhoneticHashProvider getHashProvider() { + return fHashProvider; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary#getProposals(java.lang.String,boolean) + */ + public Set getProposals(final String word, final boolean sentence) { + + try { + + if (!fLoaded) + load(getURL()); + + } catch (MalformedURLException exception) { + // Do nothing + } + + final String hash= fHashProvider.getHash(word); + final char[] mutators= fHashProvider.getMutators(); + + final ArrayList neighborhood= new ArrayList((word.length() + 1) * (mutators.length + 2)); + neighborhood.add(hash); + + final HashSet candidates= getCandidates(word, sentence, neighborhood); + neighborhood.clear(); + + char previous= 0; + char next= 0; + + char[] characters= word.toCharArray(); + for (int index= 0; index < word.length() - 1; index++) { + + next= characters[index]; + previous= characters[index + 1]; + + characters[index]= previous; + characters[index + 1]= next; + + neighborhood.add(fHashProvider.getHash(new String(characters))); + + characters[index]= next; + characters[index + 1]= previous; + } + + final String sentinel= word + " "; //$NON-NLS-1$ + + characters= sentinel.toCharArray(); + int offset= characters.length - 1; + + while (true) { + + for (int index= 0; index < mutators.length; index++) { + + characters[offset]= mutators[index]; + neighborhood.add(fHashProvider.getHash(new String(characters))); + } + + if (offset == 0) + break; + + characters[offset]= characters[offset - 1]; + --offset; + } + + char mutated= 0; + characters= word.toCharArray(); + + for (int index= 0; index < word.length(); index++) { + + mutated= characters[index]; + for (int mutator= 0; mutator < mutators.length; mutator++) { + + characters[index]= mutators[mutator]; + neighborhood.add(fHashProvider.getHash(new String(characters))); + } + characters[index]= mutated; + } + + characters= word.toCharArray(); + final char[] deleted= new char[characters.length - 1]; + + for (int index= 0; index < deleted.length; index++) + deleted[index]= characters[index]; + + next= characters[characters.length - 1]; + offset= deleted.length; + + while (true) { + + neighborhood.add(fHashProvider.getHash(new String(characters))); + if (offset == 0) + break; + + previous= next; + next= deleted[offset - 1]; + + deleted[offset - 1]= previous; + --offset; + } + + neighborhood.remove(hash); + final HashSet matches= getCandidates(word, sentence, neighborhood); + + if (matches.size() == 0 && candidates.size() == 0) + getCandidates(word, sentence, candidates); + + candidates.addAll(matches); + + return candidates; + } + + /** + * Returns the URL of the dictionary word list. + * + * @throws MalformedURLException + * if the URL could not be retrieved + * @return The URL of the dictionary word list + */ + protected abstract URL getURL() throws MalformedURLException; + + /** + * Hashes the word into the dictionary. + * + * @param word + * The word to hash in the dictionary + */ + protected final void hashWord(final String word) { + + final String hash= fHashProvider.getHash(word); + ArrayList bucket= (ArrayList)fHashBuckets.get(hash); + + if (bucket == null) { + + bucket= new ArrayList(BUCKET_CAPACITY); + fHashBuckets.put(hash, bucket); + } + + bucket.add(word); + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary#isCorrect(java.lang.String) + */ + public boolean isCorrect(final String word) { + + try { + + if (!fLoaded) + load(getURL()); + + } catch (MalformedURLException exception) { + // Do nothing + } + + final ArrayList candidates= getCandidates(fHashProvider.getHash(word)); + + if (candidates.contains(word) || candidates.contains(word.toLowerCase())) + return true; + + return false; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary#isLoaded() + */ + public final synchronized boolean isLoaded() { + return fLoaded || fHashBuckets.size() > 0; + } + + /** + * Loads a dictionary word list from disk. + * + * @param url + * The URL of the word list to load + * @return true iff the word list could be loaded, false + * otherwise + */ + protected synchronized boolean load(final URL url) { + + if (url != null) { + + try { + + final InputStream stream= url.openStream(); + if (stream != null) { + + String word= null; + + final BufferedReader reader= new BufferedReader(new InputStreamReader(stream)); + while ((word= reader.readLine()) != null) + hashWord(word); + + return fLoaded= true; + } + } catch (IOException exception) { + // Do nothing + } + } + return false; + } + + /** + * Sets the phonetic distance algorithm to use. + * + * @param algorithm + * The phonetic distance algorithm + */ + protected final void setDistanceAlgorithm(final IPhoneticDistanceAlgorithm algorithm) { + fDistanceAlgorithm= algorithm; + } + + /** + * Sets the phonetic hash provider to use. + * + * @param provider + * The phonetic hash provider + */ + protected final void setHashProvider(final IPhoneticHashProvider provider) { + fHashProvider= provider; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary#unload() + */ + public synchronized void unload() { + + fLoaded= false; + fHashBuckets.clear(); + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary#acceptsWords() + */ + public boolean acceptsWords() { + return false; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary#addWord(java.lang.String) + */ + public void addWord(final String word) { + // Do nothing + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java new file mode 100644 index 0000000..2d758bb --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +/** + * Default phonetic distance algorithm for english words. + *

+ * This algorithm implements the Levenshtein text edit distance. + *

+ * + * @since 3.0 + */ +public final class DefaultPhoneticDistanceAlgorithm implements IPhoneticDistanceAlgorithm { + + /** The change case cost */ + public static final int COST_CASE= 10; + + /** The insert character cost */ + public static final int COST_INSERT= 95; + + /** The remove character cost */ + public static final int COST_REMOVE= 95; + + /** The substitute characters cost */ + public static final int COST_SUBSTITUTE= 100; + + /** The swap characters cost */ + public static final int COST_SWAP= 90; + + /* + * @see org.eclipse.spelling.done.IPhoneticDistanceAlgorithm#getDistance(java.lang.String,java.lang.String) + */ + public final int getDistance(final String from, final String to) { + + final char[] first= (" " + from).toCharArray(); //$NON-NLS-1$ + final char[] second= (" " + to).toCharArray(); //$NON-NLS-1$ + + final int rows= first.length; + final int columns= second.length; + + final int[][] metric= new int[rows][columns]; + for (int column= 1; column < columns; column++) + metric[0][column]= metric[0][column - 1] + COST_REMOVE; + + for (int row= 1; row < rows; row++) + metric[row][0]= metric[row - 1][0] + COST_INSERT; + + char source, target; + + int swap= Integer.MAX_VALUE; + int change= Integer.MAX_VALUE; + + int minimum, diagonal, insert, remove; + for (int row= 1; row < rows; row++) { + + source= first[row]; + for (int column= 1; column < columns; column++) { + + target= second[column]; + diagonal= metric[row - 1][column - 1]; + + if (source == target) { + metric[row][column]= diagonal; + continue; + } + + change= Integer.MAX_VALUE; + if (Character.toLowerCase(source) == Character.toLowerCase(target)) + change= COST_CASE + diagonal; + + swap= Integer.MAX_VALUE; + if (row != 1 && column != 1 && source == second[column - 1] && first[row - 1] == target) + swap= COST_SWAP + metric[row - 2][column - 2]; + + minimum= COST_SUBSTITUTE + diagonal; + if (swap < minimum) + minimum= swap; + + remove= metric[row][column - 1]; + if (COST_REMOVE + remove < minimum) + minimum= COST_REMOVE + remove; + + insert= metric[row - 1][column]; + if (COST_INSERT + insert < minimum) + minimum= COST_INSERT + insert; + if (change < minimum) + minimum= change; + + metric[row][column]= minimum; + } + } + return metric[rows - 1][columns - 1]; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java new file mode 100644 index 0000000..73b4ad1 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java @@ -0,0 +1,683 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +/** + * Default phonetic hash provider for english languages. + *

+ * This algorithm uses an adapted version double metaphone algorithm by + * Lawrence Philips. + *

+ * + * @since 3.0 + */ +public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider { + + private static final String[] meta01= { "ACH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta02= { "BACHER", "MACHER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta03= { "CAESAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta04= { "CHIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta05= { "CH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta06= { "CHAE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta07= { "HARAC", "HARIS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta08= { "HOR", "HYM", "HIA", "HEM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + private static final String[] meta09= { "CHORE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta10= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta11= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta12= { "ORCHES", "ARCHIT", "ORCHID", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta13= { "T", "S", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta14= { "A", "O", "U", "E", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + private static final String[] meta15= { "L", "R", "N", "M", "B", "H", "F", "V", "W", " ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ + private static final String[] meta16= { "MC", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta17= { "CZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta18= { "WICZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta19= { "CIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta20= { "CC", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta21= { "I", "E", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta22= { "HU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta23= { "UCCEE", "UCCES", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta24= { "CK", "CG", "CQ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta25= { "CI", "CE", "CY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta26= { "GN", "KN", "PN", "WR", "PS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + private static final String[] meta27= { " C", " Q", " G", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta28= { "C", "K", "Q", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta29= { "CE", "CI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta30= { "DG", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta31= { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta32= { "DT", "DD", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta33= { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta34= { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta35= { "B", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta36= { "C", "G", "L", "R", "T", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + private static final String[] meta37= { "EY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta38= { "LI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta39= { "ES", "EP", "EB", "EL", "EY", "IB", "IL", "IN", "IE", "EI", "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ + private static final String[] meta40= { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta41= { "DANGER", "RANGER", "MANGER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta42= { "E", "I", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta43= { "RGY", "OGY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta44= { "E", "I", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta45= { "AGGI", "OGGI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta46= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta47= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta48= { "ET", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta49= { "C", "X", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta50= { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta51= { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta52= { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta53= { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta54= { "L", "T", "K", "S", "N", "M", "B", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ + private static final String[] meta55= { "S", "K", "L", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta56= { "ILLO", "ILLA", "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta57= { "AS", "OS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta58= { "A", "O", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta59= { "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta60= { "UMB", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta61= { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta62= { "P", "B", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta63= { "IE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta64= { "ME", "MA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta65= { "ISL", "YSL", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta66= { "SUGAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta67= { "SH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta68= { "HEIM", "HOEK", "HOLM", "HOLZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + private static final String[] meta69= { "SIO", "SIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta70= { "SIAN", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta71= { "M", "N", "L", "W", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + private static final String[] meta72= { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta73= { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta74= { "SC", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta75= { "OO", "ER", "EN", "UY", "ED", "EM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + private static final String[] meta76= { "ER", "EN", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta77= { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + private static final String[] meta78= { "AI", "OI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta79= { "S", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta80= { "TION", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta81= { "TIA", "TCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta82= { "TH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta83= { "TTH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta84= { "OM", "AM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta85= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta86= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta87= { "T", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta88= { "WR", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta89= { "WH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta90= { "EWSKI", "EWSKY", "OWSKI", "OWSKY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + private static final String[] meta91= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] meta92= { "WICZ", "WITZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta93= { "IAU", "EAU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta94= { "AU", "OU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static final String[] meta95= { "W", "K", "CZ", "WITZ" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + + /** The mutator characters */ + private static final char[] MUTATOR_CHARACTERS= { 'A', 'B', 'X', 'S', 'K', 'J', 'T', 'F', 'H', 'L', 'M', 'N', 'P', 'R', '0' }; + + /** The vowel characters */ + private static final char[] VOWEL_CHARACTERS= new char[] { 'A', 'E', 'I', 'O', 'U', 'Y' }; + + /** + * Test whether the specified string contains one of the candidates in the + * list. + * + * @param candidates + * Array of candidates to check + * @param token + * The token to check for occurrences of the candidates + * @param offset + * The offset where to begin checking in the string + * @param length + * The length of the range in the string to check + * @return true iff the string contains one of the + * candidates, false otherwise. + */ + protected static final boolean hasOneOf(final String[] candidates, final char[] token, final int offset, final int length) { + + if (offset < 0 || offset >= token.length || candidates.length == 0) + return false; + + final String checkable= new String(token, offset, length); + for (int index= 0; index < candidates.length; index++) { + + if (candidates[index].equals(checkable)) + return true; + } + return false; + } + + /** + * Test whether the specified token contains one of the candidates in the + * list. + * + * @param candidates + * Array of candidates to check + * @param token + * The token to check for occurrences of the candidates + * @return true iff the string contains one of the + * candidates, false otherwise. + */ + protected static final boolean hasOneOf(final String[] candidates, final String token) { + + for (int index= 0; index < candidates.length; index++) { + + if (token.indexOf(candidates[index]) >= 0) + return true; + } + return false; + } + + /** + * Tests whether the specified token contains a vowel at the specified + * offset. + * + * @param token + * The token to check for a vowel + * @param offset + * The offset where to begin checking in the token + * @param length + * The length of the range in the token to check + * @return true iff the token contains a vowel, false + * otherwise. + */ + protected static final boolean hasVowel(final char[] token, final int offset, final int length) { + + if (offset >= 0 && offset < length) { + + final char character= token[offset]; + for (int index= 0; index < VOWEL_CHARACTERS.length; index++) { + + if (VOWEL_CHARACTERS[index] == character) + return true; + } + } + return false; + } + + /* + * @see org.eclipse.spelling.done.IPhoneticHasher#getHash(java.lang.String) + */ + public final String getHash(final String word) { + + final String input= word.toUpperCase() + " "; //$NON-NLS-1$ + final char[] hashable= input.toCharArray(); + + final boolean has95= hasOneOf(meta95, input); + final StringBuffer buffer= new StringBuffer(hashable.length); + + int offset= 0; + if (hasOneOf(meta26, hashable, 0, 2)) + offset += 1; + + if (hashable[0] == 'X') { + buffer.append('S'); + offset += 1; + } + + while (offset < hashable.length) { + + switch (hashable[offset]) { + case 'A' : + case 'E' : + case 'I' : + case 'O' : + case 'U' : + case 'Y' : + if (offset == 0) + buffer.append('A'); + offset += 1; + break; + case 'B' : + buffer.append('P'); + if (hashable[offset + 1] == 'B') + offset += 2; + else + offset += 1; + break; + case 'C' : + if ((offset > 1) && !hasVowel(hashable, offset - 2, hashable.length) && hasOneOf(meta01, hashable, (offset - 1), 3) && (hashable[offset + 2] != 'I') && (hashable[offset + 2] != 'E') || hasOneOf(meta02, hashable, (offset - 2), 6)) { + buffer.append('K'); + offset += 2; + break; + } + if ((offset == 0) && hasOneOf(meta03, hashable, offset, 6)) { + buffer.append('S'); + offset += 2; + break; + } + if (hasOneOf(meta04, hashable, offset, 4)) { + buffer.append('K'); + offset += 2; + break; + } + if (hasOneOf(meta05, hashable, offset, 2)) { + if ((offset > 0) && hasOneOf(meta06, hashable, offset, 4)) { + buffer.append('K'); + offset += 2; + break; + } + if ((offset == 0) && hasOneOf(meta07, hashable, (offset + 1), 5) || hasOneOf(meta08, hashable, offset + 1, 3) && !hasOneOf(meta09, hashable, 0, 5)) { + buffer.append('K'); + offset += 2; + break; + } + if (hasOneOf(meta10, hashable, 0, 4) || hasOneOf(meta11, hashable, 0, 3) || hasOneOf(meta12, hashable, offset - 2, 6) || hasOneOf(meta13, hashable, offset + 2, 1) || (hasOneOf(meta14, hashable, offset - 1, 1) || (offset == 0)) && hasOneOf(meta15, hashable, offset + 2, 1)) { + buffer.append('K'); + } else { + if (offset > 0) { + if (hasOneOf(meta16, hashable, 0, 2)) + buffer.append('K'); + else + buffer.append('X'); + } else { + buffer.append('X'); + } + } + offset += 2; + break; + } + if (hasOneOf(meta17, hashable, offset, 2) && !hasOneOf(meta18, hashable, offset, 4)) { + buffer.append('S'); + offset += 2; + break; + } + if (hasOneOf(meta19, hashable, offset, 2)) { + buffer.append('X'); + offset += 2; + break; + } + if (hasOneOf(meta20, hashable, offset, 2) && !((offset == 1) && hashable[0] == 'M')) { + if (hasOneOf(meta21, hashable, offset + 2, 1) && !hasOneOf(meta22, hashable, offset + 2, 2)) { + if (((offset == 1) && (hashable[offset - 1] == 'A')) || hasOneOf(meta23, hashable, (offset - 1), 5)) + buffer.append("KS"); //$NON-NLS-1$ + else + buffer.append('X'); + offset += 3; + break; + } else { + buffer.append('K'); + offset += 2; + break; + } + } + if (hasOneOf(meta24, hashable, offset, 2)) { + buffer.append('K'); + offset += 2; + break; + } else if (hasOneOf(meta25, hashable, offset, 2)) { + buffer.append('S'); + offset += 2; + break; + } + buffer.append('K'); + if (hasOneOf(meta27, hashable, offset + 1, 2)) + offset += 3; + else if (hasOneOf(meta28, hashable, offset + 1, 1) && !hasOneOf(meta29, hashable, offset + 1, 2)) + offset += 2; + else + offset += 1; + break; + case '\u00C7' : + buffer.append('S'); + offset += 1; + break; + case 'D' : + if (hasOneOf(meta30, hashable, offset, 2)) { + if (hasOneOf(meta31, hashable, offset + 2, 1)) { + buffer.append('J'); + offset += 3; + break; + } else { + buffer.append("TK"); //$NON-NLS-1$ + offset += 2; + break; + } + } + buffer.append('T'); + if (hasOneOf(meta32, hashable, offset, 2)) { + offset += 2; + } else { + offset += 1; + } + break; + case 'F' : + if (hashable[offset + 1] == 'F') + offset += 2; + else + offset += 1; + buffer.append('F'); + break; + case 'G' : + if (hashable[offset + 1] == 'H') { + if ((offset > 0) && !hasVowel(hashable, offset - 1, hashable.length)) { + buffer.append('K'); + offset += 2; + break; + } + if (offset < 3) { + if (offset == 0) { + if (hashable[offset + 2] == 'I') + buffer.append('J'); + else + buffer.append('K'); + offset += 2; + break; + } + } + if ((offset > 1) && hasOneOf(meta33, hashable, offset - 2, 1) || ((offset > 2) && hasOneOf(meta34, hashable, offset - 3, 1)) || ((offset > 3) && hasOneOf(meta35, hashable, offset - 4, 1))) { + offset += 2; + break; + } else { + if ((offset > 2) && (hashable[offset - 1] == 'U') && hasOneOf(meta36, hashable, offset - 3, 1)) { + buffer.append('F'); + } else { + if ((offset > 0) && (hashable[offset - 1] != 'I')) + buffer.append('K'); + } + offset += 2; + break; + } + } + if (hashable[offset + 1] == 'N') { + if ((offset == 1) && hasVowel(hashable, 0, hashable.length) && !has95) { + buffer.append("KN"); //$NON-NLS-1$ + } else { + if (!hasOneOf(meta37, hashable, offset + 2, 2) && (hashable[offset + 1] != 'Y') && !has95) { + buffer.append("N"); //$NON-NLS-1$ + } else { + buffer.append("KN"); //$NON-NLS-1$ + } + } + offset += 2; + break; + } + if (hasOneOf(meta38, hashable, offset + 1, 2) && !has95) { + buffer.append("KL"); //$NON-NLS-1$ + offset += 2; + break; + } + if ((offset == 0) && ((hashable[offset + 1] == 'Y') || hasOneOf(meta39, hashable, offset + 1, 2))) { + buffer.append('K'); + offset += 2; + break; + } + if ((hasOneOf(meta40, hashable, offset + 1, 2) || (hashable[offset + 1] == 'Y')) && !hasOneOf(meta41, hashable, 0, 6) && !hasOneOf(meta42, hashable, offset - 1, 1) && !hasOneOf(meta43, hashable, offset - 1, 3)) { + buffer.append('K'); + offset += 2; + break; + } + if (hasOneOf(meta44, hashable, offset + 1, 1) || hasOneOf(meta45, hashable, offset - 1, 4)) { + if (hasOneOf(meta46, hashable, 0, 4) || hasOneOf(meta47, hashable, 0, 3) || hasOneOf(meta48, hashable, offset + 1, 2)) { + buffer.append('K'); + } else { + buffer.append('J'); + } + offset += 2; + break; + } + if (hashable[offset + 1] == 'G') + offset += 2; + else + offset += 1; + buffer.append('K'); + break; + case 'H' : + if (((offset == 0) || hasVowel(hashable, offset - 1, hashable.length)) && hasVowel(hashable, offset + 1, hashable.length)) { + buffer.append('H'); + offset += 2; + } else { + offset += 1; + } + break; + case 'J' : + if (hasOneOf(meta50, hashable, offset, 4) || hasOneOf(meta51, hashable, 0, 4)) { + if ((offset == 0) && (hashable[offset + 4] == ' ') || hasOneOf(meta52, hashable, 0, 4)) { + buffer.append('H'); + } else { + buffer.append('J'); + } + offset += 1; + break; + } + if ((offset == 0) && !hasOneOf(meta53, hashable, offset, 4)) { + buffer.append('J'); + } else { + if (hasVowel(hashable, offset - 1, hashable.length) && !has95 && ((hashable[offset + 1] == 'A') || hashable[offset + 1] == 'O')) { + buffer.append('J'); + } else { + if (offset == (hashable.length - 1)) { + buffer.append('J'); + } else { + if (!hasOneOf(meta54, hashable, offset + 1, 1) && !hasOneOf(meta55, hashable, offset - 1, 1)) { + buffer.append('J'); + } + } + } + } + if (hashable[offset + 1] == 'J') + offset += 2; + else + offset += 1; + break; + case 'K' : + if (hashable[offset + 1] == 'K') + offset += 2; + else + offset += 1; + buffer.append('K'); + break; + case 'L' : + if (hashable[offset + 1] == 'L') { + if (((offset == (hashable.length - 3)) && hasOneOf(meta56, hashable, offset - 1, 4)) || ((hasOneOf(meta57, hashable, (hashable.length - 1) - 1, 2) || hasOneOf(meta58, hashable, hashable.length - 1, 1)) && hasOneOf(meta59, hashable, offset - 1, 4))) { + buffer.append('L'); + offset += 2; + break; + } + offset += 2; + } else + offset += 1; + buffer.append('L'); + break; + case 'M' : + if ((hasOneOf(meta60, hashable, offset - 1, 3) && (((offset + 1) == (hashable.length - 1)) || hasOneOf(meta61, hashable, offset + 2, 2))) || (hashable[offset + 1] == 'M')) + offset += 2; + else + offset += 1; + buffer.append('M'); + break; + case 'N' : + if (hashable[offset + 1] == 'N') + offset += 2; + else + offset += 1; + buffer.append('N'); + break; + case '\u00D1' : + offset += 1; + buffer.append('N'); + break; + case 'P' : + if (hashable[offset + 1] == 'N') { + buffer.append('F'); + offset += 2; + break; + } + if (hasOneOf(meta62, hashable, offset + 1, 1)) + offset += 2; + else + offset += 1; + buffer.append('P'); + break; + case 'Q' : + if (hashable[offset + 1] == 'Q') + offset += 2; + else + offset += 1; + buffer.append('K'); + break; + case 'R' : + if (!((offset == (hashable.length - 1)) && !has95 && hasOneOf(meta63, hashable, offset - 2, 2) && !hasOneOf(meta64, hashable, offset - 4, 2))) + buffer.append('R'); + if (hashable[offset + 1] == 'R') + offset += 2; + else + offset += 1; + break; + case 'S' : + if (hasOneOf(meta65, hashable, offset - 1, 3)) { + offset += 1; + break; + } + if ((offset == 0) && hasOneOf(meta66, hashable, offset, 5)) { + buffer.append('X'); + offset += 1; + break; + } + if (hasOneOf(meta67, hashable, offset, 2)) { + if (hasOneOf(meta68, hashable, offset + 1, 4)) + buffer.append('S'); + else + buffer.append('X'); + offset += 2; + break; + } + if (hasOneOf(meta69, hashable, offset, 3) || hasOneOf(meta70, hashable, offset, 4)) { + buffer.append('S'); + offset += 3; + break; + } + if (((offset == 0) && hasOneOf(meta71, hashable, offset + 1, 1)) || hasOneOf(meta72, hashable, offset + 1, 1)) { + buffer.append('S'); + if (hasOneOf(meta73, hashable, offset + 1, 1)) + offset += 2; + else + offset += 1; + break; + } + if (hasOneOf(meta74, hashable, offset, 2)) { + if (hashable[offset + 2] == 'H') + if (hasOneOf(meta75, hashable, offset + 3, 2)) { + if (hasOneOf(meta76, hashable, offset + 3, 2)) { + buffer.append("X"); //$NON-NLS-1$ + } else { + buffer.append("SK"); //$NON-NLS-1$ + } + offset += 3; + break; + } else { + buffer.append('X'); + offset += 3; + break; + } + if (hasOneOf(meta77, hashable, offset + 2, 1)) { + buffer.append('S'); + offset += 3; + break; + } + buffer.append("SK"); //$NON-NLS-1$ + offset += 3; + break; + } + if (!((offset == (hashable.length - 1)) && hasOneOf(meta78, hashable, offset - 2, 2))) + buffer.append('S'); + if (hasOneOf(meta79, hashable, offset + 1, 1)) + offset += 2; + else + offset += 1; + break; + case 'T' : + if (hasOneOf(meta80, hashable, offset, 4)) { + buffer.append('X'); + offset += 3; + break; + } + if (hasOneOf(meta81, hashable, offset, 3)) { + buffer.append('X'); + offset += 3; + break; + } + if (hasOneOf(meta82, hashable, offset, 2) || hasOneOf(meta83, hashable, offset, 3)) { + if (hasOneOf(meta84, hashable, (offset + 2), 2) || hasOneOf(meta85, hashable, 0, 4) || hasOneOf(meta86, hashable, 0, 3)) { + buffer.append('T'); + } else { + buffer.append('0'); + } + offset += 2; + break; + } + if (hasOneOf(meta87, hashable, offset + 1, 1)) { + offset += 2; + } else + offset += 1; + buffer.append('T'); + break; + case 'V' : + if (hashable[offset + 1] == 'V') + offset += 2; + else + offset += 1; + buffer.append('F'); + break; + case 'W' : + if (hasOneOf(meta88, hashable, offset, 2)) { + buffer.append('R'); + offset += 2; + break; + } + if ((offset == 0) && (hasVowel(hashable, offset + 1, hashable.length) || hasOneOf(meta89, hashable, offset, 2))) { + buffer.append('A'); + } + if (((offset == (hashable.length - 1)) && hasVowel(hashable, offset - 1, hashable.length)) || hasOneOf(meta90, hashable, offset - 1, 5) || hasOneOf(meta91, hashable, 0, 3)) { + buffer.append('F'); + offset += 1; + break; + } + if (hasOneOf(meta92, hashable, offset, 4)) { + buffer.append("TS"); //$NON-NLS-1$ + offset += 4; + break; + } + offset += 1; + break; + case 'X' : + if (!((offset == (hashable.length - 1)) && (hasOneOf(meta93, hashable, offset - 3, 3) || hasOneOf(meta94, hashable, offset - 2, 2)))) + buffer.append("KS"); //$NON-NLS-1$ + if (hasOneOf(meta49, hashable, offset + 1, 1)) + offset += 2; + else + offset += 1; + break; + case 'Z' : + if (hashable[offset + 1] == 'H') { + buffer.append('J'); + offset += 2; + break; + } else { + buffer.append('S'); + } + if (hashable[offset + 1] == 'Z') + offset += 2; + else + offset += 1; + break; + default : + offset += 1; + } + } + return buffer.toString(); + } + + /* + * @see org.eclipse.spelling.done.IPhoneticHasher#getMutators() + */ + public final char[] getMutators() { + return MUTATOR_CHARACTERS; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java new file mode 100644 index 0000000..4ca16c5 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java @@ -0,0 +1,350 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Default spell checker for standard text. + * + * @since 3.0 + */ +public class DefaultSpellChecker implements ISpellChecker { + + /** Array of url prefixes */ + public static final String[] URL_PREFIXES= new String[] { "http://", "https://", "www.", "ftp://", "ftps://", "news://", "mailto://" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + + /** + * Does this word contain digits? + * + * @param word + * The word to check + * @return true iff this word contains digits, false> + * otherwise + */ + protected static boolean isDigits(final String word) { + + for (int index= 0; index < word.length(); index++) { + + if (Character.isDigit(word.charAt(index))) + return true; + } + return false; + } + + /** + * Does this word contain mixed-case letters? + * + * @param word + * The word to check + * @param sentence + * true iff the specified word starts a new + * sentence, false otherwise + * @return true iff the contains mixed-case letters, false + * otherwise + */ + protected static boolean isMixedCase(final String word, final boolean sentence) { + + final int length= word.length(); + boolean upper= Character.isUpperCase(word.charAt(0)); + + if (sentence && upper && (length > 1)) + upper= Character.isUpperCase(word.charAt(1)); + + if (upper) { + + for (int index= length - 1; index > 0; index--) { + if (Character.isLowerCase(word.charAt(index))) + return true; + } + } else { + + for (int index= length - 1; index > 0; index--) { + if (Character.isUpperCase(word.charAt(index))) + return true; + } + } + return false; + } + + /** + * Does this word contain upper-case letters only? + * + * @param word + * The word to check + * @return true iff this word only contains upper-case + * letters, false otherwise + */ + protected static boolean isUpperCase(final String word) { + + for (int index= word.length() - 1; index >= 0; index--) { + + if (Character.isLowerCase(word.charAt(index))) + return false; + } + return true; + } + + /** + * Does this word look like an URL? + * + * @param word + * The word to check + * @return true iff this word looks like an URL, false + * otherwise + */ + protected static boolean isUrl(final String word) { + + for (int index= 0; index < URL_PREFIXES.length; index++) { + + if (word.startsWith(URL_PREFIXES[index])) + return true; + } + return false; + } + + /** + * The dictionaries to use for spell-checking. Synchronized to avoid + * concurrent modifications. + */ + private final Set fDictionaries= Collections.synchronizedSet(new HashSet()); + + /** + * The words to be ignored. Synchronized to avoid concurrent modifications. + */ + private final Set fIgnored= Collections.synchronizedSet(new HashSet()); + + /** + * The spell event listeners. Synchronized to avoid concurrent + * modifications. + */ + private final Set fListeners= Collections.synchronizedSet(new HashSet()); + + /** + * The preference store. Assumes the IPreferenceStore + * implementation is thread safe. + */ + private final IPreferenceStore fPreferences; + + /** + * Creates a new default spell-checker. + * + * @param store + * The preference store for this spell-checker + */ + public DefaultSpellChecker(final IPreferenceStore store) { + fPreferences= store; + } + + /* + * @see org.eclipse.spelling.done.ISpellChecker#addDictionary(org.eclipse.spelling.done.ISpellDictionary) + */ + public final void addDictionary(final ISpellDictionary dictionary) { + // synchronizing is necessary as this is a write access + fDictionaries.add(dictionary); + } + + /* + * @see org.eclipse.spelling.done.ISpellChecker#addListener(org.eclipse.spelling.done.ISpellEventListener) + */ + public final void addListener(final ISpellEventListener listener) { + // synchronizing is necessary as this is a write access + fListeners.add(listener); + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellChecker#acceptsWords() + */ + public boolean acceptsWords() { + // synchronizing might not be needed here since acceptWords is + // a read-only access and only called in the same thread as + // the modifing methods add/checkWord (?) + Set copy; + synchronized (fDictionaries) { + copy= new HashSet(fDictionaries); + } + + ISpellDictionary dictionary= null; + for (final Iterator iterator= copy.iterator(); iterator.hasNext();) { + + dictionary= (ISpellDictionary)iterator.next(); + if (dictionary.acceptsWords()) + return true; + } + return false; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker#addWord(java.lang.String) + */ + public void addWord(final String word) { + // synchronizing is necessary as this is a write access + Set copy; + synchronized (fDictionaries) { + copy= new HashSet(fDictionaries); + } + + final String addable= word.toLowerCase(); + fIgnored.add(addable); + + ISpellDictionary dictionary= null; + for (final Iterator iterator= copy.iterator(); iterator.hasNext();) { + + dictionary= (ISpellDictionary)iterator.next(); + dictionary.addWord(addable); + } + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.ISpellChecker#checkWord(java.lang.String) + */ + public final void checkWord(final String word) { + // synchronizing is necessary as this is a write access + fIgnored.remove(word.toLowerCase()); + } + + /* + * @see org.eclipse.spelling.done.ISpellChecker#execute(org.eclipse.spelling.ISpellCheckTokenizer) + */ + public void execute(final ISpellCheckIterator iterator) { + + final boolean ignoreDigits= fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_IGNORE_DIGITS); + final boolean ignoreMixed= fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_IGNORE_MIXED); + final boolean ignoreSentence= fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_IGNORE_SENTENCE); + final boolean ignoreUpper= fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_IGNORE_UPPER); + final boolean ignoreURLS= fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_IGNORE_URLS); + + String word= null; + boolean starts= false; + + while (iterator.hasNext()) { + + word= (String)iterator.next(); + if (word != null) { + + // synchronizing is necessary as this is called inside the reconciler + if (!fIgnored.contains(word)) { + + starts= iterator.startsSentence(); + if (!isCorrect(word)) { + + boolean isMixed= isMixedCase(word, true); + boolean isUpper= isUpperCase(word); + boolean isDigits= isDigits(word); + boolean isURL= isUrl(word); + + if ( !ignoreMixed && isMixed || !ignoreUpper && isUpper || !ignoreDigits && isDigits || !ignoreURLS && isURL || !(isMixed || isUpper || isDigits || isURL)) + fireEvent(new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), starts, false)); + + } else { + + if (!ignoreSentence && starts && Character.isLowerCase(word.charAt(0))) + fireEvent(new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), true, true)); + } + } + } + } + } + + /** + * Fires the specified event. + * + * @param event + * Event to fire + */ + protected final void fireEvent(final ISpellEvent event) { + // synchronizing is necessary as this is called from execute + Set copy; + synchronized (fListeners) { + copy= new HashSet(fListeners); + } + for (final Iterator iterator= copy.iterator(); iterator.hasNext();) { + ((ISpellEventListener)iterator.next()).handle(event); + } + } + + /* + * @see org.eclipse.spelling.done.ISpellChecker#getProposals(java.lang.String,boolean) + */ + public Set getProposals(final String word, final boolean sentence) { + + // synchronizing might not be needed here since getProposals is + // a read-only access and only called in the same thread as + // the modifing methods add/removeDictionary (?) + Set copy; + synchronized (fDictionaries) { + copy= new HashSet(fDictionaries); + } + + ISpellDictionary dictionary= null; + final HashSet proposals= new HashSet(); + + for (final Iterator iterator= copy.iterator(); iterator.hasNext();) { + + dictionary= (ISpellDictionary)iterator.next(); + proposals.addAll(dictionary.getProposals(word, sentence)); + } + return proposals; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker#ignoreWord(java.lang.String) + */ + public final void ignoreWord(final String word) { + // synchronizing is necessary as this is a write access + fIgnored.add(word.toLowerCase()); + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker#isCorrect(java.lang.String) + */ + public final boolean isCorrect(final String word) { + // synchronizing is necessary as this is called from execute + Set copy; + synchronized (fDictionaries) { + copy= new HashSet(fDictionaries); + } + + if (fIgnored.contains(word.toLowerCase())) + return true; + + ISpellDictionary dictionary= null; + for (final Iterator iterator= copy.iterator(); iterator.hasNext();) { + + dictionary= (ISpellDictionary)iterator.next(); + if (dictionary.isCorrect(word)) + return true; + } + return false; + } + + /* + * @see org.eclipse.spelling.done.ISpellChecker#removeDictionary(org.eclipse.spelling.done.ISpellDictionary) + */ + public final void removeDictionary(final ISpellDictionary dictionary) { + // synchronizing is necessary as this is a write access + fDictionaries.remove(dictionary); + } + + /* + * @see org.eclipse.spelling.done.ISpellChecker#removeListener(org.eclipse.spelling.done.ISpellEventListener) + */ + public final void removeListener(final ISpellEventListener listener) { + // synchronizing is necessary as this is a write access + fListeners.remove(listener); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java new file mode 100644 index 0000000..dd6eec7 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +/** + * Interface of algorithms to compute the phonetic distance between two words. + * + * @since 3.0 + */ +public interface IPhoneticDistanceAlgorithm { + + /** + * Returns the non-negative phonetic distance between two words + * + * @param from + * The first word + * @param to + * The second word + * @return The non-negative phonetic distance between the words. + */ + public int getDistance(String from, String to); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java new file mode 100644 index 0000000..042b474 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +/** + * Interface of hashers to compute the phonetic hash for a word. + * + * @since 3.0 + */ +public interface IPhoneticHashProvider { + + /** + * Returns the phonetic hash for the word. + * + * @param word + * The word to get the phonetic hash for + * @return The phonetic hash for the word + */ + public String getHash(String word); + + /** + * Returns an array of characters to compute possible mutations. + * + * @return Array of possible mutator characters + */ + public char[] getMutators(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java new file mode 100644 index 0000000..1720efa --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.util.Locale; + +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Interface for spell-check engines. + * + * @since 3.0 + */ +public interface ISpellCheckEngine { + + /** + * Creates a configured instance of a spell-checker that uses the + * appropriate dictionaries. + * + * @param locale + * The locale to get the spell checker for + * @param store + * The preference store for the spell-checker + * @return A configured instance of a spell checker, or null + * iff no dictionary could be found for that locale + */ + ISpellChecker createSpellChecker(Locale locale, IPreferenceStore store); + + /** + * Returns the current locale of the spell check engine. + * + * @return The current locale of the engine + */ + Locale getLocale(); + + /** + * Registers a dictionary for all locales available on the platform. + *

+ * This call is equivalent to calling registerDictionary(Locale,ISpellDictionary) + * for each of the locales returned by Locale.getAvailableLocales(). + *

+ * + * @param dictionary + * The dictionary to register + */ + void registerDictionary(ISpellDictionary dictionary); + + /** + * Registers a dictionary tuned for the specified locale with this engine. + * + * @param locale + * The locale to register the dictionary with + * @param dictionary + * The dictionary to register + */ + void registerDictionary(Locale locale, ISpellDictionary dictionary); + + /** + * Unloads the spell check engine and its associated components. + *

+ * All registered dictionaries are unloaded and the engine unregisters for + * preference changes. After a new call to getSpellChecker(Locale), + * it registers again for preference changes. The dictionaries perform lazy + * loading, that is to say on the next query they reload their associated + * word lists. + */ + void unload(); + + /** + * Unregisters a dictionary previously registered either by a call to + * registerDictionary(Locale,ISpellDictionary) or registerDictionary(ISpellDictionary). + * If the dictionary was not registered before, nothing happens. + * + * @param dictionary + * The dictionary to unregister + */ + void unregisterDictionary(ISpellDictionary dictionary); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java new file mode 100644 index 0000000..6f1ec96 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.util.Iterator; + +/** + * Interface for iterators used for spell-checking. + * + * @since 3.0 + */ +public interface ISpellCheckIterator extends Iterator { + + /** + * Returns the begin index (inclusive) of the current word. + * + * @return The begin index of the current word + */ + public int getBegin(); + + /** + * Returns the end index (exclusive) of the current word. + * + * @return The end index of the current word + */ + public int getEnd(); + + /** + * Does the current word start a new sentence? + * + * @return true iff the current word starts a new sentence, false otherwise + */ + public boolean startsSentence(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckPreferenceKeys.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckPreferenceKeys.java new file mode 100644 index 0000000..ef4bf10 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellCheckPreferenceKeys.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +/** + * Preference keys for the comment spell-checker. + * + * @since 3.0 + */ +public interface ISpellCheckPreferenceKeys { + + /** + * A named preference that controls whether spell-checking should be + * enabled. + *

+ * Value is of type Boolean. + *

+ */ + public final static String SPELLING_CHECK_SPELLING= "spelling_check_spelling"; //$NON-NLS-1$ + + /** + * A named preference that controls whether words containing digits should + * be skipped during spell-checking. + *

+ * Value is of type Boolean. + *

+ */ + public final static String SPELLING_IGNORE_DIGITS= "spelling_ignore_digits"; //$NON-NLS-1$ + + /** + * A named preference that controls whether mixed case words should be + * skipped during spell-checking. + *

+ * Value is of type Boolean. + *

+ */ + public final static String SPELLING_IGNORE_MIXED= "spelling_ignore_mixed"; //$NON-NLS-1$ + + /** + * A named preference that controls whether sentence capitalization should + * be ignored during spell-checking. + *

+ * Value is of type Boolean. + *

+ */ + public final static String SPELLING_IGNORE_SENTENCE= "spelling_ignore_sentence"; //$NON-NLS-1$ + + /** + * A named preference that controls whether upper case words should be + * skipped during spell-checking. + *

+ * Value is of type Boolean. + *

+ */ + public final static String SPELLING_IGNORE_UPPER= "spelling_ignore_upper"; //$NON-NLS-1$ + + /** + * A named preference that controls whether urls should be ignored during + * spell-checking. + *

+ * Value is of type Boolean. + *

+ */ + public final static String SPELLING_IGNORE_URLS= "spelling_ignore_urls"; //$NON-NLS-1$ + + /** + * A named preference that controls the locale used for spell-checking. + *

+ * Value is of type String. + *

+ */ + public final static String SPELLING_LOCALE= "spelling_locale"; //$NON-NLS-1$ + + /** + * A named preference that controls the number of proposals offered during + * spell-checking. + *

+ * Value is of type Integer. + *

+ */ + public final static String SPELLING_PROPOSAL_THRESHOLD= "spelling_proposal_threshold"; //$NON-NLS-1$ + + /** + * A named preference that specifies the workspace user dictionary. + *

+ * Value is of type String. + *

+ */ + public final static String SPELLING_USER_DICTIONARY= "spelling_user_dictionary"; //$NON-NLS-1$ + + /** + * A named preference that specifies whether spelling dictionaries are available to content assist. + *

+ * Value is of type Boolean. + *

+ */ + public final static String SPELLING_ENABLE_CONTENTASSIST= "spelling_enable_contentassist"; //$NON-NLS-1$ +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellChecker.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellChecker.java new file mode 100644 index 0000000..decb9b5 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellChecker.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.util.Set; + +/** + * Interface for spell-checkers. + * + * @since 3.0 + */ +public interface ISpellChecker { + + /** + * Adds a dictionary to the list of active dictionaries. + * + * @param dictionary + * The dictionary to add + */ + public void addDictionary(ISpellDictionary dictionary); + + /** + * Adds a spell event listener to the active listeners. + * + * @param listener + * The listener to add + */ + public void addListener(ISpellEventListener listener); + + /** + * Returns whether this spell checker accepts word additions. + * + * @return true if word additions are accepted, false otherwise + */ + public boolean acceptsWords(); + + /** + * Adds the specified word to the set of correct words. + * + * @param word + * The word to add to the set of correct words + */ + public void addWord(String word); + + /** + * Checks the specified word until calling ignoreWord(String). + * + * @param word + * The word to check + */ + public void checkWord(String word); + + /** + * Checks the spelling with the spell-check iterator. Implementations must + * be thread safe as this may be called inside a reconciler thread. + * + * @param iterator + * The iterator to use for spell-checking + */ + public void execute(ISpellCheckIterator iterator); + + /** + * Returns the ranked proposals for a word. + * + * @param word + * The word to retrieve the proposals for + * @param sentence + * true iff the proposals should start a + * sentence, false otherwise + * @return Set of ranked proposals for the word + */ + public Set getProposals(String word, boolean sentence); + + /** + * Ignores the specified word until calling checkWord(String). + * + * @param word + * The word to ignore + */ + public void ignoreWord(String word); + + /** + * Is the specified word correctly spelled? Implementations must be thread + * safe as this may be called from within a reconciler thread. + * + * @param word + * The word to check its spelling + * @return true iff the word is correctly spelled, false + * otherwise + */ + public boolean isCorrect(String word); + + /** + * Remove a dictionary from the list of active dictionaries. + * + * @param dictionary + * The dictionary to remove + */ + public void removeDictionary(ISpellDictionary dictionary); + + /** + * Removes a spell event listener from the active listeners. + * + * @param listener + * The listener to remove + */ + public void removeListener(ISpellEventListener listener); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellDictionary.java new file mode 100644 index 0000000..05701c9 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellDictionary.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.util.Set; + +/** + * Interface of dictionaries to use for spell-checking. + * + * @since 3.0 + */ +public interface ISpellDictionary { + + /** + * Returns whether this dictionary accepts new words. + * + * @return true if this dictionary accepts new words, false otherwise + */ + public boolean acceptsWords(); + + /** + * Externalizes the specified word. + * + * @param word + * The word to externalize in the dictionary + */ + public void addWord(String word); + + /** + * Returns the ranked word proposals for an incorrectly spelled word. + * + * @param word + * The word to retrieve the proposals for + * @param sentence + * true iff the proposals start a new sentence, + * false otherwise + * @return Array of ranked word proposals + */ + public Set getProposals(String word, boolean sentence); + + /** + * Is the specified word correctly spelled? + * + * @param word + * The word to spell-check + * @return true iff this word is correctly spelled, false + * otherwise. + */ + public boolean isCorrect(String word); + + /** + * Is the dictionary loaded? + * + * @return true iff it is loaded, false + * otherwise + */ + public boolean isLoaded(); + + /** + * Empties the dictionary. + */ + public void unload(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEvent.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEvent.java new file mode 100644 index 0000000..98e6f9b --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEvent.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.util.Set; + +/** + * Event fired by spell-checkers. + * + * @since 3.0 + */ +public interface ISpellEvent { + + /** + * Returns the begin index of the incorrectly spelled word. + * + * @return The begin index of the word + */ + public int getBegin(); + + /** + * Returns the end index of the incorrectly spelled word. + * + * @return The end index of the word + */ + public int getEnd(); + + /** + * Returns the proposals for the incorrectly spelled word. + * + * @return Array of proposals for the word + */ + public Set getProposals(); + + /** + * Returns the incorrectly spelled word. + * + * @return The incorrect word + */ + public String getWord(); + + /** + * Was the incorrectly spelled word found in the dictionary? + * + * @return true iff the word was found, false otherwise + */ + public boolean isMatch(); + + /** + * Does the incorrectly spelled word start a new sentence? + * + * @return true iff the word starts a new sentence, false otherwise + */ + public boolean isStart(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEventListener.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEventListener.java new file mode 100644 index 0000000..dfb4a03 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/ISpellEventListener.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + + +/** + * Interface for spell event listeners. + * + * @since 3.0 + */ +public interface ISpellEventListener { + + /** + * Handles a spell event. + * + * @param event + * Event to handle + */ + public void handle(ISpellEvent event); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java new file mode 100644 index 0000000..8553ab5 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Locale; + +import net.sourceforge.phpdt.internal.ui.PHPUIMessages; + +/** + * Platform wide read-only locale sensitive dictionary for spell-checking. + * + * @since 3.0 + */ +public class LocaleSensitiveSpellDictionary extends AbstractSpellDictionary { + + /** The locale of this dictionary */ + private final Locale fLocale; + + /** The location of the dictionaries */ + private final URL fLocation; + + /** + * Creates a new locale sensitive spell dictionary. + * + * @param locale + * The locale for this dictionary + * @param location + * The location of the locale sensitive dictionaries + */ + public LocaleSensitiveSpellDictionary(final Locale locale, final URL location) { + fLocation= location; + fLocale= locale; + } + + /** + * Returns the locale of this dictionary. + * + * @return The locale of this dictionary + */ + public final Locale getLocale() { + return fLocale; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getURL() + */ + protected final URL getURL() throws MalformedURLException { + return new URL(fLocation, fLocale.toString().toLowerCase() + "." + PHPUIMessages.getString("Spelling.dictionary.file.extension")); //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java new file mode 100644 index 0000000..fe555f3 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.io.FileWriter; +import java.io.IOException; +import java.net.URL; + +/** + * Persistent modifiable word-list based dictionary. + * + * @since 3.0 + */ +public class PersistentSpellDictionary extends AbstractSpellDictionary { + + /** The word list location */ + private final URL fLocation; + + /** + * Creates a new persistent spell dictionary. + * + * @param url + * The URL of the word list for this dictionary + */ + public PersistentSpellDictionary(final URL url) { + fLocation= url; + } + + /* + * @see org.eclipse.jdt.ui.text.spelling.engine.AbstractSpellDictionary#acceptsWords() + */ + public boolean acceptsWords() { + return true; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary#addWord(java.lang.String) + */ + public void addWord(final String word) { + + if (!isCorrect(word)) { + + hashWord(word); + try { + + final FileWriter writer= new FileWriter(fLocation.getPath(), true); + writer.write(word); + writer.write("\n"); //$NON-NLS-1$ + writer.close(); + + } catch (IOException exception) { + // Do nothing + } + } + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getURL() + */ + protected final URL getURL() { + return fLocation; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/RankedWordProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/RankedWordProposal.java new file mode 100644 index 0000000..9909796 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/RankedWordProposal.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +/** + * Ranked word proposal for quick fix and content assist. + * + * @since 3.0 + */ +public class RankedWordProposal implements Comparable { + + /** The word rank */ + private int fRank; + + /** The word text */ + private final String fText; + + /** + * Creates a new ranked word proposal. + * + * @param text + * The text of this proposal + * @param rank + * The rank of this proposal + */ + public RankedWordProposal(final String text, final int rank) { + fText= text; + fRank= rank; + } + + /* + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public final int compareTo(Object object) { + + final RankedWordProposal word= (RankedWordProposal)object; + final int rank= word.getRank(); + + if (fRank < rank) + return -1; + + if (fRank > rank) + return 1; + + return 0; + } + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + public final boolean equals(Object object) { + + if (object instanceof RankedWordProposal) + return object.hashCode() == hashCode(); + + return false; + } + + /** + * Returns the rank of the word + * + * @return The rank of the word + */ + public final int getRank() { + return fRank; + } + + /** + * Returns the text of this word. + * + * @return The text of this word + */ + public final String getText() { + return fText; + } + + /* + * @see java.lang.Object#hashCode() + */ + public final int hashCode() { + return fText.hashCode(); + } + + /** + * Sets the rank of the word. + * + * @param rank + * The rank to set + */ + public final void setRank(final int rank) { + fRank= rank; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/SpellEvent.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/SpellEvent.java new file mode 100644 index 0000000..9d3eff5 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/SpellEvent.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.text.spelling.engine; + +import java.util.Set; + +/** + * Spell event fired for words detected by a spell-check iterator. + * + * @since 3.0 + */ +public class SpellEvent implements ISpellEvent { + + /** The begin index of the word in the spell-checkable medium */ + private final int fBegin; + + /** The spell-checker that causes the event */ + private final ISpellChecker fChecker; + + /** The end index of the word in the spell-checkable medium */ + private final int fEnd; + + /** Was the word found in the dictionary? */ + private final boolean fMatch; + + /** Does the word start a new sentence? */ + private final boolean fSentence; + + /** The word that causes the spell event */ + private final String fWord; + + /** + * Creates a new spell event. + * + * @param checker + * The spell-checker that causes the event + * @param word + * The word that causes the event + * @param begin + * The begin index of the word in the spell-checkable medium + * @param end + * The end index of the word in the spell-checkable medium + * @param sentence + * true iff the word starts a new sentence, + * false otherwise + * @param match + * true iff the word was found in the dictionary, + * false otherwise + */ + protected SpellEvent(final ISpellChecker checker, final String word, final int begin, final int end, final boolean sentence, final boolean match) { + fChecker= checker; + fEnd= end; + fBegin= begin; + fWord= word; + fSentence= sentence; + fMatch= match; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getBegin() + */ + public final int getBegin() { + return fBegin; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getEnd() + */ + public final int getEnd() { + return fEnd; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals() + */ + public final Set getProposals() { + return fChecker.getProposals(fWord, fSentence); + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#getWord() + */ + public final String getWord() { + return fWord; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#isMatch() + */ + public final boolean isMatch() { + return fMatch; + } + + /* + * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent#isStart() + */ + public final boolean isStart() { + return fSentence; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/package.html b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/package.html new file mode 100644 index 0000000..6ecebe0 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/engine/package.html @@ -0,0 +1,84 @@ + + + + + + + Package-level Javadoc + + +Provides the core functionality for spell-checking documents +

+Package Specification

+This package provides the interfaces for the notions of dictionary, edit distance, phonetic hash, +spell event and spell-check iterator. For most of these interfaces a default implementation +for english languages is provided. These implementations can be reused in custom dictionaries or +spell-check iterators, or replaced by more specialized algorithms for a particular group of languages. +

+Spell Check Engine

+The central point to access the spell-checker functionality is the interface ISpellCheckEngine. +Implementations of this interface provide support for life-cycle management, registering and unregistering +dictionaries, changing the locale of the engine and creating a spell-checker for a specific language. +

+The following steps are needed to obtain a spell-checker for a specific language: +

    +
  • Create an instance of ISpellCheckEngine. In this package, no default implementation is provided, +since the management of the dictionary registering and loading is application dependent. Usually, instances +of ISpellCheckEngine are implemented as singletons.
  • +
  • Create the appropriate dictionaries that should be used during the spell-check process. All dictionaries that +can be registered with ISpellCheckEngine must implement the interface ISpellCheckDictionary. +For this interface, an abstract implementation is provided in the class AbstractSpellDictionary. +Depending on the language of the words contained in this dictionary, custom algorithms for the phonetic hash + (IPhoneticHashProvider) and the edit distance (IPhoneticDistanceAlgorithm) should be implemented + and registered with the dictionary.
  • +
  • Instances of spell-checkers can now be created by calling createSpellChecker(Locale), where the locale + denotes the language that the spell-checker should use while executing.
  • +
+When requesting a new spell-checker with a different locale via createSpellChecker(Locale), the spell-checker is +reconfigured with the new dictionaries. More concretely, the old dictionary is unregistered and a new one registered for the +desired locale is associated with the spell-checker. If no such dictionary is available, no spell-checker is returned and +the locale of the engine is reset to its default locale. +

+Dictionaries

+Dictionaries are the data structures to hold word lists for a particular language. All implementations of dictionaries must +implement the interface ISpellDictionary. It provides support for life-cycle management as well as the facility to query +words from the list, add words to the list and get correction proposals for incorrectly spelt words. +

+This package provides a default implementation of a dictionary (AbstractSpellDictionary) that uses algorithms +convenient for english languages.
+Every dictionary needs two kinds of algorithms to be plugged in: +

    +
  • An edit distance algorithm: Edit distance algorithms implement the interface IPhoneticDistanceAlgorithm. The algorithm +is used to determine the similarity between two words. This package provides a default implementation for languages using the latin alphabet (DefaultPhoneticDistanceAlgorithm). +The default algorithm uses the Levenshtein text edit distance.
  • +
  • A hash algorithm: Phonetic hash providers implement the interface IPhoneticHashProvider. The purpose of +phonetic hashes is to have a representation of words which allows comparing it to other, similar words. This package provides a default +implementation which is convenient for slavic and english languages. It uses the double metaphone algorithm by published +Lawrence Philips.
  • +
+By plugging in custom implementations of one or both of these algorithms the abstract implementation AbstractSpellDictionary can +be customized to specified languages and alphabets. +

+Spell Check Iterators

+Instances of ISpellChecker are usually language-, locale- and medium independent implementations and therefore need an input provider. The +interface ISpellCheckIterator serves this purpose by abstracting the tokenizing of text media to a simple iteration. The actual spell-check process +is launched by calling ISpellChecker#execute(ISpellCheckIterator). This method uses the indicated spell-check iterator to determine the +words that are to be spell-checked. This package provides no default implementation of a spell-check iterator. +

+Event Handling

+To communicate the results of a spell-check pass, spell-checkers fire spell events that inform listeners about the status +of a particular word being spell-checked. Instances that are interested in receiving spell events must implement +the interface ISpellEventListener and register with the spell-checker before the spell-check process starts.

+A spell event contains the following information: +

    +
  • The word being spell-checked
  • +
  • The begin index of the current word in the text medium
  • +
  • The end index in the text medium
  • +
  • A flag whether this word was found in one of the registered dictionaries
  • +
  • A flag that indicates whether this word starts a new sentence
  • +
  • The set of proposals if the word was not correctly spelt. This information is lazily computed.
  • +
+Spell event listeners are free to handle the events in any way. However, listeners are not allowed to block during +the event handling unless the spell-checking process happens in another thread. + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/package.html b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/package.html new file mode 100644 index 0000000..f880e28 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/spelling/package.html @@ -0,0 +1,70 @@ + + + + + + + Package-level Javadoc + + +Provides facilities for spell-checking of comments and strings in Java source code. +

+Package Specification

+The content of this package extends the base functionality of the spell-checking engine. +

+It contains a spell-check engine specialized in Javadoc comments. +Several dictionaries with Java specific content like Javadoc keywords, HTML tags and Task tags +are provided. +Additionally, the engine contributes correction proposals to the QuickFix processor. +For non Java specific content the engine also contributes +word completion proposals to the content assist processor. +

+Spell-check engine

+SpellCheckEngine is the default implementation of the interface ISpellCheckEngine. +It provides a facade for dealing with the setup of a spell-checker. This class provides methods +to retrieve the available dictionaries and is responsible for the registration of those with the spell-checker. +SpellCheckEngine also has support for life-cycle management. Single dictionaries can be temporarily +unloaded from memory or unregistered.
+To contribute own dictionaries use the methods to register locale sensitive or insensitive dictionaries. A dictionary can +be associated to a specified locale, but can also be available for spell-checking arbitrary text in arbitrary languages. +The actual spell-checker for a specified language can then be obtained by calling createSpellChecker(Locale). +This is the central point to working with the spell-checker. When requesting a spell-checker for a specified locale, the +engine looks up the corresponding dictionary and registers it with the spell-checker. Note that the dictionaries +are lazily loaded and can be further optimized by prefiltering the queried words. +

+Note: Locale sensitive dictionaries must be located in the "dictionaries/" subdirectory of the JDT UI plugin install +location. The dictionaries are newline-separated word lists having the filename "language_country.dictionary", where "language" and "country" are +the lowercase ISO-3166 language and country codes, respectively. The default dictionary is "en_us.dictionary". For correct +behavior of the spell-check engine, at least the default dictionary must be installed. The default dictionary corresponds to the default locale +of the spell-check engine. +

+Dictionaries

+This implementation for a Javadoc comment spell-checker provides the following read-only +dictionaries: +
    +
  • A dictionary for Javadoc tags: This dictionary contains the most commonly used Javadoc tags. When +spell-checking Javadoc comments, this dictionary contributes correction proposals to the QuickFix processor to correct misspelt Javadoc tags.
  • +
  • A dictionary for HTML tags: This dictionary contains the most commonly used HTML tags for writing Javadoc comments. When spell-checking +Javadoc- or multiline comments, this dictionary contributes correction proposals to the QuickFix processor as well as +word completion proposals to the Content Assist processor.
  • +
  • A dictionary for Task tags: This dictionary reflects the currently available Java Task tags. When spell-checking arbitrary text in Java files, +this dictionary contributes proposals both to the QuickFix processor and the Content Assist processor.
  • +
+

+QuickFix processor

+The comment spell-checker also contributes a quickfix processor as an extension. This implementation of a quickfix processor +contributes the following correction proposals: +
    +
  • Proposals for correct spelling: A number of words considered most similar to the incorrectly spelt word.
  • +
  • The proposal to correct the sentence capitalization: This proposal is offered on incorrectly spelt words at the beginning of a sentence. +
  • The proposal to add the unrecognized word to the locale-insensitive dictionaries
  • +
  • The proposal to ignore the word during the current editing session
  • +
+

+Content Assist processor

+The last contribution of the spell-checker is the support for word completion. The spell-checker provides a custom +content assist processor to produce word completion proposals.
+Word completion works on all non Java code content types and delivers a number of proposals based on the current +caret position. + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java index 238423d..539a49b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java @@ -177,6 +177,8 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom return PHPUiImages.get(PHPUiImages.IMG_DEFINE); case PHPIdentifierLocation.VARIABLE : return PHPUiImages.get(PHPUiImages.IMG_VAR); + case PHPIdentifierLocation.GLOBAL_VARIABLE : + return PHPUiImages.get(PHPUiImages.IMG_VAR); } return PHPUiImages.get(PHPUiImages.IMG_FUN); } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java index 8c71647..b023981 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java @@ -11,10 +11,11 @@ package net.sourceforge.phpdt.ui; import net.sourceforge.phpdt.core.IClasspathEntry; +import net.sourceforge.phpdt.internal.ui.text.spelling.SpellCheckEngine; +import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckPreferenceKeys; import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpdt.ui.JavaUI; import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; @@ -1588,7 +1589,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_CHECK_SPELLING= ISpellCheckPreferenceKeys.SPELLING_CHECK_SPELLING; + public final static String SPELLING_CHECK_SPELLING= ISpellCheckPreferenceKeys.SPELLING_CHECK_SPELLING; /** * A named preference that controls whether words containing digits should @@ -1599,7 +1600,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_IGNORE_DIGITS= ISpellCheckPreferenceKeys.SPELLING_IGNORE_DIGITS; + public final static String SPELLING_IGNORE_DIGITS= ISpellCheckPreferenceKeys.SPELLING_IGNORE_DIGITS; /** * A named preference that controls whether mixed case words should be @@ -1610,7 +1611,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_IGNORE_MIXED= ISpellCheckPreferenceKeys.SPELLING_IGNORE_MIXED; + public final static String SPELLING_IGNORE_MIXED= ISpellCheckPreferenceKeys.SPELLING_IGNORE_MIXED; /** * A named preference that controls whether sentence capitalization should @@ -1621,7 +1622,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_IGNORE_SENTENCE= ISpellCheckPreferenceKeys.SPELLING_IGNORE_SENTENCE; + public final static String SPELLING_IGNORE_SENTENCE= ISpellCheckPreferenceKeys.SPELLING_IGNORE_SENTENCE; /** * A named preference that controls whether upper case words should be @@ -1632,7 +1633,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_IGNORE_UPPER= ISpellCheckPreferenceKeys.SPELLING_IGNORE_UPPER; + public final static String SPELLING_IGNORE_UPPER= ISpellCheckPreferenceKeys.SPELLING_IGNORE_UPPER; /** * A named preference that controls whether urls should be ignored during @@ -1643,7 +1644,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_IGNORE_URLS= ISpellCheckPreferenceKeys.SPELLING_IGNORE_URLS; + public final static String SPELLING_IGNORE_URLS= ISpellCheckPreferenceKeys.SPELLING_IGNORE_URLS; /** * A named preference that controls the locale used for spell-checking. @@ -1653,7 +1654,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_LOCALE= ISpellCheckPreferenceKeys.SPELLING_LOCALE; + public final static String SPELLING_LOCALE= ISpellCheckPreferenceKeys.SPELLING_LOCALE; /** * A named preference that controls the number of proposals offered during @@ -1664,7 +1665,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_PROPOSAL_THRESHOLD= ISpellCheckPreferenceKeys.SPELLING_PROPOSAL_THRESHOLD; + public final static String SPELLING_PROPOSAL_THRESHOLD= ISpellCheckPreferenceKeys.SPELLING_PROPOSAL_THRESHOLD; /** * A named preference that specifies the workspace user dictionary. @@ -1674,7 +1675,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_USER_DICTIONARY= ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY; + public final static String SPELLING_USER_DICTIONARY= ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY; /** * A named preference that specifies whether spelling dictionaries are available to content assist. @@ -1684,7 +1685,7 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t * * @since 3.0 */ -// public final static String SPELLING_ENABLE_CONTENTASSIST= ISpellCheckPreferenceKeys.SPELLING_ENABLE_CONTENTASSIST; + public final static String SPELLING_ENABLE_CONTENTASSIST= ISpellCheckPreferenceKeys.SPELLING_ENABLE_CONTENTASSIST; /** * A named preference that controls whether code snippets are formatted @@ -2394,6 +2395,18 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, ctrl); store.setDefault(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, SWT.CTRL); +// spell checking + store.setDefault(PreferenceConstants.SPELLING_CHECK_SPELLING, false); + store.setDefault(PreferenceConstants.SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString()); + store.setDefault(PreferenceConstants.SPELLING_IGNORE_DIGITS, true); + store.setDefault(PreferenceConstants.SPELLING_IGNORE_MIXED, true); + store.setDefault(PreferenceConstants.SPELLING_IGNORE_SENTENCE, true); + store.setDefault(PreferenceConstants.SPELLING_IGNORE_UPPER, true); + store.setDefault(PreferenceConstants.SPELLING_IGNORE_URLS, true); + store.setDefault(PreferenceConstants.SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$ + store.setDefault(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD, 20); + store.setDefault(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST, false); + // folding store.setDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED, true); store.setDefault(PreferenceConstants.EDITOR_FOLDING_PROVIDER, "org.eclipse.jdt.ui.text.defaultFoldingProvider"); //$NON-NLS-1$ diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java index 1b9238d..f29628e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java @@ -1,17 +1,22 @@ package net.sourceforge.phpeclipse; + import net.sourceforge.phpeclipse.views.browser.BrowserView; import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.search.ui.SearchUI; +import org.eclipse.search.ui.NewSearchUI; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; import org.eclipse.ui.console.IConsoleConstants; + //import org.eclipse.update.internal.ui.UpdatePerspective; public class PHPPerspectiveFactory implements IPerspectiveFactory { + public static final String ID_PROGRESS_VIEW= "org.eclipse.ui.views.ProgressView"; // see bug 63563 //$NON-NLS-1$ + public PHPPerspectiveFactory() { super(); } + public void createInitialLayout(IPageLayout layout) { String editorArea = layout.getEditorArea(); // IFolderLayout phpResourcesArea = layout.createFolder("phpresourcesarea", @@ -24,17 +29,21 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory { IFolderLayout outputfolder = layout.createFolder("bottom", IPageLayout.BOTTOM, (float) 0.75, editorArea); //$NON-NLS-1$ outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW); - outputfolder.addPlaceholder(SearchUI.SEARCH_RESULT_VIEW_ID); + + outputfolder.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID); outputfolder.addView(IConsoleConstants.ID_CONSOLE_VIEW); outputfolder.addView(IPageLayout.ID_BOOKMARKS); + outputfolder.addPlaceholder(ID_PROGRESS_VIEW); layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float) 0.75, editorArea); layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); layout.addShowViewShortcut(BrowserView.ID_BROWSER); - // views - search - layout.addShowViewShortcut(SearchUI.SEARCH_RESULT_VIEW_ID); + + // views - search + layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID); + // views - debugging layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); // views - standard workbench @@ -49,4 +58,4 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory { layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$ } -} +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 0d7154f..b094bc7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -10,6 +10,7 @@ Klaus Hartlage - www.eclipseproject.de **********************************************************************/ package net.sourceforge.phpeclipse; + import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -28,10 +29,17 @@ import net.sourceforge.phpdt.core.WorkingCopyOwner; import net.sourceforge.phpdt.externaltools.internal.model.ColorManager; import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin; import net.sourceforge.phpdt.externaltools.internal.model.VariableContextManager; +import net.sourceforge.phpdt.internal.core.BatchOperation; +import net.sourceforge.phpdt.internal.core.JavaModelManager; +import net.sourceforge.phpdt.internal.core.util.Util; +import net.sourceforge.phpdt.internal.ui.IJavaStatusConstants; import net.sourceforge.phpdt.internal.ui.JavaElementAdapterFactory; import net.sourceforge.phpdt.internal.ui.ResourceAdapterFactory; import net.sourceforge.phpdt.internal.ui.preferences.MembersOrderPreferenceCache; +import net.sourceforge.phpdt.internal.ui.preferences.MockupPreferenceStore; import net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage; +import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter; +import net.sourceforge.phpdt.internal.ui.text.folding.JavaFoldingStructureProviderRegistry; import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor; import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry; import net.sourceforge.phpdt.internal.ui.viewsupport.ProblemMarkerManager; @@ -50,23 +58,26 @@ import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr; import net.sourceforge.phpeclipse.phpeditor.WorkingCopyManager; import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; -import org.eclipse.core.boot.BootLoader; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.ISavedState; import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; 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; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -import net.sourceforge.phpdt.internal.ui.text.folding.JavaFoldingStructureProviderRegistry; - -import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; @@ -93,97 +104,141 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.ChainedPreferenceStore; +import org.eclipse.ui.texteditor.ConfigurationElementSorter; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; import org.osgi.framework.BundleContext; + /** * The main plugin class to be used in the desktop. */ -public class PHPeclipsePlugin extends AbstractUIPlugin - implements - IPreferenceConstants { +public class PHPeclipsePlugin extends AbstractUIPlugin implements + IPreferenceConstants { /** * The id of the PHP plugin (value "net.sourceforge.phpeclipse"). */ public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$ + /** * id of builder - matches plugin.xml (concatenate pluginid.builderid) */ public static final String BUILDER_PARSER_ID = PLUGIN_ID + ".parserbuilder"; + //public static final String BUILDER_INDEX_ID = PLUGIN_ID + ".indexbuilder"; /** General debug flag */ public static final boolean DEBUG = false; + /** * The maximum number of allowed proposals by category */ public final static int MAX_PROPOSALS = 200; + private static ExternalToolsPlugin externalTools; + /** * The Java virtual machine that we are running on. */ private static int jvm; + /** MRJ 2.0 */ private static final int MRJ_2_0 = 0; + /** MRJ 2.1 or later */ private static final int MRJ_2_1 = 1; + /** Java on Mac OS X 10.0 (MRJ 3.0) */ private static final int MRJ_3_0 = 3; + /** MRJ 3.1 */ private static final int MRJ_3_1 = 4; + /** JVM constant for any other platform */ private static final int OTHER = -1; + // public static final String PHP_RESOURCES_VIEW_ID = PLUGIN_ID + // ".resourcesview.ViewPHPResources"; //$NON-NLS-1$ public static final String PHP_CODING_ACTION_SET_ID = PLUGIN_ID + ".ui.CodingActionSet"; //$NON-NLS-1$ + public final static String PHP_NATURE_ID = PLUGIN_ID + ".phpnature"; + public static final String PHPPARSER_ORIGINAL = "net.sourceforge.phpdt.internal.compiler.parser.Parser"; + public static final String PHPPARSER_NEW = "test.PHPParser"; + /** Change this if you want to switch PHP Parser. */ public static final String PHPPARSER = PHPPARSER_ORIGINAL; + //The shared instance. private static PHPeclipsePlugin plugin; + /** Windows 9x */ private static final int WINDOWS_9x = 6; + /** Windows NT */ private static final int WINDOWS_NT = 5; + private ImageDescriptorRegistry fImageDescriptorRegistry; + private HashMap fIndexManagerMap = new HashMap(); + private IWorkingCopyManager fWorkingCopyManager; - private IBufferFactory fBufferFactory; + + private IBufferFactory fBufferFactory; + private PHPDocumentProvider fCompilationUnitDocumentProvider; + private JavaTextTools fJavaTextTools; + private ProblemMarkerManager fProblemMarkerManager; + private MembersOrderPreferenceCache fMembersOrderPreferenceCache; + private IFile fLastEditorFile = null; + private JavaEditorTextHoverDescriptor[] fJavaEditorTextHoverDescriptors; - + private JavaElementAdapterFactory fJavaElementAdapterFactory; -// private MarkerAdapterFactory fMarkerAdapterFactory; -// private EditorInputAdapterFactory fEditorInputAdapterFactory; - private ResourceAdapterFactory fResourceAdapterFactory; -// private LogicalPackageAdapterFactory fLogicalPackageAdapterFactory; - private IPropertyChangeListener fFontPropertyChangeListener; - /** - * Property change listener on this plugin's preference store. - * - * @since 3.0 - */ - private IPropertyChangeListener fPropertyChangeListener; - - /** - * The combined preference store. - * @since 3.0 - */ - private IPreferenceStore fCombinedPreferenceStore; - /** - * The extension point registry for the org.eclipse.jdt.ui.javaFoldingStructureProvider - * extension point. - * - * @since 3.0 - */ - private JavaFoldingStructureProviderRegistry fFoldingStructureProviderRegistry; + + // private MarkerAdapterFactory fMarkerAdapterFactory; + // private EditorInputAdapterFactory fEditorInputAdapterFactory; + private ResourceAdapterFactory fResourceAdapterFactory; + + // private LogicalPackageAdapterFactory fLogicalPackageAdapterFactory; + private IPropertyChangeListener fFontPropertyChangeListener; + + /** + * Property change listener on this plugin's preference store. + * + * @since 3.0 + */ + private IPropertyChangeListener fPropertyChangeListener; + + /** + * The combined preference store. + * + * @since 3.0 + */ + private IPreferenceStore fCombinedPreferenceStore; + + /** + * The extension point registry for the + * org.eclipse.jdt.ui.javaFoldingStructureProvider extension + * point. + * + * @since 3.0 + */ + private JavaFoldingStructureProviderRegistry fFoldingStructureProviderRegistry; + + /** + * Mockup preference store for firing events and registering listeners on + * project setting changes. FIXME: Temporary solution. + * + * @since 3.0 + */ + private MockupPreferenceStore fMockupPreferenceStore; + /** * The constructor. */ @@ -199,6 +254,20 @@ public class PHPeclipsePlugin extends AbstractUIPlugin // resourceBundle = null; // } } + + // /** + // * Returns all Java editor text hovers contributed to the workbench. + // * + // * @return an array of JavaEditorTextHoverDescriptor + // * @since 2.1 + // */ + // public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() + // { + // if (fJavaEditorTextHoverDescriptors == null) + // fJavaEditorTextHoverDescriptors = JavaEditorTextHoverDescriptor + // .getContributedHovers(); + // return fJavaEditorTextHoverDescriptors; + // } /** * Returns all Java editor text hovers contributed to the workbench. * @@ -206,11 +275,88 @@ public class PHPeclipsePlugin extends AbstractUIPlugin * @since 2.1 */ public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() { - if (fJavaEditorTextHoverDescriptors == null) + if (fJavaEditorTextHoverDescriptors == null) { fJavaEditorTextHoverDescriptors = JavaEditorTextHoverDescriptor .getContributedHovers(); + ConfigurationElementSorter sorter = new ConfigurationElementSorter() { + /* + * @see org.eclipse.ui.texteditor.ConfigurationElementSorter#getConfigurationElement(java.lang.Object) + */ + public IConfigurationElement getConfigurationElement(Object object) { + return ((JavaEditorTextHoverDescriptor) object) + .getConfigurationElement(); + } + }; + sorter.sort(fJavaEditorTextHoverDescriptors); + + // The Problem hover has to be the first and the Annotation hover has to + // be the last one in the JDT UI's hover list + int length = fJavaEditorTextHoverDescriptors.length; + int first = -1; + int last = length - 1; + int problemHoverIndex = -1; + int annotationHoverIndex = -1; + for (int i = 0; i < length; i++) { + if (!fJavaEditorTextHoverDescriptors[i].getId().startsWith(PLUGIN_ID)) { + if (problemHoverIndex == -1 || annotationHoverIndex == -1) + continue; + else { + last = i - 1; + break; + } + } + if (first == -1) + first = i; + + if (fJavaEditorTextHoverDescriptors[i].getId().equals( + "net.sourceforge.phpdt.ui.AnnotationHover")) { //$NON-NLS-1$ + annotationHoverIndex = i; + continue; + } + if (fJavaEditorTextHoverDescriptors[i].getId().equals( + "net.sourceforge.phpdt.ui.ProblemHover")) { //$NON-NLS-1$ + problemHoverIndex = i; + continue; + } + } + + JavaEditorTextHoverDescriptor hoverDescriptor = null; + + if (first > -1 && problemHoverIndex > -1 && problemHoverIndex != first) { + // move problem hover to beginning + hoverDescriptor = fJavaEditorTextHoverDescriptors[first]; + fJavaEditorTextHoverDescriptors[first] = fJavaEditorTextHoverDescriptors[problemHoverIndex]; + fJavaEditorTextHoverDescriptors[problemHoverIndex] = hoverDescriptor; + + // update annotation hover index if needed + if (annotationHoverIndex == first) + annotationHoverIndex = problemHoverIndex; + } + + if (annotationHoverIndex > -1 && annotationHoverIndex != last) { + // move annotation hover to end + hoverDescriptor = fJavaEditorTextHoverDescriptors[last]; + fJavaEditorTextHoverDescriptors[last] = fJavaEditorTextHoverDescriptors[annotationHoverIndex]; + fJavaEditorTextHoverDescriptors[annotationHoverIndex] = hoverDescriptor; + } + + // Move Best Match hover to front + for (int i = 0; i < fJavaEditorTextHoverDescriptors.length - 1; i++) { + if (PreferenceConstants.ID_BESTMATCH_HOVER + .equals(fJavaEditorTextHoverDescriptors[i].getId())) { + hoverDescriptor = fJavaEditorTextHoverDescriptors[i]; + for (int j = i; j > 0; j--) + fJavaEditorTextHoverDescriptors[j] = fJavaEditorTextHoverDescriptors[j - 1]; + fJavaEditorTextHoverDescriptors[0] = hoverDescriptor; + break; + } + + } + } + return fJavaEditorTextHoverDescriptors; } + /** * Resets the Java editor text hovers contributed to the workbench. *

@@ -224,6 +370,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin public void resetJavaEditorTextHoverDescriptors() { fJavaEditorTextHoverDescriptors = null; } + /** * Creates the PHP plugin standard groups in a context menu. */ @@ -242,12 +389,15 @@ public class PHPeclipsePlugin extends AbstractUIPlugin menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); } + public static IWorkbenchPage getActivePage() { return getDefault().internalGetActivePage(); } + public static Shell getActiveWorkbenchShell() { return getActiveWorkbenchWindow().getShell(); } + /** * Returns an array of all editors that have an unsaved content. If the * identical content is presented in more than one editor, only one of those @@ -276,27 +426,34 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]); } + public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } + /** * Returns the shared instance. */ public static PHPeclipsePlugin getDefault() { return plugin; } + public static ImageDescriptorRegistry getImageDescriptorRegistry() { return getDefault().internalGetImageDescriptorRegistry(); } + static IPath getInstallLocation() { return new Path(getDefault().getDescriptor().getInstallURL().getFile()); } + public static int getJVM() { return jvm; } + public static String getPluginId() { return getDefault().getDescriptor().getUniqueIdentifier(); } + /** * Returns the standard display to be used. The method first checks, if the * thread calling this method has an associated display. If so, this display @@ -309,6 +466,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } return display; } + // public static ExternalToolsPlugin getExternalTools() { // return externalTools; // } @@ -318,9 +476,11 @@ public class PHPeclipsePlugin extends AbstractUIPlugin public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } + public static boolean isDebug() { return getDefault().isDebugging(); } + // public static void logErrorMessage(String message) { // log(new Status(IStatus.ERROR, getPluginId(), // JavaStatusConstants.INTERNAL_ERROR, message, null)); @@ -346,13 +506,21 @@ public class PHPeclipsePlugin extends AbstractUIPlugin Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null); log(status); } + public static void log(IStatus status) { getDefault().getLog().log(status); } + public static void log(Throwable e) { log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$ } + + public static void logErrorMessage(String message) { + log(new Status(IStatus.ERROR, getPluginId(), + IJavaStatusConstants.INTERNAL_ERROR, message, null)); + } + private static void setJVM() { String osName = System.getProperty("os.name"); if (osName.startsWith("Mac OS")) { @@ -380,6 +548,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } } } + // TODO: refactor this into a better method name ! public synchronized PHPDocumentProvider getCompilationUnitDocumentProvider() { if (fCompilationUnitDocumentProvider == null) @@ -391,7 +560,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin * Get the identifier index manager for the given project * * @param iProject - * the current project + * the current project * @return */ public IdentifierIndexManager getIndexManager(IProject iProject) { @@ -405,6 +574,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } return indexManager; } + public synchronized IWorkingCopyManager getWorkingCopyManager() { if (fWorkingCopyManager == null) { PHPDocumentProvider provider = getCompilationUnitDocumentProvider(); @@ -412,25 +582,40 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } return fWorkingCopyManager; } + public synchronized MembersOrderPreferenceCache getMemberOrderPreferenceCache() { if (fMembersOrderPreferenceCache == null) fMembersOrderPreferenceCache = new MembersOrderPreferenceCache(); return fMembersOrderPreferenceCache; } + + /** + * Returns the mockup preference store for firing events and registering + * listeners on project setting changes. Temporary solution. + */ + public MockupPreferenceStore getMockupPreferenceStore() { + if (fMockupPreferenceStore == null) + fMockupPreferenceStore = new MockupPreferenceStore(); + + return fMockupPreferenceStore; + } + public synchronized ProblemMarkerManager getProblemMarkerManager() { if (fProblemMarkerManager == null) fProblemMarkerManager = new ProblemMarkerManager(); return fProblemMarkerManager; } - + public synchronized JavaTextTools getJavaTextTools() { if (fJavaTextTools == null) fJavaTextTools = new JavaTextTools(getPreferenceStore()); return fJavaTextTools; } + public IFile getLastEditorFile() { return fLastEditorFile; } + /** * Returns the string from the plugin's resource bundle, or 'key' if not * found. @@ -452,23 +637,23 @@ public class PHPeclipsePlugin extends AbstractUIPlugin protected void initializeDefaultPreferences(IPreferenceStore store) { // windows preferences: store.setDefault(LOCALHOST_PREF, "http://localhost"); -// store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true"); + // store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true"); store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false"); store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true"); store.setDefault(PHP_OBFUSCATOR_DEFAULT, "c:\\temp"); store.setDefault(PHP_BOOKMARK_DEFAULT, ""); - + store.setDefault(PHP_AUTO_PREVIEW_DEFAULT, "true"); store.setDefault(PHP_BRING_TO_TOP_PREVIEW_DEFAULT, "true"); - - String windowsSystem = BootLoader.getWS(); + + String windowsSystem = Platform.getWS(); if (jvm == WINDOWS_9x) { store.setDefault(EXTERNAL_BROWSER_PREF, "command.com /c start iexplore {0}"); - } else if (windowsSystem.equals(BootLoader.WS_WIN32)) { + } else if (windowsSystem.equals(Platform.WS_WIN32)) { store.setDefault(EXTERNAL_BROWSER_PREF, "rundll32 url.dll,FileProtocolHandler {0}"); - } else if (windowsSystem.equals(BootLoader.WS_CARBON)) { + } else if (windowsSystem.equals(Platform.WS_CARBON)) { // TODO How do we start Safari on Mac OS X ? store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}"); } else { @@ -479,7 +664,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin .toString()); // if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) { // - if (windowsSystem.equals(BootLoader.WS_WIN32)) { + if (windowsSystem.equals(Platform.WS_WIN32)) { store.setDefault(PHP_RUN_PREF, "c:\\apache\\php\\php.exe"); store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php -l -f {0}"); store.setDefault(MYSQL_RUN_PREF, "c:\\apache\\mysql\\bin\\mysqld-nt.exe"); @@ -533,15 +718,17 @@ public class PHPeclipsePlugin extends AbstractUIPlugin PHPColorProvider.PHPDOC_LINK); PreferenceConverter.setDefault(store, PHPDOC_DEFAULT, PHPColorProvider.PHPDOC_DEFAULT); - - PreferenceConverter.setDefault(store, EDITOR_PHP_KEYWORD_RETURN_COLOR, new RGB(127, 0, 85)); - store.setDefault(EDITOR_PHP_KEYWORD_RETURN_BOLD, true); - store.setDefault(EDITOR_PHP_KEYWORD_RETURN_ITALIC, false); - - PreferenceConverter.setDefault(store, EDITOR_PHP_OPERATOR_COLOR, new RGB(0, 0, 0)); - store.setDefault(EDITOR_PHP_OPERATOR_BOLD, false); - store.setDefault(EDITOR_PHP_OPERATOR_ITALIC, false); - + + PreferenceConverter.setDefault(store, EDITOR_PHP_KEYWORD_RETURN_COLOR, + new RGB(127, 0, 85)); + store.setDefault(EDITOR_PHP_KEYWORD_RETURN_BOLD, true); + store.setDefault(EDITOR_PHP_KEYWORD_RETURN_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_PHP_OPERATOR_COLOR, new RGB(0, + 0, 0)); + store.setDefault(EDITOR_PHP_OPERATOR_BOLD, false); + store.setDefault(EDITOR_PHP_OPERATOR_ITALIC, false); + // PreferenceConverter.setDefault( // store, // PHP_EDITOR_BACKGROUND, @@ -588,19 +775,22 @@ public class PHPeclipsePlugin extends AbstractUIPlugin JavaCore.initializeDefaultPluginPreferences(); PreferenceConstants.initializeDefaultValues(store); externalTools.initializeDefaultPreferences(store); - MarkerAnnotationPreferences.initializeDefaultValues(store); + MarkerAnnotationPreferences.initializeDefaultValues(store); } + private IWorkbenchPage internalGetActivePage() { IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow(); if (window != null) return window.getActivePage(); return null; } + private ImageDescriptorRegistry internalGetImageDescriptorRegistry() { if (fImageDescriptorRegistry == null) fImageDescriptorRegistry = new ImageDescriptorRegistry(); return fImageDescriptorRegistry; } + /** * Open a file in the Workbench that may or may not exist in the workspace. * Must be run on the UI thread. @@ -632,7 +822,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin IEditorDescriptor desc = registry.getDefaultEditor(filename); if (desc == null) { desc = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); - // desc = registry.getDefaultEditor(); + // desc = registry.getDefaultEditor(); } IEditorInput input = new ExternalEditorInput(storage); editor = page.openEditor(input, desc.getId()); @@ -647,6 +837,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } return textEditor; } + /** * Open a file in the Workbench that may or may not exist in the workspace. * Must be run on the UI thread. @@ -673,6 +864,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } } } + /** * Open a file in the Workbench that may or may not exist in the workspace. * Must be run on the UI thread. @@ -693,6 +885,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } } } + public void openFileAndFindString(String filename, String findString) throws CoreException { ITextEditor textEditor = openFileInTextEditor(filename); @@ -710,322 +903,515 @@ public class PHPeclipsePlugin extends AbstractUIPlugin } } } + public void setLastEditorFile(IFile textEditor) { this.fLastEditorFile = textEditor; } - /* - * @see org.eclipse.core.runtime.Plugin#stop - */ - public void stop(BundleContext context) throws Exception { - try { - JavaCore.stop(this, context); - - ColorManager.getDefault().dispose(); - // save the information from the php index files if necessary - Collection collection = fIndexManagerMap.values(); - Iterator iterator = collection.iterator(); - IdentifierIndexManager indexManager = null; - while (iterator.hasNext()) { - indexManager = (IdentifierIndexManager) iterator.next(); - indexManager.writeFile(); - } - if (fImageDescriptorRegistry != null) - fImageDescriptorRegistry.dispose(); - -// AllTypesCache.terminate(); - - if (fImageDescriptorRegistry != null) - fImageDescriptorRegistry.dispose(); - - unregisterAdapters(); - -// if (fASTProvider != null) { -// fASTProvider.dispose(); -// fASTProvider= null; -// } - - if (fWorkingCopyManager != null) { - fWorkingCopyManager.shutdown(); - fWorkingCopyManager= null; - } - - if (fCompilationUnitDocumentProvider != null) { - fCompilationUnitDocumentProvider.shutdown(); - fCompilationUnitDocumentProvider= null; - } - - if (fJavaTextTools != null) { - fJavaTextTools.dispose(); - fJavaTextTools= null; - } -// JavaDocLocations.shutdownJavadocLocations(); - - uninstallPreferenceStoreBackwardsCompatibility(); - -// RefactoringCore.getUndoManager().shutdown(); - } finally { - super.stop(context); - } - } + + /* + * @see org.eclipse.core.runtime.Plugin#stop + */ + public void stop(BundleContext context) throws Exception { + try { + // JavaCore.stop(this, context); + plugin.savePluginPreferences(); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + workspace.removeResourceChangeListener(JavaModelManager + .getJavaModelManager().deltaState); + workspace.removeSaveParticipant(plugin); + + JavaModelManager.getJavaModelManager().shutdown(); + + ColorManager.getDefault().dispose(); + // save the information from the php index files if necessary + Collection collection = fIndexManagerMap.values(); + Iterator iterator = collection.iterator(); + IdentifierIndexManager indexManager = null; + while (iterator.hasNext()) { + indexManager = (IdentifierIndexManager) iterator.next(); + indexManager.writeFile(); + } + if (fImageDescriptorRegistry != null) + fImageDescriptorRegistry.dispose(); + + // AllTypesCache.terminate(); + + if (fImageDescriptorRegistry != null) + fImageDescriptorRegistry.dispose(); + + unregisterAdapters(); + + // if (fASTProvider != null) { + // fASTProvider.dispose(); + // fASTProvider= null; + // } + + if (fWorkingCopyManager != null) { + fWorkingCopyManager.shutdown(); + fWorkingCopyManager = null; + } + + if (fCompilationUnitDocumentProvider != null) { + fCompilationUnitDocumentProvider.shutdown(); + fCompilationUnitDocumentProvider = null; + } + + if (fJavaTextTools != null) { + fJavaTextTools.dispose(); + fJavaTextTools = null; + } + // JavaDocLocations.shutdownJavadocLocations(); + + uninstallPreferenceStoreBackwardsCompatibility(); + + // RefactoringCore.getUndoManager().shutdown(); + } finally { + super.stop(context); + } + } + /** * @see org.eclipse.ui.plugin.AbstractUIPlugin#shutdown() */ -// public void shutdown() throws CoreException { -// // moved down (see below): -// // super.shutdown(); -// // externalTools.shutDown(); -// ColorManager.getDefault().dispose(); -// // save the information from the php index files if necessary -// Collection collection = fIndexManagerMap.values(); -// Iterator iterator = collection.iterator(); -// IdentifierIndexManager indexManager = null; -// while (iterator.hasNext()) { -// indexManager = (IdentifierIndexManager) iterator.next(); -// indexManager.writeFile(); -// } -// if (fImageDescriptorRegistry != null) -// fImageDescriptorRegistry.dispose(); -// // unregisterAdapters(); -// super.shutdown(); -// if (fWorkingCopyManager != null) { -// fWorkingCopyManager.shutdown(); -// fWorkingCopyManager = null; -// } -// if (fCompilationUnitDocumentProvider != null) { -// fCompilationUnitDocumentProvider.shutdown(); -// fCompilationUnitDocumentProvider = null; -// } -// if (fJavaTextTools != null) { -// fJavaTextTools.dispose(); -// fJavaTextTools = null; -// } -// // JavaDocLocations.shutdownJavadocLocations(); -// // -// // JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); -// // begin JavaCore#shutdown() -// //savePluginPreferences(); -// savePluginPreferences(); -// IWorkspace workspace = ResourcesPlugin.getWorkspace(); -// workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaState); -// workspace.removeSaveParticipant(this); -// ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown(); -// // end JavaCore#shutdown() -// } - /** - * Installs backwards compatibility for the preference store. - */ - private void installPreferenceStoreBackwardsCompatibility() { - - /* - * Installs backwards compatibility: propagate the Java editor font from a - * pre-2.1 plug-in to the Platform UI's preference store to preserve - * the Java editor font from a pre-2.1 workspace. This is done only - * once. - */ - String fontPropagatedKey= "fontPropagated"; //$NON-NLS-1$ - if (getPreferenceStore().contains(JFaceResources.TEXT_FONT) && !getPreferenceStore().isDefault(JFaceResources.TEXT_FONT)) { - if (!getPreferenceStore().getBoolean(fontPropagatedKey)) - PreferenceConverter.setValue(PlatformUI.getWorkbench().getPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT, PreferenceConverter.getFontDataArray(getPreferenceStore(), JFaceResources.TEXT_FONT)); - } - getPreferenceStore().setValue(fontPropagatedKey, true); - - /* - * Backwards compatibility: set the Java editor font in this plug-in's - * preference store to let older versions access it. Since 2.1 the - * Java editor font is managed by the workbench font preference page. - */ - PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT)); - - fFontPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty())) - PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT)); - } - }; - JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); - - /* - * Backwards compatibility: propagate the Java editor tab width from a - * pre-3.0 plug-in to the new preference key. This is done only once. - */ - final String oldTabWidthKey= PreferenceConstants.EDITOR_TAB_WIDTH; - final String newTabWidthKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH; - String tabWidthPropagatedKey= "tabWidthPropagated"; //$NON-NLS-1$ - if (getPreferenceStore().contains(oldTabWidthKey) && !getPreferenceStore().isDefault(oldTabWidthKey)) { - if (!getPreferenceStore().getBoolean(tabWidthPropagatedKey)) - getPreferenceStore().setValue(newTabWidthKey, getPreferenceStore().getInt(oldTabWidthKey)); - } - getPreferenceStore().setValue(tabWidthPropagatedKey, true); - - /* - * Backwards compatibility: set the Java editor tab width in this plug-in's - * preference store with the old key to let older versions access it. - * Since 3.0 the tab width is managed by the extended texteditor and - * uses a new key. - */ - getPreferenceStore().putValue(oldTabWidthKey, getPreferenceStore().getString(newTabWidthKey)); - - fPropertyChangeListener= new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (newTabWidthKey.equals(event.getProperty())) - getPreferenceStore().putValue(oldTabWidthKey, getPreferenceStore().getString(newTabWidthKey)); - } - }; - getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener); - - /* - * Backward compatibility for the refactoring preference key. - */ -// getPreferenceStore().setValue( -// PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, -// RefactoringCore.getConditionCheckingFailedSeverity()); - } - - /** - * Uninstalls backwards compatibility for the preference store. - */ - private void uninstallPreferenceStoreBackwardsCompatibility() { - JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); - getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); - } - /* (non - Javadoc) - * Method declared in Plugin - */ - public void start(BundleContext context) throws Exception { - super.start(context); - - JavaCore.start(this, context); - - registerAdapters(); - - // externalTools.startUp(); - getStandardDisplay().asyncExec(new Runnable() { - public void run() { - //initialize the variable context manager - VariableContextManager.getDefault(); - } - }); - -// if (USE_WORKING_COPY_OWNERS) { - WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() { - public IBuffer createBuffer(ICompilationUnit workingCopy) { - ICompilationUnit original= workingCopy.getPrimary(); - IResource resource= original.getResource(); - if (resource instanceof IFile) - return new DocumentAdapter(workingCopy, (IFile) resource); - return DocumentAdapter.NULL; - } - }); -// } - - installPreferenceStoreBackwardsCompatibility(); - -// AllTypesCache.initialize(); - - // Initialize AST provider -// getASTProvider(); - } -// public void startup() throws CoreException { -// super.startup(); -// // begin JavaCore.startup(); -// JavaModelManager manager = JavaModelManager.getJavaModelManager(); -// try { -// manager.configurePluginDebugOptions(); -// // request state folder creation (workaround 19885) -// // JavaCore.getPlugin().getStateLocation(); -// getStateLocation(); -// // retrieve variable values -// // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new -// // JavaModelManager.PluginPreferencesListener()); -// getPluginPreferences().addPropertyChangeListener( -// new JavaModelManager.PluginPreferencesListener()); -// // TODO khartlage temp-del -// // manager.loadVariablesAndContainers(); -// final IWorkspace workspace = ResourcesPlugin.getWorkspace(); -// workspace.addResourceChangeListener( -// manager.deltaState, -// IResourceChangeEvent.PRE_BUILD -// | IResourceChangeEvent.POST_BUILD -// | IResourceChangeEvent.POST_CHANGE -// | IResourceChangeEvent.PRE_DELETE -// | IResourceChangeEvent.PRE_CLOSE); -// // startIndexing(); -// workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager); -// } catch (CoreException e) { -// } catch (RuntimeException e) { -// manager.shutdown(); -// throw e; -// } -// // end JavaCore.startup(); -// IAdapterManager platformManager = Platform.getAdapterManager(); -// platformManager.registerAdapters(new PHPElementAdapterFactory(), -// PHPElement.class); -// platformManager.registerAdapters(new ResourceAdapterFactory(), -// IResource.class); -// // externalTools.startUp(); -// getStandardDisplay().asyncExec(new Runnable() { -// public void run() { -// //initialize the variable context manager -// VariableContextManager.getDefault(); -// } -// }); -// } - - - private void registerAdapters() { - fJavaElementAdapterFactory= new JavaElementAdapterFactory(); -// fMarkerAdapterFactory= new MarkerAdapterFactory(); -// fEditorInputAdapterFactory= new EditorInputAdapterFactory(); - fResourceAdapterFactory= new ResourceAdapterFactory(); -// fLogicalPackageAdapterFactory= new LogicalPackageAdapterFactory(); - - IAdapterManager manager= Platform.getAdapterManager(); - manager.registerAdapters(fJavaElementAdapterFactory, IJavaElement.class); -// manager.registerAdapters(fMarkerAdapterFactory, IMarker.class); -// manager.registerAdapters(fEditorInputAdapterFactory, IEditorInput.class); - manager.registerAdapters(fResourceAdapterFactory, IResource.class); -// manager.registerAdapters(fLogicalPackageAdapterFactory, LogicalPackage.class); - } - - private void unregisterAdapters() { - IAdapterManager manager= Platform.getAdapterManager(); - manager.unregisterAdapters(fJavaElementAdapterFactory); -// manager.unregisterAdapters(fMarkerAdapterFactory); -// manager.unregisterAdapters(fEditorInputAdapterFactory); - manager.unregisterAdapters(fResourceAdapterFactory); -// manager.unregisterAdapters(fLogicalPackageAdapterFactory); - } - - /** - * Returns a combined preference store, this store is read-only. - * - * @return the combined preference store - * - * @since 3.0 - */ - public IPreferenceStore getCombinedPreferenceStore() { - if (fCombinedPreferenceStore == null) { - IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore(); - fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(JavaCore.getPlugin().getPluginPreferences()), generalTextStore }); - } - return fCombinedPreferenceStore; - } - - public synchronized IBufferFactory getBufferFactory() { - if (fBufferFactory == null) - fBufferFactory= new CustomBufferFactory(); - return fBufferFactory; - } - /** - * Returns the registry of the extensions to the org.eclipse.jdt.ui.javaFoldingStructureProvider - * extension point. - * - * @return the registry of contributed IJavaFoldingStructureProvider - * @since 3.0 - */ - public synchronized JavaFoldingStructureProviderRegistry getFoldingStructureProviderRegistry() { - if (fFoldingStructureProviderRegistry == null) - fFoldingStructureProviderRegistry= new JavaFoldingStructureProviderRegistry(); - return fFoldingStructureProviderRegistry; - } + // public void shutdown() throws CoreException { + // // moved down (see below): + // // super.shutdown(); + // // externalTools.shutDown(); + // ColorManager.getDefault().dispose(); + // // save the information from the php index files if necessary + // Collection collection = fIndexManagerMap.values(); + // Iterator iterator = collection.iterator(); + // IdentifierIndexManager indexManager = null; + // while (iterator.hasNext()) { + // indexManager = (IdentifierIndexManager) iterator.next(); + // indexManager.writeFile(); + // } + // if (fImageDescriptorRegistry != null) + // fImageDescriptorRegistry.dispose(); + // // unregisterAdapters(); + // super.shutdown(); + // if (fWorkingCopyManager != null) { + // fWorkingCopyManager.shutdown(); + // fWorkingCopyManager = null; + // } + // if (fCompilationUnitDocumentProvider != null) { + // fCompilationUnitDocumentProvider.shutdown(); + // fCompilationUnitDocumentProvider = null; + // } + // if (fJavaTextTools != null) { + // fJavaTextTools.dispose(); + // fJavaTextTools = null; + // } + // // JavaDocLocations.shutdownJavadocLocations(); + // // + // // + // JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); + // // begin JavaCore#shutdown() + // //savePluginPreferences(); + // savePluginPreferences(); + // IWorkspace workspace = ResourcesPlugin.getWorkspace(); + // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaState); + // workspace.removeSaveParticipant(this); + // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown(); + // // end JavaCore#shutdown() + // } + /** + * Installs backwards compatibility for the preference store. + */ + private void installPreferenceStoreBackwardsCompatibility() { + + /* + * Installs backwards compatibility: propagate the Java editor font from a + * pre-2.1 plug-in to the Platform UI's preference store to preserve the + * Java editor font from a pre-2.1 workspace. This is done only once. + */ + String fontPropagatedKey = "fontPropagated"; //$NON-NLS-1$ + if (getPreferenceStore().contains(JFaceResources.TEXT_FONT) + && !getPreferenceStore().isDefault(JFaceResources.TEXT_FONT)) { + if (!getPreferenceStore().getBoolean(fontPropagatedKey)) + PreferenceConverter.setValue(PlatformUI.getWorkbench() + .getPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT, + PreferenceConverter.getFontDataArray(getPreferenceStore(), + JFaceResources.TEXT_FONT)); + } + getPreferenceStore().setValue(fontPropagatedKey, true); + + /* + * Backwards compatibility: set the Java editor font in this plug-in's + * preference store to let older versions access it. Since 2.1 the Java + * editor font is managed by the workbench font preference page. + */ + PreferenceConverter.putValue(getPreferenceStore(), + JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData( + PreferenceConstants.EDITOR_TEXT_FONT)); + + fFontPropertyChangeListener = new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty())) + PreferenceConverter.putValue(getPreferenceStore(), + JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry() + .getFontData(PreferenceConstants.EDITOR_TEXT_FONT)); + } + }; + JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); + + /* + * Backwards compatibility: propagate the Java editor tab width from a + * pre-3.0 plug-in to the new preference key. This is done only once. + */ + final String oldTabWidthKey = PreferenceConstants.EDITOR_TAB_WIDTH; + final String newTabWidthKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH; + String tabWidthPropagatedKey = "tabWidthPropagated"; //$NON-NLS-1$ + if (getPreferenceStore().contains(oldTabWidthKey) + && !getPreferenceStore().isDefault(oldTabWidthKey)) { + if (!getPreferenceStore().getBoolean(tabWidthPropagatedKey)) + getPreferenceStore().setValue(newTabWidthKey, + getPreferenceStore().getInt(oldTabWidthKey)); + } + getPreferenceStore().setValue(tabWidthPropagatedKey, true); + + /* + * Backwards compatibility: set the Java editor tab width in this plug-in's + * preference store with the old key to let older versions access it. Since + * 3.0 the tab width is managed by the extended texteditor and uses a new + * key. + */ + getPreferenceStore().putValue(oldTabWidthKey, + getPreferenceStore().getString(newTabWidthKey)); + + fPropertyChangeListener = new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + if (newTabWidthKey.equals(event.getProperty())) + getPreferenceStore().putValue(oldTabWidthKey, + getPreferenceStore().getString(newTabWidthKey)); + } + }; + getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener); + + /* + * Backward compatibility for the refactoring preference key. + */ + // getPreferenceStore().setValue( + // PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, + // RefactoringCore.getConditionCheckingFailedSeverity()); + } + + /** + * Uninstalls backwards compatibility for the preference store. + */ + private void uninstallPreferenceStoreBackwardsCompatibility() { + JFaceResources.getFontRegistry() + .removeListener(fFontPropertyChangeListener); + getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); + } + + /* + * (non - Javadoc) Method declared in Plugin + */ + public void start(BundleContext context) throws Exception { + super.start(context); + + // JavaCore.start(this, context); + final JavaModelManager manager = JavaModelManager.getJavaModelManager(); + try { + manager.configurePluginDebugOptions(); + + // request state folder creation (workaround 19885) + // JavaCore.getPlugin().getStateLocation(); + getStateLocation(); + // retrieve variable values + //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new + // JavaModelManager.PluginPreferencesListener()); + // manager.loadVariablesAndContainers(); + + final IWorkspace workspace = ResourcesPlugin.getWorkspace(); + workspace.addResourceChangeListener(manager.deltaState, + IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.POST_BUILD + | IResourceChangeEvent.POST_CHANGE + | IResourceChangeEvent.PRE_DELETE + | IResourceChangeEvent.PRE_CLOSE); + + // startIndexing(); + + // process deltas since last activated in indexer thread so that indexes + // are up-to-date. + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658 + Job processSavedState = new Job(Util.bind("savedState.jobName")) { //$NON-NLS-1$ + protected IStatus run(IProgressMonitor monitor) { + try { + // add save participant and process delta atomically + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937 + workspace.run(new IWorkspaceRunnable() { + public void run(IProgressMonitor progress) throws CoreException { + ISavedState savedState = workspace.addSaveParticipant( + PHPeclipsePlugin.this, manager); + if (savedState != null) { + // the event type coming from the saved state is always + // POST_AUTO_BUILD + // force it to be POST_CHANGE so that the delta processor can + // handle it + manager.deltaState.getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE; + savedState.processResourceChangeEvents(manager.deltaState); + } + } + }, monitor); + } catch (CoreException e) { + return e.getStatus(); + } + return Status.OK_STATUS; + } + }; + processSavedState.setSystem(true); + processSavedState.setPriority(Job.SHORT); // process asap + processSavedState.schedule(); + + } catch (RuntimeException e) { + manager.shutdown(); + throw e; + } + + registerAdapters(); + + // if (USE_WORKING_COPY_OWNERS) { + WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() { + public IBuffer createBuffer(ICompilationUnit workingCopy) { + ICompilationUnit original = workingCopy.getPrimary(); + IResource resource = original.getResource(); + if (resource instanceof IFile) + return new DocumentAdapter(workingCopy, (IFile) resource); + return DocumentAdapter.NULL; + } + }); + // } + + installPreferenceStoreBackwardsCompatibility(); + + } + + // registerAdapters(); + // + // // externalTools.startUp(); + // getStandardDisplay().asyncExec(new Runnable() { + // public void run() { + // //initialize the variable context manager + // VariableContextManager.getDefault(); + // } + // }); + // + // // if (USE_WORKING_COPY_OWNERS) { + // WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() { + // public IBuffer createBuffer(ICompilationUnit workingCopy) { + // ICompilationUnit original = workingCopy.getPrimary(); + // IResource resource = original.getResource(); + // if (resource instanceof IFile) + // return new DocumentAdapter(workingCopy, (IFile) resource); + // return DocumentAdapter.NULL; + // } + // }); + // // } + + // installPreferenceStoreBackwardsCompatibility(); + + // AllTypesCache.initialize(); + + // Initialize AST provider + // getASTProvider(); + // } + + // public void startup() throws CoreException { + // super.startup(); + // // begin JavaCore.startup(); + // JavaModelManager manager = JavaModelManager.getJavaModelManager(); + // try { + // manager.configurePluginDebugOptions(); + // // request state folder creation (workaround 19885) + // // JavaCore.getPlugin().getStateLocation(); + // getStateLocation(); + // // retrieve variable values + // // + // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new + // // JavaModelManager.PluginPreferencesListener()); + // getPluginPreferences().addPropertyChangeListener( + // new JavaModelManager.PluginPreferencesListener()); + // // TODO khartlage temp-del + // // manager.loadVariablesAndContainers(); + // final IWorkspace workspace = ResourcesPlugin.getWorkspace(); + // workspace.addResourceChangeListener( + // manager.deltaState, + // IResourceChangeEvent.PRE_BUILD + // | IResourceChangeEvent.POST_BUILD + // | IResourceChangeEvent.POST_CHANGE + // | IResourceChangeEvent.PRE_DELETE + // | IResourceChangeEvent.PRE_CLOSE); + // // startIndexing(); + // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager); + // } catch (CoreException e) { + // } catch (RuntimeException e) { + // manager.shutdown(); + // throw e; + // } + // // end JavaCore.startup(); + // IAdapterManager platformManager = Platform.getAdapterManager(); + // platformManager.registerAdapters(new PHPElementAdapterFactory(), + // PHPElement.class); + // platformManager.registerAdapters(new ResourceAdapterFactory(), + // IResource.class); + // // externalTools.startUp(); + // getStandardDisplay().asyncExec(new Runnable() { + // public void run() { + // //initialize the variable context manager + // VariableContextManager.getDefault(); + // } + // }); + // } + + private void registerAdapters() { + fJavaElementAdapterFactory = new JavaElementAdapterFactory(); + // fMarkerAdapterFactory= new MarkerAdapterFactory(); + // fEditorInputAdapterFactory= new EditorInputAdapterFactory(); + fResourceAdapterFactory = new ResourceAdapterFactory(); + // fLogicalPackageAdapterFactory= new LogicalPackageAdapterFactory(); + + IAdapterManager manager = Platform.getAdapterManager(); + manager.registerAdapters(fJavaElementAdapterFactory, IJavaElement.class); + // manager.registerAdapters(fMarkerAdapterFactory, IMarker.class); + // manager.registerAdapters(fEditorInputAdapterFactory, IEditorInput.class); + manager.registerAdapters(fResourceAdapterFactory, IResource.class); + // manager.registerAdapters(fLogicalPackageAdapterFactory, + // LogicalPackage.class); + } + + private void unregisterAdapters() { + IAdapterManager manager = Platform.getAdapterManager(); + manager.unregisterAdapters(fJavaElementAdapterFactory); + // manager.unregisterAdapters(fMarkerAdapterFactory); + // manager.unregisterAdapters(fEditorInputAdapterFactory); + manager.unregisterAdapters(fResourceAdapterFactory); + // manager.unregisterAdapters(fLogicalPackageAdapterFactory); + } + + /** + * Returns a combined preference store, this store is read-only. + * + * @return the combined preference store + * + * @since 3.0 + */ + public IPreferenceStore getCombinedPreferenceStore() { + if (fCombinedPreferenceStore == null) { + IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); + fCombinedPreferenceStore = new ChainedPreferenceStore( + new IPreferenceStore[] { + getPreferenceStore(), + new PreferencesAdapter(PHPeclipsePlugin.getDefault() + .getPluginPreferences()), generalTextStore }); + } + return fCombinedPreferenceStore; + } + + public synchronized IBufferFactory getBufferFactory() { + if (fBufferFactory == null) + fBufferFactory = new CustomBufferFactory(); + return fBufferFactory; + } + + /** + * Returns the registry of the extensions to the + * org.eclipse.jdt.ui.javaFoldingStructureProvider extension + * point. + * + * @return the registry of contributed + * IJavaFoldingStructureProvider + * @since 3.0 + */ + public synchronized JavaFoldingStructureProviderRegistry getFoldingStructureProviderRegistry() { + if (fFoldingStructureProviderRegistry == null) + fFoldingStructureProviderRegistry = new JavaFoldingStructureProviderRegistry(); + return fFoldingStructureProviderRegistry; + } + + /** + * Runs the given action as an atomic Java model operation. + *

+ * After running a method that modifies java elements, registered listeners + * receive after-the-fact notification of what just transpired, in the form of + * a element changed event. This method allows clients to call a number of + * methods that modify java elements and only have element changed event + * notifications reported at the end of the entire batch. + *

+ *

+ * If this method is called outside the dynamic scope of another such call, + * this method runs the action and then reports a single element changed event + * describing the net effect of all changes done to java elements by the + * action. + *

+ *

+ * If this method is called in the dynamic scope of another such call, this + * method simply runs the action. + *

+ * + * @param action + * the action to perform + * @param monitor + * a progress monitor, or null if progress reporting + * and cancellation are not desired + * @exception CoreException + * if the operation failed. + * @since 2.1 + */ + public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) + throws CoreException { + run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor); + } + + /** + * Runs the given action as an atomic Java model operation. + *

+ * After running a method that modifies java elements, registered listeners + * receive after-the-fact notification of what just transpired, in the form of + * a element changed event. This method allows clients to call a number of + * methods that modify java elements and only have element changed event + * notifications reported at the end of the entire batch. + *

+ *

+ * If this method is called outside the dynamic scope of another such call, + * this method runs the action and then reports a single element changed event + * describing the net effect of all changes done to java elements by the + * action. + *

+ *

+ * If this method is called in the dynamic scope of another such call, this + * method simply runs the action. + *

+ *

+ * The supplied scheduling rule is used to determine whether this operation + * can be run simultaneously with workspace changes in other threads. See + * IWorkspace.run(...) for more details. + *

+ * + * @param action + * the action to perform + * @param rule + * the scheduling rule to use when running this operation, or + * null if there are no scheduling restrictions for + * this operation. + * @param monitor + * a progress monitor, or null if progress reporting + * and cancellation are not desired + * @exception CoreException + * if the operation failed. + * @since 3.0 + */ + public static void run(IWorkspaceRunnable action, ISchedulingRule rule, + IProgressMonitor monitor) throws CoreException { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + if (workspace.isTreeLocked()) { + new BatchOperation(action).run(monitor); + } else { + // use IWorkspace.run(...) to ensure that a build will be done in + // autobuild mode + workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, + monitor); + } + } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java new file mode 100644 index 0000000..439f302 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java @@ -0,0 +1,154 @@ +package net.sourceforge.phpeclipse.actions; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; +import net.sourceforge.phpdt.core.compiler.InvalidInputException; +import net.sourceforge.phpdt.internal.compiler.parser.Scanner; +import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError; +import net.sourceforge.phpdt.internal.compiler.util.Util; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.ui.IFileEditorInput; + + +public class IncludesScanner implements ITerminalSymbols { + private final PHPOpenAllIncludesEditorAction fLineCreator; + private IProject fProject; + private IFileEditorInput fEditorInput; + HashSet fSet; + public IncludesScanner(PHPOpenAllIncludesEditorAction action, IProject project, IFileEditorInput editorInput) { + fProject = project; + this.fLineCreator = action; + fEditorInput = editorInput; + fSet = new HashSet(); + } + /** + * Add the information for a given IFile resource + * + */ + public void addFile(IFile fileToParse) { + + try { + if (fileToParse.exists()) { + addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString()); + } + } catch (CoreException e1) { + e1.printStackTrace(); + } + } + + private void addInputStream(InputStream stream, String filePath) throws CoreException { + try { + if (fSet.add(filePath)) { // new entry in set + parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1, null)); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (stream != null) { + stream.close(); + } + } catch (IOException e) { + } + } + } + + /** + * Get the next token from input + */ + private int getNextToken(Scanner scanner) { + int token; + try { + token = scanner.getNextToken(); + if (Scanner.DEBUG) { + int currentEndPosition = scanner.getCurrentTokenEndPosition(); + int currentStartPosition = scanner.getCurrentTokenStartPosition(); + System.out.print(currentStartPosition + "," + currentEndPosition + ": "); + System.out.println(scanner.toStringAction(token)); + } + return token; + } catch (InvalidInputException e) { + } + return TokenNameERROR; + } + + private void parseIdentifiers(char[] charArray) { + char[] ident; + IFile file; + String identifier; + int counter = 0; + + Scanner scanner = new Scanner(false, false, false, false, true, null, null); + scanner.setSource(charArray); + scanner.setPHPMode(false); + int token = getNextToken(scanner); + try { + while (token != TokenNameEOF) { // && fToken != TokenNameERROR) { + if (token == TokenNameinclude || token == TokenNameinclude_once || token == TokenNamerequire + || token == TokenNamerequire_once) { + while (token != TokenNameEOF && token != TokenNameERROR && token != TokenNameSEMICOLON && token != TokenNameRPAREN + && token != TokenNameLBRACE && token != TokenNameRBRACE) { + token = getNextToken(scanner); + if (token == TokenNameStringDoubleQuote || token == TokenNameStringSingleQuote) { + char[] includeName = scanner.getCurrentStringLiteralSource(); + try { + file = getIncludeFile(new String(includeName)); + addFile(file); + } catch (Exception e) { + // ignore + } + break; + } + } + } + token = getNextToken(scanner); + } + } catch (SyntaxError e) { + // e.printStackTrace(); + } + } + public IFile getIncludeFile(String relativeFilename) { + IContainer container = this.fLineCreator.getWorkingLocation(fEditorInput); + String fullPath = fProject.getLocation().toString(); + IFile file = null; + if (relativeFilename.startsWith("../")) { + Path path = new Path(relativeFilename); + file = container.getFile(path); + return file; + } + int index = relativeFilename.lastIndexOf('/'); + + if (index >= 0) { + Path path = new Path(relativeFilename); + file = fProject.getFile(path); + if (file.exists()) { + return file; + } + } + Path path = new Path(relativeFilename); + file = container.getFile(path); + + return file; + } + /** + * Returns a list of includes + * @return the determined list of includes + */ + public List getList() { + ArrayList list = new ArrayList(); + list.addAll(fSet); + return list; + } + +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java new file mode 100644 index 0000000..5396755 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java @@ -0,0 +1,212 @@ +/******************************************************************************* + * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Common Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: Klaus Hartlage - www.eclipseproject.de + ******************************************************************************/ +package net.sourceforge.phpeclipse.actions; + +import java.util.List; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.phpeditor.PHPEditor; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.IEditorActionDelegate; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionDelegate; +import org.eclipse.ui.dialogs.ListSelectionDialog; +import org.eclipse.ui.internal.dialogs.ListContentProvider; + +public class PHPOpenAllIncludesEditorAction extends ActionDelegate implements IEditorActionDelegate { + + private IWorkbenchWindow fWindow; + private PHPEditor fEditor; + private IProject fProject; + private IncludesScanner fLineCreator; + public void dispose() { + } + + public void init(IWorkbenchWindow window) { + this.fWindow = window; + } + + public void selectionChanged(IAction action, ISelection selection) { + if (!selection.isEmpty()) { + if (selection instanceof TextSelection) { + action.setEnabled(true); + } else if (fWindow.getActivePage() != null && fWindow.getActivePage().getActivePart() != null) { + // + } + } + } + private IWorkbenchPage getActivePage() { + IWorkbenchWindow workbenchWindow = fEditor.getEditorSite().getWorkbenchWindow(); + IWorkbenchPage page = workbenchWindow.getActivePage(); + return page; + } + public IContainer getWorkingLocation(IFileEditorInput editorInput) { + if (editorInput == null || editorInput.getFile() == null) { + return null; + } + return editorInput.getFile().getParent(); + } + private IFile getIncludeFile(IProject project, IFileEditorInput editorInput, String relativeFilename) { + IContainer container = getWorkingLocation(editorInput); + String fullPath = project.getLocation().toString(); + IFile file = null; + if (relativeFilename.startsWith("../")) { + Path path = new Path(relativeFilename); + file = container.getFile(path); + return file; + } + int index = relativeFilename.lastIndexOf('/'); + + if (index >= 0) { + Path path = new Path(relativeFilename); + file = project.getFile(path); + if (file.exists()) { + return file; + } + } + + Path path = new Path(relativeFilename); + file = container.getFile(path); + + return file; + } + + public void run(IAction action) { + if (fEditor == null) { + IEditorPart targetEditor = fWindow.getActivePage().getActiveEditor(); + if (targetEditor != null && (targetEditor instanceof PHPEditor)) { + fEditor = (PHPEditor) targetEditor; + } + } + if (fEditor != null) { + // determine the current Project from a (file-based) Editor + IFile f = ((IFileEditorInput) fEditor.getEditorInput()).getFile(); + fProject = f.getProject(); + // System.out.println(fProject.toString()); + + ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection(); + IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput()); + fLineCreator = new IncludesScanner(this, fProject, (IFileEditorInput) fEditor.getEditorInput()); + int pos = selection.getOffset(); + // System.out.println(selection.getText()); + String filename = getPHPIncludeText(doc, pos); + + if (filename != null && !filename.equals("")) { + try { + IFile file = fLineCreator.getIncludeFile(filename); + fLineCreator.addFile(file); + } catch (Exception e) { + // ignore + } + + try { + + List list = fLineCreator.getList(); + if (list != null && list.size() > 0) { + String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); + + ListSelectionDialog listSelectionDialog = new ListSelectionDialog(PHPeclipsePlugin.getDefault().getWorkbench() + .getActiveWorkbenchWindow().getShell(), list, new ListContentProvider(), new LabelProvider(), + "Select the includes to open."); + listSelectionDialog.setTitle("Multiple includes found"); + if (listSelectionDialog.open() == Window.OK) { + Object[] locations = listSelectionDialog.getResult(); + if (locations != null) { + try { + for (int i = 0; i < locations.length; i++) { + // PHPIdentifierLocation location = (PHPIdentifierLocation) + // locations[i]; + String openFilename = workspaceLocation + ((String) locations[i]); + PHPeclipsePlugin.getDefault().openFileInTextEditor(openFilename); + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + } + } catch (Exception e) { + } + + } + } + } + + public void setActiveEditor(IAction action, IEditorPart targetEditor) { + if (targetEditor != null && (targetEditor instanceof PHPEditor)) { + fEditor = (PHPEditor) targetEditor; + } + } + + private String getPHPIncludeText(IDocument doc, int pos) { + Point word = null; + int start = -1; + int end = -1; + + try { + + int position = pos; + char character; + + while (position >= 0) { + character = doc.getChar(position); + if ((character == '\"') || (character == '\'') || (character == '\r') || (character == '\n')) + break; + --position; + } + + start = position; + + position = pos; + int length = doc.getLength(); + + while (position < length) { + character = doc.getChar(position); + if ((character == '\"') || (character == '\'') || (character == '\r') || (character == '\n')) + break; + ++position; + } + + start++; + end = position; + + if (end > start) + word = new Point(start, end - start); + + } catch (BadLocationException x) { + } + + if (word != null) { + try { + return doc.get(word.x, word.y); + } catch (BadLocationException e) { + } + } + return ""; + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java index 4f92951..982d0ef 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java @@ -22,10 +22,12 @@ import net.sourceforge.phpdt.core.compiler.InvalidInputException; import net.sourceforge.phpdt.internal.compiler.parser.Scanner; import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError; import net.sourceforge.phpdt.internal.compiler.util.Util; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.obfuscator.PHPIdentifier; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; /** * Manages the identifer index information for a specific project * @@ -42,7 +44,7 @@ public class IdentifierIndexManager { * * @param typeOfIdentifier * the type of the identifier ('c'lass, 'd'efine, 'f'unction, - * 'm'ethod, 'v'ariable) + * 'm'ethod(class), 'v'ariable(class) 'g'lobal variable) * @param identifier * current identifier * @param line @@ -168,7 +170,7 @@ public class IdentifierIndexManager { ident[5]=='e') { if (fToken == TokenNameLPAREN) { getNextToken(); - if (fToken == TokenNameStringLiteral) { + if (fToken == TokenNameStringDoubleQuote) { ident = fScanner.getCurrentStringLiteralSource(); addIdentifierInformation('d', ident, buf, phpdocOffset, phpdocLength); @@ -176,6 +178,19 @@ public class IdentifierIndexManager { } } } + } else if (fToken == TokenNameglobal) { + // global variable + while (fToken != TokenNameEOF && fToken != TokenNameERROR && + fToken != TokenNameSEMICOLON && + fToken != TokenNameLBRACE && + fToken != TokenNameRBRACE ) { + getNextToken(); + if (fToken == TokenNameVariable) { + ident = fScanner.getCurrentIdentifierSource(); + addIdentifierInformation('g', ident, buf, phpdocOffset, + phpdocLength); + } + } } else if (fToken == TokenNameLBRACE) { getNextToken(); counter++; @@ -243,6 +258,12 @@ public class IdentifierIndexManager { } parseDeclarations(ident, buf, true); } + } else if (fToken == TokenNameVariable) { + // global variable + ident = fScanner.getCurrentIdentifierSource(); + addIdentifierInformation('g', ident, buf, phpdocOffset, + phpdocLength); + getNextToken(); } else if (fToken == TokenNameIdentifier) { ident = fScanner.getCurrentIdentifierSource(); getNextToken(); @@ -255,7 +276,7 @@ public class IdentifierIndexManager { ident[5]=='e') { if (fToken == TokenNameLPAREN) { getNextToken(); - if (fToken == TokenNameStringLiteral) { + if (fToken == TokenNameStringDoubleQuote) { ident = fScanner.getCurrentStringLiteralSource(); addIdentifierInformation('d', ident, buf, phpdocOffset, phpdocLength); @@ -402,6 +423,12 @@ public class IdentifierIndexManager { phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.FUNCTION, phpFileName); break; + case 'g' : + // global variable + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, + PHPIdentifier.GLOBAL_VARIABLE, phpFileName); + break; case 'k' : // constructor function name identifier = token.substring(1); @@ -445,6 +472,7 @@ public class IdentifierIndexManager { } break; default : + PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: "+token.charAt(0)); identifier = null; phpIdentifier = null; classname = null; @@ -554,7 +582,8 @@ public class IdentifierIndexManager { //System.out.println(token); } else { return; - } + } + int offset = -1; // all the other tokens are identifiers: while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); @@ -579,6 +608,12 @@ public class IdentifierIndexManager { phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.FUNCTION, phpFileName); break; + case 'g' : + // global variable + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, + PHPIdentifier.GLOBAL_VARIABLE, phpFileName); + break; case 'k' : // constructor function name identifier = token.substring(1); @@ -591,6 +626,10 @@ public class IdentifierIndexManager { phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.METHOD, phpFileName, classname); break; + case 'o' : + // offset information + identifier = null; + break; case 'v' : // variable inside a class identifier = token.substring(1); @@ -598,6 +637,7 @@ public class IdentifierIndexManager { PHPIdentifier.VARIABLE, phpFileName, classname); break; default : + PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: "+token.charAt(0)); identifier = null; phpIdentifier = null; classname = null; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/AND_AND_Expression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/AND_AND_Expression.java index be9ecd9..26c44ec 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/AND_AND_Expression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/AND_AND_Expression.java @@ -11,7 +11,6 @@ package net.sourceforge.phpeclipse.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor; -import net.sourceforge.phpdt.internal.compiler.codegen.Label; import net.sourceforge.phpdt.internal.compiler.flow.FlowContext; import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo; import net.sourceforge.phpdt.internal.compiler.impl.Constant; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass1Exporter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass1Exporter.java index ab2d8f9..cd18ce5 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass1Exporter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass1Exporter.java @@ -112,7 +112,7 @@ public class ObfuscatorPass1Exporter implements ITerminalSymbols { // parseDeclarations(outlineInfo, temp, true); // // stack.pop(); // } - } else if (fToken == TokenNameStringLiteral) { + } else if (fToken == TokenNameStringDoubleQuote) { char currentCharacter; int i = fScanner.startPosition; ArrayList varList = new ArrayList(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass2Exporter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass2Exporter.java index da7307a..093f1e3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass2Exporter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/ObfuscatorPass2Exporter.java @@ -130,7 +130,7 @@ public class ObfuscatorPass2Exporter implements ITerminalSymbols { buf.append(fScanner.source, startPosition, lastPosition - startPosition); startPosition = fScanner.currentPosition; getNextToken(); - } else if (fToken == TokenNameStringLiteral) { + } else if (fToken == TokenNameStringDoubleQuote) { char currentCharacter; int i = fScanner.startPosition; ArrayList varList = new ArrayList(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/PHPIdentifier.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/PHPIdentifier.java index 17dcf6d..895d942 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/PHPIdentifier.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/obfuscator/PHPIdentifier.java @@ -2,16 +2,18 @@ package net.sourceforge.phpeclipse.obfuscator; /** * @author khartlage - * + * */ public class PHPIdentifier { public final static int CLASS = 1; public final static int FUNCTION = 2; - public final static int METHOD = 4; public final static int VARIABLE = 3; + public final static int METHOD = 4; public final static int DEFINE = 5; - public final static int CONSTRUCTOR = 6; + public final static int CONSTRUCTOR = 6; + public final static int GLOBAL_VARIABLE = 7; + private String fIdentifier; private int fType; @@ -21,7 +23,9 @@ public class PHPIdentifier { fIdentifier = identifier; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { @@ -59,10 +63,14 @@ public class PHPIdentifier { return fType == DEFINE; } - public boolean isConstructor() { - return fType == CONSTRUCTOR; - } - + public boolean isGlobalVariable() { + return fType == GLOBAL_VARIABLE; + } + + public boolean isConstructor() { + return fType == CONSTRUCTOR; + } + public void setIdentifier(String fIdentifier) { this.fIdentifier = fIdentifier; } @@ -71,15 +79,17 @@ public class PHPIdentifier { this.fType = fType; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ public String toString() { switch (fType) { case CLASS : return "class - "; - case CONSTRUCTOR : - return "constructor - "; + case CONSTRUCTOR : + return "constructor - "; case DEFINE : return "define - "; case FUNCTION : @@ -92,4 +102,4 @@ public class PHPIdentifier { return ""; } -} +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BreakpointImageProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BreakpointImageProvider.java index c425748..16578e7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BreakpointImageProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BreakpointImageProvider.java @@ -11,16 +11,11 @@ package net.sourceforge.phpeclipse.phpeditor; import org.eclipse.core.resources.IMarker; - import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugModelPresentation; - -import org.eclipse.swt.graphics.Image; - import org.eclipse.jface.resource.ImageDescriptor; - import org.eclipse.jface.text.source.Annotation; - +import org.eclipse.swt.graphics.Image; import org.eclipse.ui.texteditor.IAnnotationImageProvider; import org.eclipse.ui.texteditor.MarkerAnnotation; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java index c33d664..805895b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java @@ -14,12 +14,10 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.resources.IFile; import org.eclipse.jface.action.IAction; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.SWT; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.ITextEditor; public class CompilationUnitEditorActionContributor diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CustomBufferFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CustomBufferFactory.java index 1b57e23..1a6e429 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CustomBufferFactory.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CustomBufferFactory.java @@ -11,14 +11,14 @@ Contributors: package net.sourceforge.phpeclipse.phpeditor; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; - import net.sourceforge.phpdt.core.IBuffer; import net.sourceforge.phpdt.core.IBufferFactory; import net.sourceforge.phpdt.core.ICompilationUnit; import net.sourceforge.phpdt.core.IOpenable; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; + /** * Creates IBuffers based on documents. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/IJavaAnnotation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/IJavaAnnotation.java index 5634c76..5382a0f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/IJavaAnnotation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/IJavaAnnotation.java @@ -12,11 +12,11 @@ package net.sourceforge.phpeclipse.phpeditor; import java.util.Iterator; +import net.sourceforge.phpdt.core.ICompilationUnit; + import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; -import net.sourceforge.phpdt.core.ICompilationUnit; - /** * Interface of annotations representing markers * and problems. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaAnnotationImageProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaAnnotationImageProvider.java index 6ec9b9b..e162a01 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaAnnotationImageProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaAnnotationImageProvider.java @@ -10,22 +10,18 @@ *******************************************************************************/ package net.sourceforge.phpeclipse.phpeditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; +import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import net.sourceforge.phpdt.ui.PreferenceConstants; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; - import org.eclipse.jface.text.source.Annotation; - +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.IAnnotationImageProvider; - -import net.sourceforge.phpdt.ui.PreferenceConstants; - -import net.sourceforge.phpdt.internal.ui.PHPUiImages; //import net.sourceforge.phpdt.internal.ui.text.correction.JavaCorrectionProcessor; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaDocumentFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaDocumentFactory.java index 324d440..a2fa69b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaDocumentFactory.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaDocumentFactory.java @@ -11,7 +11,6 @@ Contributors: package net.sourceforge.phpeclipse.phpeditor; import org.eclipse.core.filebuffers.IDocumentFactory; - import org.eclipse.jface.text.IDocument; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java index d72d62c..2155406 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java @@ -27,8 +27,8 @@ import net.sourceforge.phpdt.core.IParent; import net.sourceforge.phpdt.core.ISourceRange; import net.sourceforge.phpdt.core.ISourceReference; import net.sourceforge.phpdt.core.IType; -import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup; import net.sourceforge.phpdt.internal.ui.dnd.JdtViewerDragAdapter; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSelectMarkerRulerAction2.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSelectMarkerRulerAction2.java index 1abf58d..5d59b6f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSelectMarkerRulerAction2.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSelectMarkerRulerAction2.java @@ -15,7 +15,6 @@ import java.util.ResourceBundle; import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java index d300642..2c2f4f4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java @@ -12,10 +12,7 @@ package net.sourceforge.phpeclipse.phpeditor; import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Map; -import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.internal.ui.text.SmartBackspaceManager; import net.sourceforge.phpdt.ui.PreferenceConstants; @@ -23,8 +20,6 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.ITextPresentationListener; -import org.eclipse.jface.text.formatter.FormattingContextProperties; -import org.eclipse.jface.text.formatter.IFormattingContext; import org.eclipse.jface.text.information.IInformationPresenter; import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.IVerticalRuler; @@ -44,7 +39,7 @@ import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; public class JavaSourceViewer extends ProjectionViewer implements IPropertyChangeListener { - /** + /** * Text operation code for requesting the outline for the current input. */ public static final int SHOW_OUTLINE= 51; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPAnnotationHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPAnnotationHover.java index 4dd82ea..801d57b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPAnnotationHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPAnnotationHover.java @@ -12,9 +12,9 @@ Contributors: Klaus Hartlage - www.eclipseproject.de **********************************************************************/ -import java.util.List; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.eclipse.core.resources.IMarker; import org.eclipse.jface.text.BadLocationException; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java index 74f98be..599cd4f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java @@ -20,20 +20,17 @@ import java.util.Iterator; import java.util.List; import net.sourceforge.phpdt.core.ICompilationUnit; -import net.sourceforge.phpdt.core.IJavaModelStatusConstants; import net.sourceforge.phpdt.core.IProblemRequestor; import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.compiler.IProblem; -import net.sourceforge.phpdt.internal.ui.PHPUIStatus; import net.sourceforge.phpdt.internal.ui.text.java.IProblemRequestorExtension; +import net.sourceforge.phpdt.internal.ui.text.spelling.SpellReconcileStrategy.SpellProblem; import net.sourceforge.phpdt.ui.PreferenceConstants; -import net.sourceforge.phpdt.ui.text.JavaTextTools; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceRuleFactory; import org.eclipse.core.resources.ResourcesPlugin; @@ -68,11 +65,9 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.TextFileDocumentProvider; -import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; @@ -528,11 +523,10 @@ public class PHPDocumentProvider extends TextFileDocumentProvider { fProblem= problem; fCompilationUnit= cu; -// if (SpellProblem.Spelling == fProblem.getID()) { -// setType(SPELLING_ANNOTATION_TYPE); -// fLayer= WARNING_LAYER; -// } else - if (IProblem.Task == fProblem.getID()) { + if (SpellProblem.Spelling == fProblem.getID()) { + setType(SPELLING_ANNOTATION_TYPE); + fLayer= WARNING_LAYER; + } else if (IProblem.Task == fProblem.getID()) { setType(JavaMarkerAnnotation.TASK_ANNOTATION_TYPE); fLayer= TASK_LAYER; } else if (fProblem.isWarning()) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java index 2874885..401ca2c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java @@ -443,7 +443,7 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration { IPHPPartitions.SMARTY); assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY_MULTILINE_COMMENT); - assistant.setContentAssistProcessor(new PHPCompletionProcessor(), + assistant.setContentAssistProcessor(new PHPCompletionProcessor(getEditor()), IPHPPartitions.PHP_PARTITIONING); assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(), IPHPPartitions.PHP_PHPDOC_COMMENT); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java index ec370fd..1c69f89 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java @@ -6,7 +6,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; @@ -29,7 +28,6 @@ import net.sourceforge.phpeclipse.phpeditor.php.PHPType; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.preference.IPreferenceStore; import org.w3c.dom.Attr; import org.w3c.dom.Document; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java index 5535560..7be2787 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java @@ -14,12 +14,14 @@ import java.io.FileReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; + import net.sourceforge.phpdt.internal.corext.phpdoc.PHPDocUtil; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation; import net.sourceforge.phpeclipse.phpeditor.php.PHPElement; import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor; + import org.eclipse.core.resources.IProject; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; 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 3c7861a..f6d643b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java @@ -1,6 +1,5 @@ package net.sourceforge.phpeclipse.phpeditor; -import java.lang.reflect.InvocationTargetException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Iterator; @@ -29,7 +28,6 @@ import net.sourceforge.phpdt.ui.text.JavaTextTools; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -37,17 +35,12 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Preferences; - -import net.sourceforge.phpdt.internal.ui.text.java.IJavaReconcilingListener; - import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.BadLocationException; @@ -62,7 +55,6 @@ import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.IWidgetTokenKeeper; import org.eclipse.jface.text.contentassist.ContentAssistant; import org.eclipse.jface.text.contentassist.IContentAssistant; -import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; @@ -83,7 +75,6 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; -import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.editors.text.IStorageDocumentProvider; import org.eclipse.ui.help.WorkbenchHelp; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java index 13fc4dd..e76037f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java @@ -11,7 +11,9 @@ package net.sourceforge.phpeclipse.phpeditor; import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.actions.PHPEclipseShowAction; +import net.sourceforge.phpeclipse.overlaypages.Util; import net.sourceforge.phpeclipse.views.browser.BrowserView; + import org.eclipse.core.resources.IFile; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; @@ -20,7 +22,6 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; -import net.sourceforge.phpeclipse.overlaypages.Util; //import org.eclipse.update.internal.ui.UpdatePerspective; //import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/WorkingCopyManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/WorkingCopyManager.java index 4df75cd..e0f9212 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/WorkingCopyManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/WorkingCopyManager.java @@ -15,17 +15,14 @@ package net.sourceforge.phpeclipse.phpeditor; import java.util.HashMap; import java.util.Map; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.jface.text.Assert; - -import org.eclipse.ui.IEditorInput; - import net.sourceforge.phpdt.core.ICompilationUnit; - import net.sourceforge.phpdt.ui.IWorkingCopyManager; import net.sourceforge.phpdt.ui.IWorkingCopyManagerExtension; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.text.Assert; +import org.eclipse.ui.IEditorInput; + /** * This working copy manager works together with a given compilation unit document provider and diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java index 7881cea..beae245 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java @@ -18,6 +18,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.SortedMap; + +import net.sourceforge.phpdt.core.ICompilationUnit; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.ToolFactory; import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; import net.sourceforge.phpdt.core.compiler.InvalidInputException; @@ -34,14 +37,19 @@ import net.sourceforge.phpdt.internal.ui.text.template.DeclarationEngine; import net.sourceforge.phpdt.internal.ui.text.template.IdentifierEngine; import net.sourceforge.phpdt.internal.ui.text.template.SQLProposal; import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine; +import net.sourceforge.phpdt.ui.IWorkingCopyManager; +import net.sourceforge.phpdt.ui.PreferenceConstants; import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; import net.sourceforge.phpeclipse.overlaypages.Util; import net.sourceforge.phpeclipse.phpeditor.PHPEditor; import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; @@ -55,8 +63,11 @@ import org.eclipse.jface.text.contentassist.IContextInformationExtension; import org.eclipse.jface.text.contentassist.IContextInformationPresenter; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; + import com.quantum.model.Bookmark; import com.quantum.model.BookmarkCollection; import com.quantum.model.NotConnectedException; @@ -159,7 +170,11 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { private TemplateEngine fTemplateEngine; private PHPCompletionProposalComparator fComparator; private int fNumberOfComputedResults = 0; - public PHPCompletionProcessor() { + private IEditorPart fEditor; + protected IWorkingCopyManager fManager; + public PHPCompletionProcessor(IEditorPart editor) { + fEditor= editor; + fManager= PHPeclipsePlugin.getDefault().getWorkingCopyManager(); ContextType contextType = ContextTypeRegistry.getInstance().getContextType( "php"); //$NON-NLS-1$ if (contextType != null) @@ -464,17 +479,16 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { } private ICompletionProposal[] internalComputeCompletionProposals( ITextViewer viewer, int offset, int contextOffset) { + ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput()); + System.out.println( unit.toString() ); IDocument document = viewer.getDocument(); Object[] identifiers = null; IFile file = null; IProject project = null; if (offset > 0) { PHPEditor editor = null; - // JavaOutlinePage outlinePage = null; - IEditorPart targetEditor = PHPeclipsePlugin.getActiveWorkbenchWindow() - .getActivePage().getActiveEditor(); - if (targetEditor != null && (targetEditor instanceof PHPEditor)) { - editor = (PHPEditor) targetEditor; + if (fEditor != null && (fEditor instanceof PHPEditor)) { + editor = (PHPEditor) fEditor; file = ((IFileEditorInput) editor.getEditorInput()).getFile(); project = file.getProject(); // outlinePage = editor.getfOutlinePage(); -- 1.7.1