From 5c1a981cd7a29a202e88964acf034e76ffe289b2 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Thu, 17 Nov 2011 18:14:36 -0500 Subject: [PATCH] auto-clean: @Override annotations + organize imports + unnecessary casts/$NON-NLS + trailing white spaces --- .../cdt/core/model/IMethodDeclaration.java | 9 +- .../org/eclipse/cdt/core/model/IUsing.java | 3 +- .../cdt/core/model/LanguageManager.java | 146 +++--- .../model/LanguageMappingChangeEvent.java | 54 +- .../core/model/util/CDTListComparator.java | 9 +- .../model/ACExclusionFilterEntry.java | 12 +- .../cdt/core/settings/model/ACPathEntry.java | 15 +- .../core/settings/model/ACSettingEntry.java | 60 ++- .../core/settings/model/CExternalSetting.java | 25 +- .../settings/model/CIncludeFileEntry.java | 1 + .../settings/model/CIncludePathEntry.java | 2 + .../settings/model/CLibraryFileEntry.java | 34 +- .../settings/model/CLibraryPathEntry.java | 1 + .../cdt/core/settings/model/CMacroEntry.java | 5 +- .../core/settings/model/CMacroFileEntry.java | 3 +- .../cdt/core/settings/model/COutputEntry.java | 1 + .../cdt/core/settings/model/CSourceEntry.java | 1 + .../model/ICConfigurationDescription.java | 1 + .../cdt/core/settings/model/ICMacroEntry.java | 1 + .../settings/model/ICProjectDescription.java | 57 +-- .../core/settings/model/MultiItemsHolder.java | 29 +- .../settings/model/MultiLanguageSetting.java | 26 +- .../impl/CResourceDataContainer.java | 27 +- .../settings/model/util/KindBasedStore.java | 35 +- .../model/util/PathEntryTranslator.java | 2 + .../model/util/PathSettingsContainer.java | 2 + .../settings/model/util/PatternNameMap.java | 66 +-- .../model/util/ResourceChangeHandlerBase.java | 36 +- .../model/util/XmlStorageElement.java | 82 +-- .../cdt/internal/core/model/ASTCache.java | 80 +-- .../cdt/internal/core/model/Archive.java | 3 +- .../internal/core/model/ArchiveContainer.java | 3 +- .../cdt/internal/core/model/AsmLabel.java | 5 +- .../internal/core/model/AsmModelBuilder.java | 31 +- .../cdt/internal/core/model/Binary.java | 63 ++- .../internal/core/model/BinaryContainer.java | 3 +- .../internal/core/model/BinaryElement.java | 13 +- .../internal/core/model/BinaryFunction.java | 9 + .../cdt/internal/core/model/BinaryModule.java | 5 +- .../cdt/internal/core/model/BinaryRunner.java | 11 +- .../internal/core/model/BinaryVariable.java | 8 +- .../cdt/internal/core/model/Buffer.java | 52 +- .../internal/core/model/BufferManager.java | 17 +- .../cdt/internal/core/model/CContainer.java | 23 +- .../cdt/internal/core/model/CElement.java | 77 +-- .../internal/core/model/CElementDelta.java | 36 +- .../cdt/internal/core/model/CModel.java | 20 +- .../internal/core/model/CModelBuilder2.java | 20 +- .../internal/core/model/CModelManager.java | 69 +-- .../internal/core/model/CModelOperation.java | 15 +- .../cdt/internal/core/model/CModelStatus.java | 6 +- .../cdt/internal/core/model/CProject.java | 54 +- .../cdt/internal/core/model/CShiftData.java | 20 +- .../core/model/DefaultPathEntryStore.java | 35 +- .../cdt/internal/core/model/Enumeration.java | 8 +- .../cdt/internal/core/model/Enumerator.java | 7 +- .../cdt/internal/core/model/Field.java | 4 +- .../core/model/FunctionDeclaration.java | 45 +- .../internal/core/model/FunctionTemplate.java | 24 +- .../model/FunctionTemplateDeclaration.java | 8 +- .../cdt/internal/core/model/Include.java | 13 +- .../cdt/internal/core/model/IncludeEntry.java | 9 +- .../internal/core/model/IncludeFileEntry.java | 6 +- .../internal/core/model/IncludeReference.java | 13 +- .../core/model/LanguageDescriptor.java | 21 +- .../cdt/internal/core/model/LibraryEntry.java | 9 +- .../internal/core/model/LibraryReference.java | 1 + .../core/model/LibraryReferenceArchive.java | 3 +- .../core/model/LibraryReferenceShared.java | 3 +- .../cdt/internal/core/model/Macro.java | 7 +- .../cdt/internal/core/model/MacroEntry.java | 4 +- .../internal/core/model/MacroFileEntry.java | 6 +- .../core/model/MethodDeclaration.java | 22 +- .../internal/core/model/MethodTemplate.java | 26 +- .../core/model/MethodTemplateDeclaration.java | 8 +- .../cdt/internal/core/model/Namespace.java | 1 + .../internal/core/model/NullBinaryParser.java | 5 + .../cdt/internal/core/model/Openable.java | 33 +- .../cdt/internal/core/model/PathEntry.java | 11 +- .../internal/core/model/PathEntryManager.java | 67 +-- .../core/model/PathEntryStoreProxy.java | 21 +- .../model/ProgressMonitorAndCanceler.java | 7 +- .../cdt/internal/core/model/Region.java | 10 +- .../core/model/SourceManipulation.java | 31 +- .../cdt/internal/core/model/SourceRange.java | 6 + .../cdt/internal/core/model/SourceRoot.java | 7 +- .../cdt/internal/core/model/Structure.java | 11 +- .../core/model/StructureDeclaration.java | 7 + .../core/model/StructureTemplate.java | 8 +- .../model/StructureTemplateDeclaration.java | 4 + .../cdt/internal/core/model/Template.java | 8 +- .../internal/core/model/TranslationUnit.java | 103 ++-- .../cdt/internal/core/model/TypeDef.java | 1 + .../cdt/internal/core/model/Using.java | 1 + .../cdt/internal/core/model/Variable.java | 3 +- .../core/model/VariableDeclaration.java | 9 +- .../internal/core/model/VariableTemplate.java | 12 +- .../cdt/internal/core/model/WorkingCopy.java | 49 +- .../core/model/ext/CElementHandle.java | 45 +- .../core/model/ext/EnumerationHandle.java | 3 +- .../core/model/ext/EnumeratorHandle.java | 3 +- .../internal/core/model/ext/FieldHandle.java | 6 +- .../model/ext/FunctionDeclarationHandle.java | 9 +- .../FunctionTemplateDeclarationHandle.java | 6 +- .../internal/core/model/ext/MacroHandle.java | 5 +- .../model/ext/MethodDeclarationHandle.java | 20 +- .../internal/core/model/ext/SourceRange.java | 8 +- .../core/model/ext/StructureHandle.java | 12 +- .../model/ext/StructureTemplateHandle.java | 6 +- .../core/model/ext/VariableHandle.java | 5 +- .../model/AbstractCExtensionProxy.java | 39 +- .../core/settings/model/CBuildSetting.java | 11 +- .../settings/model/CBuildSettingCache.java | 28 +- .../model/CConfigExtensionReference.java | 5 + .../model/CConfigurationDescription.java | 132 +++-- .../model/CConfigurationDescriptionCache.java | 133 +++-- .../model/CConfigurationSpecSettings.java | 18 +- .../core/settings/model/CDataProxy.java | 54 +- .../settings/model/CDataProxyContainer.java | 26 +- .../model/CExternalSettingsManager.java | 150 +++--- .../core/settings/model/CFileDescription.java | 26 +- .../settings/model/CFileDescriptionCache.java | 15 +- .../settings/model/CFolderDescription.java | 43 +- .../model/CFolderDescriptionCache.java | 26 +- .../core/settings/model/CLanguageSetting.java | 72 +-- .../settings/model/CLanguageSettingCache.java | 25 +- .../settings/model/CProjectDescription.java | 158 +++--- .../model/CProjectDescriptionDelta.java | 43 +- .../model/CProjectDescriptionManager.java | 30 +- .../model/CProjectDescriptionPreferences.java | 32 +- .../model/CTargetPlatformSetting.java | 5 +- .../model/CTargetPlatformSettingCache.java | 15 +- .../CfgExportSettingContainerFactory.java | 47 +- .../core/settings/model/CfgProxyCache.java | 26 +- .../model/ConfigBasedPathEntryContainer.java | 5 +- .../model/ConfigBasedPathEntryStore.java | 9 + .../model/DescriptionScannerInfoProvider.java | 4 + .../ICProjectDescriptionStorageType.java | 4 +- .../core/settings/model/MapProxyCache.java | 8 + .../model/MultiConfigDescription.java | 76 ++- .../settings/model/MultiFileDescription.java | 1 + .../model/MultiFolderDescription.java | 11 +- .../model/MultiResourceDescription.java | 43 +- .../core/settings/model/ProxyProvider.java | 9 + .../settings/model/ResourceChangeHandler.java | 13 +- .../model/ResourceDescriptionHolder.java | 42 +- .../model/ScannerInfoProviderProxy.java | 16 +- .../core/settings/model/SettingsContext.java | 33 +- .../model/SynchronizedStorageElement.java | 20 +- .../xml/XmlProjectDescriptionStorage.java | 9 +- .../XmlProjectDescriptionStorageFactory.java | 2 + .../core/settings/model/xml/XmlStorage.java | 8 +- .../settings/model/xml/XmlStorageElement.java | 74 +-- .../xml2/XmlProjectDescriptionStorage2.java | 3 +- .../XmlProjectDescriptionStorage2Factory.java | 2 + .../core/util/LRUCacheEnumerator.java | 12 +- .../eclipse/cdt/core/AbstractCExtension.java | 9 +- .../src/org/eclipse/cdt/core/CCorePlugin.java | 262 +++++----- .../org/eclipse/cdt/core/CProjectNature.java | 16 +- .../org/eclipse/cdt/core/CommandLauncher.java | 29 +- .../eclipse/cdt/core/ErrorParserManager.java | 91 ++-- .../src/org/eclipse/cdt/core/IAddress.java | 60 +-- .../cdt/core/cdtvariables/CdtVariable.java | 12 +- .../core/cdtvariables/CdtVariableStatus.java | 55 +- .../src/org/eclipse/cdt/core/dom/CDOM.java | 85 ++-- .../cdt/core/envvar/EnvironmentVariable.java | 22 +- .../errorparsers/AbstractErrorParser.java | 5 +- .../errorparsers/ErrorParserNamedWrapper.java | 5 + .../core/errorparsers/RegexErrorParser.java | 5 + .../cdt/core/parser/CodeReaderCache.java | 80 +-- .../eclipse/cdt/core/resources/ACBuilder.java | 32 +- .../cdt/core/resources/EFSFileStorage.java | 22 +- .../cdt/core/resources/FileStorage.java | 8 +- .../core/resources/RefreshScopeManager.java | 13 +- .../cdt/core/resources/ScannerInfo.java | 11 +- .../cdt/core/resources/ScannerProvider.java | 26 +- .../internal/core/CConfigBasedDescriptor.java | 22 + .../core/CConfigBasedDescriptorManager.java | 11 + .../internal/core/CExtensionDescriptor.java | 4 +- .../org/eclipse/cdt/internal/core/COwner.java | 3 + .../core/CdtVarPathEntryVariableManager.java | 68 ++- .../cdt/internal/core/LocalProjectScope.java | 3 + .../core/PathEntryVariableManager.java | 39 +- .../core/PathEntryVariableResolver.java | 1 + .../cdt/internal/core/PositionTracker.java | 28 +- .../internal/core/PositionTrackerChain.java | 24 +- .../internal/core/PositionTrackerManager.java | 68 ++- .../cdt/internal/core/SystemBuildConsole.java | 10 +- .../core/cdtvariables/CdtVariableManager.java | 55 +- .../cdtvariables/CoreMacroSupplierBase.java | 4 +- .../DefaultVariableContextInfo.java | 12 +- .../EclipseVariablesVariableSupplier.java | 38 +- .../cdtvariables/StorableCdtVariables.java | 77 +-- .../core/cdtvariables/UserVarSupplier.java | 21 +- .../core/dom/AbstractCodeReaderFactory.java | 5 +- .../core/dom/InternalASTServiceProvider.java | 69 +-- .../core/dom/NullCodeReaderFactory.java | 6 +- .../PartialWorkingCopyCodeReaderFactory.java | 14 +- .../core/dom/SavedCodeReaderFactory.java | 22 +- .../BuildSystemEnvironmentSupplier.java | 69 +-- .../core/envvar/ContributedEnvironment.java | 46 +- .../envvar/DefaultEnvironmentContextInfo.java | 23 +- .../envvar/EclipseEnvironmentSupplier.java | 5 +- .../core/envvar/EnvVarDescriptor.java | 16 +- .../envvar/EnvironmentVariableManager.java | 105 ++-- .../UserDefinedEnvironmentSupplier.java | 161 +++--- .../core/parser/ParserLogService.java | 11 +- .../core/resources/ResourceLookup.java | 39 +- .../core/resources/ResourceLookupTree.java | 149 +++--- .../ErrorParserExtensionManager.java | 7 +- .../internal/errorparsers/GASErrorParser.java | 3 +- .../cdt/core/templateengine/TemplateCore.java | 38 +- .../cdtvariables/IVariableContextInfo.java | 13 +- .../SupplierBasedCdtVariableSubstitutor.java | 80 +-- .../envvar/PrefsStorableEnvironment.java | 6 +- .../ui/build/BuildPreferencePage.java | 1 + .../ui/buildconsole/BuildConsole.java | 13 +- .../ui/buildconsole/BuildConsoleFactory.java | 1 + .../ui/buildconsole/BuildConsoleManager.java | 42 +- .../ui/buildconsole/BuildConsolePage.java | 9 + .../BuildConsolePageParticipant.java | 5 + .../buildconsole/BuildConsolePartitioner.java | 16 + .../ui/buildconsole/BuildConsoleViewer.java | 10 + .../ui/buildconsole/BuildOutputStream.java | 9 +- .../ui/buildconsole/CBuildConsole.java | 11 +- .../ui/buildconsole/ConsoleEvent.java | 5 +- .../buildconsole/ConsoleOutputTextStore.java | 5 + .../MultiBuildConsoleAdapter.java | 5 + .../actions/BuildActiveConfigMenuAction.java | 11 +- .../ChangeBuildConfigContextAction.java | 10 +- .../actions/ChangeBuildConfigMenuAction.java | 10 +- .../ui/actions/CustomFiltersActionGroup.java | 101 ++-- .../ui/actions/DeleteResConfigsAction.java | 56 ++- .../ui/actions/ExcludeFromBuildAction.java | 54 +- .../cdt/ui/actions/FormatAllAction.java | 77 +-- .../cdt/ui/actions/GenerateActionGroup.java | 125 ++--- .../cdt/ui/actions/ManageConfigsAction.java | 19 +- .../ui/actions/MemberFilterActionGroup.java | 125 ++--- .../ui/actions/SelectionDispatchAction.java | 61 ++- .../ui/actions/WorkingSetConfigAction.java | 21 +- .../cdt/ui/dialogs/AbstractCOptionPage.java | 16 +- .../ui/dialogs/AbstractErrorParserBlock.java | 43 +- .../dialogs/AbstractGNUBinaryParserPage.java | 28 +- .../cdt/ui/dialogs/BinaryParserBlock.java | 21 +- .../CHelpConfigurationPropertyPage.java | 47 +- .../cdt/ui/dialogs/CacheSizeBlock.java | 27 +- .../ui/dialogs/CygwinPEBinaryParserPage.java | 40 +- .../eclipse/cdt/ui/dialogs/IndexerBlock.java | 74 +-- .../ui/dialogs/IndexerOptionPropertyPage.java | 13 +- .../cdt/ui/dialogs/InputStatusDialog.java | 15 +- .../cdt/ui/dialogs/MachOBinaryParserPage.java | 21 +- .../dialogs/RegexErrorParserOptionPage.java | 5 +- .../RegularExpressionStatusDialog.java | 3 +- .../cdt/ui/newui/AbstractExportTab.java | 106 ++-- .../cdt/ui/newui/AbstractLangsListTab.java | 11 + .../eclipse/cdt/ui/newui/AbstractPage.java | 320 ++++++------ .../cdt/ui/newui/AbstractPrefPage.java | 17 +- .../eclipse/cdt/ui/newui/BinaryParsTab.java | 74 +-- .../cdt/ui/newui/CDTPropertyManager.java | 55 +- .../eclipse/cdt/ui/newui/CDTStatusInfo.java | 18 +- .../eclipse/cdt/ui/newui/CLocationTab.java | 135 ++--- .../ui/newui/ConfigMultiSelectionDialog.java | 42 +- .../org/eclipse/cdt/ui/newui/EnvDialog.java | 44 +- .../eclipse/cdt/ui/newui/EnvironmentTab.java | 146 +++--- .../eclipse/cdt/ui/newui/ErrorParsTab.java | 55 +- .../eclipse/cdt/ui/newui/ExPatternDialog.java | 82 +-- .../cdt/ui/newui/ExPatternEntryDialog.java | 22 +- .../org/eclipse/cdt/ui/newui/ExpDialog.java | 90 ++-- .../cdt/ui/newui/ExpLibraryPathTab.java | 1 + .../eclipse/cdt/ui/newui/ExpLibraryTab.java | 3 +- .../eclipse/cdt/ui/newui/IncludeDialog.java | 65 +-- .../eclipse/cdt/ui/newui/LibraryPathTab.java | 15 +- .../org/eclipse/cdt/ui/newui/LibraryTab.java | 9 +- .../cdt/ui/newui/ManageConfigRunner.java | 18 +- .../newui/MultiCfgContributedEnvironment.java | 47 +- .../ui/newui/MultiLineTextFieldEditor.java | 69 +-- .../cdt/ui/newui/NewConfigurationDialog.java | 64 +-- .../cdt/ui/newui/Page_head_general.java | 9 +- .../cdt/ui/newui/ProjectContentsArea.java | 75 +-- .../eclipse/cdt/ui/newui/PropertyTester.java | 5 +- .../src/org/eclipse/cdt/ui/newui/RefsTab.java | 2 + .../ui/newui/RenameConfigurationDialog.java | 49 +- .../cdt/ui/newui/StringListModeControl.java | 1 + .../cdt/ui/newui/StructureTreeTab.java | 123 ++--- .../eclipse/cdt/ui/newui/SymbolDialog.java | 46 +- .../ui/wizards/CDTCommonProjectWizard.java | 108 ++-- .../cdt/ui/wizards/CDTMainWizardPage.java | 107 ++-- .../cdt/ui/wizards/NewCProjectWizard.java | 26 +- .../wizards/NewCProjectWizardOptionPage.java | 5 + .../wizards/NewClassCreationWizardPage.java | 476 +++++++++--------- .../conversion/ConvertProjectWizardPage.java | 208 ++++---- .../AbstractWizardDataPage.java | 9 +- .../cdt/ui/templateengine/FormBrowser.java | 3 +- .../templateengine/ProjectSelectionPage.java | 112 +++-- .../templateengine/TemplateClassWizard.java | 9 + .../templateengine/TemplateDrivenWizard.java | 15 +- .../TemplateListSelectionPage.java | 44 +- .../templateengine/TemplatesChoiceWizard.java | 12 +- .../cdt/ui/templateengine/WizardNode.java | 22 +- .../pages/NewProjectCreationPage.java | 26 +- .../pages/TemplateInputDialog.java | 23 +- .../pages/TemplatePreferencePage.java | 25 +- .../ui/templateengine/pages/UIWizardPage.java | 57 ++- .../uitree/UIElementTreeBuilderHelper.java | 25 +- .../uitree/UIElementTreeBuilderManager.java | 21 +- .../uitree/uiwidgets/UISpecialListWidget.java | 7 +- .../uitree/uiwidgets/UIStringListWidget.java | 15 +- .../uitree/uiwidgets/UITextWidget.java | 21 +- .../cdt/utils/ui/controls/ControlFactory.java | 126 ++--- .../utils/ui/controls/FileListControl.java | 77 +-- .../utils/ui/controls/RadioButtonsArea.java | 47 +- 311 files changed, 6186 insertions(+), 4412 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java index c29a448491a..cb927bb4d2a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java @@ -13,7 +13,7 @@ package org.eclipse.cdt.core.model; /** * Represents the declaration method of a class - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ @@ -46,7 +46,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration { /** * Returns whether this method is declared pure virtual. * - *

For example, a source method declared as virtual void m() = 0;. + *

For example, a source method declared as virtual void m() = 0;. * * @exception CModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource. @@ -57,14 +57,15 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration { * Returns if this method is static or not * @return boolean */ + @Override public boolean isStatic() throws CModelException; - + /** * Returns if this method is inline or not * @return boolean */ public boolean isInline() throws CModelException; - + /** * Returns whether this method is declared virtual. * diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IUsing.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IUsing.java index 03282893ae0..06b1bffffdb 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IUsing.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IUsing.java @@ -12,7 +12,7 @@ package org.eclipse.cdt.core.model; /** * Represents a "using" declaration in C translation unit. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ @@ -21,6 +21,7 @@ public interface IUsing extends ICElement, ISourceManipulation, ISourceReference * Returns the name of the package the statement refers to. * This is a handle-only method. */ + @Override String getElementName(); boolean isDirective(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java index fad740bbfd5..4b8fe51bb81 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java @@ -59,7 +59,7 @@ public class LanguageManager { private static final String ELEMENT_PDOM_LINKAGE_FACTORY = "pdomLinkageFactory"; //$NON-NLS-1$ private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ - + private static LanguageManager instance; private Map fLanguageCache = new HashMap(); private Map fPDOMLinkageFactoryCache= new HashMap(); @@ -81,19 +81,19 @@ public class LanguageManager { Map map = getDescriptorCache(); return map.get(id); } - + private HashMap getDescriptorCache() { if (fIdToLanguageDescriptorCache == null) { fIdToLanguageDescriptorCache = createDescriptorCache(); } return fIdToLanguageDescriptorCache; } - + public ILanguageDescriptor[] getLanguageDescriptors() { HashMap map = getDescriptorCache(); return map.values().toArray(new ILanguageDescriptor[map.size()]); } - + private HashMap createDescriptorCache() { HashMap map = new HashMap(); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); @@ -106,18 +106,18 @@ public class LanguageManager { } return map; } - + private HashMap> getContentTypeToDescriptorCache() { if (fContentTypeToDescriptorListCache == null) { fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache(); } return fContentTypeToDescriptorListCache; } - + public Map getContentTypeIdToLanguageDescriptionsMap() { HashMap map = new HashMap(); Map> cache = getContentTypeToDescriptorCache(); - + for (Entry> entry : cache.entrySet()) { List list = entry.getValue(); if (list.size() > 0) { @@ -125,11 +125,11 @@ public class LanguageManager { map.put(entry.getKey(), dess); } } - + return map; } - + private HashMap> createContentTypeToDescriptorCache() { HashMap> map = new HashMap>(); Map dc = getDescriptorCache(); @@ -150,7 +150,7 @@ public class LanguageManager { } return map; } - + public ILanguage getLanguage(String id) { ILanguage language = fLanguageCache.get(id); if (language != null) @@ -160,14 +160,16 @@ public class LanguageManager { for (int j = 0; j < configs.length; ++j) { final IConfigurationElement languageElem = configs[j]; if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { - String langId = getLanguageID(languageElem); + String langId = getLanguageID(languageElem); if (langId.equals(id)) { final ILanguage[] result= new ILanguage[]{null}; SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { CCorePlugin.log(exception); } + @Override public void run() throws Exception { result[0]= (ILanguage)languageElem.createExecutableExtension(ATTRIBUTE_CLASS); } @@ -185,15 +187,15 @@ public class LanguageManager { private String getLanguageID(final IConfigurationElement languageElem) { return languageElem.getNamespaceIdentifier() + NAMESPACE_SEPARATOR + languageElem.getAttribute(ATTRIBUTE_ID); } - + public ILanguage getLanguage(IContentType contentType) { String contentTypeID= contentType.getId(); return getLanguageForContentTypeID(contentTypeID); } - + public ILanguage getLanguageForContentTypeID(String contentTypeID) { cacheAllLanguages(); - + ILanguage language = fContentTypeToLanguageCache.get(contentTypeID); if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID)) return language; @@ -202,7 +204,7 @@ public class LanguageManager { for (int j = 0; j < configs.length; ++j) { final IConfigurationElement languageElem = configs[j]; if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { - IConfigurationElement[] assocContentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); + IConfigurationElement[] assocContentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); for (int k = 0; k < assocContentTypes.length; ++k) { if (contentTypeID.equals(assocContentTypes[k].getAttribute(ATTRIBUTE_ID))) { String id= getLanguageID(languageElem); @@ -216,8 +218,8 @@ public class LanguageManager { fContentTypeToLanguageCache.put(contentTypeID, null); return null; } - - /** + + /** * @deprecated use getRegisteredContentTypes() instead. */ @Deprecated @@ -229,19 +231,19 @@ public class LanguageManager { allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE); - IContentTypeManager manager = Platform.getContentTypeManager(); + IContentTypeManager manager = Platform.getContentTypeManager(); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); for (int j = 0; j < configs.length; ++j) { final IConfigurationElement languageElem = configs[j]; if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { - IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); + IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); for (int k = 0; k < contentTypes.length; ++k) { - IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID)); + IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID)); allTypes.add(langContType.getId()); } } } - + return allTypes; } @@ -253,7 +255,7 @@ public class LanguageManager { Set contentTypes= collectContentTypeIds(); return contentTypes.toArray(new String[contentTypes.size()]); } - + private Set collectContentTypeIds() { HashSet allTypes = new HashSet(); allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE); @@ -262,26 +264,26 @@ public class LanguageManager { allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE); - IContentTypeManager manager = Platform.getContentTypeManager(); + IContentTypeManager manager = Platform.getContentTypeManager(); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); for (int j = 0; j < configs.length; ++j) { final IConfigurationElement languageElem = configs[j]; if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { - IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); + IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); for (int k = 0; k < contentTypes.length; ++k) { - IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID)); + IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID)); allTypes.add(langContType.getId()); } } } - + return allTypes; } public boolean isContributedContentType(String contentTypeId) { return contentTypeId != null && getLanguageForContentTypeID(contentTypeId) != null; } - + /** * @deprecated use {@link #getContributedModelBuilderFor(ITranslationUnit)}, instead. * @noreference This method is not intended to be referenced by clients. @@ -309,36 +311,38 @@ public class LanguageManager { } /** - * Returns mappings between IDs and IPDOMLinkageFactory. The IDs are defined in {@link ILinkage}. + * Returns mappings between IDs and IPDOMLinkageFactory. The IDs are defined in {@link ILinkage}. * @return a map. * @since 4.0 */ public Map getPDOMLinkageFactoryMappings() { if (!fPDOMLinkageFactoryCache.isEmpty()) return Collections.unmodifiableMap(fPDOMLinkageFactoryCache); - + fPDOMLinkageFactoryCache.clear(); final IPDOMLinkageFactory[] result = new IPDOMLinkageFactory[] {null}; - + // read configuration IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); for (final IConfigurationElement element : configs) { if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) { SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { CCorePlugin.log(exception); } + @Override public void run() throws Exception { result[0] = (IPDOMLinkageFactory) element.createExecutableExtension(ATTRIBUTE_CLASS); }} - ); + ); fPDOMLinkageFactoryCache.put(element.getAttribute(ATTRIBUTE_ID), result[0]); - } - } + } + } return Collections.unmodifiableMap(fPDOMLinkageFactoryCache); - } - + } + /** * Returns all of the languages registered with the Platform. * @return all of the languages registered with the Platform. @@ -361,13 +365,15 @@ public class LanguageManager { for (int j = 0; j < configs.length; ++j) { final IConfigurationElement languageElem = configs[j]; if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { - String langId = getLanguageID(languageElem); + String langId = getLanguageID(languageElem); final ILanguage[] result= new ILanguage[] { null }; SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { CCorePlugin.log(exception); } + @Override public void run() throws Exception { result[0]= (ILanguage) languageElem.createExecutableExtension(ATTRIBUTE_CLASS); } @@ -379,7 +385,7 @@ public class LanguageManager { } fIsFullyCached = true; } - + /** * Returns the language configuration for the workspace. * @return the language configuration for the workspace @@ -391,16 +397,16 @@ public class LanguageManager { if (fWorkspaceMappings != null) { return fWorkspaceMappings; } - + LanguageMappingStore store = new LanguageMappingStore(); fWorkspaceMappings = store.decodeWorkspaceMappings(); return fWorkspaceMappings; } } - + /** * Saves the workspace language configuration to persistent storage and notifies - * all ILanguageMappingChangeListeners of changes. + * all ILanguageMappingChangeListeners of changes. * @param affectedContentTypes * @throws CoreException * @since 4.0 @@ -410,18 +416,18 @@ public class LanguageManager { if (fWorkspaceMappings == null) { return; } - + LanguageMappingStore store = new LanguageMappingStore(); store.storeMappings(fWorkspaceMappings); } - + // Notify listeners that the language mappings have changed. LanguageMappingChangeEvent event = new LanguageMappingChangeEvent(); event.setType(ILanguageMappingChangeEvent.TYPE_WORKSPACE); event.setAffectedContentTypes(affectedContentTypes); notifyLanguageChangeListeners(event); } - + /** * Returns the language configuration for the given project. * @param project @@ -435,18 +441,18 @@ public class LanguageManager { if (mappings != null) { return mappings; } - + LanguageMappingStore store = new LanguageMappingStore(); mappings = store.decodeMappings(project); fLanguageConfigurationCache.put(project, mappings); return mappings; } } - + /** * Saves the language configuration for the given project to persistent * storage and notifies all ILanguageMappingChangeListeners - * of changes. + * of changes. * @param project * @param affectedContentTypes * @throws CoreException @@ -458,7 +464,7 @@ public class LanguageManager { LanguageMappingStore store = new LanguageMappingStore(); store.storeMappings(project, mappings); } - + // Notify listeners that the language mappings have changed. LanguageMappingChangeEvent event = new LanguageMappingChangeEvent(); event.setType(ILanguageMappingChangeEvent.TYPE_PROJECT); @@ -466,7 +472,7 @@ public class LanguageManager { event.setAffectedContentTypes(affectedContentTypes); notifyLanguageChangeListeners(event); } - + /** * Returns an ILanguage representing the language to be used for the given file. * @since 4.0 @@ -475,20 +481,20 @@ public class LanguageManager { * @param project the IProject that this file is in the context of. This field cannot be null. * @param configuration the active build configuration, or null if build configurations * are not relevant to determining the language. - * @throws CoreException + * @throws CoreException */ public ILanguage getLanguageForFile(String fullPathToFile, IProject project, ICConfigurationDescription configuration) throws CoreException { if (project == null) throw new IllegalArgumentException("project must not be null in call to LanguageManager.getLanguageForFile(String, IProject)"); //$NON-NLS-1$ - + IContentType contentType = CContentTypes.getContentType(project, fullPathToFile); - + if (contentType == null) { return null; } - + String contentTypeID = contentType.getId(); - + return LanguageMappingResolver.computeLanguage(project, fullPathToFile, configuration, contentTypeID, false)[0].language; } @@ -507,7 +513,7 @@ public class LanguageManager { public ILanguage getLanguageForFile(IPath pathToFile, IProject project, ICConfigurationDescription configuration) throws CoreException { return getLanguageForFile(pathToFile, project, configuration, null); } - + /** * Returns an ILanguage representing the language to be used for the given file. * @return an ILanguage representing the language to be used for the given file @@ -536,7 +542,7 @@ public class LanguageManager { } contentTypeID= ct.getId(); } - + return LanguageMappingResolver.computeLanguage(project, pathToFile.toPortableString(), configuration, contentTypeID, false)[0].language; } @@ -566,7 +572,7 @@ public class LanguageManager { public ILanguage getLanguageForFile(IFile file, ICConfigurationDescription configuration, String contentTypeId) throws CoreException { IProject project = file.getProject(); - + if (contentTypeId == null) { IPath location = file.getLocation(); String filename; @@ -581,36 +587,36 @@ public class LanguageManager { } contentTypeId= contentType.getId(); } - + return LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, contentTypeId, false)[0].language; } - + /** * Adds a listener that will be notified of changes in language mappings. - * + * * @param listener the ILanguageMappingChangeListener to add */ public void registerLanguageChangeListener(ILanguageMappingChangeListener listener) { fLanguageChangeListeners.add(listener); } - + /** * Removes a language mapping change listener. - * + * * @param listener the ILanguageMappingChangeListener to remove. */ public void unregisterLanguageChangeListener(ILanguageMappingChangeListener listener) { fLanguageChangeListeners.remove(listener); } - + /** * Notifies all language mappings change listeners of a change in the mappings. - * + * * @param event the ILanguageMappingsChange event to be broadcast. */ public void notifyLanguageChangeListeners(ILanguageMappingChangeEvent event) { Object[] listeners = fLanguageChangeListeners.getListeners(); - + for (Object obj : listeners) { ILanguageMappingChangeListener listener = (ILanguageMappingChangeListener) obj; listener.handleLanguageMappingChangeEvent(event); @@ -620,7 +626,7 @@ public class LanguageManager { /** * Saves the language configuration for the given file to persistent * storage and notifies all ILanguageMappingChangeListeners - * of changes. + * of changes. * @param file * @throws CoreException * @since 4.0 @@ -632,7 +638,7 @@ public class LanguageManager { LanguageMappingStore store = new LanguageMappingStore(); store.storeMappings(project, mappings); } - + // Notify listeners that the language mappings have changed. LanguageMappingChangeEvent event = new LanguageMappingChangeEvent(); event.setType(ILanguageMappingChangeEvent.TYPE_FILE); @@ -645,10 +651,10 @@ public class LanguageManager { * Returns language binding to a particular content type for given project. * This method will check project settings, workspace settings and default * bindings (in that order) - * + * * @param contentType content type of the file * @param project C/C++ workspace project - * @return CDT language object + * @return CDT language object * @since 5.4 */ public ILanguage getLanguage(IContentType contentType, IProject project) { @@ -659,11 +665,11 @@ public class LanguageManager { * Returns language binding to a particular content type for given project. * This method will check project settings, workspace settings and default * bindings (in that order) - * + * * @param contentType content type of the file * @param project C/C++ workspace project * @param configurationDescription build configuration or null - * @return CDT language object + * @return CDT language object * @since 5.4 */ public ILanguage getLanguage(IContentType contentType, diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageMappingChangeEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageMappingChangeEvent.java index 6487fc25cfd..540b46adf58 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageMappingChangeEvent.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageMappingChangeEvent.java @@ -19,9 +19,9 @@ import org.eclipse.core.runtime.content.IContentType; /** * A minimal implementation of ILanguageMappingsChangeEvent. - * + * * @noextend This interface is not intended to be extended by clients. - * @noinstantiate This class is not intended to be instantiated by clients. + * @noinstantiate This class is not intended to be instantiated by clients. */ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { @@ -35,6 +35,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getAffectedContentTypes() */ + @Override public IContentType[] getAffectedContentTypes() { return fContentTypes; } @@ -42,6 +43,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFile() */ + @Override public IFile getFile() { return fFile; } @@ -49,11 +51,12 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFilename() */ + @Override public String getFilename() { - + // if the filename has been set, use it. otherwise get the path from // either the IFile or the IPath if we have one - + if(fFileName != null) return fFileName; else { @@ -65,30 +68,31 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { else { // use the URI if there is one URI uri = fFile.getLocationURI(); - + if(uri != null) return uri.toString(); } - + } else { // no file, use path if(fPath != null) return fPath.toString(); - + } } - + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getPath() */ + @Override public IPath getPath() { - + if(fPath != null) return fPath; - + else { // try to get the path from the file if we have one if(fFile != null) { @@ -96,31 +100,33 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { return location; } } - + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getProject() */ + @Override public IProject getProject() { - + if(fProject != null) return fProject; - + else { // try to get the project from the file if we have one - + if(fFile != null) return fFile.getProject(); - + } - - return null; + + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getType() */ + @Override public int getType() { return fType; } @@ -128,7 +134,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /** * Sets the associated IContentTypes for this event. The provided array will be returned * subsequently by getAffectedContentTypes. - * + * * @param affectedContentTypes */ public void setAffectedContentTypes(IContentType[] affectedContentTypes) { @@ -138,7 +144,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /** * Sets the associated IFile for this event. This file will be returned subsequently * by getFile(). - * + * * @param file the IFile to set */ public void setFile(IFile file) { @@ -148,7 +154,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /** * Sets the associated String filename for this event. This filename will be returned subsequently * by getFileName(). - * + * * @param fileName the fFileName to set */ public void setFileName(String fileName) { @@ -158,7 +164,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /** * Sets the associated IPath for this event. This path will be returned subsequently * by getPath(). - * + * * @param path the IPath to set */ public void setPath(IPath path) { @@ -168,16 +174,16 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { /** * Sets the associated project for this event. This project will be returned subsequently * by getProject(). - * + * * @param project the IProject to set */ public void setProject(IProject project) { fProject = project; } - + /** * Sets the type of this event. This type will be returned by getType(). - * + * * @param type the type to set * @see ILanguageMappingChangeEvent#TYPE_WORKSPACE * @see ILanguageMappingChangeEvent#TYPE_PROJECT diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java index 14cfa3a2610..294af9234ac 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CDTListComparator.java @@ -25,19 +25,20 @@ public class CDTListComparator implements Comparator { comparator = new CDTListComparator(); return comparator; } + @Override public int compare(Object a, Object b) { - if (a == null || b == null) + if (a == null || b == null) return 0; if (a instanceof ICLanguageSetting) { ICLanguageSetting c1 = (ICLanguageSetting)a; ICLanguageSetting c2 = (ICLanguageSetting)b; return c1.getName().compareToIgnoreCase(c2.getName()); - } + } if (a instanceof ICLanguageSettingEntry) { ICLanguageSettingEntry c1 = (ICLanguageSettingEntry)a; ICLanguageSettingEntry c2 = (ICLanguageSettingEntry)b; return c1.getName().compareToIgnoreCase(c2.getName()); - } + } if (a instanceof ICConfigurationDescription) { ICConfigurationDescription c1 = (ICConfigurationDescription)a; ICConfigurationDescription c2 = (ICConfigurationDescription)b; @@ -46,7 +47,7 @@ public class CDTListComparator implements Comparator { if (a instanceof ICdtVariable) { ICdtVariable c1 = (ICdtVariable) a; ICdtVariable c2 = (ICdtVariable) b; - return c1.getName().compareToIgnoreCase(c2.getName()); + return c1.getName().compareToIgnoreCase(c2.getName()); } return a.toString().compareTo(b.toString()); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java index 061696b7136..098b5c62313 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACExclusionFilterEntry.java @@ -40,11 +40,12 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx protected final boolean isFile() { return false; } - + /** * Returns the exclusion patterns * @return IPath[] */ + @Override public IPath[] getExclusionPatterns() { return exclusionPatterns.length != 0 ? (IPath[])exclusionPatterns.clone() : exclusionPatterns; } @@ -52,6 +53,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx /** * Returns a char based representation of the exclusions patterns full path. */ + @Override public char[][] fullExclusionPatternChars() { if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) { int length = this.exclusionPatterns.length; @@ -61,18 +63,18 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx path = getLocation(); IPath prefixPath = path.removeTrailingSeparator(); for (int i = 0; i < length; i++) { - this.fullCharExclusionPatterns[i] = + this.fullCharExclusionPatterns[i] = prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray(); } } return this.fullCharExclusionPatterns; } - + @Override public boolean equals(Object other) { if(!super.equals(other)) return false; - + ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other; return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns); } @@ -86,7 +88,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx public boolean equalsByContents(ICSettingEntry entry) { if(!super.equalsByContents(entry)) return false; - + ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry; return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java index 363b4d6a9a1..3835d6e878b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java @@ -20,7 +20,7 @@ public abstract class ACPathEntry extends ACSettingEntry // IPath fFullPath; // IPath fLocation; // private IPath fPath; - + ACPathEntry(IResource rc, int flags) { super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH); // fFullPath = rc.getFullPath(); @@ -37,7 +37,7 @@ public abstract class ACPathEntry extends ACSettingEntry ACPathEntry(String value, int flags) { super(value, flags); } - + ACPathEntry(IPath path, int flags) { super(path.toString(), flags /*| RESOLVED*/); // fPath = path; @@ -47,6 +47,7 @@ public abstract class ACPathEntry extends ACSettingEntry // fLocation = path; } + @Override public IPath getFullPath() { if(isValueWorkspacePath()) return new Path(getValue()); @@ -56,19 +57,20 @@ public abstract class ACPathEntry extends ACSettingEntry } return null; } - + protected IPath fullPathForLocation(IPath location){ IResource rcs[] = isFile() ? (IResource[])ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location) : (IResource[])ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location); - + if(rcs.length > 0) return rcs[0].getFullPath(); return null; } - + protected abstract boolean isFile(); + @Override public IPath getLocation() { if(!isValueWorkspacePath()) return new Path(getValue()); @@ -80,7 +82,8 @@ public abstract class ACPathEntry extends ACSettingEntry } return null; } - + + @Override public boolean isValueWorkspacePath() { return checkFlags(VALUE_WORKSPACE_PATH); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java index 37420be10a1..840047ff044 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java @@ -18,107 +18,115 @@ import org.eclipse.cdt.internal.core.SafeStringInterner; public abstract class ACSettingEntry implements ICSettingEntry { int fFlags; String fName; - + ACSettingEntry(String name, int flags){ fName = SafeStringInterner.safeIntern(name); fFlags = flags; } + @Override public boolean isBuiltIn() { return checkFlags(BUILTIN); } + @Override public boolean isReadOnly() { return checkFlags(READONLY); } - + protected boolean checkFlags(int flags){ return (fFlags & flags) == flags; } - + + @Override public String getName() { return fName; } + @Override public String getValue() { - //name and value differ only for macro entry and have the same contents + //name and value differ only for macro entry and have the same contents //for all other entries return fName; } + @Override public boolean isResolved() { return checkFlags(RESOLVED); } - + @Override public boolean equals(Object other){ if(other == this) return true; - + if(!(other instanceof ACSettingEntry)) return false; - + ACSettingEntry e = (ACSettingEntry)other; - + if(getKind() != e.getKind()) return false; - + if(fFlags != e.fFlags) return false; - + if(!fName.equals(e.fName)) return false; - + return true; } - + @Override public int hashCode(){ - return getKind() + fFlags + fName.hashCode(); + return getKind() + fFlags + fName.hashCode(); } + @Override public int getFlags() { return fFlags; } + @Override public boolean equalsByContents(ICSettingEntry entry) { return equalsByName(entry); } - + protected int getByNameMatchFlags(){ return (fFlags & (~ (BUILTIN | READONLY | RESOLVED))); } + @Override public final boolean equalsByName(ICSettingEntry entry) { if(entry == this) return true; - + if(!(entry instanceof ACSettingEntry)) return false; - + ACSettingEntry e = (ACSettingEntry)entry; - + if(getKind() != e.getKind()) return false; - + if(getByNameMatchFlags() != e.getByNameMatchFlags()) return false; - + if(!fName.equals(e.fName)) return false; - + return true; } - + public final int codeForNameKey(){ - return getKind() + getByNameMatchFlags() + fName.hashCode(); + return getKind() + getByNameMatchFlags() + fName.hashCode(); } - + public int codeForContentsKey(){ return codeForNameKey(); } - + @Override public final String toString(){ StringBuffer buf = new StringBuffer(); @@ -127,7 +135,7 @@ public abstract class ACSettingEntry implements ICSettingEntry { buf.append(" ; flags: ").append(LanguageSettingEntriesSerializer.composeFlagsString(getFlags())); //$NON-NLS-1$ return buf.toString(); } - + protected abstract String contentsToString(); - + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java index 6768253b104..5872650ccdd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java @@ -29,14 +29,14 @@ public final class CExternalSetting implements ICExternalSetting { fLanguageIds = base.getCompatibleLanguageIds(); fContentTypeIds = base.getCompatibleContentTypeIds(); fExtensions = base.getCompatibleExtensions(); - + // fEntryStore = new EntryStore(); initEntryStore(base.getEntries()); } public CExternalSetting(ICExternalSetting base, ICSettingEntry entries[]) { this(base); - + initEntryStore(entries); } @@ -48,25 +48,25 @@ public final class CExternalSetting implements ICExternalSetting { fContentTypeIds = contentTypeIds.clone(); if (extensions != null) fExtensions = extensions.clone(); - + initEntryStore(entries); } - + private void initEntryStore(ICSettingEntry entries[]) { ICSettingEntry entry; for (int i = 0; i < entries.length; i++) { entry = entries[i]; - + addEntry(entry); } - + // trimToSize(); } - + private void addEntry(ICSettingEntry entry) { getEntriesSet(entry.getKind(), true).addEntry(entry); } - + // private void trimToSize() { // int kinds[] = KindBasedStore.getSupportedKinds(); // for (int i = 0; i < kinds.length; i++) { @@ -75,7 +75,7 @@ public final class CExternalSetting implements ICExternalSetting { // set.trimToSize(); // } // } - + private CEntriesSet getEntriesSet(int kind, boolean create) { CEntriesSet set = fStore.get(kind); if (set == null && create) { @@ -85,24 +85,28 @@ public final class CExternalSetting implements ICExternalSetting { return set; } + @Override public String[] getCompatibleContentTypeIds() { if (fContentTypeIds != null) return fContentTypeIds.clone(); return null; } + @Override public String[] getCompatibleExtensions() { if (fExtensions != null) return fExtensions.clone(); return null; } + @Override public String[] getCompatibleLanguageIds() { if (fLanguageIds != null) return fLanguageIds.clone(); return null; } + @Override public ICSettingEntry[] getEntries(int kind) { CEntriesSet set = getEntriesSet(kind, false); if (set != null) @@ -114,6 +118,7 @@ public final class CExternalSetting implements ICExternalSetting { // return fId; // } + @Override public ICSettingEntry[] getEntries() { List result = new ArrayList(); int kinds[] = KindBasedStore.getAllEntryKinds(); @@ -122,7 +127,7 @@ public final class CExternalSetting implements ICExternalSetting { if (list != null) result.addAll(Arrays.asList(list.toArray())); } - + return result.toArray(new ICSettingEntry[result.size()]); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java index fa6081596cd..beb55889422 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludeFileEntry.java @@ -28,6 +28,7 @@ public final class CIncludeFileEntry extends ACPathEntry implements super(rc, flags); } + @Override public final int getKind() { return INCLUDE_FILE; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java index ec1b0146079..9b88425ee54 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CIncludePathEntry.java @@ -27,10 +27,12 @@ public final class CIncludePathEntry extends ACPathEntry implements ICIncludePat super(rc, flags); } + @Override public boolean isLocal() { return checkFlags(LOCAL); } + @Override public final int getKind() { return INCLUDE_PATH; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java index a0b3f5e896d..4d693cf33d8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java @@ -20,7 +20,7 @@ public final class CLibraryFileEntry extends ACPathEntry implements private IPath fSourceAttachmentPath; private IPath fSourceAttachmentRootPath; private IPath fSourceAttachmentPrefixMapping; - + public CLibraryFileEntry(String value, int flags) { this(value, flags, null, null, null); } @@ -33,8 +33,8 @@ public final class CLibraryFileEntry extends ACPathEntry implements this(rc, flags, null, null, null); } - public CLibraryFileEntry(String value, - int flags, + public CLibraryFileEntry(String value, + int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) { @@ -43,7 +43,7 @@ public final class CLibraryFileEntry extends ACPathEntry implements } public CLibraryFileEntry(IPath location, - int flags, + int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) { @@ -51,26 +51,27 @@ public final class CLibraryFileEntry extends ACPathEntry implements setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); } - public CLibraryFileEntry(IFile rc, - int flags, + public CLibraryFileEntry(IFile rc, + int flags, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping) { super(rc, flags); setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); } - + private void setSourceAttachmentSettings(IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping){ if(sourceAttachmentPath == null) return; - + fSourceAttachmentPath = sourceAttachmentPath; fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY; fSourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping != null ? sourceAttachmentPrefixMapping : Path.EMPTY; } + @Override public final int getKind() { return LIBRARY_FILE; } @@ -80,14 +81,17 @@ public final class CLibraryFileEntry extends ACPathEntry implements return true; } + @Override public IPath getSourceAttachmentPath() { return fSourceAttachmentPath; } + @Override public IPath getSourceAttachmentPrefixMapping() { return fSourceAttachmentPrefixMapping; } + @Override public IPath getSourceAttachmentRootPath() { return fSourceAttachmentRootPath; } @@ -108,10 +112,10 @@ public final class CLibraryFileEntry extends ACPathEntry implements public boolean equals(Object other) { if(other == this) return true; - + if(!super.equals(other)) return false; - + return sourceAttachmentSettingsEqual((CLibraryFileEntry)other); } @@ -119,13 +123,13 @@ public final class CLibraryFileEntry extends ACPathEntry implements public boolean equalsByContents(ICSettingEntry entry) { if(entry == this) return true; - + if(!super.equalsByContents(entry)) return false; - + return sourceAttachmentSettingsEqual((CLibraryFileEntry)entry); } - + private boolean sourceAttachmentSettingsEqual(CLibraryFileEntry otherEntry){ if(!CDataUtil.objectsEqual(fSourceAttachmentPath, otherEntry.fSourceAttachmentPath)) return false; @@ -135,11 +139,11 @@ public final class CLibraryFileEntry extends ACPathEntry implements return false; return true; } - + @Override protected String contentsToString() { String result = super.contentsToString(); - + if(fSourceAttachmentPath != null){ StringBuffer buf = new StringBuffer(); buf.append(result); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java index f980921c382..90b832a5b09 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryPathEntry.java @@ -28,6 +28,7 @@ public final class CLibraryPathEntry extends ACPathEntry implements super(rc, flags); } + @Override public final int getKind() { return LIBRARY_PATH; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java index 451efd313d8..df0c903803d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroEntry.java @@ -29,6 +29,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{ return fValue; } + @Override public final int getKind() { return MACRO; } @@ -49,7 +50,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{ public boolean equalsByContents(ICSettingEntry entry) { if(!super.equalsByContents(entry)) return false; - + return fValue.equals(((CMacroEntry)entry).fValue); } @@ -57,5 +58,5 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{ protected String contentsToString() { return new StringBuffer().append(fName).append('=').append(fValue).toString(); } - + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java index 076ddd8dcfb..10114fccfd2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CMacroFileEntry.java @@ -28,10 +28,11 @@ public final class CMacroFileEntry extends ACPathEntry implements super(rc, flags); } + @Override public final int getKind() { return MACRO_FILE; } - + @Override public final boolean isFile() { return true; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java index a256d3551e5..d682cbcc663 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/COutputEntry.java @@ -27,6 +27,7 @@ public final class COutputEntry extends ACExclusionFilterEntry implements ICOutp super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH); } + @Override public final int getKind() { return OUTPUT_PATH; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java index 5adb0d93e9e..f0fcdfc3646 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CSourceEntry.java @@ -27,6 +27,7 @@ public final class CSourceEntry extends ACExclusionFilterEntry implements ICSour super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH); } + @Override public final int getKind() { return SOURCE_PATH; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java index 6e54e180496..eac75d44021 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java @@ -175,6 +175,7 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin /** * Returns whether or not the configuration description was modified */ + @Override boolean isModified(); /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java index 64004033c9a..a53f5b1754f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICMacroEntry.java @@ -19,5 +19,6 @@ public interface ICMacroEntry extends ICLanguageSettingEntry { /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICSettingEntry#getValue() */ + @Override String getValue(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java index 321ac95c8b2..0199ba259f3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java @@ -20,11 +20,11 @@ import org.eclipse.core.runtime.QualifiedName; * The ICProjectDescription is the root element for obtaining the CDT project settings * it can be obtained by the {@link CoreModel#getProjectDescription(IProject, boolean)} call * @see CoreModel#getProjectDescription(IProject) - * @see CoreModel#getProjectDescription(IProject, boolean) + * @see CoreModel#getProjectDescription(IProject, boolean) * */ -public interface ICProjectDescription extends ICSettingContainer, - ICSettingObject, +public interface ICProjectDescription extends ICSettingContainer, + ICSettingObject, ICSettingsStorage, ICProjectDescriptionPreferences { @@ -32,7 +32,7 @@ public interface ICProjectDescription extends ICSettingContainer, * @return {@link ICConfigurationDescription}[] containing all configurations in the project */ ICConfigurationDescription[] getConfigurations(); - + /** * Returns the Project's active configuration. This is the configuration which is built by default * @see ICProjectDescriptionPreferences#setConfigurationRelations(int) @@ -42,9 +42,9 @@ public interface ICProjectDescription extends ICSettingContainer, /** * sets active configuration for this project description - * + * * @param cfg - * + * * @throws WriteAccessException when the project description is read-only * the description is read only if it was queried/returned by the CoreModel.getProjectDescription(org.eclipse.core.resources.IProject, false) call */ @@ -52,7 +52,7 @@ public interface ICProjectDescription extends ICSettingContainer, /** * creates/adds a new configuration for this project description - * + * * @param id configuration id * @param name configuration name * @param base the configuration description from which the settings are to be copied @@ -60,15 +60,15 @@ public interface ICProjectDescription extends ICSettingContainer, * @throws CoreException * @throws WriteAccessException when the project description is read-only * the description is read only if it was queried/returned by the CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false) call - * + * */ ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException, WriteAccessException; /** * creates/adds a new configuration for this project description * This method is typically used by the Build System-specific code for creating new configurations - * - * @param buildSystemId build system id, i.e. the extension id contributing to the + * + * @param buildSystemId build system id, i.e. the extension id contributing to the * org.eclipse.cdt.core.CConfigurationDataProvider extension point * @param data CConfigurationData to be associated with this configuration * @return {@link ICConfigurationDescription} created @@ -89,7 +89,7 @@ public interface ICProjectDescription extends ICSettingContainer, * @return {@link ICConfigurationDescription} of the given id or null if not found */ ICConfigurationDescription getConfigurationById(String id); - + /** * Remove Configuration of the given name from the project description * @param name String name of the configuration to remove @@ -105,23 +105,24 @@ public interface ICProjectDescription extends ICSettingContainer, * the description is read only if it was queried/returned by the CoreModel.getProjectDescription(IProject, false) call */ void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException; - + /** * @return IProject this project description is associated with */ IProject getProject(); - + /** * @return true if the project description was modified, false otherwise */ + @Override boolean isModified(); - + /** * the get/setSettionsProperty methods allow to associate the session properties with the given project description * session properties are not persisted and are not restored on the next eclipse session * the scope of project description session properties is the current project description, * i.e. modifications to the properties are not applied until the setProjectDescription call - * + * * @param name */ Object getSessionProperty(QualifiedName name); @@ -131,16 +132,16 @@ public interface ICProjectDescription extends ICSettingContainer, * session properties are not persisted and are not restored on the next eclipse session * the scope of project description session properties is the current project description, * i.e. modifications to the properties are not applied until the setProjectDescription call - * + * * @param name * @param value */ void setSessionProperty(QualifiedName name, Object value); - + /** * Returns the default setting ICConfigurationDescription. This is the configuration - * used by the CDT editor and views. - * + * used by the CDT editor and views. + * * @see ICProjectDescriptionPreferences#setConfigurationRelations(int) * @return the default {@link ICConfigurationDescription} */ @@ -153,28 +154,28 @@ public interface ICProjectDescription extends ICSettingContainer, * @param cfg */ void setDefaultSettingConfiguration(ICConfigurationDescription cfg); - + /** * when true specifies that the project creation is in progress. * Sometimes project creation might be performed via multiple steps, e.g. * the New Project Wizard may create a temporary project with temporary settings * and delete it on cancel, etc. - * + * * Thus the project may exist as well as the project may contain the associated ICProjectDescription, * but its initialization may not be completed. - * + * * once the flag is set to false it can never be reset back to true. - * if {@link ICProjectDescriptionManager#setProjectDescription(IProject, ICProjectDescription)} is called + * if {@link ICProjectDescriptionManager#setProjectDescription(IProject, ICProjectDescription)} is called * for the description containing the true "isCdtProjectCreating" state, * but the project already contains the project description with the false "isCdtProjectCreating" state * the true state will be ignored, i.e. the resulting setting will contain false "isCdtProjectCreating" state - * + * * so only the newly created descriptions (created via a {@link ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)}) may contain * true "isCdtProjectCreating" state - * - * + * + * * @return boolean - * + * * @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean) * @see #setCdtProjectCreated() */ @@ -182,7 +183,7 @@ public interface ICProjectDescription extends ICSettingContainer, /** * sets the project creation state to false - * + * * @see #isCdtProjectCreating() * @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean) */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.java index cca81f3960f..4ca7069c6fd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiItemsHolder.java @@ -25,21 +25,22 @@ public abstract class MultiItemsHolder implements ICMultiItemsHolder { /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#getItems() */ + @Override public abstract Object[] getItems(); /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#setStringListMode(int) */ /** - * This method is put here to prevent UI from - * accessing constructors in "internal" dirs. - * + * This method is put here to prevent UI from + * accessing constructors in "internal" dirs. + * * Creates multiple configuration description. - * If there's 1 cfg.desc in array, - * it's returned itself. - * + * If there's 1 cfg.desc in array, + * it's returned itself. + * * @param rds - array of cfg.descs - * + * * @return multiple cfg.description or single cfg.desc. */ public static ICConfigurationDescription createCDescription(ICConfigurationDescription[] rds) { @@ -51,16 +52,16 @@ public abstract class MultiItemsHolder implements ICMultiItemsHolder { return new MultiConfigDescription(rds); } /** - * This method is put here to prevent UI from - * accessing constructors in "internal" dirs. - * + * This method is put here to prevent UI from + * accessing constructors in "internal" dirs. + * * Creates multiple resource description, it * can be either MultiFile or MultiFolder. - * If there's 1 description in array, - * it's returned itself. - * + * If there's 1 description in array, + * it's returned itself. + * * @param rds - array of resource descs - * + * * @return multiple res.description or single res.desc. */ public static ICResourceDescription createRDescription(ICResourceDescription[] rds) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiLanguageSetting.java index e6cf701c1e5..6b51d2e9363 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/MultiLanguageSetting.java @@ -15,21 +15,22 @@ import java.util.List; /** - * This class is intended to hold "similar" Language Setting objects. + * This class is intended to hold "similar" Language Setting objects. * Normally, they should have the same name. */ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguageSetting { ICLanguageSetting[] items = null; ICConfigurationDescription cfgd = null; - + public MultiLanguageSetting(List data, ICConfigurationDescription cf) { items = data.toArray(new ICLanguageSetting[data.size()]); cfgd = cf; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getLanguageId() */ + @Override public String getLanguageId() { return items[0].getLanguageId(); // Assuming language is the same. } @@ -48,6 +49,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSettingEntriesList(int) */ + @Override public List getSettingEntriesList(int kind) { return Arrays.asList(getSettingEntries(kind)); } @@ -75,6 +77,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSupportedEntryKinds() */ + @Override public int getSupportedEntryKinds() { int res = 0; for (ICLanguageSetting item : items) @@ -85,11 +88,13 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setLanguageId(java.lang.String) */ + @Override public void setLanguageId(String id) {} // Do nothing /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry[]) */ + @Override public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) { for (ICLanguageSetting item : items) item.setSettingEntries(kind, entries); @@ -98,6 +103,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, java.util.List) */ + @Override public void setSettingEntries(int kind, List entriesList) { for (ICLanguageSetting item : items) item.setSettingEntries(kind, entriesList); @@ -106,6 +112,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceContentTypeIds(java.lang.String[]) */ + @Override public void setSourceContentTypeIds(String[] ids) { for (ICLanguageSetting item : items) item.setSourceContentTypeIds(ids); @@ -114,6 +121,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceExtensions(java.lang.String[]) */ + @Override public void setSourceExtensions(String[] exts) { for (ICLanguageSetting item : items) item.setSourceExtensions(exts); @@ -122,6 +130,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#supportsEntryKind(int) */ + @Override public boolean supportsEntryKind(int kind) { for (ICLanguageSetting item : items) if (item.supportsEntryKind(kind)) @@ -132,6 +141,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getConfiguration() */ + @Override public ICConfigurationDescription getConfiguration() { if (DEBUG) System.out.println("Bad multi access: MultiLanguageSetting.getConfiguration()"); //$NON-NLS-1$ @@ -141,6 +151,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getId() */ + @Override public String getId() { // IDs are different if (DEBUG) System.out.println("Bad multi access: MultiLanguageSetting.getId()"); //$NON-NLS-1$ @@ -150,6 +161,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getName() */ + @Override public String getName() { // names are proposed to be equal return items[0].getName(); } @@ -157,6 +169,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getParent() */ + @Override public ICSettingContainer getParent() { if (DEBUG) System.out.println("Bad multi access: MultiLanguageSetting.getParent()"); //$NON-NLS-1$ @@ -166,6 +179,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getType() */ + @Override public int getType() { int x = items[0].getType(); for (ICLanguageSetting item : items) @@ -177,6 +191,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICSettingObject#isReadOnly() */ + @Override public boolean isReadOnly() { for (int i=0; i clazz){ List list = getRcDataList(kind); CResourceData datas[] = (CResourceData[])Array.newInstance(clazz, list.size()); - + return list.toArray(datas); } - + public List getRcDataList(final int kind){ - final List list = new ArrayList(); + final List list = new ArrayList(); fRcDataContainer.accept(new IPathSettingsContainerVisitor(){ + @Override public boolean visit(PathSettingsContainer container) { if(fIncludeCurrent || container != fRcDataContainer){ CResourceData data = (CResourceData)container.getValue(); @@ -79,7 +80,7 @@ public class CResourceDataContainer { return true; } }); - + return list; } @@ -93,16 +94,16 @@ public class CResourceDataContainer { public void removeResourceData(IPath path) { fRcDataContainer.removeChildContainer(path); } - + public void addResourceData(CResourceData data){ PathSettingsContainer cr = fRcDataContainer.getChildContainer(data.getPath(), true, true); cr.setValue(data); } - + public CFileData getFileData(IPath path){ return (CFileData)getResourceData(path, true, ICSettingBase.SETTING_FILE); } - + public CFolderData getFolderData(IPath path){ return (CFolderData)getResourceData(path, true, ICSettingBase.SETTING_FOLDER); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java index c9ce9d75018..3ced074d468 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/KindBasedStore.java @@ -16,9 +16,9 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; /** * A storage where stored data is organized by "kind". * In most cases kind is one of {@link ICLanguageSettingEntry}, i.e. include path, macro etc. - * + * * @param - stored type - * + * * @see ICSettingEntry#INCLUDE_PATH * @see ICSettingEntry#INCLUDE_FILE * @see ICSettingEntry#MACRO @@ -41,8 +41,8 @@ public class KindBasedStore implements Cloneable { private static final int INDEX_SOURCE_PATH = 6; private static final int INDEX_OUPUT_PATH = 7; private static final int ALL_STORAGE_SIZE = 8; - - public static final int ORED_LANG_ENTRY_KINDS = + + public static final int ORED_LANG_ENTRY_KINDS = ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.MACRO @@ -50,7 +50,7 @@ public class KindBasedStore implements Cloneable { | ICLanguageSettingEntry.LIBRARY_PATH | ICLanguageSettingEntry.LIBRARY_FILE; - public static final int ORED_ALL_ENTRY_KINDS = + public static final int ORED_ALL_ENTRY_KINDS = ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.MACRO @@ -59,7 +59,7 @@ public class KindBasedStore implements Cloneable { | ICLanguageSettingEntry.LIBRARY_FILE | ICLanguageSettingEntry.SOURCE_PATH | ICLanguageSettingEntry.OUTPUT_PATH; - + private static final int LANG_ENTRY_KINDS[] = new int[]{ ICLanguageSettingEntry.INCLUDE_PATH, ICLanguageSettingEntry.INCLUDE_FILE, @@ -81,7 +81,7 @@ public class KindBasedStore implements Cloneable { }; // private static final int INEXISTENT_INDEX = -1; - + private Object[] fEntryStorage; public KindBasedStore(){ @@ -162,11 +162,11 @@ public class KindBasedStore implements Cloneable { fEntryStorage[index] = object; return old; } - + private class KindBasedInfo implements IKindBasedInfo { int fIdex; int fKind; - + KindBasedInfo(int num, boolean isKind){ if(isKind){ fIdex = kindToIndex(num); @@ -176,26 +176,29 @@ public class KindBasedStore implements Cloneable { fKind = indexToKind(num); } } - + + @Override public T getInfo() { @SuppressWarnings("unchecked") T info = (T)fEntryStorage[fIdex]; return info; } + @Override public int getKind() { return fKind; } + @Override public T setInfo(T newInfo) { @SuppressWarnings("unchecked") T old = (T)fEntryStorage[fIdex]; fEntryStorage[fIdex] = newInfo; return old; } - + } - + public IKindBasedInfo[] getContents(){ @SuppressWarnings("unchecked") IKindBasedInfo infos[] = new IKindBasedInfo[fEntryStorage.length]; @@ -204,11 +207,11 @@ public class KindBasedStore implements Cloneable { } return infos; } - + public IKindBasedInfo getInfo(int kind){ return new KindBasedInfo(kind, true); } - + public void clear(){ for(int i = 0; i < fEntryStorage.length; i++){ fEntryStorage[i] = null; @@ -226,6 +229,6 @@ public class KindBasedStore implements Cloneable { } return null; } - - + + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java index f399fdbbdde..4a9db6d9ebb 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java @@ -990,6 +990,7 @@ public class PathEntryTranslator { final Set set = new HashSet(); fStorage.accept(new IPathSettingsContainerVisitor() { + @Override public boolean visit(PathSettingsContainer container) { PathEntryCollector clr = (PathEntryCollector)container.getValue(); clr.getLocalCollectedEntries(kind, list, set); @@ -2033,6 +2034,7 @@ public class PathEntryTranslator { final int kinds[] = KindBasedStore.getLanguageEntryKinds(); rcDatas.accept(new IPathSettingsContainerVisitor() { + @Override public boolean visit(PathSettingsContainer container) { CResourceData data = (CResourceData)container.getValue(); if (data != null) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java index 5f7bf9568ae..54476b5479f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathSettingsContainer.java @@ -181,6 +181,7 @@ public final class PathSettingsContainer { final List list = new ArrayList(); accept(new IPathSettingsContainerVisitor(){ + @Override public boolean visit(PathSettingsContainer container) { if(container != PathSettingsContainer.this || includeThis) list.add(container); @@ -258,6 +259,7 @@ public final class PathSettingsContainer { final List list = new ArrayList(); accept(new IPathSettingsContainerVisitor(){ + @Override public boolean visit(PathSettingsContainer container) { if(container != PathSettingsContainer.this || includeThis) list.add(container.getValue()); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PatternNameMap.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PatternNameMap.java index 63832c37365..34f8da91ae5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PatternNameMap.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PatternNameMap.java @@ -17,13 +17,13 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Map.Entry; +import java.util.NoSuchElementException; import org.eclipse.cdt.core.model.CoreModelUtil; public class PatternNameMap { - private static final char[] SPEC_CHARS = new char[]{'*', '?'}; + private static final char[] SPEC_CHARS = new char[]{'*', '?'}; static final String DOUBLE_STAR_PATTERN = "**"; //$NON-NLS-1$ private Map fChildrenMap; @@ -38,7 +38,7 @@ public class PatternNameMap { StringCharArray(String string){ fString = string; } - + char[] getCharArray(){ if(fCharArray == null){ fCharArray = fString.toCharArray(); @@ -50,10 +50,10 @@ public class PatternNameMap { public boolean equals(Object obj) { if(obj == this) return true; - + if(!(obj instanceof StringCharArray)) return false; - + return fString.equals(((StringCharArray)obj).fString); } @@ -67,25 +67,28 @@ public class PatternNameMap { return fString; } } - + private class EmptyIterator implements Iterator{ + @Override public boolean hasNext() { return false; } + @Override public PathSettingsContainer next() { throw new NoSuchElementException(); } + @Override public void remove() { throw new IllegalStateException(); } - + } - + private class ValuesCollection extends AbstractCollection { - + private class Iter implements Iterator { private Iterator> fEntrySetIter; private Entry fCur; @@ -93,15 +96,18 @@ public class PatternNameMap { Iter (Iterator> entryIter){ this.fEntrySetIter = entryIter; } + @Override public boolean hasNext() { return fEntrySetIter.hasNext(); } + @Override public PathSettingsContainer next() { fCur = fEntrySetIter.next(); return fCur.getValue(); } + @Override public void remove() { fEntrySetIter.remove(); String name = fCur.getKey(); @@ -122,12 +128,12 @@ public class PatternNameMap { public int size() { return PatternNameMap.this.size(); } - + @Override public void clear(){ PatternNameMap.this.clear(); } - + @Override public boolean contains(Object o){ return fChildrenMap != null ? fChildrenMap.containsValue(o) : false; @@ -137,15 +143,15 @@ public class PatternNameMap { public /* PathSettingsContainer */ Object get(String name){ return fChildrenMap != null ? fChildrenMap.get(name) : null; } - + public int size(){ return fChildrenMap != null ? fChildrenMap.size() : 0; } - + public boolean isEmpty(){ return fChildrenMap == null || fChildrenMap.isEmpty(); } - + public boolean hasPatterns(){ return fContainsDoubleStar || hasPatternsMap(); } @@ -157,7 +163,7 @@ public class PatternNameMap { public List getValues(String name){ if(fChildrenMap == null) return null; - + PathSettingsContainer val = fChildrenMap.get(name); if(hasPatternsMap()){ List list; @@ -167,10 +173,10 @@ public class PatternNameMap { } else { list = null; } - + Map.Entry entry; StringCharArray strCA; - char[] nameCharArray = name.toCharArray(); + char[] nameCharArray = name.toCharArray(); for(Iterator> iter = fPatternMap.entrySet().iterator(); iter.hasNext();){ entry = iter.next(); strCA = entry.getKey(); @@ -188,19 +194,19 @@ public class PatternNameMap { } return null; } - + public boolean containsDoubleStar(){ return fContainsDoubleStar; } - + public /* PathSettingsContainer */ Object put(String name, /* PathSettingsContainer */Object value){ return put(name, (PathSettingsContainer)value); } - + private PathSettingsContainer put(String name, PathSettingsContainer value){ if(value == null) return (PathSettingsContainer)remove(name); - + PathSettingsContainer oldValue; if(fChildrenMap == null){ fChildrenMap = new HashMap(); @@ -208,22 +214,22 @@ public class PatternNameMap { } else { oldValue = fChildrenMap.get(name); } - + fChildrenMap.put(name, value); - + if(DOUBLE_STAR_PATTERN.equals(name)){ fContainsDoubleStar = true; } else if(isPatternName(name)){ StringCharArray strCA = new StringCharArray(name); if(fPatternMap == null) fPatternMap = new HashMap(); - + fPatternMap.put(strCA, value); } - + return oldValue; } - + public /* PathSettingsContainer */ Object remove(String name){ if(fChildrenMap != null){ PathSettingsContainer oldVal = fChildrenMap.remove(name); @@ -240,7 +246,7 @@ public class PatternNameMap { } return null; } - + private void removePattern(String name){ if (fPatternMap != null){ fPatternMap.remove(new StringCharArray(name)); @@ -248,7 +254,7 @@ public class PatternNameMap { fPatternMap = null; } } - + private static boolean hasSpecChars(String str){ for(int i = 0; i < SPEC_CHARS.length; i++){ if(str.indexOf(SPEC_CHARS[i]) != -1) @@ -261,13 +267,13 @@ public class PatternNameMap { //TODO: check escape chars return hasSpecChars(str); } - + public void clear(){ fChildrenMap = null; fPatternMap = null; fContainsDoubleStar = false; } - + public Collection values(){ if(fValues == null) fValues = new ValuesCollection(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ResourceChangeHandlerBase.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ResourceChangeHandlerBase.java index 569c767d3b5..4fa7a6dff8a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ResourceChangeHandlerBase.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/ResourceChangeHandlerBase.java @@ -50,7 +50,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen void handleProjectClose(IProject project); /** - * Call-back ticked at end of a resource change event + * Call-back ticked at end of a resource change event */ void done(); } @@ -66,7 +66,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen fHandler = handler; // fRootDelta = rootDelta; } - + private IResource getResource(IPath path, IResource baseResource){ switch(baseResource.getType()){ case IResource.FILE: @@ -80,24 +80,25 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen throw new IllegalArgumentException(); } } - + private boolean checkInitHandleResourceMove(IResource fromRc, IResource toRc){ if(fMoveMap.put(fromRc, toRc) == null){ return fHandler.handleResourceMove(fromRc, toRc); } - + return true; } - + + @Override public boolean visit(IResourceDelta delta) throws CoreException { IResource dResource = delta.getResource(); - + if(dResource.getType() == IResource.PROJECT && !shouldVisit((IProject)dResource)) return false; - + boolean resume = true; boolean removed = false; - + switch (delta.getKind()) { case IResourceDelta.REMOVED: removed = true; @@ -126,29 +127,30 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen break; } - + return resume; // visit the children } } - + /* - * I R e s o u r c e C h a n g e L i s t e n e r + * I R e s o u r c e C h a n g e L i s t e n e r */ /* (non-Javadoc) - * + * * Handle the renaming and deletion of project resources * This is necessary in order to update ResourceConfigurations and AdditionalInputs - * + * * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) */ + @Override public void resourceChanged(IResourceChangeEvent event) { if (event.getSource() instanceof IWorkspace) { IResourceMoveHandler handler = createResourceMoveHandler(event); doHandleResourceMove(event, handler); } } - + protected boolean shouldVisit(IProject project){ try { return project.isOpen() ? project.hasNature(CProjectNature.C_NATURE_ID) : true; @@ -165,7 +167,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen protected void doHahdleResourceMove(IResourceChangeEvent event, IResourceMoveHandler handler) { doHandleResourceMove(event, handler); } - + /** * @since 5.1 */ @@ -194,9 +196,9 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen default : break; } - + handler.done(); } - + protected abstract IResourceMoveHandler createResourceMoveHandler(IResourceChangeEvent event); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java index ae07d2800a9..b471cccdd13 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java @@ -58,14 +58,14 @@ public class XmlStorageElement implements ICStorageElement { fElement = element; fParent = parent; fParentRefAlowed = alowReferencingParent; - + if(attributeFilters != null && attributeFilters.length != 0) fAttributeFilters = attributeFilters.clone(); - + if(childFilters != null && childFilters.length != 0) fChildFilters = childFilters.clone(); } - + // public String[] getAttributeFilters(){ // if(fAttributeFilters != null) // return (String[])fAttributeFilters.clone(); @@ -77,7 +77,7 @@ public class XmlStorageElement implements ICStorageElement { // return (String[])fChildFilters.clone(); // return null; // } -// +// // public boolean isParentRefAlowed(){ // return fParentRefAlowed; // } @@ -85,7 +85,7 @@ public class XmlStorageElement implements ICStorageElement { private void createChildren(){ if(fChildrenCreated) return; - + fChildrenCreated = true; NodeList list = fElement.getChildNodes(); int size = list.getLength(); @@ -97,16 +97,16 @@ public class XmlStorageElement implements ICStorageElement { } } } - + private XmlStorageElement createAddChild(Element element, boolean alowReferencingParent, String[] attributeFilters, String[] childFilters){ XmlStorageElement child = createChild(element, alowReferencingParent, attributeFilters, childFilters); fChildList.add(child); - return child; + return child; } - + protected XmlStorageElement createChild(Element element, boolean alowReferencingParent, String[] attributeFilters, @@ -114,6 +114,7 @@ public class XmlStorageElement implements ICStorageElement { return new XmlStorageElement(element, this, alowReferencingParent, attributeFilters, childFilters); } + @Override public ICStorageElement[] getChildren() { return getChildren(XmlStorageElement.class); } @@ -136,16 +137,18 @@ public class XmlStorageElement implements ICStorageElement { return fChildList.toArray(children); } + @Override public ICStorageElement getParent() { return fParentRefAlowed ? fParent : null; } + @Override public String getAttribute(String name) { if(isPropertyAlowed(name) && fElement.hasAttribute(name)) return fElement.getAttribute(name); return null; } - + private boolean isPropertyAlowed(String name){ if(fAttributeFilters != null){ return checkString(name, fAttributeFilters); @@ -173,15 +176,16 @@ public class XmlStorageElement implements ICStorageElement { // protected void childRemoved(ICStorageElement child) { // fChildList.remove(child); // } - + protected void removed(){ // fElement.getParentNode().removeChild(fElement); fElement = null; // if(fParent != null) // ((XmlStorageElement)fParent).childRemoved(this); } - + + @Override public void removeChild(ICStorageElement el) { if(el instanceof XmlStorageElement){ ICStorageElement[] children = getChildren(); @@ -202,19 +206,22 @@ public class XmlStorageElement implements ICStorageElement { } } } - + } + @Override public void removeAttribute(String name) { if(isPropertyAlowed(name)) fElement.removeAttribute(name); } + @Override public void setAttribute(String name, String value) { if(isPropertyAlowed(name)) fElement.setAttribute(name, value); } - + + @Override public void clear(){ createChildren(); @@ -222,14 +229,14 @@ public class XmlStorageElement implements ICStorageElement { for(int i = 0; i < children.length; i++){ removeChild(children[i]); } - + NamedNodeMap map = fElement.getAttributes(); for(int i = 0; i < map.getLength(); i++){ Node attr = map.item(i); if(isPropertyAlowed(attr.getNodeName())) map.removeNamedItem(attr.getNodeName()); } - + NodeList list = fElement.getChildNodes(); for(int i = 0; i < list.getLength(); i++){ Node node = list.item(i); @@ -237,8 +244,8 @@ public class XmlStorageElement implements ICStorageElement { fElement.removeChild(node); } } - - public ICStorageElement createChild(String name, + + public ICStorageElement createChild(String name, boolean alowReferencingParent, String[] attributeFilters, String[] childFilters) { @@ -249,14 +256,17 @@ public class XmlStorageElement implements ICStorageElement { return createAddChild(childElement, alowReferencingParent, attributeFilters, childFilters); } + @Override public String getName() { return fElement.getNodeName(); } + @Override public ICStorageElement createChild(String name) { return createChild(name, true, null, null); } + @Override public String getValue() { Text text = getTextChild(); if(text != null) @@ -264,6 +274,7 @@ public class XmlStorageElement implements ICStorageElement { return null; } + @Override public void setValue(String value) { Text text = getTextChild(); if(value != null){ @@ -279,7 +290,7 @@ public class XmlStorageElement implements ICStorageElement { } } } - + private Text getTextChild(){ NodeList nodes = fElement.getChildNodes(); Text text = null; @@ -293,16 +304,17 @@ public class XmlStorageElement implements ICStorageElement { return text; } - + + @Override public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException { return addChild(el, true, null, null); } - public ICStorageElement addChild(ICStorageElement el, + public ICStorageElement addChild(ICStorageElement el, boolean alowReferencingParent, String[] attributeFilters, String[] childFilters) throws UnsupportedOperationException { - + if(!isChildAlowed(el.getName())) return null; @@ -316,14 +328,14 @@ public class XmlStorageElement implements ICStorageElement { } else { xmlEl = (Element)xmlEl.cloneNode(true); } - + xmlEl = (Element)fElement.appendChild(xmlEl); return createAddChild(xmlEl, alowReferencingParent, attributeFilters, childFilters); } else { throw new UnsupportedOperationException(); } } - + public String[] getAttributeFilters(){ if(fAttributeFilters != null) return fAttributeFilters.clone(); @@ -339,20 +351,20 @@ public class XmlStorageElement implements ICStorageElement { public boolean isParentRefAlowed(){ return fParentRefAlowed; } - + public boolean matches(ICStorageElement el){ if(!getName().equals(el.getName())) return false; - + if (!valuesMatch(getValue(), el.getValue())) return false; - + String[] attrs = getAttributeNames(); String[] otherAttrs = el.getAttributeNames(); if(attrs.length != otherAttrs.length) return false; - + if(attrs.length != 0){ Set set = new HashSet(Arrays.asList(attrs)); set.removeAll(Arrays.asList(otherAttrs)); @@ -365,21 +377,21 @@ public class XmlStorageElement implements ICStorageElement { } } - - + + XmlStorageElement[] children = (XmlStorageElement[])getChildren(); ICStorageElement[] otherChildren = el.getChildren(); - + if(children.length != otherChildren.length) return false; - + if(children.length != 0){ for(int i = 0; i < children.length; i++){ if(!children[i].matches(otherChildren[i])) return false; } } - + return true; } @@ -393,6 +405,7 @@ public class XmlStorageElement implements ICStorageElement { } } + @Override public String[] getAttributeNames() { NamedNodeMap nodeMap = fElement.getAttributes(); int length = nodeMap.getLength(); @@ -409,6 +422,7 @@ public class XmlStorageElement implements ICStorageElement { /** * @since 5.1 */ + @Override public ICStorageElement createCopy() throws UnsupportedOperationException, CoreException { // todo Auto-generated method stub return null; @@ -417,6 +431,7 @@ public class XmlStorageElement implements ICStorageElement { /** * @since 5.1 */ + @Override public boolean equals(ICStorageElement other) { // todo Auto-generated method stub return false; @@ -425,6 +440,7 @@ public class XmlStorageElement implements ICStorageElement { /** * @since 5.1 */ + @Override public ICStorageElement[] getChildrenByName(String name) { // todo Auto-generated method stub return null; @@ -433,6 +449,7 @@ public class XmlStorageElement implements ICStorageElement { /** * @since 5.1 */ + @Override public boolean hasAttribute(String name) { // todo Auto-generated method stub return false; @@ -441,6 +458,7 @@ public class XmlStorageElement implements ICStorageElement { /** * @since 5.1 */ + @Override public boolean hasChildren() { // todo Auto-generated method stub return false; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java index 3068febd2e0..3738e9246db 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java @@ -3,8 +3,8 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: + * + * Contributors: * Anton Leherbauer (Wind River Systems) - initial API and implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) @@ -29,7 +29,7 @@ import org.eclipse.core.runtime.Status; /** * Provides a shared AST of a single translation unit at a time. - * + * * @since 4.0 */ public class ASTCache { @@ -43,7 +43,7 @@ public class ASTCache { public static int PARSE_MODE_FULL = ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS | ITranslationUnit.AST_PARSE_INACTIVE_CODE; - + /** Fast parse mode (use PDOM) */ public static int PARSE_MODE_FAST = ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT @@ -52,28 +52,28 @@ public class ASTCache { /** * Do something with an AST. - * + * * @see #runOnAST(ILanguage, IASTTranslationUnit) */ public static interface ASTRunnable { /** * Do something with the given AST. - * + * * @param lang the language with which the AST has been created. * @param ast the translation unit AST, may be null * @return a status object */ IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException; } - + private final int fParseMode; private final Object fCacheMutex= new Object(); - + /** The active translation unit for which to cache the AST */ private ITranslationUnit fActiveTU; /** The cached AST if any */ private IASTTranslationUnit fAST; - /** + /** * The timestamp of the last index write access at the time * the AST got cached. A cached AST becomes invalid on any index * write access afterwards. @@ -107,11 +107,11 @@ public class ASTCache { IProgressMonitor progressMonitor) { if (tUnit == null) return null; - + while (true) { if (progressMonitor != null && progressMonitor.isCanceled()) return null; - + final boolean isActiveElement; synchronized (fCacheMutex) { isActiveElement= tUnit.equals(fActiveTU); @@ -132,7 +132,7 @@ public class ASTCache { if (!wait) { // no AST, no wait - we are done if (DEBUG) - System.out.println(DEBUG_PREFIX + getThreadName() + "returning null (WAIT_NO) for: " + tUnit.getElementName()); //$NON-NLS-1$ + System.out.println(DEBUG_PREFIX + getThreadName() + "returning null (WAIT_NO) for: " + tUnit.getElementName()); //$NON-NLS-1$ return null; } } @@ -141,12 +141,12 @@ public class ASTCache { try { // Wait for AST if (DEBUG) - System.out.println(DEBUG_PREFIX + getThreadName() + "waiting for AST for: " + tUnit.getElementName()); //$NON-NLS-1$ + System.out.println(DEBUG_PREFIX + getThreadName() + "waiting for AST for: " + tUnit.getElementName()); //$NON-NLS-1$ fCacheMutex.wait(); // Check whether active element is still valid if (fAST != null) { if (DEBUG) - System.out.println(DEBUG_PREFIX + getThreadName() + "...got AST for: " + tUnit.getElementName()); //$NON-NLS-1$ + System.out.println(DEBUG_PREFIX + getThreadName() + "...got AST for: " + tUnit.getElementName()); //$NON-NLS-1$ return fAST; } // try again @@ -158,20 +158,20 @@ public class ASTCache { return null; } } - + if (isActiveElement) aboutToBeReconciled(tUnit); - + if (DEBUG) - System.err.println(DEBUG_PREFIX + getThreadName() + "creating AST for " + tUnit.getElementName()); //$NON-NLS-1$ - + System.err.println(DEBUG_PREFIX + getThreadName() + "creating AST for " + tUnit.getElementName()); //$NON-NLS-1$ + IASTTranslationUnit ast= null; try { ast= createAST(tUnit, index, progressMonitor); if (progressMonitor != null && progressMonitor.isCanceled()) ast= null; else if (DEBUG && ast != null) - System.err.println(DEBUG_PREFIX + getThreadName() + "created AST for: " + tUnit.getElementName()); //$NON-NLS-1$ + System.err.println(DEBUG_PREFIX + getThreadName() + "created AST for: " + tUnit.getElementName()); //$NON-NLS-1$ } finally { if (isActiveElement) { if (fAST != null) { @@ -191,7 +191,7 @@ public class ASTCache { * Executes {@link ASTRunnable#runOnAST(ILanguage, IASTTranslationUnit)} with the AST * provided by this cache for the given translation unit. Handles acquiring * and releasing the index read-lock for the client. - * + * * @param tUnit * the translation unit * @param wait @@ -212,7 +212,7 @@ public class ASTCache { } catch (InterruptedException e) { return Status.CANCEL_STATUS; } - + try { IASTTranslationUnit ast= acquireSharedAST(tUnit, index, wait, monitor); ILanguage lang= (tUnit instanceof TranslationUnit) ? ((TranslationUnit) tUnit).getLanguageOfContext() : tUnit.getLanguage(); @@ -286,12 +286,12 @@ public class ASTCache { assert Thread.holdsLock(fCacheMutex); if (fActiveTU != null && !fActiveTU.equals(tUnit)) { if (DEBUG && tUnit != null) // don't report call from disposeAST() - System.out.println(DEBUG_PREFIX + getThreadName() + "don't cache AST for inactive: " + toString(tUnit)); //$NON-NLS-1$ + System.out.println(DEBUG_PREFIX + getThreadName() + "don't cache AST for inactive: " + toString(tUnit)); //$NON-NLS-1$ return; } if (DEBUG && (tUnit != null || ast != null)) // don't report call from disposeAST() - System.out.println(DEBUG_PREFIX + getThreadName() + "caching AST: " + toString(ast) + " for: " + toString(tUnit)); //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println(DEBUG_PREFIX + getThreadName() + "caching AST: " + toString(ast) + " for: " + toString(tUnit)); //$NON-NLS-1$ //$NON-NLS-2$ if (fAST != null) disposeAST(); @@ -310,10 +310,10 @@ public class ASTCache { synchronized (fCacheMutex) { if (fAST == null) return; - + if (DEBUG) - System.out.println(DEBUG_PREFIX + getThreadName() + "disposing AST: " + toString(fAST) + " for: " + toString(fActiveTU)); //$NON-NLS-1$ //$NON-NLS-2$ - + System.out.println(DEBUG_PREFIX + getThreadName() + "disposing AST: " + toString(fAST) + " for: " + toString(fActiveTU)); //$NON-NLS-1$ //$NON-NLS-2$ + fAST= null; cache(null, null); } @@ -321,7 +321,7 @@ public class ASTCache { /** * Creates a new translation unit AST. - * + * * @param tUnit the translation unit for which to create the AST * @param index the index for AST generation, needs to be read-locked. * @param progressMonitor a progress monitor, may be null @@ -331,9 +331,10 @@ public class ASTCache { if (progressMonitor != null && progressMonitor.isCanceled()) return null; - final IASTTranslationUnit root[]= new IASTTranslationUnit[1]; - + final IASTTranslationUnit root[]= new IASTTranslationUnit[1]; + SafeRunner.run(new ISafeRunnable() { + @Override public void run() throws CoreException { try { if (progressMonitor != null && progressMonitor.isCanceled()) { @@ -345,18 +346,19 @@ public class ASTCache { root[0]= null; } } + @Override public void handleException(Throwable ex) { IStatus status= new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, "Error in CDT Core during AST creation", ex); //$NON-NLS-1$ CCorePlugin.getDefault().getLog().log(status); } }); - + return root[0]; } /** * Set the given translation unit as active element to cache an AST for. - * + * * @param tUnit the translation unit */ public void setActiveElement(ITranslationUnit tUnit) { @@ -369,12 +371,12 @@ public class ASTCache { cache(null, tUnit); } if (DEBUG) - System.out.println(DEBUG_PREFIX + getThreadName() + "active element is: " + toString(tUnit)); //$NON-NLS-1$ + System.out.println(DEBUG_PREFIX + getThreadName() + "active element is: " + toString(tUnit)); //$NON-NLS-1$ } /** * Check whether the given translation unit is the active element of this cache. - * + * * @param tUnit the translation unit * @return true, if this cache manages the given translation unit */ @@ -385,7 +387,7 @@ public class ASTCache { } /** - * Informs that reconciling (computation of the AST) for the given element + * Informs that reconciling (computation of the AST) for the given element * is about to be started. * * @param tUnit the translation unit @@ -393,15 +395,15 @@ public class ASTCache { public void aboutToBeReconciled(ITranslationUnit tUnit) { if (tUnit == null) return; - + synchronized (fCacheMutex) { if (fActiveTU == null || !fActiveTU.equals(tUnit)) { return; } - + if (DEBUG) - System.out.println(DEBUG_PREFIX + getThreadName() + "about to reconcile: " + toString(tUnit)); //$NON-NLS-1$ - + System.out.println(DEBUG_PREFIX + getThreadName() + "about to reconcile: " + toString(tUnit)); //$NON-NLS-1$ + fIsReconciling= true; cache(null, tUnit); } @@ -409,7 +411,7 @@ public class ASTCache { /** * Informs that reconciling of the AST of the given translation unit has finished. - * + * * @param ast the translation unit AST * @param tUnit the translation unit */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Archive.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Archive.java index 925412a4caa..70e4e0be82e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Archive.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Archive.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - + import java.util.Map; import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive; @@ -42,6 +42,7 @@ public class Archive extends Openable implements IArchive { binaryArchive = ar; } + @Override public IBinary[] getBinaries() throws CModelException { ICElement[] e = getChildren(); IBinary[] b = new IBinary[e.length]; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java index 5186b5e36fc..34a6d54e3e8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - + import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; @@ -30,6 +30,7 @@ public class ArchiveContainer extends Openable implements IArchiveContainer { super (cProject, null, CCorePlugin.getResourceString("CoreModel.ArchiveContainer.Archives"), ICElement.C_VCONTAINER); //$NON-NLS-1$ } + @Override public IArchive[] getArchives() throws CModelException { ((ArchiveContainerInfo)getElementInfo()).sync(); ICElement[] e = getChildren(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmLabel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmLabel.java index 332118ce9a9..6a6027bd36a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmLabel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmLabel.java @@ -26,7 +26,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent { /** * Create a new assembly label. - * + * * @param parent the parent element (must be ITranslationUnit) * @param name the name of the label * @param global if true, the label is declared global (visible to the linker) @@ -41,6 +41,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent { /* * @see org.eclipse.cdt.core.model.IAsmLabel#isGlobal() */ + @Override public final boolean isGlobal() { return fIsGlobal; } @@ -55,7 +56,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent { } return false; } - + public static boolean equals(AsmLabel lhs, AsmLabel rhs) { if (CElement.equals(lhs, rhs)) { return lhs.fIndex == rhs.fIndex && lhs.fIsGlobal == rhs.fIsGlobal; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmModelBuilder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmModelBuilder.java index 10e783a7264..a9bf1726d20 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmModelBuilder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/AsmModelBuilder.java @@ -22,14 +22,14 @@ import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.OffsetLimitReachedException; import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog; import org.eclipse.cdt.internal.core.parser.scanner.Lexer; -import org.eclipse.cdt.internal.core.parser.scanner.Token; import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions; +import org.eclipse.cdt.internal.core.parser.scanner.Token; /** * A simple model builder for assembly translation units. * Recognizes preprocessor directives (#include and #define) * and labels. - * + * * @see AssemblyLanguage * @since 5.0 */ @@ -41,8 +41,10 @@ public class AsmModelBuilder implements IContributedModelBuilder { } private static final class LexerLog implements ILexerLog { + @Override public void handleComment(boolean isBlockComment, int offset, int endOffset) { } + @Override public void handleProblem(int problemID, char[] info, int offset, int endOffset) { } } @@ -52,7 +54,7 @@ public class AsmModelBuilder implements IContributedModelBuilder { } private static final Map fgDirectives; - + static { fgDirectives= new HashMap(); fgDirectives.put("globl", AsmDirective.GLOBAL); //$NON-NLS-1$ @@ -63,12 +65,12 @@ public class AsmModelBuilder implements IContributedModelBuilder { fgDirectives.put("long", AsmDirective.DATA); //$NON-NLS-1$ fgDirectives.put("word", AsmDirective.DATA); //$NON-NLS-1$ } - + private TranslationUnit fTranslationUnit; private char fLineSeparatorChar; private Map fGlobals; private Map fLabels; - + private int fLastLabelEndOffset; private AsmLabel fLastGlobalLabel; private SourceManipulation fLastLabel; @@ -76,7 +78,7 @@ public class AsmModelBuilder implements IContributedModelBuilder { /** * Creates a model builder for the given assembly translation unit. - * + * * @param tu the translation unit */ public AsmModelBuilder(ITranslationUnit tu) { @@ -85,7 +87,7 @@ public class AsmModelBuilder implements IContributedModelBuilder { /** * Configure the line separator character (in addition to normal newlines). - * + * * @param lineSeparatorChar */ public void setLineSeparatorCharacter(char lineSeparatorChar) { @@ -95,6 +97,7 @@ public class AsmModelBuilder implements IContributedModelBuilder { /* * @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean) */ + @Override public void parse(boolean quickParseMode) throws Exception { char[] source = fTranslationUnit.getContents(); if (source == null) { @@ -111,7 +114,7 @@ public class AsmModelBuilder implements IContributedModelBuilder { /** * Build the model. - * + * * @param source * @throws CModelException */ @@ -124,7 +127,7 @@ public class AsmModelBuilder implements IContributedModelBuilder { final LexerOptions lexerOptions= new LexerOptions(); fLexer= new Lexer(source, lexerOptions, new LexerLog(), null); - + // if true the next token is the first on a (logical) line boolean firstTokenOnLine= true; // next token can be an instruction or a label @@ -207,7 +210,7 @@ public class AsmModelBuilder implements IContributedModelBuilder { fixupLastGlobalLabel(); } } - + /** * @return the next token from the scanner or null on end-of-input. */ @@ -313,8 +316,8 @@ public class AsmModelBuilder implements IContributedModelBuilder { /** * Set the body position of the last global label. - * - * @throws CModelException + * + * @throws CModelException */ private void fixupLastGlobalLabel() throws CModelException { if (fLastLabel != null && fLastLabel != fLastGlobalLabel) { @@ -327,8 +330,8 @@ public class AsmModelBuilder implements IContributedModelBuilder { /** * Set the body position of the last label. - * - * @throws CModelException + * + * @throws CModelException */ private void fixupLastLabel() throws CModelException { if (fLastLabelEndOffset > 0) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java index 5e13712ffc5..f918f7f0fb3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java @@ -12,7 +12,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - + import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -22,13 +22,13 @@ import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePreferenceConstants; -import org.eclipse.cdt.core.ISourceFinder; -import org.eclipse.cdt.core.ISymbolReader; import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.IBinaryParser.IBinaryShared; import org.eclipse.cdt.core.IBinaryParser.ISymbol; +import org.eclipse.cdt.core.ISourceFinder; +import org.eclipse.cdt.core.ISymbolReader; import org.eclipse.cdt.core.model.BinaryFilePresentation; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; @@ -58,7 +58,7 @@ public class Binary extends Openable implements IBinary { private long longBSS; private String endian; private String soname; - + private long fLastModification; private IBinaryObject binaryObject; @@ -84,22 +84,27 @@ public class Binary extends Openable implements IBinary { showInBinaryContainer= determineShowInBinaryContainer(bin); } + @Override public boolean isSharedLib() { return getType() == IBinaryFile.SHARED; } + @Override public boolean isExecutable() { return getType() == IBinaryFile.EXECUTABLE; } + @Override public boolean isObject() { return getType() == IBinaryFile.OBJECT; } + @Override public boolean isCore() { return getType() == IBinaryFile.CORE; } + @Override public boolean hasDebug() { if (isObject() || isExecutable() || isSharedLib()) { if (hasDebug == null || hasChanged()) { @@ -112,6 +117,7 @@ public class Binary extends Openable implements IBinary { return Boolean.valueOf(hasDebug).booleanValue(); } + @Override public String getCPU() { if (isObject() || isExecutable() || isSharedLib() || isCore()) { if (cpu == null || hasChanged()) { @@ -122,6 +128,7 @@ public class Binary extends Openable implements IBinary { return (cpu == null ? "" : cpu); //$NON-NLS-1$ } + @Override public String[] getNeededSharedLibs() { if (isExecutable() || isSharedLib()) { if (needed == null || hasChanged()) { @@ -134,6 +141,7 @@ public class Binary extends Openable implements IBinary { return (needed == null ? new String[0] : needed); } + @Override public long getText() { if (isObject() || isExecutable() || isSharedLib()) { if (longText == -1 || hasChanged()) { @@ -146,6 +154,7 @@ public class Binary extends Openable implements IBinary { return longText; } + @Override public long getData() { if (isObject() || isExecutable() || isSharedLib()) { if (longData == -1 || hasChanged()) { @@ -158,6 +167,7 @@ public class Binary extends Openable implements IBinary { return longData; } + @Override public long getBSS() { if (isObject() || isExecutable() || isSharedLib()) { if (longBSS == -1 || hasChanged()) { @@ -170,6 +180,7 @@ public class Binary extends Openable implements IBinary { return longBSS; } + @Override public String getSoname() { if (isSharedLib()) { if (soname == null || hasChanged()) { @@ -182,6 +193,7 @@ public class Binary extends Openable implements IBinary { return (soname == null ? "" : soname); //$NON-NLS-1$ } + @Override public boolean isLittleEndian() { if (isObject() || isExecutable() || isSharedLib() || isCore()) { if (endian == null || hasChanged()) { @@ -290,7 +302,7 @@ public class Binary extends Openable implements IBinary { break; } } - } + } ok = true; } } @@ -311,34 +323,34 @@ public class Binary extends Openable implements IBinary { ISourceFinder srcFinder = (ISourceFinder) getAdapter(ISourceFinder.class); try { for (String filename : sourceFiles) { - + // Find the file locally if (srcFinder != null) { String localPath = srcFinder.toLocalPath(filename); if (localPath != null) { - filename = localPath; + filename = localPath; } } - + // Be careful how you use this File object. If filename is a relative path, the resulting File // object will apply the relative path to the working directory, which is not what we want. // Stay away from methods that return or use the absolute path of the object. Note that // File.isAbsolute() returns false when the object was constructed with a relative path. File file = new File(filename); - + // Create a translation unit for this file and add it as a child of the binary String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), file.getName()); if (id == null) { // Don't add files we can't get an ID for. continue; } - + // See if this source file is already in the project. // We check this to determine if we should create a TranslationUnit or ExternalTranslationUnit IFile wkspFile = null; if (file.isAbsolute()) { IFile[] filesInWP = ResourceLookup.findFilesForLocation(new Path(filename)); - + for (IFile element : filesInWP) { if (element.isAccessible()) { wkspFile = element; @@ -346,7 +358,7 @@ public class Binary extends Openable implements IBinary { } } } - + TranslationUnit tu; if (wkspFile != null) tu = new TranslationUnit(this, wkspFile, id); @@ -362,12 +374,12 @@ public class Binary extends Openable implements IBinary { tu = new ExternalTranslationUnit(this, Path.fromOSString(filename), id); } else { - tu = new ExternalTranslationUnit(this, URIUtil.toURI(filename, true), id); + tu = new ExternalTranslationUnit(this, URIUtil.toURI(filename, true), id); } } - + if (! info.includesChild(tu)) - info.addChild(tu); + info.addChild(tu); } return true; } @@ -376,11 +388,11 @@ public class Binary extends Openable implements IBinary { srcFinder.dispose(); } } - + } return false; } - + private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) throws CModelException { IPath filename= symbol.getFilename(); BinaryFunction function = null; @@ -431,7 +443,7 @@ public class Binary extends Openable implements IBinary { variable.setLines(symbol.getStartLine(), symbol.getEndLine()); info.addChild(variable); } - + //if (variable != null) { // if (!external) { // variable.getVariableInfo().setAccessControl(IConstants.AccStatic); @@ -441,7 +453,7 @@ public class Binary extends Openable implements IBinary { /** * @see org.eclipse.cdt.core.model.IOpenable#getBuffer() - * + * * overridden from default as we do not need to create our children to provider a buffer since the buffer just contains * IBinaryOject contents which is not model specific. */ @@ -465,11 +477,11 @@ public class Binary extends Openable implements IBinary { protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException { // create buffer - translation units only use default buffer factory - BufferManager bufManager = getBufferManager(); + BufferManager bufManager = getBufferManager(); IBuffer buffer = getBufferFactory().createBuffer(this); - if (buffer == null) + if (buffer == null) return null; - + // set the buffer source if (buffer.getCharacters() == null){ IBinaryObject bin = getBinaryObject(); @@ -496,13 +508,13 @@ public class Binary extends Openable implements IBinary { // add buffer to buffer cache bufManager.addBuffer(buffer); - + // listen to buffer changes buffer.addBufferChangedListener(this); - + return buffer; } - + /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.model.Openable#hasBuffer() */ @@ -534,6 +546,7 @@ public class Binary extends Openable implements IBinary { super.closing(info); } + @Override public boolean showInBinaryContainer() { return showInBinaryContainer; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainer.java index c6b70e48a1f..f1f548a59a7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainer.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - + import java.util.ArrayList; import java.util.Map; @@ -38,6 +38,7 @@ public class BinaryContainer extends Openable implements IBinaryContainer { } } + @Override public IBinary[] getBinaries() throws CModelException { sync(); ICElement[] e = getChildren(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java index 199919dab4f..7d76c3118e1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java @@ -50,6 +50,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceManipulation#copy(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void copy(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws CModelException { throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); @@ -58,6 +59,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void delete(boolean force, IProgressMonitor monitor) throws CModelException { throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); } @@ -65,6 +67,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceManipulation#move(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void move(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws CModelException { throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); @@ -73,6 +76,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void rename(String name, boolean replace, IProgressMonitor monitor) throws CModelException { throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); } @@ -80,6 +84,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceReference#getSource() */ + @Override public String getSource() throws CModelException { ITranslationUnit tu = getTranslationUnit(); if (tu != null) { @@ -100,11 +105,12 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceReference#getSourceRange() */ + @Override public ISourceRange getSourceRange() throws CModelException { return new SourceRange(getStartPos(), getLength(), getIdStartPos(), - getIdLength(), + getIdLength(), getStartLine(), getEndLine()); } @@ -112,6 +118,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit() */ + @Override public ITranslationUnit getTranslationUnit() { if (fSourceTU == null) { ITranslationUnit tu = null; @@ -171,6 +178,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IBinaryElement#getAddress() */ + @Override public IAddress getAddress() throws CModelException { return addr; } @@ -212,6 +220,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IBinaryElement#getBinary() */ + @Override public IBinary getBinary() { ICElement current = this; do { @@ -245,10 +254,12 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa return 0; } + @Override public boolean isActive() { return true; } + @Override public int getIndex() { return 0; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java index a3ede9dd495..d9d33b98dac 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java @@ -26,6 +26,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getExceptions() */ + @Override public String[] getExceptions() { return new String[0]; } @@ -33,6 +34,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getNumberOfParameters() */ + @Override public int getNumberOfParameters() { // TODO Auto-generated method stub return 0; @@ -41,6 +43,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterInitializer(int) */ + @Override public String getParameterInitializer(int pos) { // TODO Auto-generated method stub return new String(); @@ -49,6 +52,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterTypes() */ + @Override public String[] getParameterTypes() { // TODO Auto-generated method stub return new String[0]; @@ -57,6 +61,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getReturnType() */ + @Override public String getReturnType() { // TODO Auto-generated method stub return new String(); @@ -65,6 +70,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getSignature() */ + @Override public String getSignature() { return getElementName(); } @@ -72,6 +78,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isStatic() */ + @Override public boolean isStatic() { // TODO Auto-generated method stub return false; @@ -80,6 +87,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isConst() */ + @Override public boolean isConst() { // TODO Auto-generated method stub return false; @@ -88,6 +96,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() */ + @Override public boolean isVolatile() { // TODO Auto-generated method stub return false; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java index 6f41a5b97bd..8e6c45b64f0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java @@ -41,6 +41,7 @@ public class BinaryModule extends Parent implements IBinaryModule { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IBinaryModule#getBinaryElements() */ + @Override public IBinaryElement[] getBinaryElements() throws CModelException { ICElement[] e = getChildren(); IBinaryElement[] b = new IBinaryElement[e.length]; @@ -51,13 +52,15 @@ public class BinaryModule extends Parent implements IBinaryModule { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IBinaryElement#getAddress() */ + @Override public IAddress getAddress() throws CModelException { - return null; + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IBinaryElement#getBinary() */ + @Override public IBinary getBinary() { return (IBinary)getParent(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java index cba4fe9450b..cd4d11c62d0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java @@ -80,9 +80,9 @@ public class BinaryRunner { } addDelta(cdelta); } - + } - + private final ICProject cproject; private final Job runnerJob; // final fields don't need synchronization private IOutputEntry[] entries = new IOutputEntry[0]; @@ -182,6 +182,7 @@ public class BinaryRunner { textContentType = mgr.getContentType("org.eclipse.core.runtime.text"); //$NON-NLS-1$ } + @Override public boolean visit(IResourceProxy proxy) throws CoreException { if (vMonitor.isCanceled()) { return false; @@ -189,13 +190,13 @@ public class BinaryRunner { vMonitor.worked(1); // Attempt to speed things up by rejecting up front // Things we know should not be Binary files. - + // check if it's a file resource // and bail out early if (proxy.getType() != IResource.FILE) { return true; } - + // check against known content types String name = proxy.getName(); IContentType contentType = CCorePlugin.getContentType(project, name); @@ -228,7 +229,7 @@ public class BinaryRunner { } return true; } - + private boolean isOnOutputEntry(IOutputEntry entry, IPath path) { if (entry.getPath().isPrefixOf(path) && !CoreModelUtil.isExcluded(path, entry.fullExclusionPatternChars())) { return true; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java index 79216fdd342..278a2b1d632 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java @@ -26,6 +26,7 @@ public class BinaryVariable extends BinaryElement implements IVariable { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IVariable#getInitializer() */ + @Override public String getInitializer() { // TODO Auto-generated method stub return ""; //$NON-NLS-1$ @@ -34,6 +35,7 @@ public class BinaryVariable extends BinaryElement implements IVariable { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName() */ + @Override public String getTypeName() { // TODO Auto-generated method stub return ""; //$NON-NLS-1$ @@ -42,6 +44,7 @@ public class BinaryVariable extends BinaryElement implements IVariable { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String) */ + @Override public void setTypeName(String type) { // TODO Auto-generated method stub } @@ -49,6 +52,7 @@ public class BinaryVariable extends BinaryElement implements IVariable { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isStatic() */ + @Override public boolean isStatic() { // TODO Auto-generated method stub return false; @@ -57,6 +61,7 @@ public class BinaryVariable extends BinaryElement implements IVariable { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isConst() */ + @Override public boolean isConst() { // TODO Auto-generated method stub return false; @@ -65,9 +70,10 @@ public class BinaryVariable extends BinaryElement implements IVariable { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() */ + @Override public boolean isVolatile() { // TODO Auto-generated method stub return false; } - + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java index 23b34a1f1c3..b43b23f9b0e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java @@ -61,6 +61,7 @@ public class Buffer implements IBuffer { /** * @see IBuffer */ + @Override public void addBufferChangedListener(IBufferChangedListener listener) { if (this.changeListeners == null) { this.changeListeners = new ArrayList(5); @@ -72,6 +73,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#append(char[]) */ + @Override public void append(char[] text) { if (!isReadOnly()) { if (text == null || text.length == 0) { @@ -89,6 +91,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String) */ + @Override public void append(String text) { if (text == null) { return; @@ -99,6 +102,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#close() */ + @Override public void close() { BufferChangedEvent event = null; synchronized (this.lock) { @@ -115,6 +119,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#getChar(int) */ + @Override public char getChar(int position) { synchronized (this.lock) { if (position < this.gapStart) { @@ -128,6 +133,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#getCharacters() */ + @Override public char[] getCharacters() { if (this.contents == null) return null; synchronized (this.lock) { @@ -145,6 +151,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#getContents() */ + @Override public String getContents() { if (this.contents == null) return null; return new String(this.getCharacters()); @@ -153,6 +160,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#getLength() */ + @Override public int getLength() { synchronized (this.lock) { int length = this.gapEnd - this.gapStart; @@ -163,6 +171,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#getOwner() */ + @Override public IOpenable getOwner() { return this.owner; } @@ -170,6 +179,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int) */ + @Override public String getText(int offset, int length) { if (this.contents == null) return ""; //$NON-NLS-1$ @@ -190,6 +200,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource() */ + @Override public IResource getUnderlyingResource() { return this.file; } @@ -197,6 +208,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges() */ + @Override public boolean hasUnsavedChanges() { return (this.flags & F_HAS_UNSAVED_CHANGES) != 0; } @@ -204,6 +216,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#isClosed() */ + @Override public boolean isClosed() { return (this.flags & F_IS_CLOSED) != 0; } @@ -211,6 +224,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly() */ + @Override public boolean isReadOnly() { if (this.file == null) { return (this.flags & F_IS_READ_ONLY) != 0; @@ -227,9 +241,11 @@ public class Buffer implements IBuffer { for (int i = 0, size = this.changeListeners.size(); i < size; ++i) { final IBufferChangedListener listener = this.changeListeners.get(i); SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in listener of buffer change notification", ICLogConstants.CDT); //$NON-NLS-1$ } + @Override public void run() throws Exception { listener.bufferChanged(event); } @@ -240,6 +256,7 @@ public class Buffer implements IBuffer { /** * @see IBuffer */ + @Override public void removeBufferChangedListener(IBufferChangedListener listener) { if (this.changeListeners != null) { this.changeListeners.remove(listener); @@ -251,6 +268,7 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[]) */ + @Override public void replace(int position, int length, char[] text) { if (!isReadOnly()) { int textLength = text == null ? 0 : text.length; @@ -277,13 +295,14 @@ public class Buffer implements IBuffer { if (textLength > 0) { string = new String(text); } - notifyChanged(new BufferChangedEvent(this, position, length, string)); + notifyChanged(new BufferChangedEvent(this, position, length, string)); } } /** * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String) */ + @Override public void replace(int position, int length, String text) { this.replace(position, length, text == null ? null : text.toCharArray()); } @@ -291,16 +310,17 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean) */ + @Override public void save(IProgressMonitor progress, boolean force) throws CModelException { - // determine if saving is required + // determine if saving is required if (isReadOnly() || this.file == null) { return; } synchronized (this.lock) { if (!hasUnsavedChanges()) return; - + // use a platform operation to update the resource contents try { String encoding = null; @@ -312,19 +332,19 @@ public class Buffer implements IBuffer { } String contents = this.getContents(); if (contents == null) return; - byte[] bytes = encoding == null - ? contents.getBytes() + byte[] bytes = encoding == null + ? contents.getBytes() : contents.getBytes(encoding); ByteArrayInputStream stream = new ByteArrayInputStream(bytes); if (this.file.exists()) { this.file.setContents( - stream, - force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, + stream, + force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, null); } else { this.file.create(stream, force, null); - } + } } catch (IOException e) { throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION); } @@ -340,15 +360,16 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[]) */ + @Override public void setContents(char[] newContents) { - // allow special case for first initialization + // allow special case for first initialization // after creation by buffer factory if (this.contents == null) { this.contents = newContents; this.flags &= ~ (F_HAS_UNSAVED_CHANGES); return; } - + if (!isReadOnly()) { String string = null; if (newContents != null) { @@ -368,13 +389,14 @@ public class Buffer implements IBuffer { /** * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String) */ + @Override public void setContents(String newContents) { this.setContents(newContents.toCharArray()); } - + /** * Moves the gap to location and adjust its size to the - * anticipated change size. The size represents the expected + * anticipated change size. The size represents the expected * range of the gap that will be filled after the gap has been moved. * Thus the gap is resized to actual size + the specified size and * moved to the given position. @@ -414,7 +436,7 @@ public class Buffer implements IBuffer { this.gapStart = newGapStart; this.gapEnd = newGapEnd; } - + /** * Sets this Buffer to be read only. */ @@ -425,7 +447,7 @@ public class Buffer implements IBuffer { this.flags &= ~(F_IS_READ_ONLY); } } - + @Override public String toString() { StringBuffer buffer = new StringBuffer(); @@ -442,7 +464,7 @@ public class Buffer implements IBuffer { for (int i = 0; i < length; i++) { char car = contents[i]; switch (car) { - case '\n': + case '\n': buffer.append("\\n\n"); //$NON-NLS-1$ break; case '\r': diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BufferManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BufferManager.java index 370c5c755ed..2a2c26ef5f8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BufferManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BufferManager.java @@ -22,7 +22,7 @@ import org.eclipse.core.resources.IResource; /** * The buffer manager manages the set of open buffers. * It implements an LRU cache of buffers. - * + * * This class is similar to the JDT BufferManager class */ @@ -92,17 +92,18 @@ public class BufferManager implements IBufferFactory { /** * @see org.eclipse.cdt.internal.core.model.IBufferFactory#createBuffer(org.eclipse.cdt.core.model.IOpenable) */ + @Override public IBuffer createBuffer(IOpenable owner) { ICElement element = (ICElement)owner; IResource resource = element.getResource(); - return + return new Buffer( - resource instanceof IFile ? (IFile)resource : null, - owner, + resource instanceof IFile ? (IFile)resource : null, + owner, element.isReadOnly()); } - + /** * Returns the open buffer associated with the given owner, * or null if the owner does not have an open @@ -128,7 +129,7 @@ public class BufferManager implements IBufferFactory { } /** * Returns an enumeration of all open buffers. - *

+ *

* The Enumeration answered is thread safe. * * @see OverflowingLRUCache @@ -140,8 +141,8 @@ public class BufferManager implements IBufferFactory { return openBuffers.elements(); } } - - + + /** * Removes a buffer from the table of open buffers. */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java index 93354258423..dfcb3193f4c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java @@ -50,9 +50,10 @@ public class CContainer extends Openable implements ICContainer { /** * Returns a the collection of binary files in this ccontainer - * + * * @see ICContainer#getBinaries() */ + @Override public IBinary[] getBinaries() throws CModelException { List list = getChildrenOfType(C_BINARY); IBinary[] array = new IBinary[list.size()]; @@ -63,6 +64,7 @@ public class CContainer extends Openable implements ICContainer { /** * @see ICContainer#getBinary(String) */ + @Override public IBinary getBinary(String name) { IFile file = getContainer().getFile(new Path(name)); return getBinary(file); @@ -78,9 +80,10 @@ public class CContainer extends Openable implements ICContainer { /** * Returns a the collection of archive files in this ccontainer - * + * * @see ICContainer#getArchives() */ + @Override public IArchive[] getArchives() throws CModelException { List list = getChildrenOfType(C_ARCHIVE); IArchive[] array = new IArchive[list.size()]; @@ -91,6 +94,7 @@ public class CContainer extends Openable implements ICContainer { /** * @see ICContainer#getArchive(String) */ + @Override public IArchive getArchive(String name) { IFile file = getContainer().getFile(new Path(name)); return getArchive(file); @@ -107,6 +111,7 @@ public class CContainer extends Openable implements ICContainer { /** * @see ICContainer#getTranslationUnits() */ + @Override public ITranslationUnit[] getTranslationUnits() throws CModelException { List list = getChildrenOfType(C_UNIT); ITranslationUnit[] array = new ITranslationUnit[list.size()]; @@ -116,9 +121,10 @@ public class CContainer extends Openable implements ICContainer { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.model.ICContainer#getTranslationUnit(java.lang.String) */ + @Override public ITranslationUnit getTranslationUnit(String name) { IFile file = getContainer().getFile(new Path(name)); return getTranslationUnit(file); @@ -131,9 +137,10 @@ public class CContainer extends Openable implements ICContainer { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.model.ICContainer#getCContainers() */ + @Override public ICContainer[] getCContainers() throws CModelException { List list = getChildrenOfType(C_CCONTAINER); ICContainer[] array = new ICContainer[list.size()]; @@ -143,9 +150,10 @@ public class CContainer extends Openable implements ICContainer { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.model.ICContainer#getCContainer(java.lang.String) */ + @Override public ICContainer getCContainer(String name) { IFolder folder = getContainer().getFolder(new Path(name)); return getCContainer(folder); @@ -195,9 +203,10 @@ public class CContainer extends Openable implements ICContainer { /* * (non-Javadoc) Returns an array of non-c resources contained in the * receiver. - * + * * @see org.eclipse.cdt.core.model.ICContainer#getNonCResources() */ + @Override public Object[] getNonCResources() throws CModelException { return ((CContainerInfo) getElementInfo()).getNonCResources(getResource()); } @@ -273,7 +282,7 @@ public class CContainer extends Openable implements ICContainer { } return celement; } - + @Override public ICElement getHandleFromMemento(String token, MementoTokenizer memento) { switch (token.charAt(0)) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java index 2624bc16bfc..7a1f3f31d24 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java @@ -41,7 +41,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.PlatformObject; public abstract class CElement extends PlatformObject implements ICElement { - + public static final char CEM_ESCAPE = '\\'; public static final char CEM_CPROJECT = '='; public static final char CEM_SOURCEROOT = '/'; @@ -53,7 +53,7 @@ public abstract class CElement extends PlatformObject implements ICElement { protected static final CElement[] NO_ELEMENTS = new CElement[0]; protected int fType; - + protected ICElement fParent; protected String fName; @@ -63,7 +63,7 @@ public abstract class CElement extends PlatformObject implements ICElement { fName= name; fType= type; } - + /* (non-Javadoc) * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) */ @@ -79,8 +79,8 @@ public abstract class CElement extends PlatformObject implements ICElement { } return super.getAdapter(adapter); } - - + + // setters public void setElementType (int type) { @@ -90,44 +90,50 @@ public abstract class CElement extends PlatformObject implements ICElement { public void setElementName(String name) { fName = name; } - + public void setParent (ICElement parent) { fParent = parent; } - + // getters - + + @Override public int getElementType() { return fType; - } + } + @Override public String getElementName() { return fName; } - + + @Override public ICElement getParent() { return fParent; } + @Override public IPath getPath() { IResource res = getUnderlyingResource(); if (res != null) return res.getFullPath(); return new Path(getElementName()); } - + + @Override public URI getLocationURI() { IResource res = getUnderlyingResource(); - + if(res != null) { return res.getLocationURI(); } - + else { return null; } } + @Override public boolean exists() { try { return getElementInfo() != null; @@ -201,7 +207,8 @@ public abstract class CElement extends PlatformObject implements ICElement { } return new ICElement[]{this}; } - + + @Override public boolean isReadOnly () { IResource r = getUnderlyingResource(); if (r != null) { @@ -209,14 +216,16 @@ public abstract class CElement extends PlatformObject implements ICElement { if (attributes != null) { return attributes.isReadOnly(); } - } + } return false; } + @Override public boolean isStructureKnown() throws CModelException { return getElementInfo().isStructureKnown(); } + @Override public ICModel getCModel () { ICElement current = this; do { @@ -225,6 +234,7 @@ public abstract class CElement extends PlatformObject implements ICElement { return null; } + @Override public ICProject getCProject() { ICElement current = this; do { @@ -236,6 +246,7 @@ public abstract class CElement extends PlatformObject implements ICElement { protected void addChild(ICElement e) throws CModelException { } + @Override public IResource getUnderlyingResource() { IResource res = getResource(); if (res == null) { @@ -247,6 +258,7 @@ public abstract class CElement extends PlatformObject implements ICElement { return res; } + @Override public abstract IResource getResource() ; protected abstract CElementInfo createElementInfo(); @@ -263,7 +275,7 @@ public abstract class CElement extends PlatformObject implements ICElement { } return false; } - + public static boolean equals(ICElement lhs, ICElement rhs) { if (lhs == rhs) { return true; @@ -277,19 +289,19 @@ public abstract class CElement extends PlatformObject implements ICElement { !lhsName.equals(rhsName)) { return false; } - + if (lhs instanceof ISourceReference && rhs instanceof ISourceReference) { if (((ISourceReference) lhs).getIndex() != ((ISourceReference) rhs).getIndex()) { return false; } } - + ICElement lhsParent= lhs.getParent(); ICElement rhsParent= rhs.getParent(); if (lhsParent == rhsParent) { return true; } - + return lhsParent != null && lhsParent.equals(rhsParent); } @@ -370,7 +382,7 @@ public abstract class CElement extends PlatformObject implements ICElement { return "UNKNOWN"; //$NON-NLS-1$ } } - + /** * Close the C Element * @throws CModelException @@ -398,7 +410,7 @@ public abstract class CElement extends PlatformObject implements ICElement { *

Subclasses that are not IOpenable's must override this method. */ public IOpenable getOpenableParent() { - if (fParent instanceof IOpenable) { + if (fParent instanceof IOpenable) { return (IOpenable)fParent; } return null; @@ -455,6 +467,7 @@ public abstract class CElement extends PlatformObject implements ICElement { /** * @see ICElement */ + @Override public ICElement getAncestor(int ancestorType) { ICElement element = this; while (element != null) { @@ -477,14 +490,14 @@ public abstract class CElement extends PlatformObject implements ICElement { } return parent != null; } - + /** * Creates and returns and not present exception for this element. */ protected CModelException newNotPresentException() { return new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this)); } - + /** * Returns the hash code for this Java element. By default, * the hash code for an element is a combination of its name @@ -497,7 +510,7 @@ public abstract class CElement extends PlatformObject implements ICElement { public int hashCode() { return hashCode(this); } - + public static int hashCode(ICElement elem) { ICElement parent= elem.getParent(); if (parent == null) { @@ -505,7 +518,7 @@ public abstract class CElement extends PlatformObject implements ICElement { } return Util.combineHashCodes(elem.getElementName().hashCode(), parent.hashCode()); } - + /* * Test to see if two objects are identical * Subclasses should override accordingly @@ -513,10 +526,11 @@ public abstract class CElement extends PlatformObject implements ICElement { public boolean isIdentical(CElement otherElement){ return this.equals(otherElement); } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElement#accept(org.eclipse.cdt.core.model.ICElementVisitor) */ + @Override public void accept(ICElementVisitor visitor) throws CoreException { // Visit me, return right away if the visitor doesn't want to visit my children if (!visitor.visit(this)) @@ -533,13 +547,14 @@ public abstract class CElement extends PlatformObject implements ICElement { /* * @see org.eclipse.cdt.core.model.ICElement#getHandleIdentifier() */ + @Override public String getHandleIdentifier() { return getHandleMemento(); } /** * Builds a string representation of this element. - * + * * @return the string representation */ public String getHandleMemento(){ @@ -550,7 +565,7 @@ public abstract class CElement extends PlatformObject implements ICElement { /** * Append this elements memento string to the given buffer. - * + * * @param buff the buffer building the memento string */ public void getHandleMemento(StringBuilder buff) { @@ -567,7 +582,7 @@ public abstract class CElement extends PlatformObject implements ICElement { /** * Creates a C element handle from the given memento. - * + * * @param memento the memento tokenizer */ public ICElement getHandleFromMemento(MementoTokenizer memento) { @@ -579,7 +594,7 @@ public abstract class CElement extends PlatformObject implements ICElement { /** * Creates a C element handle from the given memento. * The given token is the current delimiter indicating the type of the next token(s). - * + * * @param token the curren memento token * @param memento the memento tokenizer */ @@ -587,7 +602,7 @@ public abstract class CElement extends PlatformObject implements ICElement { /** * Escape special characters in the given name and append the result to buffer. - * + * * @param buffer the buffer to build the memento string * @param mementoName the name to escape */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java index abc9162b7f5..7106893b5c5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDelta.java @@ -103,12 +103,12 @@ public class CElementDelta implements ICElementDelta { fChangeFlags |= F_CHILDREN; } - // if a child delta is added to a translation unit delta or below, + // if a child delta is added to a translation unit delta or below, // it's a fine grained delta if (!(fChangedElement.getElementType() >= ICElement.C_UNIT)) { fineGrained(); } - + if (fAffectedChildren.length == 0) { fAffectedChildren = new ICElementDelta[] {child}; return; @@ -189,7 +189,7 @@ public class CElementDelta implements ICElementDelta { return; } break; - default: + default: // unknown -> existing child becomes the child with the existing child's flags int flags = existingChild.getFlags(); fAffectedChildren[existingChildIndex] = child; @@ -201,7 +201,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from an add operation. * Convenience method for creating add deltas. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then an add operation should call this method. */ public void added(ICElement element) { @@ -242,7 +242,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from a change operation. * Convenience method for creating change deltas. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then a change operation should call this method. */ public void changed(ICElement element, int changeFlag) { @@ -329,6 +329,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public ICElementDelta[] getAddedChildren() { return getChildrenOfType(ADDED); } @@ -336,6 +337,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public ICElementDelta[] getAffectedChildren() { return fAffectedChildren; } @@ -366,6 +368,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public ICElementDelta[] getChangedChildren() { return getChildrenOfType(CHANGED); } @@ -415,6 +418,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public ICElement getElement() { return fChangedElement; } @@ -422,6 +426,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public int getFlags() { return fChangeFlags; } @@ -429,6 +434,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public int getKind() { return fKind; } @@ -436,6 +442,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public ICElement getMovedFromElement() { return fMovedFromHandle; } @@ -443,6 +450,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public ICElement getMovedToElement() { return fMovedToHandle; } @@ -450,6 +458,7 @@ public class CElementDelta implements ICElementDelta { /** * @see ICElementDelta */ + @Override public ICElementDelta[] getRemovedChildren() { return getChildrenOfType(REMOVED); } @@ -457,6 +466,7 @@ public class CElementDelta implements ICElementDelta { /** * Return the collection of resource deltas. Return null if none. */ + @Override public IResourceDelta[] getResourceDeltas() { if (resourceDeltas == null) return null; @@ -493,7 +503,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from an move operation. * Convenience method for creating the "move from" delta. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then the move operation should call this method. */ public void movedFrom(ICElement movedFromElement, ICElement movedToElement) { @@ -507,7 +517,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from an move operation. * Convenience method for creating the "move to" delta. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then the move operation should call this method. */ public void movedTo(ICElement movedToElement, ICElement movedFromElement) { @@ -563,7 +573,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from an delete operation. * Convenience method for creating removed deltas. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then the delete operation should call this method. */ public void removed(ICElement element) { @@ -580,7 +590,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from a change operation. * Convenience method for creating change deltas. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then a change operation should call this method. */ public void binaryParserChanged(ICElement element) { @@ -593,7 +603,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from a change operation. * Convenience method for creating change deltas. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then a change operation should call this method. */ public void sourceAttached(ICElement element) { @@ -606,7 +616,7 @@ public class CElementDelta implements ICElementDelta { /** * Creates the nested deltas resulting from a change operation. * Convenience method for creating change deltas. - * The constructor should be used to create the root delta + * The constructor should be used to create the root delta * and then a change operation should call this method. */ public void sourceDetached(ICElement element) { @@ -616,7 +626,7 @@ public class CElementDelta implements ICElementDelta { insertDeltaTree(element, detachedDelta); } - /** + /** * Returns a string representation of this delta's * structure suitable for debug purposes. * @@ -761,7 +771,7 @@ public class CElementDelta implements ICElementDelta { return buffer.toString(); } - /** + /** * Returns a string representation of this delta's * structure suitable for debug purposes. */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java index 1ea7dceea65..9460c2b47b2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java @@ -10,7 +10,7 @@ * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - + import java.util.List; import java.util.Map; @@ -48,6 +48,7 @@ public class CModel extends Openable implements ICModel { return super.equals(o); } + @Override public ICProject[] getCProjects() throws CModelException { List list = getChildrenOfType(C_PROJECT); ICProject[] array= new ICProject[list.size()]; @@ -58,9 +59,10 @@ public class CModel extends Openable implements ICModel { /** * ICModel#getCProject(String) */ + @Override public ICProject getCProject(String name) { - IProject project = ((IWorkspaceRoot) getResource()).getProject(name); - return CModelManager.getDefault().create(project); + IProject project = ((IWorkspaceRoot) getResource()).getProject(name); + return CModelManager.getDefault().create(project); } /** @@ -101,11 +103,13 @@ public class CModel extends Openable implements ICModel { } return null; } - + + @Override public IWorkspace getWorkspace() { return getUnderlyingResource().getWorkspace(); } + @Override public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT ) { @@ -117,6 +121,7 @@ public class CModel extends Openable implements ICModel { } } + @Override public void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) throws CModelException { CModelOperation op; @@ -128,6 +133,7 @@ public class CModel extends Openable implements ICModel { op.runOperation(monitor); } + @Override public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { @@ -139,6 +145,7 @@ public class CModel extends Openable implements ICModel { } } + @Override public void rename(ICElement[] elements, ICElement[] destinations, String[] renamings, boolean force, IProgressMonitor monitor) throws CModelException { CModelOperation op; @@ -210,6 +217,7 @@ public class CModel extends Openable implements ICModel { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICModel#getNonCResources() */ + @Override public Object[] getNonCResources() throws CModelException { return ((CModelInfo) getElementInfo()).getNonCResources(); } @@ -241,12 +249,12 @@ public class CModel extends Openable implements ICModel { } return null; } - + @Override public void getHandleMemento(StringBuilder buff) { buff.append(getElementName()); } - + @Override protected char getHandleMementoDelimiter() { Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java index b5a07055e55..8b3966eb81b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java @@ -104,7 +104,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { /** * Create a model builder for the given translation unit. - * + * * @param tu the translation unit (must be a {@link TranslationUnit} * @param newElements element cache * @param monitor the progress monitor @@ -118,10 +118,11 @@ public class CModelBuilder2 implements IContributedModelBuilder { /* * @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean) */ + @Override public void parse(boolean quickParseMode) throws Exception { final IIndexManager indexManager= CCorePlugin.getIndexManager(); IIndex index= indexManager.getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES); - + try { if (index != null) { try { @@ -229,6 +230,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { // sort by offset final List children= getElementInfo(fTranslationUnit).internalGetChildren(); Collections.sort(children, new Comparator() { + @Override public int compare(ICElement o1, ICElement o2) { final SourceManipulationInfo info1= getSourceManipulationInfo((SourceManipulation) o1); final SourceManipulationInfo info2= getSourceManipulationInfo((SourceManipulation) o2); @@ -589,7 +591,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { final Enumeration element= new Enumeration (parent, enumName); setIndex(element); element.setActive(enumSpecifier.isActive()); - + // add to parent parent.addChild(element); EnumerationInfo info= (EnumerationInfo) getElementInfo(element); @@ -600,7 +602,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { final IASTFileLocation enumLocation= enumSpecifier.getFileLocation(); info.setIdPos(enumLocation.getNodeOffset(), type.length()); } - // add enumerators + // add enumerators final IASTEnumerator[] enumerators= enumSpecifier.getEnumerators(); for (final IASTEnumerator enumerator : enumerators) { createEnumerator(element, enumerator); @@ -967,7 +969,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { element.setParameterTypes(parameterTypes); element.setReturnType(returnType); setIndex(element); - + info= (FunctionInfo) getElementInfo(element); info.setConst(cppFunctionDeclarator.isConst()); } @@ -978,7 +980,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { element.setParameterTypes(parameterTypes); element.setReturnType(returnType); setIndex(element); - + info= (FunctionInfo) getElementInfo(element); } element.setActive(functionDeclaration.isActive()); @@ -1053,7 +1055,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { element.setParameterTypes(parameterTypes); element.setReturnType(returnType); setIndex(element); - + info= (FunctionInfo)getElementInfo(element); info.setConst(cppFunctionDeclarator.isConst()); } @@ -1073,7 +1075,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { return null; } element.setActive(declarator.isActive()); - + // TODO [cmodel] correctly resolve isStatic info.setStatic(declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static); @@ -1281,7 +1283,7 @@ public class CModelBuilder2 implements IContributedModelBuilder { /** * Determine the scope for given name. - * + * * @param astName * @return the scope or null */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java index 4dd7d8d4c96..6cb6cd4ac45 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java @@ -230,7 +230,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } if (res != null && !res.exists()) { res = null; - } + } } // In case this is an external resource see if we can find @@ -343,7 +343,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang break; } } - + // check for binary on output entry if (celement == null && cproject.isOnOutputEntry(file)) { IBinaryFile bin = createBinaryFile(file); @@ -371,12 +371,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (cproject.isOnOutputEntry(file)) { IPath resourcePath = file.getParent().getFullPath(); ICElement cfolder = cproject.findElement(resourcePath); - + // Check if folder is a source root and use that instead ISourceRoot sourceRoot = cproject.findSourceRoot(resourcePath); if (sourceRoot != null) cfolder = sourceRoot; - + if (bin.getType() == IBinaryFile.ARCHIVE) { ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer(); celement = new Archive(cfolder, file, (IBinaryArchive)bin); @@ -405,7 +405,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (!Util.isNonZeroLengthFile(path)) { return null; } - + try { IIncludeReference[] includeReferences = cproject.getIncludeReferences(); for (IIncludeReference includeReference : includeReferences) { @@ -414,7 +414,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (headerContentTypeId == null) { headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; } - + // TODO: use URI return new ExternalTranslationUnit(includeReference, URIUtil.toURI(path), headerContentTypeId); } @@ -439,7 +439,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (headerContentTypeId == null) { headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; } - + // TODO: use URI return new ExternalTranslationUnit(includeReference, URIUtil.toURI(includePath), headerContentTypeId); } @@ -449,10 +449,10 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } return null; } - + /** * Creates a translation unit in the given project for the given location. - * + * * @param cproject * @param locationURI * @return ITranslationUnit @@ -465,9 +465,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if(!locationURI.isAbsolute()) { throw new IllegalArgumentException(); } - + final IProject project= cproject.getProject(); - + IFileStore fileStore = null; try { fileStore = EFS.getStore(locationURI); @@ -475,12 +475,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang CCorePlugin.log(e1); return null; } - + final String contentTypeId = CoreModel.getRegistedContentTypeId(project, fileStore.getName()); if (!Util.isNonZeroLengthFile(locationURI)) { return null; } - + try { IIncludeReference[] includeReferences = cproject.getIncludeReferences(); for (IIncludeReference includeReference : includeReferences) { @@ -492,7 +492,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (headerContentTypeId == null) { headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; } - + return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId); } } @@ -502,11 +502,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang // if the file exists and it has a known C/C++ file extension then just create // an external translation unit for it. IFileInfo info = fileStore.fetchInfo(); - + if (contentTypeId != null && info != null && info.exists()) { return new ExternalTranslationUnit(cproject, locationURI, contentTypeId); } - + return null; } @@ -632,7 +632,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang if (parsers.length == 0) { return null; } - + // Only if file has no extension, has an extension that is an integer // or is a binary file content type String ext = file.getFileExtension(); @@ -650,7 +650,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang baseFileName = baseFileName.removeFileExtension(); ext = baseFileName.getFileExtension(); } while (ext != null && ext.length() > 0); - + boolean isBinary= false; final IContentTypeManager ctm = Platform.getContentTypeManager(); final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE); @@ -662,7 +662,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang return null; } } - + URI fileUri = file.getLocationURI(); //Avoid name special devices, empty files and the like if (!Util.isNonZeroLengthFile(fileUri)) { @@ -677,9 +677,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } //return null; } - + int hints = 0; - + for (BinaryParserConfig parser2 : parsers) { IBinaryParser parser = null; try { @@ -850,10 +850,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang * on the platform, and that the C Model should update any required * internal structures such that its elements remain consistent. * Translates IResourceDeltas into ICElementDeltas. - * + * * @see IResourceDelta * @see IResource */ + @Override public void resourceChanged(IResourceChangeEvent event) { if (event.getSource() instanceof IWorkspace) { IResourceDelta delta = event.getDelta(); @@ -861,7 +862,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang switch (event.getType()) { case IResourceChangeEvent.PRE_DELETE: try { - if (resource.getType() == IResource.PROJECT && + if (resource.getType() == IResource.PROJECT && ( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) || ((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){ this.preDeleteProject((IProject) resource);} @@ -871,7 +872,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang case IResourceChangeEvent.PRE_CLOSE: try { - if (resource.getType() == IResource.PROJECT && + if (resource.getType() == IResource.PROJECT && ( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) || ((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){ this.preCloseProject((IProject) resource);} @@ -899,6 +900,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } } + @Override public void handleEvent(CProjectDescriptionEvent event) { switch(event.getEventType()) { case CProjectDescriptionEvent.APPLIED: @@ -961,6 +963,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang /* (non-Javadoc) * @see org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeListener#contentTypeChanged() */ + @Override public void contentTypeChanged(ContentTypeChangeEvent event) { ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event }); } @@ -975,12 +978,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang public void fireShift(ICElement element, int offset, int size, int lines) { ICElementDelta delta = new CShiftData(element, offset, size, lines); - fire(delta, ElementChangedEvent.POST_SHIFT); + fire(delta, ElementChangedEvent.POST_SHIFT); } - + /** - * Fire C Model deltas, flushing them after the fact. - * If the firing mode has been turned off, this has no effect. + * Fire C Model deltas, flushing them after the fact. + * If the firing mode has been turned off, this has no effect. */ @SuppressWarnings("deprecation") void fire(ICElementDelta customDeltas, int eventType) { @@ -1077,7 +1080,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang notifyListeners(deltaToNotify, ElementChangedEvent.POST_SHIFT, listeners, listenerMask, listenerCount); } } - + public void notifyListeners(ICElementDelta deltaToNotify, int eventType, IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) { @@ -1093,10 +1096,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang // wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { //CCorePlugin.log(exception, "Exception occurred in listener of C element change notification"); //$NON-NLS-1$ CCorePlugin.log(exception); } + @Override public void run() throws Exception { listener.elementChanged(extraEvent); } @@ -1192,7 +1197,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang /* * Puts the infos in the given map (keys are ICElements and values are CElementInfos) * in the C model cache in an atomic way. - * First checks that the info for the opened element (or one of its ancestors) has not been + * First checks that the info for the opened element (or one of its ancestors) has not been * added to the cache. If it is the case, another thread has opened the element (or one of * its ancestors). So returns without updating the cache. */ @@ -1306,10 +1311,10 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang movedTo= delta.getMovedToPath(); } LocalProjectScope.deletePreferences(res.getFullPath(), movedTo); - } + } } } - + private void preDeleteProject(IProject project) { // remove binary parsers binaryParsersMap.remove(project); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java index cfa141c61f3..6c3efc54a06 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java @@ -198,6 +198,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /** * @see IProgressMonitor */ + @Override public void beginTask(String name, int totalWork) { if (fMonitor != null) { fMonitor.beginTask(name, totalWork); @@ -320,6 +321,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /** * @see IProgressMonitor */ + @Override public void done() { if (fMonitor != null) { fMonitor.done(); @@ -436,7 +438,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo } /** - * Returns the scheduling rule for this operation (i.e. the resource that needs to be locked + * Returns the scheduling rule for this operation (i.e. the resource that needs to be locked * while this operation is running. * Subclasses can override. */ @@ -477,6 +479,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo return !this.isReadOnly() && this.hasModifiedResource; } + @Override public void internalWorked(double work) { if (fMonitor != null) { fMonitor.internalWorked(work); @@ -486,6 +489,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /** * @see IProgressMonitor */ + @Override public boolean isCanceled() { if (fMonitor != null) { return fMonitor.isCanceled(); @@ -543,7 +547,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /* * Returns the stack of operations running in the current thread. - * Returns an empty stack if no operations are currently running in this thread. + * Returns an empty stack if no operations are currently running in this thread. */ protected ArrayList getCurrentOperationStack() { ArrayList stack = operationStacks.get(); @@ -562,7 +566,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo ArrayList stack = getCurrentOperationStack(); int size = stack.size(); if (size > 0) { - if (size == 1) { // top level operation + if (size == 1) { // top level operation operationStacks.set(null); // release reference (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927) } return stack.remove(size-1); @@ -593,6 +597,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo * @see IWorkspaceRunnable * @exception CoreException if the operation fails */ + @Override public void run(IProgressMonitor monitor) throws CoreException { CModelManager manager= CModelManager.getDefault(); int previousDeltaCount = manager.fCModelDeltas.size(); @@ -649,6 +654,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /** * @see IProgressMonitor */ + @Override public void setCanceled(boolean b) { if (fMonitor != null) { fMonitor.setCanceled(b); @@ -666,6 +672,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /** * @see IProgressMonitor */ + @Override public void setTaskName(String name) { if (fMonitor != null) { fMonitor.setTaskName(name); @@ -675,6 +682,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /** * @see IProgressMonitor */ + @Override public void subTask(String name) { if (fMonitor != null) { fMonitor.subTask(name); @@ -698,6 +706,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo /** * @see IProgressMonitor */ + @Override public void worked(int work) { if (fMonitor != null) { fMonitor.worked(work); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelStatus.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelStatus.java index 620ad312f00..51f37a0a2fb 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelStatus.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelStatus.java @@ -157,6 +157,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus /** * @see ICModelStatus */ + @Override public ICElement[] getElements() { return fElements; } @@ -289,6 +290,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus return exception.toString(); } + @Override public IPath getPath() { if (fPath == null) { return Path.EMPTY; @@ -316,6 +318,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus /** * @see ICModelStatus */ + @Override public String getString() { if (fString == null) { return EMPTY_STRING; @@ -333,6 +336,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus /** * @see ICModelStatus */ + @Override public boolean doesNotExist() { return getCode() == ELEMENT_DOES_NOT_EXIST; } @@ -381,7 +385,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus /** * Creates and returns a new ICModelStatus that is a a * multi-status status. - * + * * @see IStatus#isMultiStatus() */ public static ICModelStatus newMultiStatus(ICModelStatus[] children) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java index 758a83019a8..2fc62218e2b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java @@ -72,18 +72,22 @@ public class CProject extends Openable implements ICProject { super(parent, project, ICElement.C_PROJECT); } + @Override public IBinaryContainer getBinaryContainer() throws CModelException { return ((CProjectInfo) getElementInfo()).getBinaryContainer(); } + @Override public IArchiveContainer getArchiveContainer() throws CModelException { return ((CProjectInfo) getElementInfo()).getArchiveContainer(); } + @Override public IProject getProject() { return getUnderlyingResource().getProject(); } + @Override public ICElement findElement(IPath path) throws CModelException { ICElement celem = null; if (path.isAbsolute()) { @@ -134,13 +138,13 @@ public class CProject extends Openable implements ICProject { */ @Override public boolean equals(Object o) { - + if (this == o) return true; - + if (!(o instanceof CProject)) return false; - + CProject other = (CProject) o; return getProject().equals(other.getProject()); } @@ -156,6 +160,7 @@ public class CProject extends Openable implements ICProject { return getProject().hashCode(); } + @Override public IIncludeReference[] getIncludeReferences() throws CModelException { CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); IIncludeReference[] incRefs = null; @@ -179,6 +184,7 @@ public class CProject extends Openable implements ICProject { return incRefs; } + @Override public ILibraryReference[] getLibraryReferences() throws CModelException { CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); ILibraryReference[] libRefs = null; @@ -240,6 +246,7 @@ public class CProject extends Openable implements ICProject { /** * @see ICProject#getRequiredProjectNames() */ + @Override public String[] getRequiredProjectNames() throws CModelException { return projectPrerequisites(getResolvedPathEntries()); } @@ -252,6 +259,7 @@ public class CProject extends Openable implements ICProject { /** * @see org.eclipse.cdt.core.model.ICProject#getOption(String, boolean) */ + @Override public String getOption(String optionName, boolean inheritCCoreOptions) { if (CModelManager.OptionNames.contains(optionName)) { IEclipsePreferences preferences = getPreferences(); @@ -269,6 +277,7 @@ public class CProject extends Openable implements ICProject { /** * @see org.eclipse.cdt.core.model.ICProject#getOptions(boolean) */ + @Override public Map getOptions(boolean inheritCCoreOptions) { // initialize to the defaults from CCorePlugin options pool Map options= inheritCCoreOptions ? CCorePlugin.getOptions() : new HashMap(5); @@ -296,6 +305,7 @@ public class CProject extends Openable implements ICProject { /** * @see org.eclipse.cdt.core.model.ICProject#setOption(java.lang.String, java.lang.String) */ + @Override public void setOption(String optionName, String optionValue) { if (!CModelManager.OptionNames.contains(optionName)) return; // unrecognized option @@ -307,7 +317,7 @@ public class CProject extends Openable implements ICProject { } else { projectPreferences.put(optionName, optionValue); } - + // Dump changes try { projectPreferences.flush(); @@ -319,6 +329,7 @@ public class CProject extends Openable implements ICProject { /** * @see org.eclipse.cdt.core.model.ICProject#setOptions(Map) */ + @Override public void setOptions(Map newOptions) { Preferences preferences = new Preferences(); setPreferences(preferences); // always reset (26255) @@ -397,6 +408,7 @@ public class CProject extends Openable implements ICProject { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#getResolvedCPathEntries() */ + @Override public IPathEntry[] getResolvedPathEntries() throws CModelException { return CoreModel.getResolvedPathEntries(this); } @@ -404,6 +416,7 @@ public class CProject extends Openable implements ICProject { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#getRawCPathEntries() */ + @Override public IPathEntry[] getRawPathEntries() throws CModelException { return CoreModel.getRawPathEntries(this); } @@ -411,6 +424,7 @@ public class CProject extends Openable implements ICProject { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#setRawCPathEntries(org.eclipse.cdt.core.model.IPathEntry[], org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void setRawPathEntries(IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException { CoreModel.setRawPathEntries(this, newEntries, monitor); } @@ -418,6 +432,7 @@ public class CProject extends Openable implements ICProject { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#getSourceRoot(org.eclipse.cdt.core.model.ISourceEntry) */ + @Override public ISourceRoot getSourceRoot(ISourceEntry entry) throws CModelException { return getSourceRoot(new CSourceEntry(entry.getPath(), entry.getExclusionPatterns(), 0)); } @@ -444,6 +459,7 @@ public class CProject extends Openable implements ICProject { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#findSourceRoot() */ + @Override public ISourceRoot findSourceRoot(IResource res) { try { ISourceRoot[] roots = getAllSourceRoots(); @@ -460,6 +476,7 @@ public class CProject extends Openable implements ICProject { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#findSourceRoot() */ + @Override public ISourceRoot findSourceRoot(IPath path) { try { ISourceRoot[] roots = getAllSourceRoots(); @@ -472,10 +489,11 @@ public class CProject extends Openable implements ICProject { } return null; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#getSourceRoots() */ + @Override public ISourceRoot[] getSourceRoots() throws CModelException { Object[] children = getChildren(); ArrayList result = new ArrayList(children.length); @@ -489,10 +507,11 @@ public class CProject extends Openable implements ICProject { /** * Get all source roots. - * + * * @return all source roots * @throws CModelException */ + @Override public ISourceRoot[] getAllSourceRoots() throws CModelException { CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); ISourceRoot[] roots = null; @@ -510,6 +529,7 @@ public class CProject extends Openable implements ICProject { return roots; } + @Override public IOutputEntry[] getOutputEntries() throws CModelException { CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this); IOutputEntry[] outs = null; @@ -528,7 +548,7 @@ public class CProject extends Openable implements ICProject { } /** - * + * */ public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException { ArrayList list = new ArrayList(entries.length); @@ -543,11 +563,12 @@ public class CProject extends Openable implements ICProject { } /** - * + * */ + @Override public boolean isOnOutputEntry(IResource resource) { IPath path = resource.getFullPath(); - + // ensure that folders are only excluded if all of their children are excluded if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.PROJECT) { path = path.append("*"); //$NON-NLS-1$ @@ -606,7 +627,7 @@ public class CProject extends Openable implements ICProject { if(cfg != null) entries = cfg.getResolvedSourceEntries(); } - + if(entries != null){ ArrayList list = new ArrayList(entries.length); for (ICSourceEntry sourceEntry : entries) { @@ -624,14 +645,14 @@ public class CProject extends Openable implements ICProject { List sourceRoots = computeSourceRoots(); List children = new ArrayList(sourceRoots.size()); children.addAll(sourceRoots); - + boolean projectIsSourceRoot = false; for (ISourceRoot sourceRoot : sourceRoots) if (sourceRoot.getResource().equals(getProject())) { projectIsSourceRoot = true; break; } - + // Now look for output folders try { IResource[] resources = getProject().members(); @@ -644,7 +665,7 @@ public class CProject extends Openable implements ICProject { break; } } - + // Not in source folder, check if it's a container on output entry // Also make sure I'm not a source root since my SourceRoot object would // have already added this. @@ -655,7 +676,7 @@ public class CProject extends Openable implements ICProject { } catch (CoreException e) { // ignore } - + info.setChildren(children); if (info instanceof CProjectInfo) { CProjectInfo pinfo = (CProjectInfo)info; @@ -664,10 +685,11 @@ public class CProject extends Openable implements ICProject { } return true; } - + /* * @see ICProject */ + @Override public boolean isOnSourceRoot(ICElement element) { try { ISourceRoot[] roots = getSourceRoots(); @@ -685,6 +707,7 @@ public class CProject extends Openable implements ICProject { /* * @see ICProject */ + @Override public boolean isOnSourceRoot(IResource resource) { try { ISourceRoot[] roots = getSourceRoots(); @@ -713,6 +736,7 @@ public class CProject extends Openable implements ICProject { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICProject#getNonCResources() */ + @Override public Object[] getNonCResources() throws CModelException { return ((CProjectInfo) getElementInfo()).getNonCResources(getResource()); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CShiftData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CShiftData.java index 36169004ec2..31987214fbf 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CShiftData.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CShiftData.java @@ -17,7 +17,7 @@ import org.eclipse.core.resources.IResourceDelta; /** * In this case, no delta for specific element passed * Instead we'll notify Outline about offsets change. - * + * * @author Oleg Krasilnikov */ public class CShiftData implements ICElementDelta { @@ -26,7 +26,7 @@ public class CShiftData implements ICElementDelta { private final int offset; private final int size; private final int lines; - + public CShiftData(ICElement element, int offset, int size, int lines) { this.element = element; this.offset = offset; @@ -37,18 +37,19 @@ public class CShiftData implements ICElementDelta { public int getOffset() { return offset; } - + public int getSize() { return size; } - + public int getLines() { return lines; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getAddedChildren() */ + @Override public ICElementDelta[] getAddedChildren() { return new ICElementDelta[0]; } @@ -56,6 +57,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getAffectedChildren() */ + @Override public ICElementDelta[] getAffectedChildren() { return new ICElementDelta[0]; } @@ -63,6 +65,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getChangedChildren() */ + @Override public ICElementDelta[] getChangedChildren() { return new ICElementDelta[0]; } @@ -70,6 +73,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getElement() */ + @Override public ICElement getElement() { return element; } @@ -77,6 +81,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getFlags() */ + @Override public int getFlags() { return 0; } @@ -84,6 +89,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getKind() */ + @Override public int getKind() { return 0; } @@ -91,6 +97,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getMovedFromElement() */ + @Override public ICElement getMovedFromElement() { return null; } @@ -98,6 +105,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getMovedToElement() */ + @Override public ICElement getMovedToElement() { return null; } @@ -105,6 +113,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getRemovedChildren() */ + @Override public ICElementDelta[] getRemovedChildren() { return new ICElementDelta[0]; } @@ -112,6 +121,7 @@ public class CShiftData implements ICElementDelta { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElementDelta#getResourceDeltas() */ + @Override public IResourceDelta[] getResourceDeltas() { return null; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java index 3f6e49de5ff..64fa28dda13 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DefaultPathEntryStore.java @@ -72,9 +72,9 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe List listeners; IProject fProject; - + /** - * + * */ public DefaultPathEntryStore(IProject project) { fProject = project; @@ -84,6 +84,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(this); } + @Override public IPathEntry[] getRawPathEntries() throws CoreException { ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, false); if (cdesc != null) { @@ -91,17 +92,18 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe ICStorageElement entry = cdesc.getProjectStorageElement(PATH_ENTRY_ID); for (ICStorageElement childNode : entry.getChildrenByName(PATH_ENTRY)) pathEntries.add(decodePathEntry(fProject, childNode)); - IPathEntry[] entries = new IPathEntry[pathEntries.size()]; + IPathEntry[] entries = new IPathEntry[pathEntries.size()]; pathEntries.toArray(entries); return entries; } return NO_PATHENTRIES; } + @Override public void setRawPathEntries(IPathEntry[] newRawEntries) throws CoreException { if (Arrays.equals(newRawEntries, getRawPathEntries())) { return; - } + } ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(fProject, true); ICStorageElement rootElement = descriptor.getProjectStorageElement(PATH_ENTRY_ID); // Clear out all current children @@ -116,11 +118,11 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe static IPathEntry decodePathEntry(IProject project, ICStorageElement element) throws CModelException { IPath projectPath = project.getFullPath(); - + // kind String kindAttr = element.getAttribute(ATTRIBUTE_KIND); int kind = PathEntry.kindFromString(kindAttr); - + // exported flag boolean isExported = false; if (element.hasAttribute(ATTRIBUTE_EXPORTED)) { @@ -157,13 +159,13 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe } } } - + // recreate the entry switch (kind) { case IPathEntry.CDT_PROJECT : return CoreModel.newProjectEntry(path, isExported); case IPathEntry.CDT_LIBRARY : { - IPath libraryPath = new Path(element.getAttribute(ATTRIBUTE_LIBRARY)); + IPath libraryPath = new Path(element.getAttribute(ATTRIBUTE_LIBRARY)); // source attachment info (optional) IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path( element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null; @@ -171,7 +173,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe element.getAttribute(ATTRIBUTE_ROOTPATH)) : null; IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path( element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null; - + if (!baseRef.isEmpty()) { return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath); } @@ -207,7 +209,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe case IPathEntry.CDT_INCLUDE_FILE: { // include path info IPath includeFilePath = new Path(element.getAttribute(ATTRIBUTE_INCLUDE_FILE)); - return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, isExported); + return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, isExported); } case IPathEntry.CDT_MACRO : { String macroName = element.getAttribute(ATTRIBUTE_NAME); @@ -276,7 +278,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe element.setAttribute(ATTRIBUTE_LIBRARY, libraryPath.toString()); IPath sourcePath = lib.getSourceAttachmentPath(); if (sourcePath != null) { - // translate to project relative from absolute + // translate to project relative from absolute if (projectPath != null && projectPath.isPrefixOf(sourcePath)) { if (sourcePath.segment(0).equals(projectPath.segment(0))) { sourcePath = sourcePath.removeFirstSegments(1); @@ -356,9 +358,10 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent) */ + @Override public void descriptorChanged(CDescriptorEvent event) { if (event.getType() == CDescriptorEvent.CDTPROJECT_CHANGED /*|| event.getType() == CDescriptorEvent.CDTPROJECT_ADDED*/) { @@ -373,13 +376,15 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) */ - public void addPathEntryStoreListener(IPathEntryStoreListener listener) { + @Override + public void addPathEntryStoreListener(IPathEntryStoreListener listener) { listeners.add(listener); } /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) */ + @Override public void removePathEntryStoreListener(IPathEntryStoreListener listener) { listeners.remove(listener); } @@ -396,6 +401,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject) */ + @Override public void close() { PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED); IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()]; @@ -406,14 +412,17 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(this); } + @Override public IProject getProject() { return fProject; } + @Override public ICExtensionReference getExtensionReference() { return null; } + @Override public ICConfigExtensionReference getConfigExtensionReference() { return null; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumeration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumeration.java index f7f21071909..d2e74975683 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumeration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumeration.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.model.IEnumeration; public class Enumeration extends SourceManipulation implements IEnumeration{ public Enumeration(ICElement parent, String name) { - super(parent, name, ICElement.C_ENUMERATION); + super(parent, name, ICElement.C_ENUMERATION); } @Override @@ -34,6 +34,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{ /** * @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName() */ + @Override public String getTypeName() throws CModelException { return getEnumerationInfo().getTypeName(); } @@ -48,6 +49,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{ /** * @see org.eclipse.cdt.core.model.IDeclaration#isConst() */ + @Override public boolean isConst() throws CModelException { return getEnumerationInfo().isConst(); } @@ -55,6 +57,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{ /** * @see org.eclipse.cdt.core.model.IDeclaration#isStatic() */ + @Override public boolean isStatic() throws CModelException { return getEnumerationInfo().isStatic(); } @@ -62,6 +65,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{ /** * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() */ + @Override public boolean isVolatile() throws CModelException { return getEnumerationInfo().isVolatile(); } @@ -88,6 +92,6 @@ public class Enumeration extends SourceManipulation implements IEnumeration{ */ public void setVolatile(boolean isVolatile) throws CModelException { getEnumerationInfo().setVolatile(isVolatile); - } + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumerator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumerator.java index 7ad4be5bf8c..ed42a229fac 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumerator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumerator.java @@ -16,19 +16,20 @@ import org.eclipse.cdt.core.model.IEnumerator; public class Enumerator extends SourceManipulation implements IEnumerator{ String constantExpression = ""; //$NON-NLS-1$ - + public Enumerator(ICElement parent, String name) { super(parent, name, ICElement.C_ENUMERATOR); } - + @Override protected CElementInfo createElementInfo () { return new SourceManipulationInfo(this); } - + /** * @see org.eclipse.cdt.core.model.IEnumerator#getConstantExpression() */ + @Override public String getConstantExpression() { return constantExpression; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java index 25b1d69a051..8778c7a431e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java @@ -17,11 +17,12 @@ import org.eclipse.cdt.core.model.IField; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; public class Field extends VariableDeclaration implements IField { - + public Field(ICElement parent, String name) { super(parent, name, ICElement.C_FIELD); } + @Override public boolean isMutable() throws CModelException{ return getFieldInfo().isMutable(); } @@ -70,6 +71,7 @@ public class Field extends VariableDeclaration implements IField { getFieldInfo().setStatic(isStatic); } + @Override public ASTAccessVisibility getVisibility() throws CModelException { return getFieldInfo().getVisibility(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java index 3f6f6984621..6cfd7499b20 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.model.IFunctionDeclaration; public class FunctionDeclaration extends SourceManipulation implements IFunctionDeclaration { protected String[] fParameterTypes; protected String returnType; - + public FunctionDeclaration(ICElement parent, String name) { super(parent, name, ICElement.C_FUNCTION_DECLARATION); fParameterTypes= fgEmptyStrings; @@ -31,6 +31,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction fParameterTypes= fgEmptyStrings; } + @Override public String getReturnType(){ if (returnType != null) { return returnType; @@ -42,22 +43,25 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction returnType = type; } + @Override public int getNumberOfParameters() { return fParameterTypes == null ? 0 : fParameterTypes.length; } + @Override public String[] getParameterTypes() { return fParameterTypes; } - + public void setParameterTypes(String[] parameterTypes) { fParameterTypes = parameterTypes; - } - + } + + @Override public String getSignature() throws CModelException{ return getSignature(this); } - + public static String getSignature(IFunctionDeclaration func) { StringBuffer sig = new StringBuffer(func.getElementName()); sig.append(getParameterClause(func.getParameterTypes())); @@ -68,17 +72,17 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction sig.append(" volatile"); //$NON-NLS-1$ } } catch (CModelException e) { - } + } return sig.toString(); } - + public String getParameterClause() { return getParameterClause(getParameterTypes()); } - + public static String getParameterClause(String[] paramTypes){ StringBuffer sig = new StringBuffer(); - + if(paramTypes.length > 0){ sig.append("("); //$NON-NLS-1$ int i = 0; @@ -92,13 +96,15 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction else{ sig.append("()"); //$NON-NLS-1$ } - return sig.toString(); + return sig.toString(); } - + + @Override public String getParameterInitializer(int pos) { return ""; //$NON-NLS-1$ } - + + @Override public String[] getExceptions(){ return new String[] {}; } @@ -107,11 +113,11 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction protected CElementInfo createElementInfo () { return new FunctionInfo(this); } - + protected FunctionInfo getFunctionInfo() throws CModelException{ return (FunctionInfo) getElementInfo(); } - + @Override public boolean equals(Object other) { if (other instanceof IFunctionDeclaration) { @@ -119,17 +125,18 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction } return false; } - + public static boolean equals(IFunctionDeclaration lhs, IFunctionDeclaration rhs) { - return CElement.equals(lhs, rhs) && + return CElement.equals(lhs, rhs) && Util.equalArraysOrNull(lhs.getParameterTypes(), rhs.getParameterTypes()) && lhs.getReturnType().equals(rhs.getReturnType()); } - + /** - * FunctionDeclarations and Functions can not be constant + * FunctionDeclarations and Functions can not be constant * @see org.eclipse.cdt.core.model.IDeclaration#isConst() */ + @Override public boolean isConst() throws CModelException{ return getFunctionInfo().isConst(); } @@ -142,6 +149,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction * Returns the isStatic. * @return boolean */ + @Override public boolean isStatic() throws CModelException { return getFunctionInfo().isStatic(); } @@ -150,6 +158,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction * Returns the isVolatile. * @return boolean */ + @Override public boolean isVolatile() throws CModelException { return getFunctionInfo().isVolatile(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplate.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplate.java index 7767d79bb40..116af256f8b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplate.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplate.java @@ -16,23 +16,25 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IFunctionTemplate; public class FunctionTemplate extends Function implements IFunctionTemplate { - + protected Template fTemplate; - + public FunctionTemplate(ICElement parent, String name) { super(parent, name, ICElement.C_TEMPLATE_FUNCTION); fTemplate = new Template(name); } - + /** * Returns the parameterTypes. * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @return String[] */ + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } @@ -47,6 +49,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate { /** * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() */ + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } @@ -55,13 +58,14 @@ public class FunctionTemplate extends Function implements IFunctionTemplate { * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() */ /* - * The signature in the outline view will be: - * The class X followed by its template parameters, - * then the scope resolution, then the function name, - * followed by its template parameters, folowed by its - * normal parameter list, then a colon then the function's + * The signature in the outline view will be: + * The class X followed by its template parameters, + * then the scope resolution, then the function name, + * followed by its template parameters, folowed by its + * normal parameter list, then a colon then the function's * return type. - */ + */ + @Override public String getTemplateSignature() throws CModelException { StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); sig.append(this.getParameterClause()); @@ -71,7 +75,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate { if (isVolatile()) { sig.append(" volatile"); //$NON-NLS-1$ } - if ((this.getReturnType() != null) && (this.getReturnType().length() > 0)) { + if ((this.getReturnType() != null) && (this.getReturnType().length() > 0)) { sig.append(" : "); //$NON-NLS-1$ sig.append(this.getReturnType()); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplateDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplateDeclaration.java index 4f6c18ba4a3..ebcdf95a416 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionTemplateDeclaration.java @@ -24,14 +24,17 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements fTemplate = new Template(name); } + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } + @Override public String getTemplateSignature() throws CModelException { StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); sig.append(this.getParameterClause()); @@ -40,14 +43,15 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements if(isVolatile()) sig.append(" volatile"); //$NON-NLS-1$ - if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ + if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ sig.append(" : "); //$NON-NLS-1$ sig.append(this.getReturnType()); } - + return sig.toString(); } + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Include.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Include.java index 595814c1068..78bac12264d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Include.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Include.java @@ -16,7 +16,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IInclude; public class Include extends SourceManipulation implements IInclude { - + private String fullPath; private final boolean standard; private boolean fIsResolved= true; @@ -26,10 +26,12 @@ public class Include extends SourceManipulation implements IInclude { standard = isStandard; } + @Override public String getIncludeName() { return getElementName(); } + @Override public boolean isStandard() { return standard; } @@ -37,6 +39,7 @@ public class Include extends SourceManipulation implements IInclude { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IInclude#getFullFileName() */ + @Override public String getFullFileName() { return fullPath; } @@ -44,6 +47,7 @@ public class Include extends SourceManipulation implements IInclude { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IInclude#isLocal() */ + @Override public boolean isLocal() { return !isStandard(); } @@ -63,6 +67,7 @@ public class Include extends SourceManipulation implements IInclude { /* * @see org.eclipse.cdt.core.model.IInclude#isResolved() */ + @Override public boolean isResolved() { return fIsResolved; } @@ -77,13 +82,13 @@ public class Include extends SourceManipulation implements IInclude { } return false; } - + public static boolean equals(IInclude lhs, IInclude rhs) { return CElement.equals(lhs, rhs) - && lhs.isActive() == rhs.isActive() + && lhs.isActive() == rhs.isActive() && lhs.isResolved() == rhs.isResolved() && lhs.isLocal() == rhs.isLocal() - && (lhs.getFullFileName() == rhs.getFullFileName() + && (lhs.getFullFileName() == rhs.getFullFileName() || lhs.getFullFileName() != null && lhs.getFullFileName().equals(rhs.getFullFileName())); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java index 9088cafda72..b0868045283 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java @@ -33,18 +33,20 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry { /** * Returns the include path - * + * * @return IPath */ + @Override public IPath getIncludePath() { return includePath; } /** * Whether or not it a system include path - * + * * @return boolean */ + @Override public boolean isSystemInclude() { return isSystemInclude; } @@ -95,6 +97,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath() */ + @Override public IPath getFullIncludePath() { final IPath inc = getIncludePath(); if (!basePath.isEmpty()) { @@ -110,7 +113,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry { } return loc.append(inc); } - + if (!inc.isAbsolute()) { IPath resPath = getPath(); IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc)); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java index ae0ad3748af..cbac4944b5f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java @@ -33,9 +33,10 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry { /** * Returns the include path - * + * * @return IPath */ + @Override public IPath getIncludeFilePath() { return includeFilePath; } @@ -83,6 +84,7 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath() */ + @Override public IPath getFullIncludeFilePath() { final IPath inc = getIncludeFilePath(); if (!basePath.isEmpty()) { @@ -98,7 +100,7 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry { } return loc.append(inc); } - + if (!inc.isAbsolute()) { IPath resPath = getPath(); IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc)); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java index 881f595c761..41dcef85022 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java @@ -41,7 +41,7 @@ import org.eclipse.core.runtime.Path; * IncludeReference */ public class IncludeReference extends Openable implements IIncludeReference { - + final IIncludeEntry fIncludeEntry; final IPath fPath; @@ -76,7 +76,7 @@ public class IncludeReference extends Openable implements IIncludeReference { } return file != null && file.isDirectory(); } - + /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo() */ @@ -88,6 +88,7 @@ public class IncludeReference extends Openable implements IIncludeReference { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IIncludeReference#getIncludeEntry() */ + @Override public IIncludeEntry getIncludeEntry() { return fIncludeEntry; } @@ -103,6 +104,7 @@ public class IncludeReference extends Openable implements IIncludeReference { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IIncludeReference#getAffectedPath() */ + @Override public IPath getAffectedPath() { return fIncludeEntry.getPath(); } @@ -124,7 +126,7 @@ public class IncludeReference extends Openable implements IIncludeReference { String[] names = null; if (file != null && file.isDirectory()) { names = file.list(); - + if (names != null) { IPath path = new Path(file.getAbsolutePath()); for (String name : names) { @@ -175,8 +177,9 @@ public class IncludeReference extends Openable implements IIncludeReference { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IIncludeReference#isOnIncludeEntry(org.eclipse.core.runtime.IPath) */ + @Override public boolean isOnIncludeEntry(IPath path) { - if (fIncludeEntry.getFullIncludePath().isPrefixOf(path) + if (fIncludeEntry.getFullIncludePath().isPrefixOf(path) && !CoreModelUtil.isExcluded(path, fIncludeEntry.fullExclusionPatternChars())) { return true; } @@ -190,7 +193,7 @@ public class IncludeReference extends Openable implements IIncludeReference { public IPath getPath() { return fPath; } - + @Override public ICElement getHandleFromMemento(String token, MementoTokenizer memento) { return null; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java index d2091a5f7ea..2cfe0932635 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LanguageDescriptor.java @@ -31,19 +31,22 @@ public class LanguageDescriptor extends CExtensionDescriptor implements private String fContentTypeIds[]; private String fId; private IContentType[] fContentTypes; - + public LanguageDescriptor(IConfigurationElement el) { super(el); } + @Override public ILanguage getLanguage() { if(fLanguage == null){ SafeRunner.run(new ISafeRunnable(){ + @Override public void handleException(Throwable exception) { CCorePlugin.log(exception); } + @Override public void run() throws Exception { fLanguage = (ILanguage)getConfigurationElement().createExecutableExtension(ATTRIBUTE_CLASS); } @@ -52,13 +55,14 @@ public class LanguageDescriptor extends CExtensionDescriptor implements return fLanguage; } + @Override public String[] getContentTypeIds() { if(fContentTypeIds == null){ fContentTypeIds = calculateCintentTypeIds(); } return fContentTypeIds; } - + private String[] calculateCintentTypeIds(){ IConfigurationElement el = getConfigurationElement(); IConfigurationElement children[] = el.getChildren(); @@ -80,10 +84,10 @@ public class LanguageDescriptor extends CExtensionDescriptor implements ids = t; } } - + return ids; } - + @Override public String getId(){ if(fId == null) @@ -91,26 +95,27 @@ public class LanguageDescriptor extends CExtensionDescriptor implements return fId; } + @Override public IContentType[] getContentTypes() { if(fContentTypes == null){ fContentTypes = calculateContentTypes(getContentTypeIds()); } return fContentTypes; } - + private IContentType[] calculateContentTypes(String ids[]){ IContentType cTypes[] = new IContentType[ids.length]; if(ids.length > 0){ int num = 0; - IContentTypeManager manager = Platform.getContentTypeManager(); - + IContentTypeManager manager = Platform.getContentTypeManager(); + for (int k = 0; k < ids.length; ++k) { IContentType langContType = manager.getContentType(ids[k]); if(langContType != null) cTypes[num++] = langContType; } - + if(num < ids.length){ IContentType tmp[] = new IContentType[num]; System.arraycopy(cTypes, 0, tmp, 0, num); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java index 42a51f27d10..b156448dad1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java @@ -25,7 +25,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { IPath sourceAttachmentPrefixMapping; /** - * + * * @param basePath * @param baseRef * @param libraryPath @@ -58,6 +58,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { * * @return the path to the source archive or folder, or null if none */ + @Override public IPath getSourceAttachmentPath() { return sourceAttachmentPath; } @@ -72,10 +73,11 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { * @return the path within the source archive or folder, or null if * not applicable */ + @Override public IPath getSourceAttachmentRootPath() { return sourceAttachmentRootPath; } - + /** * Returns the path to map the source paths with to the source achive or folder * An empty path indicates that the is a one-to-one mapping of source paths to the @@ -86,6 +88,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { * @return the path mapping within the source archive or folder, or null if * not applicable */ + @Override public IPath getSourceAttachmentPrefixMapping() { return sourceAttachmentPrefixMapping; } @@ -143,6 +146,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { return super.equals(obj); } + @Override public IPath getFullLibraryPath() { IPath p; IPath lib = getLibraryPath(); @@ -178,6 +182,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILibraryEntry#getLibraryPath() */ + @Override public IPath getLibraryPath() { return libraryPath; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReference.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReference.java index 159683f31e7..680093f7bd7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReference.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReference.java @@ -62,6 +62,7 @@ public class LibraryReference extends Parent implements ILibraryReference { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry() */ + @Override public ILibraryEntry getLibraryEntry() { return entry; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceArchive.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceArchive.java index 48ac4a07d6e..b1c637ffd76 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceArchive.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceArchive.java @@ -39,7 +39,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc return null; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ICElement#getPath() @@ -64,6 +64,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry() */ + @Override public ILibraryEntry getLibraryEntry() { return entry; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceShared.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceShared.java index 0a6c7582712..6f4e78aab24 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceShared.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryReferenceShared.java @@ -9,7 +9,7 @@ * QNX Software Systems - Initial API and implementation * Created on Apr 2, 2003 * - * To change this generated comment go to + * To change this generated comment go to * Window>Preferences>Java>Code Generation>Code Template * / *******************************************************************************/ @@ -79,6 +79,7 @@ public class LibraryReferenceShared extends Binary implements ILibraryReference /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry() */ + @Override public ILibraryEntry getLibraryEntry() { return entry; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java index 49c4aed6107..2d300d750e0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java @@ -15,9 +15,9 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IMacro; public class Macro extends SourceManipulation implements IMacro { - + private boolean fFunctionStyle = false; - + public void setFunctionStyle(boolean isFunctionStyle) { this.fFunctionStyle = isFunctionStyle; } @@ -26,10 +26,12 @@ public class Macro extends SourceManipulation implements IMacro { super(parent, name, ICElement.C_MACRO); } + @Override public String getIdentifierList() { return ""; //$NON-NLS-1$ } + @Override public String getTokenSequence() { return ""; //$NON-NLS-1$ } @@ -39,6 +41,7 @@ public class Macro extends SourceManipulation implements IMacro { return new SourceManipulationInfo(this); } + @Override public boolean isFunctionStyle() { return fFunctionStyle; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java index 0ea521a1376..d35450fb39d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java @@ -32,6 +32,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry { * Returns the macro name. * @return String */ + @Override public String getMacroName() { return macroName; } @@ -40,6 +41,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry { * Returns the macro value. * @return String */ + @Override public String getMacroValue() { return macroValue; } @@ -84,7 +86,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry { } return super.equals(obj); } - + /* (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java index 7d4091ed197..faef460f5cd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java @@ -32,9 +32,10 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry { /** * Returns the macro file path - * + * * @return IPath */ + @Override public IPath getMacroFilePath() { return macroFilePath; } @@ -81,6 +82,7 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath() */ + @Override public IPath getFullMacroFilePath() { IPath p; IPath inc = getMacroFilePath(); @@ -95,7 +97,7 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry { p = loc.append(inc); return p; } - + p = inc; if (!p.isAbsolute()) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java index 920f2e42463..75df25f7350 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.model.IMethodDeclaration; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{ - + boolean isConst = false; boolean isConstructor = false; boolean isDestructor = false; @@ -31,11 +31,13 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec public MethodDeclaration(ICElement parent, String name, int type){ super(parent, name, type); } - + + @Override public boolean isConstructor(){ return isConstructor; } + @Override public boolean isDestructor() { return isDestructor; } @@ -48,10 +50,12 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec this.isDestructor = isDestructor; } + @Override public boolean isOperator(){ return getElementName().startsWith("operator"); //$NON-NLS-1$ } + @Override public boolean isPureVirtual() throws CModelException{ return getMethodInfo().isPureVirtual(); } @@ -60,6 +64,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec getMethodInfo().setPureVirtual(isPureVirtual); } + @Override public boolean isInline() throws CModelException{ return getMethodInfo().isInline(); } @@ -68,6 +73,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec getMethodInfo().setInline(isInline); } + @Override public boolean isVirtual() throws CModelException{ return getMethodInfo().isVirtual(); } @@ -76,6 +82,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec getMethodInfo().setVirtual(isVirtual); } + @Override public boolean isFriend() throws CModelException{ return getMethodInfo().isFriend(); } @@ -94,23 +101,24 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec this.isConst = isConst; } + @Override public ASTAccessVisibility getVisibility() throws CModelException{ return getMethodInfo().getVisibility(); } - + public void setVisibility(ASTAccessVisibility visibility) throws CModelException{ getMethodInfo().setVisibility(visibility); } - + @Override protected CElementInfo createElementInfo () { return new MethodInfo(this); } - + protected MethodInfo getMethodInfo() throws CModelException{ return (MethodInfo) getElementInfo(); } - + @Override public boolean equals(Object other) { if (other instanceof IMethodDeclaration) { @@ -127,6 +135,6 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec return false; } } - + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplate.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplate.java index 460a7128bfe..30bea0771a7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplate.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplate.java @@ -18,21 +18,23 @@ import org.eclipse.cdt.core.model.IMethodTemplate; public class MethodTemplate extends Method implements IMethodTemplate { protected Template fTemplate; - + public MethodTemplate(ICElement parent, String name) { super(parent, name, ICElement.C_TEMPLATE_METHOD); fTemplate = new Template(name); } - + /** * Returns the parameterTypes. * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @return String[] */ + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } @@ -48,22 +50,24 @@ public class MethodTemplate extends Method implements IMethodTemplate { /** * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() */ + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } /** * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() - */ + */ /* - * The signature in the outline view will be: - * The class X followed by its template parameters, - * then the scope resolution, then the function name, - * followed by its template parameters, folowed by its - * normal parameter list, then a colon then the function's + * The signature in the outline view will be: + * The class X followed by its template parameters, + * then the scope resolution, then the function name, + * followed by its template parameters, folowed by its + * normal parameter list, then a colon then the function's * return type. - */ + */ + @Override public String getTemplateSignature() throws CModelException { StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); sig.append(this.getParameterClause()); @@ -72,11 +76,11 @@ public class MethodTemplate extends Method implements IMethodTemplate { if(isVolatile()) sig.append(" volatile"); //$NON-NLS-1$ - if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ + if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ sig.append(" : "); //$NON-NLS-1$ sig.append(this.getReturnType()); } - + return sig.toString(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplateDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplateDeclaration.java index 083f5c0f5db..dc1135ee76e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodTemplateDeclaration.java @@ -24,14 +24,17 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet fTemplate = new Template(name); } + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } + @Override public String getTemplateSignature() throws CModelException { StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); sig.append(this.getParameterClause()); @@ -40,15 +43,16 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet if(isVolatile()) sig.append(" volatile"); //$NON-NLS-1$ - if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ + if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ sig.append(" : "); //$NON-NLS-1$ sig.append(this.getReturnType()); } - + return sig.toString(); } + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Namespace.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Namespace.java index 52524b8e2af..c62ecc3cf4d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Namespace.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Namespace.java @@ -27,6 +27,7 @@ public class Namespace extends SourceManipulation implements INamespace{ * Returns the typeName. * @return String */ + @Override public String getTypeName() { return typeName; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java index 625bc43d97e..763499babdc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/NullBinaryParser.java @@ -25,6 +25,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser { /* (non-Javadoc) * @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath) */ + @Override public IBinaryFile getBinary(byte[] data, IPath path) throws IOException { throw new IOException(CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Not_binary_file")); //$NON-NLS-1$ } @@ -32,6 +33,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser { /* (non-Javadoc) * @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath) */ + @Override public IBinaryFile getBinary(IPath path) throws IOException { throw new IOException(CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Not_binary_file")); //$NON-NLS-1$ } @@ -39,6 +41,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser { /* (non-Javadoc) * @see org.eclipse.cdt.core.IBinaryParser#getFormat() */ + @Override public String getFormat() { return CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Null_Format"); //$NON-NLS-1$ } @@ -46,6 +49,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser { /* (non-Javadoc) * @see org.eclipse.cdt.core.IBinaryParser#isBinary(byte[], org.eclipse.core.runtime.IPath) */ + @Override public boolean isBinary(byte[] array, IPath path) { return false; } @@ -53,6 +57,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser { /* (non-Javadoc) * @see org.eclipse.cdt.core.IBinaryParser#getBufferSize() */ + @Override public int getHintBufferSize() { return 0; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java index c2f1fa6d455..d305e3c5177 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java @@ -9,7 +9,7 @@ * QNX Software Systems - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - + import java.util.Enumeration; import java.util.Map; @@ -27,7 +27,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; public abstract class Openable extends Parent implements IOpenable { - protected IResource resource; + protected IResource resource; public Openable(ICElement parent, IPath path, int type) { // Check if the file is under the workspace. @@ -38,7 +38,7 @@ public abstract class Openable extends Parent implements IOpenable { public Openable(ICElement parent, IResource resource, int type) { this(parent, resource, resource.getName(), type); } - + public Openable(ICElement parent, IResource res, String name, int type) { super(parent, name, type); resource = res; @@ -57,6 +57,7 @@ public abstract class Openable extends Parent implements IOpenable { * * @see IBufferChangedListener */ + @Override public void bufferChanged(BufferChangedEvent event) { if (event.getBuffer().isClosed()) { CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this); @@ -64,7 +65,7 @@ public abstract class Openable extends Parent implements IOpenable { } else { CModelManager.getDefault().getElementsOutOfSynchWithBuffers().put(this, this); } - } + } /** * Builds this element's structure and properties in the given @@ -103,6 +104,7 @@ public abstract class Openable extends Parent implements IOpenable { /** * @see org.eclipse.cdt.core.model.IOpenable#getBuffer() */ + @Override public IBuffer getBuffer() throws CModelException { if (hasBuffer()) { // ensure element is open @@ -132,7 +134,7 @@ public abstract class Openable extends Parent implements IOpenable { protected BufferManager getBufferManager() { return BufferManager.getDefaultBufferManager(); } - + /** * Returns true if this element may have an associated source buffer, * otherwise false. Subclasses must override as required. @@ -143,6 +145,7 @@ public abstract class Openable extends Parent implements IOpenable { /** * @see org.eclipse.cdt.core.model.IOpenable#hasUnsavedChanges() */ + @Override public boolean hasUnsavedChanges() throws CModelException{ if (isReadOnly() || !isOpen()) { return false; @@ -165,22 +168,24 @@ public abstract class Openable extends Parent implements IOpenable { } } } - + return false; } /** * Subclasses must override as required. - * + * * @see org.eclipse.cdt.core.model.IOpenable#isConsistent() */ + @Override public boolean isConsistent() throws CModelException { return true; } /** * @see org.eclipse.cdt.core.model.IOpenable#isOpen() - */ + */ + @Override public boolean isOpen() { return CModelManager.getDefault().getInfo(this) != null; } @@ -203,10 +208,12 @@ public abstract class Openable extends Parent implements IOpenable { /** * @see org.eclipse.cdt.core.model.IOpenable#makeConsistent(IProgressMonitor) */ + @Override public void makeConsistent(IProgressMonitor pm) throws CModelException { makeConsistent(pm, false); } - + + @Override public void makeConsistent(IProgressMonitor monitor, boolean forced) throws CModelException { // only translation units can be inconsistent // other openables cannot be inconsistent so default is to do nothing @@ -215,6 +222,7 @@ public abstract class Openable extends Parent implements IOpenable { /** * @see org.eclipse.cdt.core.model.IOpenable#open(IProgressMonitor) */ + @Override public void open(IProgressMonitor pm) throws CModelException { getElementInfo(pm); } @@ -249,7 +257,7 @@ public abstract class Openable extends Parent implements IOpenable { if (CModelManager.VERBOSE){ System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$ } - + // open the parent if necessary openParent(info, newElements, monitor); if (monitor != null && monitor.isCanceled()) @@ -268,7 +276,7 @@ public abstract class Openable extends Parent implements IOpenable { newElements.remove(this); throw e; } - + // remove out of sync buffer for this element CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this); } @@ -276,6 +284,7 @@ public abstract class Openable extends Parent implements IOpenable { /** * @see org.eclipse.cdt.core.model.IOpenable#save(IProgressMonitor, boolean) */ + @Override public void save(IProgressMonitor pm, boolean force) throws CModelException { IResource res = getResource(); if (res != null) { @@ -289,7 +298,7 @@ public abstract class Openable extends Parent implements IOpenable { throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); } IBuffer buf = getBuffer(); - if (buf != null) { + if (buf != null) { buf.save(pm, force); this.makeConsistent(pm); // update the element info of this element } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java index b308cf25b3f..0c5f610cd13 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java @@ -28,27 +28,30 @@ public class PathEntry implements IPathEntry { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.IPathEntry#getEntryKind() */ + @Override public IPath getPath() { return path; } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.IPathEntry#getEntryKind() */ + @Override public int getEntryKind() { return entryKind; } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.IPathEntry#isExported() */ + @Override public boolean isExported() { return isExported; } @@ -80,7 +83,7 @@ public class PathEntry implements IPathEntry { } return super.equals(obj); } - + /** * Returns the kind from its String form. */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java index 68e2035a743..a85ebce90c0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java @@ -114,7 +114,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange // Synchronized the access of the cache entries. protected Map> resolvedMap = new Hashtable>(); private Map resolvedInfoMap = new Hashtable(); - private ThreadLocalMap resolveInfoValidState = new ThreadLocalMap(); + private ThreadLocalMap resolveInfoValidState = new ThreadLocalMap(); // Accessing the map is synch with the class private Map storeMap = new HashMap(); @@ -122,7 +122,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange private static PathEntryManager pathEntryManager; protected ConcurrentLinkedQueue markerProblems = new ConcurrentLinkedQueue(); - + //Setting up a generate markers job, it does not get scheduled Job markerTask = new GenerateMarkersJob("PathEntry Marker Job"); //$NON-NLS-1$ @@ -132,11 +132,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange private class PathEntryProblem { IProject project; ICModelStatus[] problems; - + public PathEntryProblem(IProject project, ICModelStatus[] problems) { this.project = project; this.problems = problems; - } + } } private class PathEntryContainerLock implements IPathEntryContainer { @@ -153,27 +153,30 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries() */ + @Override public IPathEntry[] getPathEntries() { return NO_PATHENTRIES; } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription() */ + @Override public String getDescription() { return new String("Lock container"); //$NON-NLS-1$ } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath() */ + @Override public IPath getPath() { return Path.EMPTY; } @@ -294,8 +297,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange IMacroEntry[] macros = macroList.toArray(new IMacroEntry[macroList.size()]); macroList.clear(); - - // For the macros the closest symbol will override + + // For the macros the closest symbol will override // /projec/src/file.c --> NDEBUG=1 // /project/src --> NDEBUG=0 // @@ -387,7 +390,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange // includes with the closest match to the resource will come first // /project/src/file.c --> /usr/local/include // /project --> /usr/include - // + // // /usr/local/include must come first. // int count = resPath.segmentCount(); @@ -422,7 +425,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange } } } - return entryList; + return entryList; } /** @@ -440,7 +443,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange } return null; } - + public PathEntryResolveInfo getResolveInfo(ICProject cproject, boolean useCache) throws CModelException{ PathEntryResolveInfo info = resolvedInfoMap.get(cproject); if (info == null && useCache){ @@ -450,20 +453,20 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange if (info == null || !useCache || !getResolveInfoValidState(cproject)){ Object[] resolved = getResolvedPathEntries(cproject, false, false); if (resolved != null) - info = (PathEntryResolveInfo)resolved[1]; + info = (PathEntryResolveInfo)resolved[1]; } return info; } - + private void setResolveInfoValidState(ICProject cproject, boolean valid){ Object v = valid ? null : Boolean.FALSE; resolveInfoValidState.set(cproject, v); } - + private boolean getResolveInfoValidState(ICProject cproject){ return resolveInfoValidState.get(cproject) == null; } - + protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) { ArrayList resolvedListEntries = resolvedMap.remove(cproject); resolvedInfoMap.remove(cproject); @@ -523,7 +526,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange /** * This method will not expand container extending IPathEntryContainerExtension - * + * * @param cproject * @param generateMarkers * @return @@ -745,12 +748,14 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange // causing some grief SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { - IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Exception occurred in container initializer: " + initializer, exception); //$NON-NLS-1$ CCorePlugin.log(status); } + @Override public void run() throws Exception { initializer.initialize(containerPath, project); ok[0] = true; @@ -777,7 +782,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange * A containerID is the first segment of any container path, used to * identify the registered container initializer. *

- * + * * @param containerID - * a containerID identifying a registered initializer * @return PathEntryContainerInitializer - the registered container @@ -1011,7 +1016,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange throw new CModelException(e); } } - + /** * Collects path entry errors for each project and generate error markers for these errors * @param project - Project with path entry errors @@ -1031,7 +1036,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange } @Override - public IStatus runInWorkspace(IProgressMonitor monitor) { + public IStatus runInWorkspace(IProgressMonitor monitor) { while (markerProblems.peek() != null && !monitor.isCanceled()) { PathEntryProblem problem = markerProblems.poll(); IProject project = problem.project; @@ -1044,7 +1049,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange return Status.OK_STATUS; } } - + private boolean needDelta(ICProject cproject){ try { PathEntryStoreProxy store = (PathEntryStoreProxy)getPathEntryStore(cproject.getProject(), false); @@ -1172,7 +1177,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE; break; } - case IPathEntry.CDT_MACRO: { + case IPathEntry.CDT_MACRO: { IMacroEntry macro = (IMacroEntry)entry; IPath path = macro.getPath(); celement = CoreModel.getDefault().create(path); @@ -1286,7 +1291,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange // } // return store; } - + // private IPathEntryStore createDefaultStore(IProject project){ // if (CProjectDescriptionManager.getInstance().isNewStyleIndexCfg(project)){ // return new ConfigBasedPathEntryStore(project); @@ -1296,9 +1301,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryChangedEvent) */ + @Override public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) { IProject project = event.getProject(); @@ -1329,9 +1335,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent) */ + @Override public void elementChanged(ElementChangedEvent event) { try { if (processDelta(event.getDelta()) == true) { @@ -1369,7 +1376,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange protected boolean processDelta(ICElementDelta delta) throws CModelException { int kind = delta.getKind(); ICElement element = delta.getElement(); - int type = element.getElementType(); + int type = element.getElementType(); // handle open, closing and removing of projects if ( type == ICElement.C_PROJECT) { @@ -1392,11 +1399,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange containerRemove(cproject); } } - } + } return true; } // project change, traverse children. - } + } if (element instanceof IWorkingCopy) { return false; } @@ -1464,7 +1471,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange updatePathEntry.schedule(); } } - + public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) { return PathEntryUtil.validatePathEntry(cProject, entries); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java index c47e8e4d7a5..1982e27b43b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryStoreProxy.java @@ -30,12 +30,12 @@ import org.eclipse.core.runtime.CoreException; public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener { private List fListeners; private IPathEntryStore fStore; - + public PathEntryStoreProxy(IProject project){ super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID); fListeners = Collections.synchronizedList(new ArrayList()); } - + public IPathEntryStore getStore(){ providerRequested(); return fStore; @@ -43,13 +43,15 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) */ - public void addPathEntryStoreListener(IPathEntryStoreListener listener) { + @Override + public void addPathEntryStoreListener(IPathEntryStoreListener listener) { fListeners.add(listener); } /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) */ + @Override public void removePathEntryStoreListener(IPathEntryStoreListener listener) { fListeners.remove(listener); } @@ -58,7 +60,7 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED); notifyListeners(evt); } - + private void notifyListeners(PathEntryStoreChangedEvent evt){ IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()]; fListeners.toArray(observers); @@ -86,30 +88,35 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat return super.getProject(); } + @Override public ICExtensionReference getExtensionReference() { //TODO: calculate return null; } + @Override public ICConfigExtensionReference getConfigExtensionReference() { return null; } + @Override public IPathEntry[] getRawPathEntries() throws CoreException { providerRequested(); return fStore.getRawPathEntries(); } + @Override public void setRawPathEntries(IPathEntry[] entries) throws CoreException { providerRequested(); fStore.setRawPathEntries(entries); } + @Override public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) { notifyListeners(event); } - + @Override protected Object createDefaultProvider(ICConfigurationDescription cfgDes, boolean newStile) { @@ -148,10 +155,10 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat @Override protected boolean doHandleEvent(CProjectDescriptionEvent event) { IPathEntryStore oldStore = fStore; - boolean result = super.doHandleEvent(event); + boolean result = super.doHandleEvent(event); if(!result) postProcessProviderChange(fStore, oldStore); - + return result; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProgressMonitorAndCanceler.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProgressMonitorAndCanceler.java index 2f605a2d291..a7a08f869db 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProgressMonitorAndCanceler.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ProgressMonitorAndCanceler.java @@ -16,24 +16,25 @@ import org.eclipse.core.runtime.NullProgressMonitor; /** * A progress monitor accepting a ICancelable object to receive the cancel request. - * + * * @since 5.0 */ public class ProgressMonitorAndCanceler extends NullProgressMonitor implements ICanceler { private ICancelable fCancelable; + @Override public void setCancelable(ICancelable cancelable) { fCancelable= cancelable; checkCanceled(); } - + @Override public void setCanceled(boolean canceled) { super.setCanceled(canceled); checkCanceled(); } - + private void checkCanceled() { if (fCancelable != null && isCanceled()) { fCancelable.cancel(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Region.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Region.java index 565b706e310..049eaf787de 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Region.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Region.java @@ -32,7 +32,7 @@ public class Region implements IRegion { /** * Creates an empty region. - * + * * @see IRegion */ public Region() { @@ -42,6 +42,7 @@ public class Region implements IRegion { /** * @see IRegion#add(ICElement) */ + @Override public void add(ICElement element) { if (!contains(element)) { // "new" element added to region @@ -54,6 +55,7 @@ public class Region implements IRegion { /** * @see IRegion */ + @Override public boolean contains(ICElement element) { int size = fRootElements.size(); @@ -77,7 +79,7 @@ public class Region implements IRegion { /** * Returns a collection of all the parents of this element in bottom-up * order. - * + * */ private ArrayList getAncestors(ICElement element) { ArrayList parents = new ArrayList(); @@ -93,6 +95,7 @@ public class Region implements IRegion { /** * @see IRegion */ + @Override public ICElement[] getElements() { int size = fRootElements.size(); ICElement[] roots = new ICElement[size]; @@ -106,6 +109,7 @@ public class Region implements IRegion { /** * @see IRegion#remove(ICElement) */ + @Override public boolean remove(ICElement element) { removeAllChildren(element); @@ -115,7 +119,7 @@ public class Region implements IRegion { /** * Removes any children of this element that are contained within this * region as this parent is about to be added to the region. - * + * *

* Children are all children, not just direct children. */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulation.java index 389bb1f97f0..aa4957e8f8f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulation.java @@ -52,6 +52,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I /** * @see ISourceManipulation */ + @Override public void copy(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { if (container == null) { @@ -73,6 +74,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I /** * @see ISourceManipulation */ + @Override public void delete(boolean force, IProgressMonitor monitor) throws CModelException { ICElement[] elements = new ICElement[] {this}; getCModel().delete(elements, force, monitor); @@ -81,6 +83,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I /** * @see ISourceManipulation */ + @Override public void move(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { if (container == null) { @@ -102,6 +105,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I /** * @see ISourceManipulation */ + @Override public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException { if (name == null) { throw new IllegalArgumentException("element.nullName"); //$NON-NLS-1$ @@ -115,6 +119,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I /** * @see IMember */ + @Override public ITranslationUnit getTranslationUnit() { try { return getSourceManipulationInfo().getTranslationUnit(); @@ -152,6 +157,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I /** * @see ISourceReference */ + @Override public String getSource() throws CModelException { return getSourceManipulationInfo().getSource(); } @@ -159,6 +165,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I /** * @see ISourceReference */ + @Override public ISourceRange getSourceRange() throws CModelException { return getSourceManipulationInfo().getSourceRange(); } @@ -175,7 +182,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I public IResource getResource() { return null; } - + @Override protected CElementInfo createElementInfo () { return new SourceManipulationInfo(this); @@ -184,9 +191,9 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I protected SourceManipulationInfo getSourceManipulationInfo() throws CModelException { return (SourceManipulationInfo)getElementInfo(); } - + public boolean isIdentical(SourceManipulation other) throws CModelException{ - return (this.equals(other) + return (this.equals(other) && (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo()))); } @@ -199,7 +206,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I if (openableParent == null) { return; } - + newElements.put(this, info); CElementInfo openableParentInfo = (CElementInfo) CModelManager.getDefault().getInfo(openableParent); @@ -215,7 +222,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I // } } - + public void setIdPos(int startPos, int length) { try { getSourceManipulationInfo().setIdPos(startPos, length); @@ -301,7 +308,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I case ICElement.C_TEMPLATE_METHOD: case ICElement.C_TEMPLATE_METHOD_DECLARATION: for (ICElement element2 : children) { - if (elementType == element2.getElementType() + if (elementType == element2.getElementType() && elementName.equals(element2.getElementName())) { assert element2 instanceof IFunctionDeclaration; String[] functionParams= ((IFunctionDeclaration)element2).getParameterTypes(); @@ -316,7 +323,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I case ICElement.C_TEMPLATE_STRUCT: case ICElement.C_TEMPLATE_UNION: for (ICElement element2 : children) { - if (elementType == element2.getElementType() + if (elementType == element2.getElementType() && elementName.equals(element2.getElementName())) { assert element2 instanceof ITemplate; String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes(); @@ -329,7 +336,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I break; default: for (ICElement element2 : children) { - if (elementType == element2.getElementType() + if (elementType == element2.getElementType() && elementName.equals(element2.getElementName())) { element= (CElement) element2; break; @@ -362,14 +369,16 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I return CElement.CEM_SOURCEELEMENT; } + @Override public boolean isActive() { return fIsActive; } + @Override public int getIndex() { return fIndex; } - + public void setActive(boolean active) { fIsActive= active; } @@ -377,12 +386,12 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I public void setIndex(int i) { fIndex= (short) i; } - + @Override public int hashCode() { return Util.combineHashCodes(fIndex, super.hashCode()); } - + @Override public boolean equals(Object other) { if (other instanceof ISourceReference) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRange.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRange.java index 82cf253af0f..9e4a982b190 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRange.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRange.java @@ -50,6 +50,7 @@ class SourceRange implements ISourceRange { /** * @see ISourceRange */ + @Override public int getLength() { return length; } @@ -57,24 +58,29 @@ class SourceRange implements ISourceRange { /** * @see ISourceRange */ + @Override public int getStartPos() { return startPos; } /** */ + @Override public int getIdStartPos() { return idStartPos; } + @Override public int getIdLength() { return idLength; } + @Override public int getStartLine() { return startLine; } + @Override public int getEndLine() { return endLine; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java index 2334508fabc..c4fafe18743 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java @@ -50,6 +50,7 @@ public class SourceRoot extends CContainer implements ISourceRoot { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement) */ + @Override public boolean isOnSourceEntry(ICElement element) { IPath path = element.getPath(); return this.isOnSourceEntry(path); @@ -58,13 +59,15 @@ public class SourceRoot extends CContainer implements ISourceRoot { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource) */ + @Override public boolean isOnSourceEntry(IResource res) { IPath path = res.getFullPath(); return isOnSourceEntry(path); } + @Override public boolean isOnSourceEntry(IPath path) { - if (sourceEntry.getFullPath().isPrefixOf(path) + if (sourceEntry.getFullPath().isPrefixOf(path) && !CoreModelUtil.isExcluded(path, sourceEntry.fullExclusionPatternChars())) { return true; } @@ -86,7 +89,7 @@ public class SourceRoot extends CContainer implements ISourceRoot { } ((CElement)getParent()).getHandleMemento(buff); buff.append(getHandleMementoDelimiter()); - escapeMementoName(buff, path.toString()); + escapeMementoName(buff, path.toString()); } /** diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java index 295e289104d..342a0bf3006 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java @@ -24,19 +24,21 @@ import org.eclipse.cdt.core.model.IStructure; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; public class Structure extends StructureDeclaration implements IStructure { - + Map superClassesNames = new TreeMap(); public Structure(ICElement parent, int kind, String name) { super(parent, name, kind); } + @Override public IField[] getFields() throws CModelException { List fields = new ArrayList(); fields.addAll(getChildrenOfType(ICElement.C_FIELD)); return fields.toArray(new IField[fields.size()]); } + @Override public IField getField(String name) { try { IField[] fields = getFields(); @@ -50,6 +52,7 @@ public class Structure extends StructureDeclaration implements IStructure { return null; } + @Override public IMethodDeclaration[] getMethods() throws CModelException { List methods = new ArrayList(); methods.addAll(getChildrenOfType(ICElement.C_METHOD_DECLARATION)); @@ -57,6 +60,7 @@ public class Structure extends StructureDeclaration implements IStructure { return methods.toArray(new IMethodDeclaration[methods.size()]); } + @Override public IMethodDeclaration getMethod(String name) { try { IMethodDeclaration[] methods = getMethods(); @@ -70,6 +74,7 @@ public class Structure extends StructureDeclaration implements IStructure { return null; } + @Override public boolean isAbstract() throws CModelException { IMethodDeclaration[] methods = getMethods(); for (IMethodDeclaration method : methods) { @@ -79,14 +84,16 @@ public class Structure extends StructureDeclaration implements IStructure { return false; } + @Override public String[] getSuperClassesNames(){ return superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]); } + @Override public ASTAccessVisibility getSuperClassAccess(String name){ return superClassesNames.get(name); } - + public void addSuperClass(String name) { superClassesNames.put(name, ASTAccessVisibility.PUBLIC); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureDeclaration.java index 2d1ec33a8e9..6d15e29e56a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureDeclaration.java @@ -24,6 +24,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu super(parent, name, kind); } + @Override public String getTypeName() throws CModelException { return getStructureInfo().getTypeName(); } @@ -32,14 +33,17 @@ public class StructureDeclaration extends SourceManipulation implements IStructu getStructureInfo().setTypeName(type); } + @Override public boolean isUnion() throws CModelException { return getStructureInfo().isUnion(); } + @Override public boolean isClass() throws CModelException { return getStructureInfo().isClass(); } + @Override public boolean isStruct() throws CModelException { return getStructureInfo().isStruct(); } @@ -56,6 +60,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isStatic() */ + @Override public boolean isStatic() throws CModelException { return getStructureInfo().isStatic(); } @@ -63,6 +68,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isConst() */ + @Override public boolean isConst() throws CModelException { return getStructureInfo().isConst(); } @@ -70,6 +76,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() */ + @Override public boolean isVolatile() throws CModelException { return getStructureInfo().isVolatile(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplate.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplate.java index a2460e76eb5..8e435caf05b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplate.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplate.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.model.IStructureTemplate; public class StructureTemplate extends Structure implements IStructureTemplate { protected Template fTemplate; - + public StructureTemplate(ICElement parent, int kind, String name) { super(parent, kind, name); fTemplate = new Template(name); @@ -27,10 +27,12 @@ public class StructureTemplate extends Structure implements IStructureTemplate { * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @return String[] */ + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } @@ -46,13 +48,15 @@ public class StructureTemplate extends Structure implements IStructureTemplate { /** * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() */ + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } /** * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() - */ + */ + @Override public String getTemplateSignature() { return fTemplate.getTemplateSignature(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplateDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplateDeclaration.java index 5c20c5de040..ca3ade5f4b5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureTemplateDeclaration.java @@ -25,10 +25,12 @@ public class StructureTemplateDeclaration extends StructureDeclaration implement fTemplate = new Template(name); } + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } @@ -37,10 +39,12 @@ public class StructureTemplateDeclaration extends StructureDeclaration implement fTemplate.setTemplateInfo(templateParameterTypes, null); } + @Override public String getTemplateSignature() throws CModelException { return fTemplate.getTemplateSignature(); } + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Template.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Template.java index 56b1c162177..6aecf587947 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Template.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Template.java @@ -18,7 +18,7 @@ public class Template implements ITemplate { protected String[] fTemplateParameterTypes; protected String[] fTemplateArgs; protected String fName; - + public Template(String name) { fName = name; fTemplateParameterTypes= fgEmptyList; @@ -29,10 +29,12 @@ public class Template implements ITemplate { * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @return String[] */ + @Override public String[] getTemplateParameterTypes() { return fTemplateParameterTypes; } + @Override public String[] getTemplateArguments() { return fTemplateArgs; } @@ -48,13 +50,15 @@ public class Template implements ITemplate { } } + @Override public int getNumberOfTemplateParameters() { return fTemplateParameterTypes == null ? 0 : fTemplateParameterTypes.length; } /** * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() - */ + */ + @Override public String getTemplateSignature() { StringBuffer sig = new StringBuffer(fName); if(getNumberOfTemplateParameters() > 0){ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 908aa8fdcaa..56921c2368c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -117,10 +117,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit { setContentTypeID(idType); } + @Override public ITranslationUnit getTranslationUnit() { return this; } + @Override public IInclude createInclude(String includeName, boolean isStd, ICElement sibling, IProgressMonitor monitor) throws CModelException { CreateIncludeOperation op = new CreateIncludeOperation(includeName, isStd, this); @@ -131,6 +133,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return getInclude(includeName); } + @Override public IUsing createUsing(String usingName, boolean isDirective, ICElement sibling, IProgressMonitor monitor) throws CModelException { CreateIncludeOperation op = new CreateIncludeOperation(usingName, isDirective, this); @@ -141,6 +144,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return getUsing(usingName); } + @Override public INamespace createNamespace(String namespace, ICElement sibling, IProgressMonitor monitor) throws CModelException { CreateNamespaceOperation op = new CreateNamespaceOperation(namespace, this); @@ -151,6 +155,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return getNamespace(namespace); } + @Override public ICElement getElementAtLine(int line) throws CModelException { ICElement[] celements = getChildren(); for (ICElement celement : celements) { @@ -164,6 +169,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } + @Override public ICElement getElementAtOffset(int pos) throws CModelException { ICElement e = getSourceElementAtOffset(pos); if (e == this) { @@ -172,6 +178,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return e; } + @Override public ICElement[] getElementsAtOffset(int pos) throws CModelException { ICElement[] e = getSourceElementsAtOffset(pos); if (e.length == 1 && e[0] == this) { @@ -180,6 +187,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return e; } + @Override public ICElement getElement(String name) { if (name == null || name.length() == 0) { return null; @@ -218,6 +226,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return current; } + @Override public IInclude getInclude(String name) { try { ICElement[] celements = getChildren(); @@ -233,6 +242,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } + @Override public IInclude[] getIncludes() throws CModelException { ICElement[] celements = getChildren(); ArrayList aList = new ArrayList(); @@ -244,6 +254,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return aList.toArray(new IInclude[0]); } + @Override public IUsing getUsing(String name) { try { ICElement[] celements = getChildren(); @@ -259,6 +270,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } + @Override public IUsing[] getUsings() throws CModelException { ICElement[] celements = getChildren(); ArrayList aList = new ArrayList(); @@ -270,6 +282,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return aList.toArray(new IUsing[0]); } + @Override public INamespace getNamespace(String name) { try { String[] names = name.split("::"); //$NON-NLS-1$ @@ -298,6 +311,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } + @Override public INamespace[] getNamespaces() throws CModelException { ICElement[] celements = getChildren(); ArrayList elementList = new ArrayList(); @@ -313,6 +327,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { location = loc; } + @Override public IPath getLocation() { if (location == null) { IFile file = getFile(); @@ -324,7 +339,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } return UNCPathConverter.toPath(location); } - + @Override public URI getLocationURI() { if (location == null) { @@ -346,28 +361,34 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } + @Override public void copy(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { getSourceManipulationInfo().copy(container, sibling, rename, force, monitor); } + @Override public void delete(boolean force, IProgressMonitor monitor) throws CModelException { getSourceManipulationInfo().delete(force, monitor); } + @Override public void move(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { getSourceManipulationInfo().move(container, sibling, rename, force, monitor); } + @Override public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException { getSourceManipulationInfo().rename(name, force, monitor); } + @Override public String getSource() throws CModelException { return getSourceManipulationInfo().getSource(); } + @Override public ISourceRange getSourceRange() throws CModelException { return getSourceManipulationInfo().getSourceRange(); } @@ -391,9 +412,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit { /** * Returns true if this handle represents the same Java element * as the given handle. - * + * *

Compilation units must also check working copy state; - * + * * @see Object#equals(java.lang.Object) */ @Override @@ -402,6 +423,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return super.equals(o) && !((ITranslationUnit) o).isWorkingCopy(); } + @Override public IWorkingCopy findSharedWorkingCopy() { return CModelManager.getDefault().findSharedWorkingCopy(null, this); } @@ -442,6 +464,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return unitInfo.isStructureKnown(); } + @Override public char[] getContents() { try { IBuffer buffer = this.getBuffer(); @@ -451,19 +474,23 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } } + @Override public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) throws CModelException { return CModelManager.getDefault().getSharedWorkingCopy(null, this, requestor, monitor); } + @Override public IWorkingCopy getWorkingCopy() throws CModelException { return this.getWorkingCopy(null, null); } + @Override public IWorkingCopy getWorkingCopy(IProgressMonitor monitor) throws CModelException { return getWorkingCopy(monitor, null); } + @Override public IWorkingCopy getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException { WorkingCopy workingCopy; IFile file= getFile(); @@ -513,7 +540,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { if (!computeAST && isConsistent()) { return null; } - + // create a new info and make it the current info // (this will remove the info and its children just before storing the new infos) CModelManager manager = CModelManager.getDefault(); @@ -559,6 +586,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return true; } + @Override public boolean isWorkingCopy() { return false; } @@ -601,6 +629,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return buffer; } + @Override public Map parse() { throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$ } @@ -655,10 +684,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return problemRequestor; } + @Override public boolean isHeaderUnit() { return isHeaderContentType(contentTypeId); } + @Override public boolean isSourceUnit() { return isSourceContentType(contentTypeId); } @@ -678,16 +709,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit { || LanguageManager.getInstance().isContributedContentType(contentType); } + @Override public boolean isCLanguage() { return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId) || CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId); } + @Override public boolean isCXXLanguage() { return CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId) || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentTypeId); } + @Override public boolean isASMLanguage() { return CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId); } @@ -705,20 +739,21 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } catch (CoreException e) { CCorePlugin.log(e); } - + } return false; } + @Override public ILanguage getLanguage() throws CoreException { ILanguage language = null; - + ICProject cProject = getCProject(); IProject project= cProject.getProject(); - + ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false); ICConfigurationDescription configuration; - + if (description == null) { // TODO: Sometimes, CoreModel returns a null ICProjectDescription // so for now, fall back to configuration-less language determination. @@ -726,7 +761,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } else { configuration = description.getActiveConfiguration(); } - + IFile file= getFile(); if (file != null) { language = LanguageManager.getInstance().getLanguageForFile(file, configuration, contentTypeId); @@ -738,6 +773,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return language; } + @Override public String getContentTypeId() { return contentTypeId; } @@ -759,9 +795,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit { * Contributed languages' model builders need to be able to indicate whether or * not the parse of a translation unit was successful without having access to * the CElementInfo object associated with the translation unit - * + * * @param wasSuccessful */ + @Override public void setIsStructureKnown(boolean wasSuccessful) { try { this.getElementInfo().setIsStructureKnown(wasSuccessful); @@ -769,10 +806,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } } + @Override public IASTTranslationUnit getAST() throws CoreException { return getAST(null, 0, null); } + @Override public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException { return getAST(index, style, null); } @@ -782,12 +821,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit { ITranslationUnit configureWith = getConfigureWith(contextToHeader); if (configureWith == this) contextToHeader= null; - + IScannerInfo scanInfo= configureWith.getScannerInfo((style & AST_SKIP_IF_NO_BUILD_INFO) == 0); if (scanInfo == null) { return null; } - + FileContent fileContent= FileContent.create(this); if (fileContent == null) { return null; @@ -833,19 +872,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } else { fileContentsProvider= IncludeFileContentProvider.getSavedFilesProvider(); } - + if (index != null && (style & AST_SKIP_INDEXED_HEADERS) != 0) { IndexBasedFileContentProvider ibcf= new IndexBasedFileContentProvider(index, pathResolver, linkageID, fileContentsProvider); ibcf.setContextToHeaderGap(contextToHeader); fileContentsProvider= ibcf; } - + if (fileContentsProvider instanceof InternalFileContentProvider) { final ProjectIndexerIncludeResolutionHeuristics heuristics = new ProjectIndexerIncludeResolutionHeuristics(cprj.getProject(), pathResolver); ((InternalFileContentProvider) fileContentsProvider).setIncludeResolutionHeuristics(heuristics); } - + return fileContentsProvider; } @@ -874,7 +913,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } } } - + if (best != null && contextOfBest != best) { return new IIndexFile[] { contextOfBest, best }; } @@ -897,10 +936,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } return indexFile; } - + /** * Returns true if the given file was parsed in a context of a source file. - * @throws CoreException + * @throws CoreException */ private boolean isSourceFile(IIndexFile indexFile) throws CoreException { String path = indexFile.getLocation().getURI().getPath(); @@ -912,28 +951,29 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } private ITranslationUnit getConfigureWith(IIndexFile[] contextToHeader) throws CoreException { - if (contextToHeader != null) { + if (contextToHeader != null) { ITranslationUnit configureWith = CoreModelUtil.findTranslationUnitForLocation( contextToHeader[0].getLocation(), getCProject()); - if (configureWith != null) + if (configureWith != null) return configureWith; } return this; } + @Override public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException { IIndexFile[] contextToHeader = getContextToHeader(index, style); ITranslationUnit configureWith = getConfigureWith(contextToHeader); if (configureWith == this) contextToHeader= null; - + IScannerInfo scanInfo = configureWith.getScannerInfo((style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0); if (scanInfo == null) { return null; } - + FileContent fileContent= FileContent.create(this); - + ILanguage language= configureWith.getLanguage(); fLanguageOfContext= language; if (language != null) { @@ -952,6 +992,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } + @Override @Deprecated public org.eclipse.cdt.core.parser.CodeReader getCodeReader() { IPath location= getLocation(); @@ -960,12 +1001,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit { if (isWorkingCopy()) { return new org.eclipse.cdt.core.parser.CodeReader(location.toOSString(), getContents()); } - + IResource res= getResource(); try { if (res instanceof IFile) return InternalParserUtil.createWorkspaceFileReader(location.toOSString(), (IFile) res, null); - else + else return InternalParserUtil.createExternalFileReader(location.toOSString(), null); } catch (CoreException e) { CCorePlugin.log(e); @@ -975,6 +1016,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } + @Override public IScannerInfo getScannerInfo(boolean force) { IResource resource = getResource(); ICProject project = getCProject(); @@ -984,7 +1026,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { if (!force && CoreModel.isScannerInformationEmpty(infoResource)) { return null; } - + IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject); if (provider != null) { IScannerInfo scanInfo = provider.getScannerInformation(infoResource); @@ -996,7 +1038,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } return null; } - + /** * Return the language of the context this file was parsed in. Works only after using * {@link #getAST(IIndex, int, IProgressMonitor)} with the flag {@link ITranslationUnit#AST_CONFIGURE_USING_SOURCE_CONTEXT}. @@ -1159,30 +1201,35 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } } } - + @Override protected char getHandleMementoDelimiter() { return CElement.CEM_TRANSLATIONUNIT; } + @Override public boolean isActive() { return true; } + @Override public int getIndex() { return 0; } + @Override @Deprecated public IWorkingCopy findSharedWorkingCopy(IBufferFactory bufferFactory) { return CModelManager.getDefault().findSharedWorkingCopy(bufferFactory, this); } + @Override @Deprecated public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor requestor) throws CModelException { return CModelManager.getDefault().getSharedWorkingCopy(factory, this, requestor, monitor); } + @Override @Deprecated public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException { return CModelManager.getDefault().getSharedWorkingCopy(factory, this, null, monitor); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TypeDef.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TypeDef.java index 5d920eacb91..6ee2833b92f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TypeDef.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TypeDef.java @@ -24,6 +24,7 @@ public class TypeDef extends SourceManipulation implements ITypeDef { * Returns the typeName. * @return String */ + @Override public String getTypeName() { return typeName; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Using.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Using.java index 2b96827a662..3a1d6dd200e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Using.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Using.java @@ -31,6 +31,7 @@ public class Using extends SourceManipulation implements IUsing { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IUsing#isDirective() */ + @Override public boolean isDirective() { return directive; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java index f04e6855cc0..35245ce2d99 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java @@ -15,7 +15,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IVariable; public class Variable extends VariableDeclaration implements IVariable { - + public Variable(ICElement parent, String name) { super(parent, name, ICElement.C_VARIABLE); } @@ -24,6 +24,7 @@ public class Variable extends VariableDeclaration implements IVariable { super(parent, name, kind); } + @Override public String getInitializer() { return ""; //$NON-NLS-1$ } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java index a72529dd332..122dbc1c318 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java @@ -16,7 +16,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IVariableDeclaration; public class VariableDeclaration extends SourceManipulation implements IVariableDeclaration { - + public VariableDeclaration(ICElement parent, String name) { super(parent, name, ICElement.C_VARIABLE_DECLARATION); } @@ -25,14 +25,17 @@ public class VariableDeclaration extends SourceManipulation implements IVariable super(parent, name, type); } + @Override public String getTypeName() throws CModelException { return getVariableInfo().getTypeName(); } + @Override public void setTypeName(String type) throws CModelException { getVariableInfo().setTypeString(type); } + @Override public boolean isConst() throws CModelException { return getVariableInfo().isConst(); } @@ -41,6 +44,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable getVariableInfo().setConst(isConst); } + @Override public boolean isVolatile() throws CModelException { return getVariableInfo().isVolatile(); } @@ -49,6 +53,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable getVariableInfo().setVolatile(isVolatile); } + @Override public boolean isStatic() throws CModelException { return getVariableInfo().isStatic(); } @@ -60,7 +65,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable public VariableInfo getVariableInfo() throws CModelException{ return (VariableInfo) getElementInfo(); } - + @Override protected CElementInfo createElementInfo () { return new VariableInfo(this); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableTemplate.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableTemplate.java index 0cac69111da..2f5b3fd1245 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableTemplate.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableTemplate.java @@ -17,15 +17,16 @@ public class VariableTemplate extends Variable implements ITemplate { protected static final String[] fgEmptyList= new String[] {}; protected String[] templateParameterTypes; - + public VariableTemplate(ICElement parent, String name) { super(parent, name, ICElement.C_TEMPLATE_VARIABLE); - templateParameterTypes= fgEmptyList; + templateParameterTypes= fgEmptyList; } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() */ + @Override public int getNumberOfTemplateParameters() { return templateParameterTypes == null ? 0 : templateParameterTypes.length; } @@ -33,10 +34,12 @@ public class VariableTemplate extends Variable implements ITemplate { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() */ + @Override public String[] getTemplateParameterTypes() { return templateParameterTypes; } + @Override public String[] getTemplateArguments() { return fgEmptyList; } @@ -51,6 +54,7 @@ public class VariableTemplate extends Variable implements ITemplate { /* (non-Javadoc) * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() */ + @Override public String getTemplateSignature() throws CModelException { StringBuffer sig = new StringBuffer(getElementName()); if(getNumberOfTemplateParameters() > 0){ @@ -67,10 +71,10 @@ public class VariableTemplate extends Variable implements ITemplate { else{ sig.append("<>"); //$NON-NLS-1$ } - + sig.append(" : "); //$NON-NLS-1$ sig.append(this.getTypeName()); - + return sig.toString(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java index ff68ab605b7..3e03e1b09f2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java @@ -38,13 +38,13 @@ import org.eclipse.core.runtime.IProgressMonitor; * the timestamp of the resource it was created from. */ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { - + /** * If set, this is the factory that will be used to create the buffer. */ protected IBufferFactory bufferFactory; /** - * A counter of the number of time clients have asked for this + * A counter of the number of time clients have asked for this * working copy. It is set to 1, if the working * copy is not managed. When destroyed, this counter is * set to 0. Once destroyed, this working copy cannot be opened @@ -74,6 +74,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { /** * @see org.eclipse.cdt.core.model.IWorkingCopy#commit(boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void commit(boolean force, IProgressMonitor monitor) throws CModelException { ITranslationUnit original = this.getOriginalElement(); if (original.exists()) { @@ -94,8 +95,8 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { ByteArrayInputStream stream = new ByteArrayInputStream(bytes); if (originalRes.exists()) { originalRes.setContents( - stream, - force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, + stream, + force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, null); } else { originalRes.create( @@ -108,12 +109,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { } catch (CoreException e) { throw new CModelException(e); } - } + } } - + /** * @see org.eclipse.cdt.core.model.IWorkingCopy#destroy() */ + @Override public void destroy() { if (--this.useCount > 0) { return; @@ -151,17 +153,18 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { */ @Override public boolean equals(Object o) { - return this == o; + return this == o; } /** * Returns the original element the specified working copy element was created from, * or null if this is not a working copy element. - * + * * @param workingCopyElement the specified working copy element * @return the original element the specified working copy element was created from, * or null if this is not a working copy element */ + @Override public ICElement getOriginal(ICElement workingCopyElement) { // It has to come from the same workingCopy, meaning ours. if (workingCopyElement instanceof ISourceReference) { @@ -207,10 +210,11 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { } return current; } - + /** * @see org.eclipse.cdt.core.model.IWorkingCopy#getOriginalElement() */ + @Override public ITranslationUnit getOriginalElement() { IFile file= getFile(); if (file != null) { @@ -224,12 +228,12 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { */ @Override public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) { - return this; + return this; } /** * @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy() - */ + */ @Override public IWorkingCopy getWorkingCopy() { return this; @@ -246,6 +250,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { /** * @see IWorkingCopy */ + @Override public boolean isBasedOn(IResource resource) { if (resource.getType() != IResource.FILE) { return false; @@ -282,12 +287,12 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { public void open(IProgressMonitor monitor) throws CModelException { if (this.useCount == 0) { // was destroyed throw newNotPresentException(); - } + } super.open(monitor); //if (monitor != null && monitor.isCanceled()) return; //if (this.problemRequestor != null && this.problemRequestor.isActive()){ // this.problemRequestor.beginReporting(); - // TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor); + // TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor); // this.problemRequestor.endReporting(); //} } @@ -298,10 +303,10 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { @Override protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException { if (this.useCount == 0) throw newNotPresentException(); - + // create buffer - working copies may use custom buffer factory IBuffer buffer = getBufferFactory().createBuffer(this); - if (buffer == null) + if (buffer == null) return null; // set the buffer source if needed @@ -333,20 +338,22 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { // listen to buffer changes buffer.addBufferChangedListener(this); - return buffer; + return buffer; } - + /** * @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile() */ + @Override public IMarker[] reconcile() throws CModelException { reconcile(false, null); return null; } - + /** * @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws CModelException { reconcile(false, forceProblemDetection, monitor); } @@ -354,6 +361,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { /** * @see org.eclipse.cdt.core.model.IWorkingCopy#restore() */ + @Override public void restore() throws CModelException{ if (this.useCount == 0) throw newNotPresentException(); //was destroyed @@ -362,7 +370,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { if (buffer == null) return; buffer.setContents(original.getContents()); updateTimeStamp(original); - makeConsistent(null); + makeConsistent(null); } /** @@ -375,7 +383,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { } // computes fine-grain deltas in case the working copy is being reconciled already // (if not it would miss one iteration of deltas). - this.reconcile(); + this.reconcile(); } /** @@ -394,6 +402,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy { /* * @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor) throws CModelException { if (this.useCount == 0) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java index 36932ec7aa2..5ac310c1370 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandle.java @@ -8,7 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Anton Leherbauer (Wind River Systems) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import java.net.URI; @@ -42,7 +42,7 @@ import org.eclipse.jface.text.Region; abstract class CElementHandle implements ICElementHandle, ISourceReference { protected static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final ICElement[] NO_CHILDREN = new ICElement[0]; - + private ICElement fParent; private String fName; private int fType; @@ -54,7 +54,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { public CElementHandle(ICElement parent, int type, String name) { fParent= parent; fType= type; - // anonymous types are assigned a name in the index, we + // anonymous types are assigned a name in the index, we // undo this here if (name.length() > 0 && name.charAt(0)=='{') { fName= ""; //$NON-NLS-1$ @@ -64,7 +64,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { } fRegion= new Region(0,0); } - + @Override public boolean equals(Object obj) { if (obj instanceof ICElement) { @@ -79,6 +79,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { } + @Override @SuppressWarnings("rawtypes") public Object getAdapter(Class adapter) { return null; @@ -89,6 +90,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { fTimestamp= timestamp; } + @Override public ISourceRange getSourceRange() throws CModelException { IRegion region= fRegion; ITranslationUnit tu= getTranslationUnit(); @@ -103,10 +105,12 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { return new SourceRange(startpos, length); } + @Override public String getSource() throws CModelException { return null; } - + + @Override public ITranslationUnit getTranslationUnit() { ICElement parent= fParent; do { @@ -118,58 +122,72 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { while (parent != null); return null; } - + + @Override public void accept(ICElementVisitor visitor) throws CoreException { } + @Override public boolean exists() { return true; } + @Override public ICElement getAncestor(int ancestorType) { return null; } + @Override public ICModel getCModel() { return fParent.getCModel(); } + @Override public ICProject getCProject() { return fParent.getCProject(); } + @Override public String getElementName() { return fName; } + @Override public int getElementType() { return fType; } + @Override public ICElement getParent() { return fParent; } + @Override public IPath getPath() { return getTranslationUnit().getPath(); } + @Override public URI getLocationURI() { return getTranslationUnit().getLocationURI(); } - + + @Override public IResource getResource() { return getTranslationUnit().getResource(); } + @Override public IResource getUnderlyingResource() { return getResource(); } + @Override public boolean isReadOnly() { return true; } + @Override public boolean isStructureKnown() throws CModelException { return false; } @@ -185,7 +203,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { public void rename(String name, boolean replace, IProgressMonitor monitor) throws CModelException { } - + public void setTypeName(String type) throws CModelException { } @@ -224,7 +242,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { public boolean isFriend() throws CModelException { return false; } - + public boolean isInline() throws CModelException { return false; } @@ -248,7 +266,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { public String getInitializer() { return null; } - + public boolean isAbstract() throws CModelException { return false; } @@ -260,7 +278,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { public String[] getSuperClassesNames() { return EMPTY_STRING_ARRAY; } - + protected String[] extractParameterTypes(IFunction func) { IParameter[] params= func.getParameters(); String[] parameterTypes= new String[params.length]; @@ -273,7 +291,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { } return parameterTypes; } - + protected ASTAccessVisibility getVisibility(IBinding binding) { if (binding instanceof ICPPMember) { ICPPMember member= (ICPPMember) binding; @@ -292,6 +310,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { /** * @see ICElement */ + @Override public String getHandleIdentifier() { ICElement cModelElement= mapToModelElement(); if (cModelElement != null) { @@ -309,10 +328,12 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference { } } + @Override public boolean isActive() { return true; } + @Override public int getIndex() { return fIndex; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumerationHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumerationHandle.java index 0321f531be8..c1323ad2d53 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumerationHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumerationHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; @@ -21,6 +21,7 @@ public class EnumerationHandle extends CElementHandle implements org.eclipse.cdt super(parent, ICElement.C_ENUMERATION, enumeration.getName()); } + @Override public boolean isStatic() throws CModelException { return false; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumeratorHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumeratorHandle.java index 4114ae59e26..1bb1260867d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumeratorHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/EnumeratorHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; @@ -20,6 +20,7 @@ public class EnumeratorHandle extends CElementHandle implements org.eclipse.cdt. super(parent, ICElement.C_ENUMERATOR, enumerator.getName()); } + @Override public String getConstantExpression() { return null; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java index 21664def22e..2055a2a7117 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; @@ -33,11 +33,13 @@ public class FieldHandle extends CElementHandle implements org.eclipse.cdt.core. public String getTypeName() { return fTypeName; } - + + @Override public ASTAccessVisibility getVisibility() throws CModelException { return fVisibility; } + @Override public boolean isStatic() throws CModelException { return fIsStatic; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java index 9484e3377e3..1d7bbe616e9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionDeclarationHandle.java @@ -8,7 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Anton Leherbauer (Wind River Systems) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; @@ -43,22 +43,27 @@ public class FunctionDeclarationHandle extends CElementHandle implements IFuncti return false; } + @Override public int getNumberOfParameters() { return fParameterTypes.length; } + @Override public String[] getParameterTypes() { return fParameterTypes; } + @Override public String getReturnType() { return fReturnType; } - + + @Override public String getSignature() throws CModelException { return FunctionDeclaration.getSignature(this); } + @Override public boolean isStatic() throws CModelException { return fIsStatic; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionTemplateDeclarationHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionTemplateDeclarationHandle.java index 0b8b97eb01a..2250f366f9a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionTemplateDeclarationHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FunctionTemplateDeclarationHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; @@ -55,18 +55,22 @@ public class FunctionTemplateDeclarationHandle extends FunctionDeclarationHandle fTemplate.setTemplateInfo(null, args); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String getTemplateSignature() throws CModelException { return fTemplate.getTemplateSignature(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java index 39c6ca8a6f2..ee32044b52b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import org.eclipse.cdt.core.index.IIndexMacro; @@ -24,14 +24,17 @@ public class MacroHandle extends CElementHandle implements IMacro { fFunctionStyle= macro.isFunctionStyle(); } + @Override public String getIdentifierList() { return ""; //$NON-NLS-1$ } + @Override public String getTokenSequence() { return ""; //$NON-NLS-1$ } + @Override public boolean isFunctionStyle() { return fFunctionStyle; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java index ea4b3923a6b..83c35245dc5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MethodDeclarationHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; @@ -27,11 +27,11 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe private boolean fIsStatic; private boolean fIsConstructor; private boolean fIsDestructor; - + public MethodDeclarationHandle(ICElement parent, ICPPMethod method) { this(parent, ICElement.C_METHOD_DECLARATION, method); } - + protected MethodDeclarationHandle(ICElement parent, int type, ICPPMethod method) { super(parent, type, method.getName()); fParameterTypes= extractParameterTypes(method); @@ -39,7 +39,7 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe fVisibility= getVisibility(method); fIsStatic= method.isStatic(); fIsConstructor= method instanceof ICPPConstructor; - if (!fIsConstructor) + if (!fIsConstructor) fIsDestructor= method.isDestructor(); } @@ -52,34 +52,42 @@ public class MethodDeclarationHandle extends CElementHandle implements IMethodDe return false; } + @Override public int getNumberOfParameters() { return fParameterTypes.length; } + @Override public String[] getParameterTypes() { return fParameterTypes; } + @Override public String getReturnType() { return fReturnType; } - + + @Override public String getSignature() throws CModelException { return FunctionDeclaration.getSignature(this); } + @Override public boolean isStatic() throws CModelException { return fIsStatic; } + @Override public ASTAccessVisibility getVisibility() throws CModelException { return fVisibility; } - + + @Override public boolean isConstructor() throws CModelException { return fIsConstructor; } + @Override public boolean isDestructor() throws CModelException { return fIsDestructor; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/SourceRange.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/SourceRange.java index 53a7f6013a2..3a2759b387a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/SourceRange.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/SourceRange.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; @@ -23,26 +23,32 @@ public class SourceRange implements ISourceRange { fLength= length; } + @Override public int getEndLine() { return -1; } + @Override public int getIdLength() { return fLength; } + @Override public int getIdStartPos() { return fOffset; } + @Override public int getLength() { return fLength; } + @Override public int getStartLine() { return -1; } + @Override public int getStartPos() { return fOffset; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureHandle.java index 8d2d2629108..85b9418b745 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; @@ -36,34 +36,42 @@ public class StructureHandle extends CElementHandle implements IStructure { return ICElement.C_CLASS; } + @Override public IField getField(String name) { return null; } + @Override public IField[] getFields() throws CModelException { return EMPTY_FIELDS; } + @Override public IMethodDeclaration getMethod(String name) { return null; } + @Override public IMethodDeclaration[] getMethods() throws CModelException { return EMPTY_METHODS; } - + + @Override public boolean isClass() throws CModelException { return getElementType() == ICElement.C_CLASS; } + @Override public boolean isStruct() throws CModelException { return getElementType() == ICElement.C_STRUCT; } + @Override public boolean isUnion() throws CModelException { return getElementType() == ICElement.C_UNION; } + @Override public boolean isStatic() throws CModelException { return false; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureTemplateHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureTemplateHandle.java index 1e2f1ff8726..55632606c0b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureTemplateHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/StructureTemplateHandle.java @@ -8,7 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Anton Leherbauer (Wind River Systems) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import java.util.ArrayList; @@ -75,18 +75,22 @@ public class StructureTemplateHandle extends StructureHandle implements IStructu fTemplate.setTemplateInfo(null, args.toArray(new String[args.size()])); } + @Override public int getNumberOfTemplateParameters() { return fTemplate.getNumberOfTemplateParameters(); } + @Override public String[] getTemplateParameterTypes() { return fTemplate.getTemplateParameterTypes(); } + @Override public String[] getTemplateArguments() { return fTemplate.getTemplateArguments(); } + @Override public String getTemplateSignature() throws CModelException { return fTemplate.getTemplateSignature(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java index 49a24d37819..5f49ac891d6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/VariableHandle.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; @@ -29,7 +29,8 @@ public class VariableHandle extends CElementHandle implements org.eclipse.cdt.co public String getTypeName() { return fTypeName; } - + + @Override public boolean isStatic() throws CModelException { return fIsStatic; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java index 61b39f3bfe4..9be3f96767b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java @@ -58,11 +58,11 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis } return null; } - + protected IProject getProject(){ return fProject; } - + private boolean checkUpdateProvider(ICProjectDescription des, boolean recreate, boolean rescan){ Object newProvider = null; Object oldProvider = null; @@ -79,7 +79,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis newStyle = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfg); } } - + if(ref != null){ if(recreate || !ref.getID().equals(fExtId)){ try { @@ -90,52 +90,52 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis } } } - + if(newProvider == null){ if(recreate || fProvider == null || newStyle != fIsNewStyle){ newStyle = isNewStyleCfg(cfg); newProvider = createDefaultProvider(cfg, newStyle); } } - + if(newProvider != null){ if(fProvider != null){ deinitializeProvider(fProvider); oldProvider = fProvider; } - + fProvider = newProvider; if(ref != null) fExtId = ref.getID(); - + fIsNewStyle = newStyle; - + initializeProvider(fProvider); } - + fInited = true; } } - + if(newProvider != null){ postProcessProviderChange(newProvider, oldProvider); return true; } return false; } - + protected boolean isNewStyleCfg(ICConfigurationDescription des){ return CProjectDescriptionManager.getInstance().isNewStyleCfg(des); } - + protected abstract boolean isValidProvider(Object o); - + protected abstract void initializeProvider(Object o); - + protected abstract void deinitializeProvider(Object o); - + protected abstract Object createDefaultProvider(ICConfigurationDescription cfgDes, boolean newStile); - + protected void postProcessProviderChange(Object newProvider, Object oldProvider){ } @@ -146,13 +146,14 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis } } + @Override public void handleEvent(CProjectDescriptionEvent event) { if(!fProject.equals(event.getProject())) return; - + doHandleEvent(event); } - + protected boolean doHandleEvent(CProjectDescriptionEvent event){ boolean force = false; switch(event.getEventType()){ @@ -167,7 +168,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis } break; } - + return false; } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java index 0ad7c081b38..8c30a0b2c51 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSetting.java @@ -25,6 +25,7 @@ public class CBuildSetting extends CDataProxy implements ICBuildSetting { super(data, cfg, cfg); } + @Override public IPath getBuilderCWD() { CBuildData data = getBuildData(false); return data.getBuilderCWD(); @@ -34,11 +35,13 @@ public class CBuildSetting extends CDataProxy implements ICBuildSetting { return (CBuildData)getData(write); } + @Override public String[] getErrorParserIDs() { CBuildData data = getBuildData(false); return data.getErrorParserIDs(); } + @Override public ICOutputEntry[] getOutputDirectories() { CBuildData data = getBuildData(false); ICOutputEntry[] entries = data.getOutputDirectories(); @@ -47,16 +50,19 @@ public class CBuildSetting extends CDataProxy implements ICBuildSetting { return entries; } + @Override public void setBuilderCWD(IPath path) { CBuildData data = getBuildData(true); data.setBuilderCWD(path); } + @Override public void setErrorParserIDs(String[] ids) { CBuildData data = getBuildData(true); data.setErrorParserIDs(ids); } + @Override public void setOutputDirectories(ICOutputEntry[] entries) { CBuildData data = getBuildData(true); IProject project = getProject(); @@ -69,16 +75,19 @@ public class CBuildSetting extends CDataProxy implements ICBuildSetting { CExternalSettingsManager.getInstance().restoreOutputEntryDefaults(getConfiguration()); } } - + + @Override public final int getType() { return ICSettingBase.SETTING_BUILD; } + @Override public IEnvironmentContributor getBuildEnvironmentContributor() { CBuildData data = getBuildData(false); return data.getBuildEnvironmentContributor(); } + @Override public ICOutputEntry[] getResolvedOutputDirectories() { ICOutputEntry[] entries = getOutputDirectories(); return CDataUtil.resolveEntries(entries, getConfiguration()); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java index 14570e3c43a..41c7df773bc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java @@ -33,26 +33,26 @@ public class CBuildSettingCache extends CDefaultBuildData implements CBuildSettingCache(CBuildData base, CConfigurationDescriptionCache cfgCache){ super(/*base.getId(), base*/); - + fId = base.getId(); - + fCfgCache = cfgCache; - + fCfgCache.addBuildSetting(this); - + copySettingsFrom(base); } - + void initEnvironmentCache(){ fEnvironment = new StorableEnvironment( EnvironmentVariableManager.getDefault().getVariables(fCfgCache, false), true); } - + public StorableEnvironment getCachedEnvironment(){ return fEnvironment; } - + public StorableEnvironment getResolvedEnvironment(){ if(fResolvedEnvironment == null){ fResolvedEnvironment = new StorableEnvironment( @@ -62,14 +62,17 @@ public class CBuildSettingCache extends CDefaultBuildData implements return fResolvedEnvironment; } + @Override public ICConfigurationDescription getConfiguration() { return fCfgCache; } + @Override public ICSettingContainer getParent() { return fCfgCache; } + @Override public boolean isReadOnly() { return true; } @@ -98,6 +101,7 @@ public class CBuildSettingCache extends CDefaultBuildData implements return fCfgCache.getConfigurationData().getBuildData().getBuildEnvironmentContributor(); } + @Override public ICOutputEntry[] getResolvedOutputDirectories() { if(fResolvedOutputEntries == null){ ICOutputEntry[] entries = getOutputDirectories(); @@ -105,24 +109,24 @@ public class CBuildSettingCache extends CDefaultBuildData implements } return fResolvedOutputEntries; } - + @Override public ICOutputEntry[] getOutputDirectories() { initOutputEntries(); return fProjOutputEntries.clone(); } - + private void initOutputEntries(){ if(fProjOutputEntries == null){ - IProject project = getProject(); + IProject project = getProject(); fProjOutputEntries = CDataUtil.adjustEntries(fOutputEntries, true, project); } } - + private IProject getProject(){ ICConfigurationDescription cfg = getConfiguration(); return cfg.isPreferenceConfiguration() ? null : cfg.getProjectDescription().getProject(); } - + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java index 751e50cc8b5..5a14accc7c1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigExtensionReference.java @@ -33,10 +33,12 @@ public class CConfigExtensionReference implements ICConfigExtensionReference { fId = base.fId; } + @Override public String getExtensionPoint() { return fExtPoint; } + @Override public String getID() { return fId; } @@ -64,15 +66,18 @@ public class CConfigExtensionReference implements ICConfigExtensionReference { return fExtPoint.hashCode() + fId.hashCode(); } + @Override public void setExtensionData(String key, String value) throws CoreException { getInfo().setAttribute(key, value); fCfgSettings.setModified(); } + @Override public String getExtensionData(String key) { return getInfo().getAttribute(key); } + @Override public ICConfigurationDescription getConfiguration() { return fCfgSettings.getConfigurarion(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java index 0edac50159b..0f2af5f4b18 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java @@ -69,7 +69,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC super(data, cr, null); if(!(cr instanceof ICProjectDescription)) fIsPreference = true; - + if(data instanceof CConfigurationDescriptionCache) fCfgCache = (CConfigurationDescriptionCache)data; @@ -81,7 +81,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC /** * Creating a new configuration as a copy of an existing base CConfigurationDescription - * + * * @param id * @param name * @param base @@ -114,9 +114,9 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC */ CConfigurationDescription(String id, String name, ICStorageElement el, CProjectDescription projectDes) throws CoreException { super(null, projectDes, null); - + setConfiguration(this); - + ICStorageElement storage = CProjectDescriptionManager.getInstance().createStorage(projectDes, id); fCfgSpecSettings = new CConfigurationSpecSettings(this, storage, el); fCfgSpecSettings.setId(id); @@ -134,9 +134,9 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC CConfigurationDescription(String id, String name, String bsId, ICStorageElement el, ICDataProxyContainer cr) throws CoreException { super(null, cr, null); fIsPreference = true; - + setConfiguration(this); - + fCfgSpecSettings = new CConfigurationSpecSettings(this, el); fCfgSpecSettings.setId(id); fCfgSpecSettings.setName(name); @@ -152,11 +152,11 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC setData(CProjectDescriptionManager.getInstance().createData(this, cache, data, true, null)); } } - + // public CConfigurationDescriptionCache getCache(){ // return fCfgCache; // } - + @Override public String getId() { String id = super.getId(); @@ -183,11 +183,13 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return name; } + @Override public String getDescription() { CConfigurationData data = getConfigurationData(false); return data.getDescription(); } - + + @Override public CConfigurationData getConfigurationData(boolean write){ CConfigurationData data = (CConfigurationData)getData(write); if(data == null) @@ -195,6 +197,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return data; } + @Override public ICProjectDescription getProjectDescription() { if(fIsPreference) return null; @@ -205,22 +208,26 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return getRcHolder().getResourceDescriptions(kind); } + @Override public ICFolderDescription getRootFolderDescription() { return (ICFolderDescription)getRcHolder().getCurrentResourceDescription(); } + @Override public boolean isActive() { if(fIsPreference) return false; return getProjectDescription().getActiveConfiguration() == this; } - + + @Override public void setActive() throws WriteAccessException{ if(fIsPreference) return; getProjectDescription().setActiveConfiguration(this); } - + + @Override public void removeResourceDescription(ICResourceDescription des) throws CoreException { CConfigurationData data = getConfigurationData(true); @@ -229,10 +236,12 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC data.removeResourceData((CResourceData)((CDataProxy)des).getData(false)); } + @Override public final int getType() { return ICSettingBase.SETTING_CONFIGURATION; } + @Override public CDataProxy createProxy(CDataObject data) { switch(data.getType()){ case ICSettingBase.SETTING_FOLDER: @@ -242,8 +251,8 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC case ICSettingBase.SETTING_TARGET_PLATFORM: return new CTargetPlatformSetting((CTargetPlatformData)data, this); case ICSettingBase.SETTING_BUILD: - return new CBuildSetting((CBuildData)data, this); - + return new CBuildSetting((CBuildData)data, this); + } return null; } @@ -252,6 +261,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC protected IProxyProvider createChildProxyProvider() { ICDataScope scope = new ICDataScope(){ + @Override public CDataObject[] getChildren() { CConfigurationData data = getConfigurationData(false); List list = new ArrayList(); @@ -267,16 +277,17 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return list.toArray(new CDataObject[list.size()]); } + @Override public boolean isStatic() { return !containsWritableData(); } - + }; IProxyCache cache = getCfgProxyCache(); - + return new ProxyProvider(scope, cache, this); } - + protected ResourceDescriptionHolder createHolder(CFolderDescription des){ PathSettingsContainer container = des.getPathContainer(); if(container == null){ @@ -302,13 +313,13 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC fCache = new CfgProxyCache(getPathContainer()); return fCache; } - + private PathSettingsContainer getPathContainer(){ if(fPathContainer == null) fPathContainer = PathSettingsContainer.createRootContainer(); return fPathContainer; } - + private ResourceDescriptionHolder getRcHolder(){ if(fRcHolder == null) fRcHolder = new ProviderBasedRcDesHolder(getChildrenProxyProvider(), @@ -316,32 +327,39 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC true); return fRcHolder; } - + + @Override public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) { return getRcHolder().getResourceDescription(path, exactPath); } + @Override public void setDescription(String des) throws WriteAccessException { getConfigurationData(true).setDescription(des); } + @Override public ICResourceDescription[] getResourceDescriptions() { return getResourceDescriptions(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER); } + @Override public ICStorageElement getStorage(String id, boolean create) throws CoreException { return getSpecSettings().getStorage(id, create); } - + + @Override public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException, CoreException { return getSpecSettings().importStorage(id, el); } + @Override public void removeStorage(String id) throws CoreException { getSpecSettings().removeStorage(id); } + @Override public void setReadOnly(boolean readOnly, boolean keepModify) { try { getSpecSettings().setReadOnly(readOnly, keepModify); @@ -350,6 +368,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public CConfigurationSpecSettings getSpecSettings() throws CoreException{ if(fCfgSpecSettings == null){ if(fCfgCache != null){ @@ -373,6 +392,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return fCfgSpecSettings; } + @Override public String getBuildSystemId() { try { return getSpecSettings().getBuildSystemId(); @@ -381,6 +401,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return null; } + @Override public CConfigurationData getConfigurationData() { CConfigurationData data = getConfigurationData(true); if(data instanceof CConfigurationDescriptionCache){ @@ -388,7 +409,8 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } return data; } - + + @Override public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException { String oldId = getId(); setData(data); @@ -404,6 +426,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public boolean isModified() { try { CConfigurationSpecSettings settings = getSpecSettings(); @@ -413,16 +436,16 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } return !(getConfigurationData(false) instanceof CConfigurationDescriptionCache); } - + void removeConfiguration(){ // CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance(); -// CConfigurationData data = getConfigurationData(true);//fCfgCache.getBaseData(); +// CConfigurationData data = getConfigurationData(true);//fCfgCache.getBaseData(); // // try { // mngr.removeData(this, data); // } catch (CoreException e) { // } - + try { getSpecSettings().removeConfiguration(); } catch (CoreException e) { @@ -432,6 +455,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC remove(); } + @Override public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException { CConfigurationData data = getConfigurationData(true); CResourceData baseRcData = (CResourceData)((CDataProxy)base).getData(true); @@ -450,11 +474,11 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC CLanguageData baseLangData = baseLang != null ? (CLanguageData)baseLang.getData(false) : null; createdData = data.createFileData(path, (CFolderData)baseRcData, baseLangData); } - - + + if(createdData == null) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CConfigurationDescription.0")); //$NON-NLS-1$ - + CDataProxy proxy = getChildrenProxyProvider().getProxy(createdData); if(!(proxy instanceof ICFileDescription)) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CConfigurationDescription.1") + proxy.getClass().getName()); //$NON-NLS-1$ @@ -462,14 +486,15 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return (ICFileDescription)proxy; } + @Override public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException { CConfigurationData data = getConfigurationData(true); CFolderData baseRcData = (CFolderData)((CDataProxy)base).getData(true); CFolderData createdData = data.createFolderData(path, baseRcData); - + if(createdData == null) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CConfigurationDescription.2")); //$NON-NLS-1$ - + CDataProxy proxy = getChildrenProxyProvider().getProxy(createdData); if(!(proxy instanceof ICFolderDescription)) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CConfigurationDescription.3") + proxy.getClass().getName()); //$NON-NLS-1$ @@ -477,19 +502,23 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return (ICFolderDescription)proxy; } + @Override public ICTargetPlatformSetting getTargetPlatformSetting() { CConfigurationData data = getConfigurationData(false); return (ICTargetPlatformSetting)getChildrenProxyProvider().getProxy(data.getTargetPlatformData()); } + @Override public ICFileDescription[] getFileDescriptions() { return (ICFileDescription[])getRcHolder().getResourceDescriptions(ICSettingBase.SETTING_FILE); } + @Override public ICFolderDescription[] getFolderDescriptions() { return (ICFolderDescription[])getRcHolder().getResourceDescriptions(ICSettingBase.SETTING_FOLDER); } + @Override public ICSourceEntry[] getSourceEntries() { CConfigurationData data = getConfigurationData(false); ICSourceEntry[] srcEntries = data.getSourceEntries(); @@ -498,20 +527,21 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC // return getRcHolder().calculateSourceEntriesFromPaths(proj, srcPaths); } + @Override public void setSourceEntries(ICSourceEntry[] entries) throws CoreException { CConfigurationData data = getConfigurationData(true); IProject project = fIsPreference ? null : getProjectDescription().getProject(); if(entries != null){ entries = CDataUtil.adjustEntries(entries, false, project); } - + data.setSourceEntries(entries); if(entries == null){ CExternalSettingsManager.getInstance().restoreSourceEntryDefaults(this); } } - + // private ICResourceDescription createResourceDescription(IPath path, ICResourceDescription base){ // if(fIsPreference) // return null; @@ -533,10 +563,11 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC // } // } // } -// +// // return des; // } + @Override public Map getReferenceInfo() { try { CConfigurationSpecSettings specs = getSpecSettings(); @@ -546,6 +577,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return new HashMap(0); } + @Override public void setReferenceInfo(Map refs) { try { CConfigurationSpecSettings specs = getSpecSettings(); @@ -554,6 +586,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIDs, String[] extensions, ICSettingEntry[] entries) { @@ -564,6 +597,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return null; } + @Override public ICExternalSetting[] getExternalSettings() { try { return getSpecSettings().getExternalSettings(); @@ -572,6 +606,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return null; } + @Override public void removeExternalSetting(ICExternalSetting setting) { try { getSpecSettings().removeExternalSetting(setting); @@ -579,6 +614,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public void removeExternalSettings() { try { getSpecSettings().removeExternalSettings(); @@ -586,11 +622,13 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public ICBuildSetting getBuildSetting() { CConfigurationData data = getConfigurationData(false); return (ICBuildSetting)getChildrenProxyProvider().getProxy(data.getBuildData()); } + @Override public void setSessionProperty(QualifiedName name, Object value){ try { getSpecSettings().setSettionProperty(name, value); @@ -598,6 +636,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public Object getSessionProperty(QualifiedName name) { try { return getSpecSettings().getSettionProperty(name); @@ -606,15 +645,17 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return null; } + @Override public ICdtVariablesContributor getBuildVariablesContributor() { CConfigurationData data = getConfigurationData(false); return data.getBuildVariablesContributor(); } + @Override public void setName(String name) { if(name.equals(getName())) return; - + getConfigurationData(true).setName(name); try { getSpecSettings().setName(name); @@ -622,11 +663,13 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException { return getSpecSettings().create(extensionPoint, extension); } + @Override public ICConfigExtensionReference[] get(String extensionPointID) { try { return getSpecSettings().get(extensionPointID); @@ -635,31 +678,35 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return new ICConfigExtensionReference[0]; } + @Override public void remove(ICConfigExtensionReference ext) throws CoreException { getSpecSettings().remove(ext); } + @Override public void remove(String extensionPoint) throws CoreException { getSpecSettings().remove(extensionPoint); } + @Override public boolean isPreferenceConfiguration() { return fIsPreference; } - + @Override protected boolean containsWritableData(){ if(super.containsWritableData()) return true; - + CConfigurationDescriptionCache data = (CConfigurationDescriptionCache)doGetData(); return data.isInitializing(); } + @Override public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExcludeStatus) { return CProjectDescriptionManager.getLanguageSettingForFile(this, path, ignoreExcludeStatus); } - + boolean isExcluded(IPath path){ // if(path.segmentCount() == 0) // return false; @@ -689,7 +736,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC boolean canExclude(IPath path, boolean isFolder, boolean exclude){ if(isExcluded(path) == exclude) return true; - + return getUpdatedSourceEntries(path, isFolder, exclude) != null; } @@ -717,7 +764,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } } - + if(newEntries == null){ try { newEntries = CDataUtil.setExcluded(path, isFolder, exclude, getResolvedSourceEntries(), false); @@ -726,10 +773,11 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } catch (CoreException e) { } } - + return newEntries; } + @Override public String[] getExternalSettingsProviderIds() { try { return getSpecSettings().getExternalSettingsProviderIds(); @@ -739,6 +787,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC return new String[0]; } + @Override public void setExternalSettingsProviderIds(String[] ids) { try { getSpecSettings().setExternalSettingsProviderIds(ids); @@ -746,7 +795,8 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC CCorePlugin.log(e); } } - + + @Override public void updateExternalSettingsProviders(String[] ids) { try { getSpecSettings().updateExternalSettingsProviders(ids); @@ -755,11 +805,13 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC } } + @Override public ICSourceEntry[] getResolvedSourceEntries() { ICSourceEntry[] entries = getSourceEntries(); return CDataUtil.resolveEntries(entries, this); } + @Override public CConfigurationStatus getConfigurationStatus() { CConfigurationData data = getConfigurationData(false); CConfigurationStatus status = data.getStatus(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java index 95f54d667c7..0f537ed8b63 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java @@ -75,31 +75,31 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData fInitializing = true; fParent = parent; fSpecSettings = new CConfigurationSpecSettings(this, storage); - + fId = fSpecSettings.getId(); fName = fSpecSettings.getName(); - + // loadData(); } - + public boolean isInitializing(){ return fInitializing; } - + void loadData(CSettingEntryFactory factory) throws CoreException{ if(fDataLoadded) return; - + fDataLoadded = true; - + fData = CProjectDescriptionManager.getInstance().loadData(this, null); - + fSettingsFactory = factory; - + copySettingsFrom(fData, true); - + fSettingsFactory = null; - + fSpecSettings.reconcileExtensionSettings(true); ((CBuildSettingCache)fBuildData).initEnvironmentCache(); ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this); @@ -121,25 +121,25 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData fData = base; // base = CProjectDescriptionManager.getInstance().applyData(this, baseDescription, base); // fData = base; - } - + } + fBaseCache = baseCache; } - + CConfigurationDescriptionCache getBaseCache(){ return fBaseCache; } - + boolean applyData(CSettingEntryFactory factory, SettingsContext context) throws CoreException{ - boolean modified = true; + boolean modified = true; if(fBaseDescription != null){ - + fData = CProjectDescriptionManager.getInstance().applyData(this, fBaseDescription, fData, context, null); fDataLoadded = true; fName = fData.getName(); fId = fData.getId(); fSettingsFactory = factory; - + if((context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_SETTINGS_UNMODIFIED) == 0 || fBaseCache == null){ copySettingsFrom(fData, true); } else { @@ -148,26 +148,26 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData if(!modified) modified = (context.getAllConfigurationSettingsFlags() & IModificationContext.CFG_DATA_STORAGE_UNMODIFIED) == 0; } - + fSettingsFactory = null; - + ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this); fMacros = new StorableCdtVariables(vars, true); fSpecSettings.serialize(); fSpecSettings.setModified(false); - + } - + fBaseDescription = null; fBaseCache = null; - + return modified; } - + CSettingEntryFactory getSettingsFactory(){ return fSettingsFactory; } - + public StorableCdtVariables getCachedVariables(){ return fMacros; } @@ -175,7 +175,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData protected void setId(String id) throws CoreException { throw ExceptionFactory.createIsReadOnlyException(); } - + @Override public CFileData copyFileData(IPath path, CFileData base, boolean clone) { return new CFileDescriptionCache(base, this); @@ -202,20 +202,22 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData fRcHolder.addResourceDescription(des.getPath(), des); fChildList.add(des); } - + void addTargetPlatformSetting(ICTargetPlatformSetting tpS){ fChildList.add(tpS); } - + void addBuildSetting(ICBuildSetting bs){ fChildList.add(bs); fBuildData = (CBuildData)bs; } + @Override public ICProjectDescription getProjectDescription() { return fParent; } + @Override public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) { return fRcHolder.getResourceDescription(path, exactPath); } @@ -224,16 +226,19 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return fRcHolder.getResourceDescriptions(kind); } + @Override public ICFolderDescription getRootFolderDescription() { return (ICFolderDescription)fRootFolderData; } + @Override public boolean isActive() { if(isPreferenceConfiguration()) return false; return fParent.getActiveConfiguration() == this; } + @Override public void removeResourceDescription(ICResourceDescription des) throws CoreException { throw new CoreException(new DescriptionStatus(SettingsModelMessages.getString("CConfigurationDescriptionCache.0"))); //$NON-NLS-1$ @@ -269,46 +274,57 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData throw ExceptionFactory.createIsReadOnlyException(); } + @Override public ICSettingObject[] getChildSettings() { return fChildList.toArray(new ICSettingObject[fChildList.size()]); } + @Override public ICConfigurationDescription getConfiguration() { return this; } + @Override public ICSettingContainer getParent() { return fParent; } + @Override public ICResourceDescription[] getResourceDescriptions() { return fRcHolder.getResourceDescriptions(); } - + + @Override public ICStorageElement getStorage(String id, boolean create) throws CoreException { return getSpecSettings().getStorage(id, create); } - + + @Override public void removeStorage(String id) throws CoreException { getSpecSettings().removeStorage(id); } - + + @Override public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException, CoreException { return getSpecSettings().importStorage(id, el); } + @Override public CConfigurationSpecSettings getSpecSettings() /*throws CoreException*/{ return fSpecSettings; } + @Override public String getBuildSystemId() { return fSpecSettings.getBuildSystemId(); } + @Override public CConfigurationData getConfigurationData() { return fData; } + @Override public void setConfigurationData(String bsId, CConfigurationData data) throws WriteAccessException { throw ExceptionFactory.createIsReadOnlyException(); } @@ -318,42 +334,49 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return false; } + @Override public CConfigurationData getConfigurationData(boolean write) throws WriteAccessException { if(write) throw ExceptionFactory.createIsReadOnlyException(); - + return this; } + @Override public void setActive() throws WriteAccessException { throw ExceptionFactory.createIsReadOnlyException(); } - + /* public CConfigurationData getBaseData(){ return fData; } */ + @Override public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException { throw ExceptionFactory.createIsReadOnlyException(); } + @Override public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException { throw ExceptionFactory.createIsReadOnlyException(); } - + ResourceDescriptionHolder createHolderForRc(IPath path){ return new ResourceDescriptionHolder(fPathSettingContainer.getChildContainer(path, true, true), false); } + @Override public boolean isReadOnly() { return !fInitializing; } + @Override public void setReadOnly(boolean readOnly, boolean keepModify) { if (readOnly) throw ExceptionFactory.createIsReadOnlyException(); } + @Override public ICTargetPlatformSetting getTargetPlatformSetting() { return (ICTargetPlatformSetting)getTargetPlatformData(); } @@ -363,10 +386,12 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return new CTargetPlatformSettingCache(base, this); } + @Override public ICFileDescription[] getFileDescriptions() { return (ICFileDescription[])fRcHolder.getResourceDescriptions(ICSettingBase.SETTING_FILE); } + @Override public ICFolderDescription[] getFolderDescriptions() { return (ICFolderDescription[])fRcHolder.getResourceDescriptions(ICSettingBase.SETTING_FOLDER); } @@ -380,14 +405,14 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData initSourceEntries(); return fProjSourceEntries.clone(); } - + private void initSourceEntries(){ if(fProjSourceEntries == null){ - IProject project = getProject(); + IProject project = getProject(); fProjSourceEntries = CDataUtil.adjustEntries(fSourceEntries, true, project); } } - + private IProject getProject(){ return isPreferenceConfiguration() ? null : getProjectDescription().getProject(); } @@ -397,50 +422,59 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData throw ExceptionFactory.createIsReadOnlyException(); } + @Override public Map getReferenceInfo() { return getSpecSettings().getReferenceInfo(); } + @Override public void setReferenceInfo(Map refs) { throw ExceptionFactory.createIsReadOnlyException(); } + @Override public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIds, String[] extensions, ICSettingEntry[] entries) { if(!fInitializing) throw ExceptionFactory.createIsReadOnlyException(); - + return fSpecSettings.createExternalSetting(languageIDs, contentTypeIds, extensions, entries); } + @Override public ICExternalSetting[] getExternalSettings() { return fSpecSettings.getExternalSettings(); } + @Override public void removeExternalSetting(ICExternalSetting setting) { if(!fInitializing) throw ExceptionFactory.createIsReadOnlyException(); - + fSpecSettings.removeExternalSetting(setting); } + @Override public void removeExternalSettings() { if(!fInitializing) throw ExceptionFactory.createIsReadOnlyException(); - + fSpecSettings.removeExternalSettings(); } - + + @Override public ICBuildSetting getBuildSetting() { return (ICBuildSetting)getBuildData(); } + @Override public void setSessionProperty(QualifiedName name, Object value) { fSpecSettings.setSettionProperty(name, value); //throw ExceptionFactory.createIsReadOnlyException(); } + @Override public Object getSessionProperty(QualifiedName name) { return fSpecSettings.getSettionProperty(name); } @@ -450,6 +484,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return fData.getBuildVariablesContributor(); } + @Override public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException { if(!fInitializing) @@ -457,32 +492,37 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return fSpecSettings.create(extensionPoint, extension); } + @Override public ICConfigExtensionReference[] get(String extensionPointID) { return fSpecSettings.get(extensionPointID); } + @Override public void remove(ICConfigExtensionReference ext) throws CoreException { if(!fInitializing) throw ExceptionFactory.createIsReadOnlyException(); fSpecSettings.remove(ext); } + @Override public void remove(String extensionPoint) throws CoreException { if(!fInitializing) throw ExceptionFactory.createIsReadOnlyException(); fSpecSettings.remove(extensionPoint); } - + + @Override public boolean isPreferenceConfiguration() { return getProjectDescription() == null; } - + void doneInitialization(){ CProjectDescriptionManager.getInstance().notifyCached(this, fData, null); fInitializing = false; fSpecSettings.doneInitialization(); } - + + @Override public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExcludeStatus) { return CProjectDescriptionManager.getLanguageSettingForFile(this, path, ignoreExcludeStatus); } @@ -502,26 +542,30 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData IProject project = getProject(); if(project != null) path = project.getFullPath().append(path); - + return CDataUtil.isExcluded(path, fProjSourceEntries); } + @Override public String[] getExternalSettingsProviderIds() { return fSpecSettings.getExternalSettingsProviderIds(); } + @Override public void setExternalSettingsProviderIds(String[] ids) { if(!fInitializing) throw ExceptionFactory.createIsReadOnlyException(); fSpecSettings.setExternalSettingsProviderIds(ids); } + @Override public void updateExternalSettingsProviders(String[] ids) { if(!fInitializing) throw ExceptionFactory.createIsReadOnlyException(); fSpecSettings.updateExternalSettingsProviders(ids); } + @Override public ICSourceEntry[] getResolvedSourceEntries() { if(fResolvedSourceEntries == null){ ICSourceEntry[] entries = getSourceEntries(); @@ -530,6 +574,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData return fResolvedSourceEntries; } + @Override public CConfigurationStatus getConfigurationStatus() { CConfigurationStatus status = getStatus(); return status != null ? status : CConfigurationStatus.CFG_STATUS_OK; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java index ae5a488764f..416bce252a1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java @@ -16,8 +16,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.CExternalSetting; @@ -267,10 +267,12 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ return fSettingsStorageElement; } + @Override public ICStorageElement getStorage(String id,boolean create) throws CoreException { return getStorageBase().getStorage(id, create); } + @Override public void removeStorage(String id) throws CoreException { getStorageBase().removeStorage(id); } @@ -389,10 +391,12 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ encodeProjectExtensions(extEl); } + @Override public boolean isReadOnly(){ return fCfg.isReadOnly(); } + @Override public void setReadOnly(boolean readOnly, boolean keepModify) { fCfg.setReadOnly(readOnly, keepModify); } @@ -499,6 +503,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ fExtSettingsProvider.removeExternalSettings(); } + @Override public boolean isModified(){ if(fIsModified) return true; @@ -838,6 +843,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ } } + @Override public ICStorageElement importStorage(String id, ICStorageElement el) throws CoreException { return getStorageBase().importStorage(id, el); } @@ -902,7 +908,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ } return null; } - + private DeltaSet getReferenceDelta(ICConfigExtensionReference refs[], String[] extIds){ if(refs == null || refs.length == 0){ @@ -913,16 +919,16 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ Map map = createRefMap(refs); return new DeltaSet(new HashSet(map.values()), null); } - + Set idSet = new HashSet(Arrays.asList(extIds)); Set idSetCopy = new HashSet(idSet); Map refsMap = createRefMap(refs); - + idSet.removeAll(refsMap.keySet()); refsMap.keySet().removeAll(idSetCopy); - + Set extSet = new HashSet(refsMap.values()); - + return new DeltaSet(extSet, idSet); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java index f2c0aa3548a..068ce5f1161 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxy.java @@ -23,10 +23,10 @@ public abstract class CDataProxy implements ICSettingObject { private int fFlags; private CConfigurationDescription fConfiguration; private String fId; - + private static final int F_RESCAN = 1; // private static final int F_WRITABLE = 1 << 1; - + CDataProxy(CDataObject data, ICDataProxyContainer parent, CConfigurationDescription cfg) { fData = data; if(fData != null) @@ -35,26 +35,27 @@ public abstract class CDataProxy implements ICSettingObject { fConfiguration = cfg; } + @Override public ICSettingContainer getParent() { return fParent; } - + protected void setRescan(boolean rescan){ if(isRescan() == rescan) return; - + if(rescan) addFlags(F_RESCAN); else clearFlags(F_RESCAN); } - + protected boolean isRescan(){ if(checkFlags(F_RESCAN)) return true; return false;//fData == null ? true : !fData.isValid(); } - + private boolean checkFlags(int flags){ return (fFlags & flags) == flags; } @@ -66,16 +67,16 @@ public abstract class CDataProxy implements ICSettingObject { private void clearFlags(int flags){ fFlags &= (~flags); } - + protected CDataObject getData(boolean write){ checkUpdate(write); - return fData; + return fData; } - + protected CDataObject doGetData(){ return fData; } - + protected boolean containsWritableData(){ return !(fData instanceof ICachedData); } @@ -88,35 +89,35 @@ public abstract class CDataProxy implements ICSettingObject { else clearFlags(F_WRITABLE); } -*/ +*/ /* void setData(CDataObject data, boolean write){ fData = data; setWritable(write); setRescan(false); } */ - + /* void updateData(CDataObject data){ fData = data; setRescan(false); } -*/ +*/ void setData(CDataObject data){ fId = data.getId(); fData = data; } - + void internalSetId(String id){ fId = id; } - + void doClearData(){ fData = null; setRescan(true); } final protected void checkUpdate(boolean write){ - if((write && !containsWritableData()) + if((write && !containsWritableData()) || isRescan()) fParent.updateChild(this, write); } @@ -125,16 +126,19 @@ public abstract class CDataProxy implements ICSettingObject { fData = null; fParent = null; } - + + @Override public boolean isValid(){ checkUpdate(false); return fData != null ? fData.isValid() : false; } - + + @Override public ICConfigurationDescription getConfiguration() { return fConfiguration; } + @Override public String getId() { return fId; // CDataObject data = getData(false); @@ -146,31 +150,33 @@ public abstract class CDataProxy implements ICSettingObject { return data != null ? data.getKind() : 0; } */ + @Override public String getName() { CDataObject data = getData(false); return data != null ? data.getName() : null; } - + void setConfiguration(CConfigurationDescription cfg){ fConfiguration = cfg; } - + + @Override public boolean isReadOnly() { return false; } - + protected IProject getProject(){ ICConfigurationDescription cfg = getConfiguration(); if(cfg == null) return null; - + ICProjectDescription projDes = cfg.getProjectDescription(); if(projDes == null) return null; - + return projDes.getProject(); } - + /** * This method is intended for debugging purpose only. */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java index 80d77ab7f63..b93a4b2cbf1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CDataProxyContainer.java @@ -15,11 +15,11 @@ import org.eclipse.cdt.core.settings.model.extension.CDataObject; public abstract class CDataProxyContainer extends CDataProxy implements ICDataProxyContainer{ private IProxyProvider fChildProxyProvider; - + CDataProxyContainer(CDataObject data, ICDataProxyContainer parent, CConfigurationDescription cfg) { super(data, parent, cfg); } - + /* protected class ChildrenDataScope implements ICDataScope{ public boolean isStatic() { return isWritable(); @@ -40,7 +40,7 @@ public abstract class CDataProxyContainer extends CDataProxy implements ICDataPr return provider.getProxy(id); } - + public ICSettingObject[] getChildrenOfKind(int kind){ IProxyProvider provider = getChildrenProxyProvider(); @@ -56,9 +56,10 @@ public abstract class CDataProxyContainer extends CDataProxy implements ICDataPr fChildProxyProvider = createChildProxyProvider(); return fChildProxyProvider; } - + protected abstract IProxyProvider createChildProxyProvider(); + @Override public ICSettingObject[] getChildSettings() { IProxyProvider provider = getChildrenProxyProvider(); @@ -68,29 +69,30 @@ public abstract class CDataProxyContainer extends CDataProxy implements ICDataPr return provider.getProxies(); } + @Override public void updateChild(CDataProxy child, boolean write){ getData(write); getChildrenProxyProvider().cacheValues(); } - + @Override protected void setRescan(boolean rescan){ if(isRescan() == rescan) return; - + super.setRescan(rescan); - + if(rescan){ setRescanChildren(); } } - + @Override void setData(CDataObject data) { super.setData(data); setRescanChildren(); } - + protected void setRescanChildren(){ IProxyProvider provider = getChildrenProxyProvider(); if(provider == null) @@ -102,12 +104,12 @@ public abstract class CDataProxyContainer extends CDataProxy implements ICDataPr for(int i = 0; i < proxies.length; i++){ proxies[i].setRescan(true); } - + } public ICSettingObject getChildSettingById(String id) { return getChildrenProxyProvider().getProxy(id); } - - + + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java index 1368e5063a9..6f8c9966869 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java @@ -42,13 +42,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP private static final int OP_CHANGED = 1; private static final int OP_ADDED = 2; private static final int OP_REMOVED = 3; - + private static final QualifiedName EXTERNAL_SETTING_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "externalSettings"); //$NON-NLS-1$ private static final String EXTERNAL_SETTING_STORAGE_ID = CCorePlugin.PLUGIN_ID + ".externalSettings"; //$NON-NLS-1$ - + private Map fFactoryMap = new HashMap(); private static CExternalSettingsManager fInstance; - + private CExternalSettingsManager(){ } @@ -67,14 +67,14 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); } - + public static CExternalSettingsManager getInstance(){ if(fInstance == null){ fInstance = new CExternalSettingsManager(); } return fInstance; } - + /** * A simple class representing an external settings container. * These are uniquely identifiable by the factoryId + factory @@ -83,7 +83,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP public final static class CContainerRef { private final String fFactoryId; private final String fContainerId; - + public CContainerRef(String factoryId, String containerId){ fFactoryId = factoryId; fContainerId = containerId; @@ -101,15 +101,15 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP public boolean equals(Object obj) { if(obj == this) return true; - + if(obj == null) return false; - + if(!(obj instanceof CContainerRef)) return false; - + CContainerRef other = (CContainerRef)obj; - + if(!fContainerId.equals(other.fContainerId)) return false; @@ -129,14 +129,14 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP private static class ContainerDescriptor { private FactoryDescriptor fFactoryDr; private CExternalSettingsHolder fHolder; - + private CExternalSettingsContainer fContainer; /** Stash error messages so we're not too noisy if things go wrong */ private static Set failingProvidersMessages; private ContainerDescriptor(FactoryDescriptor factoryDr, - String containerId, + String containerId, IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings){ @@ -162,7 +162,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } return fHolder.getExternalSettings(); } - + } /** @@ -170,13 +170,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP */ static class NullContainer extends CExternalSettingsContainer { static final NullContainer INSTANCE = new NullContainer(); - + @Override public CExternalSetting[] getExternalSettings() { return new CExternalSetting[0]; } } - + private static class NullFactory extends CExternalSettingContainerFactory { static NullFactory INSTANCE = new NullFactory(); @@ -186,15 +186,15 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return NullContainer.INSTANCE; } } - + private class FactoryDescriptor { private CExternalSettingContainerFactory fFactory; private String fId; - + private FactoryDescriptor(String id){ fId = id; } - + private CExternalSettingContainerFactory getFactory(){ if(fFactory == null){ fFactory = createFactory(fId); @@ -203,7 +203,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } return fFactory; } - + private CExternalSettingContainerFactory createFactory(String id) { if(id.equals(CfgExportSettingContainerFactory.FACTORY_ID)) return CfgExportSettingContainerFactory.getInstance(); @@ -211,7 +211,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return ExtensionContainerFactory.getInstance(); return NullFactory.INSTANCE; } - + public void shutdown(){ if(fFactory != null){ fFactory.removeListener(CExternalSettingsManager.this); @@ -220,35 +220,36 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } } } - + private interface ICfgContainer { ICConfigurationDescription getConfguration(boolean write); } - + private static class CfgContainer implements ICfgContainer { private ICConfigurationDescription fCfgDes; - + CfgContainer(ICConfigurationDescription cfgDes){ fCfgDes = cfgDes; } - + + @Override public ICConfigurationDescription getConfguration(boolean write) { return fCfgDes; } - + } - + private class CfgContainerRefInfoContainer { private ICfgContainer fCfgContainer; private CSettingsRefInfo fRefInfo; private boolean fWriteWasRequested; - + CfgContainerRefInfoContainer(ICfgContainer container){ fCfgContainer = container; } - + public CSettingsRefInfo getRefInfo(boolean write) { - if(fRefInfo == null + if(fRefInfo == null || (write && !fWriteWasRequested)){ ICConfigurationDescription cfg = fCfgContainer.getConfguration(write); fRefInfo = CExternalSettingsManager.this.getRefInfo(cfg, write); @@ -257,20 +258,20 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return fRefInfo; } } - + private static class HolderContainer { private CfgContainerRefInfoContainer fRIContainer; private CRefSettingsHolder fHolder; private boolean fWriteWasRequested; private CContainerRef fCRef; - + HolderContainer(CfgContainerRefInfoContainer cr, CContainerRef cref){ fRIContainer = cr; fCRef = cref; } - + CRefSettingsHolder getHolder(boolean write){ - if(fHolder == null + if(fHolder == null || (write && !fWriteWasRequested)){ CSettingsRefInfo ri = fRIContainer.getRefInfo(write); fHolder = ri.get(fCRef); @@ -278,42 +279,43 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } return fHolder; } - + void setHolder(CRefSettingsHolder holder){ fRIContainer.getRefInfo(true).put(holder); fWriteWasRequested = true; fHolder = holder; } - + void removeHolder(){ fWriteWasRequested = true; fHolder = null; fRIContainer.getRefInfo(true).remove(fCRef); } } - + private static class CfgListCfgContainer implements ICfgContainer{ private ProjDesCfgList fList; private int fNum; - + CfgListCfgContainer(ProjDesCfgList list, int num){ fList = list; fNum = num; } - + + @Override public ICConfigurationDescription getConfguration(boolean write) { return fList.get(fNum, write); } } - + /** - * A simple container type that contains a Project Description & and associated list + * A simple container type that contains a Project Description & and associated list * of configuration descriptions. */ private static class ProjDesCfgList { private ICProjectDescription fProjDes; private List fCfgList = new ArrayList(); - + public ProjDesCfgList(ICProjectDescription des, Set idSet){ fProjDes = des; ICConfigurationDescription[] cfgs = des.getConfigurations(); @@ -326,14 +328,14 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP public boolean isWritable(){ return !fProjDes.isReadOnly(); } - + public ICConfigurationDescription get(int num, boolean write) { if(write && fProjDes.isReadOnly()){ makeWritable(); } return fCfgList.get(num); } - + private void makeWritable(){ ICProjectDescription writeDes = CProjectDescriptionManager.getInstance().getProjectDescription(fProjDes.getProject()); fProjDes = writeDes; @@ -346,12 +348,12 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP fCfgList.remove(i); } } - + public int size() { return fCfgList.size(); } } - + private FactoryDescriptor getFactoryDescriptor(String id){ FactoryDescriptor dr = fFactoryMap.get(id); if(dr == null){ @@ -360,20 +362,21 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } return dr; } - + CExternalSettingContainerFactory getFactory(String id){ FactoryDescriptor dr = getFactoryDescriptor(id); return dr.getFactory(); } - private volatile IWorkspaceRunnable workspaceReconcileRunnable; + private volatile IWorkspaceRunnable workspaceReconcileRunnable; /** * External settings call-back from the setting container factories * to notify that settings have changed in a container. - * + * * Schedules a runnable to update any referencing projects */ + @Override public void settingsChanged(final IProject project, final String cfgId, final CExternalSettingChangeEvent event) { // Performance: If workspace reconcile already scheduled, then nothing to do... // Current project && cfgId always null (i.e. always reconcile at the workspace level) but don't assume this for the future @@ -385,6 +388,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP // Modifying the project description in an asynchronous runnable is likely bad... // Unfortunately there's nothing else we can do as it's not safe to modify the referencing configurations in place r = new IWorkspaceRunnable() { + @Override @SuppressWarnings("unchecked") public void run(IProgressMonitor monitor) throws CoreException { // Unset workspaceReconcileRunnable @@ -483,36 +487,36 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return new ProjDesCfgList(des, cfgIdSet); } - - private boolean processContainerChange(int op, - ICfgContainer cr, - CfgContainerRefInfoContainer riContainer, + + private boolean processContainerChange(int op, + ICfgContainer cr, + CfgContainerRefInfoContainer riContainer, CContainerRef crInfo){ ICConfigurationDescription cfg = cr.getConfguration(false); - ExtSettingsDelta[] deltas = checkExternalSettingsChange(op, + ExtSettingsDelta[] deltas = checkExternalSettingsChange(op, cfg.getProjectDescription().getProject(), cfg, riContainer, crInfo); - + if(deltas != null) return CExternalSettingsDeltaProcessor.applyDelta(cr.getConfguration(true), deltas); return false; } - + private static class RefInfoContainer{ CSettingsRefInfo fRefInfo; int fInstanceId; - + RefInfoContainer(CSettingsRefInfo ri, int id){ fRefInfo = ri; fInstanceId = id; } } - + private CSettingsRefInfo getRefInfo(ICConfigurationDescription cfg, boolean write){ if(write && cfg.isReadOnly()) throw new IllegalArgumentException(SettingsModelMessages.getString("CExternalSettingsManager.3")); //$NON-NLS-1$ - + RefInfoContainer cr = (RefInfoContainer)cfg.getSessionProperty(EXTERNAL_SETTING_PROPERTY); CSettingsRefInfo ri; boolean setCr = false; @@ -528,15 +532,15 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP ri = cr.fRefInfo; setCr = false; } - + if(setCr){ cr = new RefInfoContainer(ri, cfg.hashCode()); cfg.setSessionProperty(EXTERNAL_SETTING_PROPERTY, cr); } - + return ri; } - + private CSettingsRefInfo load(ICConfigurationDescription cfg){ try { ICStorageElement el = cfg.getStorage(EXTERNAL_SETTING_STORAGE_ID, false); @@ -556,13 +560,14 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP * writable, store cached external settings into the configuration * - LOADED: Check whether a reconcile is needed and update the settings atomically */ + @Override public void handleEvent(CProjectDescriptionEvent event) { switch(event.getEventType()){ case CProjectDescriptionEvent.DATA_APPLIED: { ICProjectDescription des = event.getNewCProjectDescription(); if(des == null) return; - + ICConfigurationDescription[] cfgs = des.getConfigurations(); for(int i = 0; i < cfgs.length; i++){ ICConfigurationDescription cfg = cfgs[i]; @@ -577,7 +582,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP // If the project description has no references, short-circuit: boolean needsReconcile = false; for (ICConfigurationDescription desc : event.getNewCProjectDescription().getConfigurations()) { - if (!desc.getReferenceInfo().isEmpty() || + if (!desc.getReferenceInfo().isEmpty() || (desc.getExternalSettingsProviderIds() != null && desc.getExternalSettingsProviderIds().length > 0)) { needsReconcile = true; break; @@ -591,6 +596,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP // us to reconcile / update the cached configuration during load final IProject project = event.getProject(); IWorkspaceRunnable r = new IWorkspaceRunnable(){ + @Override @SuppressWarnings("unchecked") public void run(IProgressMonitor monitor) throws CoreException { if (!project.isAccessible()) @@ -631,12 +637,12 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP CCorePlugin.log(e); } } - + public void containerContentsChanged(ICConfigurationDescription cfg, CContainerRef cr){ CfgContainer ccr = new CfgContainer(cfg); processContainerChange(OP_CHANGED, ccr, new CfgContainerRefInfoContainer(ccr), cr); } - + public void addContainer(ICConfigurationDescription cfg, CContainerRef cr){ CfgContainer ccr = new CfgContainer(cfg); processContainerChange(OP_ADDED, ccr, new CfgContainerRefInfoContainer(ccr), cr); @@ -646,16 +652,16 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP CfgContainer ccr = new CfgContainer(cfg); processContainerChange(OP_REMOVED, ccr, new CfgContainerRefInfoContainer(ccr), cr); } - + public CContainerRef[] getReferences(ICConfigurationDescription cfg, String factoryId){ CSettingsRefInfo info = getRefInfo(cfg, false); return info.getReferences(factoryId); } - - private ExtSettingsDelta[] checkExternalSettingsChange(int op, - IProject proj, - ICConfigurationDescription cfgDes, - CfgContainerRefInfoContainer riContainer, + + private ExtSettingsDelta[] checkExternalSettingsChange(int op, + IProject proj, + ICConfigurationDescription cfgDes, + CfgContainerRefInfoContainer riContainer, CContainerRef cr){ HolderContainer hCr = new HolderContainer(riContainer, cr); CRefSettingsHolder holder = hCr.getHolder(false); @@ -688,7 +694,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP hCr.removeHolder(); return deltas; } - + public void restoreSourceEntryDefaults(ICConfigurationDescription cfg){ CfgContainer cr = new CfgContainer(cfg); CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java index 49a07e96697..95e95ceea01 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescription.java @@ -31,21 +31,25 @@ public class CFileDescription extends CDataProxyContainer implements super(data, cfg, cfg); } + @Override public IPath getPath() { CResourceData data = (CResourceData)getData(false); return ResourceDescriptionHolder.normalizePath(data.getPath()); } + @Override public boolean isExcluded() { CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration(); return cfg.isExcluded(getPath()); } + @Override public void setExcluded(boolean excluded) { CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration(); cfg.setExcluded(getPath(), false, excluded); } + @Override public void setPath(IPath path) { path = ResourceDescriptionHolder.normalizePath(path); if(getPath().equals(path)) @@ -53,7 +57,7 @@ public class CFileDescription extends CDataProxyContainer implements CResourceData data = (CResourceData)getData(true); data.setPath(path); } - + @Override void setData(CDataObject data) { super.setData(data); @@ -64,20 +68,24 @@ public class CFileDescription extends CDataProxyContainer implements } } + @Override public IPath getCachedPath() { if(fCache != null) return fCache.getPath(); return null; } + @Override public final int getType() { return ICSettingBase.SETTING_FILE; } + @Override public void setPathContainer(PathSettingsContainer cr) { fCache = cr; } + @Override public ICLanguageSetting getLanguageSetting() { CFileData data = getFileData(false); IProxyProvider provider = getChildrenProxyProvider(); @@ -86,7 +94,7 @@ public class CFileDescription extends CDataProxyContainer implements return (ICLanguageSetting)provider.getProxy(lData); return null; } - + protected CFileData getFileData(boolean write){ return (CFileData)getData(write); } @@ -95,26 +103,29 @@ public class CFileDescription extends CDataProxyContainer implements protected IProxyProvider createChildProxyProvider() { ICDataScope scope = new ICDataScope(){ + @Override public CDataObject[] getChildren() { return new CLanguageData[]{getFileData(false).getLanguageData()}; } + @Override public boolean isStatic() { return !containsWritableData(); } - + }; IProxyCache cache = new MapProxyCache(); - + return new ProxyProvider(scope, cache, this); } - + + @Override public CDataProxy createProxy(CDataObject data) { if(data instanceof CLanguageData) return new CLanguageSetting((CLanguageData)data, this, (CConfigurationDescription)getConfiguration()); return null; } - + private ResourceDescriptionHolder getRcHolder(){ if(fRcHolder == null){ fRcHolder = ((CConfigurationDescription)getConfiguration()).createHolder(this); @@ -122,14 +133,17 @@ public class CFileDescription extends CDataProxyContainer implements return fRcHolder; } + @Override public ICFolderDescription getParentFolderDescription() { return getRcHolder().getParentFolderDescription(); } + @Override public PathSettingsContainer getPathContainer() { return fCache; } + @Override public boolean canExclude(boolean exclude) { CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration(); return cfg.canExclude(getPath(), false, exclude); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java index 873c832446a..ec209fc84c8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFileDescriptionCache.java @@ -34,16 +34,18 @@ public class CFileDescriptionCache extends CDefaultFileData implements copyDataFrom(base, true); } - + @Override protected CLanguageData copyLanguageData(CLanguageData data, boolean clone) { return new CLanguageSettingCache(data, this); } + @Override public void setExcluded(boolean excluded) throws WriteAccessException { throw ExceptionFactory.createIsReadOnlyException(); } - + + @Override public boolean canExclude(boolean exclude) { return exclude == isExcluded(); } @@ -59,26 +61,31 @@ public class CFileDescriptionCache extends CDefaultFileData implements throw ExceptionFactory.createIsReadOnlyException(); } + @Override public ICConfigurationDescription getConfiguration() { return fCfg; } + @Override public ICSettingContainer getParent() { return fCfg; } + @Override public ICLanguageSetting getLanguageSetting() { return (ICLanguageSetting)fLanguageData; } + @Override public ICSettingObject[] getChildSettings() { return new ICSettingObject[]{(ICSettingObject)fLanguageData}; } + @Override public boolean isReadOnly() { return true; } - + private ResourceDescriptionHolder getRcDesHolder(){ if(fRcDesHolder == null) fRcDesHolder = fCfg.createHolderForRc(getPath()); @@ -86,6 +93,7 @@ public class CFileDescriptionCache extends CDefaultFileData implements } + @Override public ICFolderDescription getParentFolderDescription() { return getRcDesHolder().getParentFolderDescription(); } @@ -100,6 +108,7 @@ public class CFileDescriptionCache extends CDefaultFileData implements return true; } + @Override public boolean isExcluded() { return fCfg.isExcluded(getPath()); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java index f030725d679..63e98ae13b2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescription.java @@ -27,32 +27,36 @@ public class CFolderDescription extends CDataProxyContainer implements ICFolderDescription, IProxyFactory, IInternalResourceDescription { private ResourceDescriptionHolder fRcHolder; private PathSettingsContainer fCache; - + CFolderDescription(CFolderData data, CConfigurationDescription cfg) { super(data, cfg, cfg); } + @Override public IPath getPath() { CResourceData data = (CResourceData)getData(false); return ResourceDescriptionHolder.normalizePath(data.getPath()); } + @Override public boolean isExcluded() { CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration(); return cfg.isExcluded(getPath()); } + @Override public void setExcluded(boolean excluded) { CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration(); cfg.setExcluded(getPath(), true, excluded); } + @Override public void setPath(IPath path) { path = ResourceDescriptionHolder.normalizePath(path); if(getPath().equals(path)) return; - + CResourceData data = (CResourceData)getData(true); data.setPath(path); } @@ -65,36 +69,42 @@ public class CFolderDescription extends CDataProxyContainer implements protected IProxyProvider createChildProxyProvider() { ICDataScope scope = new ICDataScope(){ + @Override public CDataObject[] getChildren() { return getFolderData(false).getLanguageDatas(); } + @Override public boolean isStatic() { return !containsWritableData(); } - + }; IProxyCache cache = new MapProxyCache(); - + return new ProxyProvider(scope, cache, this); } + @Override public ICResourceDescription getNestedResourceDescription(IPath relPath, boolean exactPath) { return getRcHolder().getResourceDescription(relPath, exactPath); } + @Override public ICResourceDescription[] getNestedResourceDescriptions(int kind) { return getRcHolder().getResourceDescriptions(kind); } + @Override public ICLanguageSetting getLanguageSettingForFile(String fileName) { IProject project = getConfiguration().getProjectDescription().getProject(); return CProjectDescriptionManager.getInstance().findLanguagSettingForFile(fileName, project, getLanguageSettings()); } + @Override public ICLanguageSetting[] getLanguageSettings() { IProxyProvider provider = getChildrenProxyProvider(); CFolderData data = (CFolderData)getData(false); @@ -107,12 +117,13 @@ public class CFolderDescription extends CDataProxyContainer implements } + @Override public CDataProxy createProxy(CDataObject data) { if(data instanceof CLanguageData) return new CLanguageSetting((CLanguageData)data, this, (CConfigurationDescription)getConfiguration()); return null; } - + private ResourceDescriptionHolder getRcHolder(){ if(fRcHolder == null){ fRcHolder = ((CConfigurationDescription)getConfiguration()).createHolder(this); @@ -130,43 +141,50 @@ public class CFolderDescription extends CDataProxyContainer implements } } + @Override public IPath getCachedPath() { if(fCache != null) return fCache.getPath(); return null; } + @Override public final int getType() { return ICSettingBase.SETTING_FOLDER; } + @Override public void setPathContainer(PathSettingsContainer cr) { fCache = cr; } - + + @Override public PathSettingsContainer getPathContainer(){ return fCache; } + @Override public ICResourceDescription[] getNestedResourceDescriptions() { return getNestedResourceDescriptions(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER); } + @Override public ICFolderDescription getParentFolderDescription() { return getRcHolder().getParentFolderDescription(); } + @Override public ICLanguageSetting createLanguageSettingForContentTypes( String languageId, String[] typeIds) throws CoreException { CFolderData data = getFolderData(true); - + CLanguageData lData = data.createLanguageDataForContentTypes(languageId, typeIds); if(lData == null) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CFolderDescription.0")); //$NON-NLS-1$ - + CDataProxy proxy = getChildrenProxyProvider().getProxy(lData); if(!(proxy instanceof ICLanguageSetting)) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CFolderDescription.1") + proxy.getClass().getName()); //$NON-NLS-1$ @@ -175,14 +193,15 @@ public class CFolderDescription extends CDataProxyContainer implements } + @Override public ICLanguageSetting createLanguageSettingForExtensions( String languageId, String[] extensions) throws CoreException { CFolderData data = getFolderData(true); - + CLanguageData lData = data.createLanguageDataForExtensions(languageId, extensions); if(lData == null) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CFolderDescription.2")); //$NON-NLS-1$ - + CDataProxy proxy = getChildrenProxyProvider().getProxy(lData); if(!(proxy instanceof ICLanguageSetting)) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CFolderDescription.3") + proxy.getClass().getName()); //$NON-NLS-1$ @@ -190,10 +209,12 @@ public class CFolderDescription extends CDataProxyContainer implements return (ICLanguageSetting)proxy; } + @Override public boolean isRoot() { return getPath().segmentCount() == 0; } - + + @Override public boolean canExclude(boolean exclude) { CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration(); return cfg.canExclude(getPath(), true, exclude); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java index adbb0655c37..c9f7bfd4f76 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CFolderDescriptionCache.java @@ -34,35 +34,42 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements super(base.getId(), base.getPath(), cfg, null); fCfg = cfg; fCfg.addResourceDescription(this); - + copyDataFrom(base, true); } - + + @Override public ICLanguageSetting getLanguageSettingForFile(String fileName) { IProject project = getConfiguration().getProjectDescription().getProject(); return CProjectDescriptionManager.getInstance().findLanguagSettingForFile(fileName, project, getLanguageSettings()); } + @Override public ICLanguageSetting[] getLanguageSettings() { return fLanguageDatas.toArray(new CLanguageSettingCache[fLanguageDatas.size()]); } + @Override public ICResourceDescription getNestedResourceDescription(IPath relPath, boolean exactPath) { return getRcDesHolder().getResourceDescription(relPath, exactPath); } + @Override public ICResourceDescription[] getNestedResourceDescriptions(int kind) { return getRcDesHolder().getResourceDescriptions(kind); } + @Override public ICConfigurationDescription getConfiguration() { return fCfg; } + @Override public ICSettingContainer getParent() { return fCfg; } + @Override public ICSettingObject[] getChildSettings() { return getLanguageSettings(); } @@ -72,10 +79,12 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements return new CLanguageSettingCache(base, this); } + @Override public void setExcluded(boolean excluded) { throw ExceptionFactory.createIsReadOnlyException(); } + @Override public boolean canExclude(boolean exclude) { return exclude == isExcluded(); } @@ -88,21 +97,24 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements public void setName(String name) throws WriteAccessException { throw ExceptionFactory.createIsReadOnlyException(); } - + + @Override public ICResourceDescription[] getNestedResourceDescriptions() { return getNestedResourceDescriptions(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER); } - + private ResourceDescriptionHolder getRcDesHolder(){ if(fRcDesHolder == null) fRcDesHolder = fCfg.createHolderForRc(getPath()); return fRcDesHolder; } + @Override public boolean isReadOnly() { return true; } + @Override public ICFolderDescription getParentFolderDescription() { return getRcDesHolder().getParentFolderDescription(); } @@ -111,11 +123,13 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements throw ExceptionFactory.createIsReadOnlyException(); } + @Override public ICLanguageSetting createLanguageSettingForContentTypes( String languageId, String[] typeIds) { throw ExceptionFactory.createIsReadOnlyException(); } + @Override public ICLanguageSetting createLanguageSettingForExtensions( String languageId, String[] extensions) { throw ExceptionFactory.createIsReadOnlyException(); @@ -133,10 +147,11 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements throw ExceptionFactory.createIsReadOnlyException(); } + @Override public boolean isRoot() { return getPath().segmentCount() == 0; } - + @Override public IPath getPath() { return ResourceDescriptionHolder.normalizePath(super.getPath()); @@ -147,6 +162,7 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements return true; } + @Override public boolean isExcluded() { return fCfg.isExcluded(getPath()); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java index 7b2c1139b6e..f195379e48c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java @@ -30,6 +30,7 @@ public class CLanguageSetting extends CDataProxy implements super(data, parent, cfg); } + @Override public final int getType() { return ICSettingBase.SETTING_LANGUAGE; } @@ -39,16 +40,18 @@ public class CLanguageSetting extends CDataProxy implements // return data.getHeaderContentType(); // } + @Override public String getLanguageId() { CLanguageData data = getCLanguageData(false); return data.getLanguageId(); } - + + @Override public void setLanguageId(String id){ CLanguageData data = getCLanguageData(true); data.setLanguageId(id); } - + private CLanguageData getCLanguageData(boolean write){ return (CLanguageData)getData(write); } @@ -57,11 +60,13 @@ public class CLanguageSetting extends CDataProxy implements // return getSettingEntries(ICLanguageSettingEntry.ALL); // } + @Override public ICLanguageSettingEntry[] getSettingEntries(int kind) { CLanguageData data = getCLanguageData(false); return data.getEntries(kind); } + @Override public List getSettingEntriesList(int kind) { CLanguageData data = getCLanguageData(false); ICLanguageSettingEntry entries[] = data.getEntries(kind); @@ -70,6 +75,7 @@ public class CLanguageSetting extends CDataProxy implements return new ArrayList(); } + @Override public String[] getSourceContentTypeIds() { CLanguageData data = getCLanguageData(false); String ids[] = data.getSourceContentTypeIds(); @@ -78,15 +84,17 @@ public class CLanguageSetting extends CDataProxy implements return CDefaultLanguageData.EMPTY_STRING_ARRAY; } + @Override public int getSupportedEntryKinds() { CLanguageData data = getCLanguageData(false); return data.getSupportedEntryKinds(); } + @Override public boolean supportsEntryKind(int kind) { return (getSupportedEntryKinds() & kind) == kind; } - + /* public String[] getHeaderExtensions() { CLanguageData data = getCLanguageData(false); IContentType type = data.getHeaderContentType(); @@ -100,10 +108,11 @@ public class CLanguageSetting extends CDataProxy implements else exts = new String[0]; } - + return exts; } */ + @Override public String[] getSourceExtensions() { CLanguageData data = getCLanguageData(false); return CDataUtil.getSourceExtensions(getProject(), data); @@ -118,17 +127,17 @@ public class CLanguageSetting extends CDataProxy implements // else // exts = CDefaultLanguageData.EMPTY_STRING_ARRAY; // } -// +// // if(exts == null) // exts = CDefaultLanguageData.EMPTY_STRING_ARRAY; // return exts; } - + /* private Map fillNameToEntryMap(ICLanguageSettingEntry entries[], Map map){ if(map == null) map = new HashMap(); - + for(int i = 0; i < entries.length; i++){ ICLanguageSettingEntry entry = entries[i]; map.put(entry.getName(), entry); @@ -136,14 +145,14 @@ public class CLanguageSetting extends CDataProxy implements return map; } - + private class SettingChangeInfo implements ICSettingsChangeInfo { CLanguageData fData; ICLanguageSettingEntry fNewEntries[]; int fKind; ICLanguageSettingEntryInfo fAddedInfo[]; ICLanguageSettingEntry fRemoved[]; - + SettingChangeInfo(int kind, ICLanguageSettingEntry newEntries[], CLanguageData data){ fNewEntries = newEntries; fData = data; @@ -170,11 +179,11 @@ public class CLanguageSetting extends CDataProxy implements ICLanguageSettingEntry entry = oldEntries[i]; if(entry.getKind() != fKind) continue; - + list.add(entry); } - - + + } return fNewEntries; } @@ -187,19 +196,19 @@ public class CLanguageSetting extends CDataProxy implements // TODO Auto-generated method stub return null; } - + } public void changeEntries(ICLanguageSettingEntryInfo[] added, ICLanguageSettingEntry[] removed) { CLanguageData data = getCLanguageData(true); - Map map = null; + Map map = null; if(added != null && added.length > 0){ map = sortEntries(added, true, map); } if(removed != null && removed.length > 0){ map = sortEntries(removed, false, map); } - + if(map != null){ for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ Map.Entry entry = (Map.Entry)iter.next(); @@ -208,21 +217,21 @@ public class CLanguageSetting extends CDataProxy implements List aList = lists[0]; List rList = lists[1]; ICLanguageSettingEntry sortedAdded[] = aList != null ? - (ICLanguageSettingEntry[])aList.toArray(new ICLanguageSettingEntry[aList.size()]) + (ICLanguageSettingEntry[])aList.toArray(new ICLanguageSettingEntry[aList.size()]) : null; ICLanguageSettingEntry sortedRemoved[] = rList != null ? - (ICLanguageSettingEntry[])rList.toArray(new ICLanguageSettingEntry[rList.size()]) + (ICLanguageSettingEntry[])rList.toArray(new ICLanguageSettingEntry[rList.size()]) : null; - + data.changeEntries(kind, sortedAdded, sortedRemoved); } } } - + private Map sortEntries(ICLanguageSettingEntry entries[], boolean added, Map map){ if(map == null) map = new HashMap(); - + int index = added ? 0 : 1; for(int i = 0; i < entries.length; i++){ ICLanguageSettingEntry entry = entries[i]; @@ -244,6 +253,7 @@ public class CLanguageSetting extends CDataProxy implements return map; } */ + @Override public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) { CLanguageData data = getCLanguageData(true); EntryStore store = new EntryStore(); @@ -266,11 +276,11 @@ public class CLanguageSetting extends CDataProxy implements } } } - } - + } + setSettingEntries(kind, data, store); } - + private int[] flagsToArray(int flags){ int arr[] = new int[32]; int num = 0; @@ -287,12 +297,13 @@ public class CLanguageSetting extends CDataProxy implements return result; } + @Override public void setSettingEntries(int kind, List list) { CLanguageData data = getCLanguageData(true); EntryStore store = new EntryStore(); // KindBasedStore nameSetStore = new KindBasedStore(); int eKind; - + if(list != null){ if(list.size() != 0){ for(ICLanguageSettingEntry entry : list){ @@ -310,10 +321,10 @@ public class CLanguageSetting extends CDataProxy implements } } } - + setSettingEntries(kind, data, store); } - + private void setSettingEntries(int kind, CLanguageData data, EntryStore store){ int oredk = getSupportedEntryKinds(); int kinds[] = flagsToArray(oredk); @@ -344,22 +355,25 @@ public class CLanguageSetting extends CDataProxy implements // return getSettingEntries(); // } + @Override public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) { ICLanguageSettingEntry entries[] = getSettingEntries(kind); entries = CDataUtil.resolveEntries(entries, getConfiguration()); return entries; } + @Override public void setSourceContentTypeIds(String[] ids) { CLanguageData data = getCLanguageData(true); - + data.setSourceContentTypeIds(ids); } + @Override public void setSourceExtensions(String[] exts) { CLanguageData data = getCLanguageData(true); - + data.setSourceExtensions(exts); } - + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java index 27d5c9c9e33..abddfa77cae 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java @@ -54,29 +54,30 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements return getSettingEntries(); } */ + @Override public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) { ICLanguageSettingEntry[] entries = getSettingEntries(kind); if(entries.length != 0){ if(fResolvedEntriesStore == null){ fResolvedEntriesStore = new EntryStore(); } - + ICLanguageSettingEntry[] resolved = fResolvedEntriesStore.getEntries(kind); if(resolved.length == 0){ resolved = CDataUtil.resolveEntries(entries, getConfiguration()); fResolvedEntriesStore.storeEntries(kind, resolved); } - + entries = resolved; } return entries; } - + private IProject getProject(){ return getConfiguration().getProjectDescription().getProject(); } - + @Override public String[] getSourceExtensions() { if(fCachedExtensions == null ){ @@ -91,17 +92,18 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements else exts = CDefaultLanguageData.EMPTY_STRING_ARRAY; } - + if(exts == null) exts = CDefaultLanguageData.EMPTY_STRING_ARRAY; fCachedExtensions = exts; } - + if(fCachedExtensions.length != 0) return fCachedExtensions.clone(); return fCachedExtensions; } + @Override public ICLanguageSettingEntry[] getSettingEntries(int kind) { // int kinds[] = KindBasedStore.getSupportedKinds(); // List list = new ArrayList(); @@ -114,7 +116,8 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements // return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]); return fStore.getEntries(kind); } - + + @Override public List getSettingEntriesList(int kind) { // int kinds[] = KindBasedStore.getSupportedKinds(); // List list = new ArrayList(); @@ -127,7 +130,7 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements // return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]); return fStore.getEntriesList(kind); } - + @Override public void setLanguageId(String id) { @@ -138,6 +141,7 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements throw ExceptionFactory.createIsReadOnlyException(); } + @Override public void setSettingEntries(int kind, List entriesList) { throw ExceptionFactory.createIsReadOnlyException(); } @@ -147,22 +151,27 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements throw ExceptionFactory.createIsReadOnlyException(); } + @Override public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) { throw ExceptionFactory.createIsReadOnlyException(); } + @Override public boolean supportsEntryKind(int kind) { return (getSupportedEntryKinds() & kind) == kind; } + @Override public ICConfigurationDescription getConfiguration() { return fParent.getConfiguration(); } + @Override public ICSettingContainer getParent() { return fParent; } + @Override public boolean isReadOnly() { return true; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java index 1867e78157a..fdc44e08985 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java @@ -31,12 +31,12 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.QualifiedName; -public class CProjectDescription implements ICProjectDescription, ICDataProxyContainer { +public class CProjectDescription implements ICProjectDescription, ICDataProxyContainer { private static final String ACTIVE_CFG = "activeConfiguration"; //$NON-NLS-1$ private static final QualifiedName ACTIVE_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, ACTIVE_CFG); private static final String SETTING_CFG = "settingConfiguration"; //$NON-NLS-1$ private static final QualifiedName SETTING_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, SETTING_CFG); - + private CfgIdPair fActiveCfgInfo; private CfgIdPair fSettingCfgInfo; private CProjectDescriptionPreferences fPrefs; @@ -62,7 +62,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon private QualifiedName fPersistanceName; private boolean fNeedsPersistance; private boolean fIsCfgModified; - + CfgIdPair(CfgIdPair base){ fId = base.fId; fPersistanceName = base.fPersistanceName; @@ -71,7 +71,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon CfgIdPair(QualifiedName persistanceName){ fPersistanceName = persistanceName; } - + public String getId(){ if(fId == null){ fId = load(); @@ -84,7 +84,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } return fId; } - + public ICConfigurationDescription getConfiguration() { if(fCfg == null){ String id = getId(); @@ -101,20 +101,20 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } return fCfg; } - + public void setConfiguration(ICConfigurationDescription cfg){ if(cfg.getProjectDescription() != CProjectDescription.this) throw new IllegalArgumentException(); - + if(cfg.getId().equals(getId())) return; - + fCfg = cfg; fId = cfg.getId(); fIsCfgModified = true; fNeedsPersistance = true; } - + public void configurationRemoved(ICConfigurationDescription cfg){ if(cfg.getProjectDescription() != CProjectDescription.this) throw new IllegalArgumentException(); @@ -126,7 +126,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon fCfg = null; getConfiguration(); } - + private String load(){ try { return getProject().getPersistentProperty(fPersistanceName); @@ -174,13 +174,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon el = getStorage(CProjectDescriptionManager.MODULE_ID, false); } - fPrefs = new CProjectDescriptionPreferences(el, - (CProjectDescriptionPreferences)mngr.getProjectDescriptionWorkspacePreferences(false), + fPrefs = new CProjectDescriptionPreferences(el, + (CProjectDescriptionPreferences)mngr.getProjectDescriptionWorkspacePreferences(false), false); fPropertiesMap = new HashMap(); } - + public void updateProject(IProject project){ fProject = project; } @@ -188,7 +188,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon public void loadDatas(){ if(!fIsReadOnly || !fIsLoading) return; - + CSettingEntryFactory factory = new CSettingEntryFactory(); for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){ CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next(); @@ -200,16 +200,16 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon iter.remove(); } } - + // doneInitializing(); - + // fIsLoading = false; } public boolean applyDatas(SettingsContext context){ if(!fIsReadOnly || !fIsApplying) return false; - + CSettingEntryFactory factory = new CSettingEntryFactory(); boolean modified = false; for (Iterator iter = fCfgMap.values().iterator(); iter.hasNext();) { @@ -224,14 +224,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon iter.remove(); } } - + // doneInitializing(); - + // fIsApplying = false; - + return modified; } - + /** * Called when the read-only project description has / is being set * fIsApplying => false @@ -241,13 +241,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon public void doneApplying(){ doneInitializing(); fIsApplying = false; - + try { getStorageBase().setReadOnly(true, false); } catch (CoreException e1) { CCorePlugin.log(e1); } - + setModified(false); } @@ -255,7 +255,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon doneInitializing(); fIsLoading = false; } - + public void setLoading(boolean loading){ fIsLoading = loading; } @@ -280,8 +280,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } /** - * Create a project description based on another project description - * + * Create a project description based on another project description + * * @param base * @param saving * @param storage @@ -298,9 +298,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon fIsLoading = base.fIsLoading; fIsApplying = saving || base.fIsApplying; fIsCreating = isCreating; - + fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false); - + for(Iterator iter = base.fCfgMap.values().iterator(); iter.hasNext();){ try { IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next(); @@ -322,18 +322,18 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon CCorePlugin.log(e); } } - + @SuppressWarnings("unchecked") HashMap cloneMap = (HashMap)base.fPropertiesMap.clone(); fPropertiesMap = cloneMap; } - + /** * Convert the current CConfigurationDescriptions to cached versions * This occurs during the SetCProjectDescription Operation */ void switchToCachedConfigurationDescriptions() throws CoreException { - + for (Map.Entry e : fCfgMap.entrySet()) { if (e.getValue() instanceof CConfigurationDescription) { CConfigurationDescription cfgDes = (CConfigurationDescription)e.getValue(); @@ -343,7 +343,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon baseCache = (CConfigurationDescriptionCache)baseData; baseData = baseCache.getConfigurationData(); } - CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache, + CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null); e.setValue(cache); } @@ -353,7 +353,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon void configurationCreated(ICConfigurationDescription des){ fCfgMap.put(des.getId(), des); } - + + @Override public ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException{ if(fIsReadOnly) @@ -363,21 +364,24 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return cfg; } + @Override public ICConfigurationDescription getActiveConfiguration() { return fActiveCfgInfo.getConfiguration(); } private String getFirstCfgId(){ if(!fCfgMap.isEmpty()){ - return fCfgMap.keySet().iterator().next(); + return fCfgMap.keySet().iterator().next(); } return null; } + @Override public ICConfigurationDescription getConfigurationById(String id) { return fCfgMap.get(id); } + @Override public ICConfigurationDescription getConfigurationByName(String name) { for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){ ICConfigurationDescription cfg = iter.next(); @@ -387,22 +391,24 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return null; } + @Override public ICConfigurationDescription[] getConfigurations() { return fCfgMap.values().toArray(new ICConfigurationDescription[fCfgMap.size()]); } + @Override public void removeConfiguration(String name) throws WriteAccessException { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); - - + + CConfigurationDescription cfgDes = (CConfigurationDescription)getConfigurationByName(name); if(cfgDes != null){ cfgDes.removeConfiguration(); } - + } - + void configurationRemoved(CConfigurationDescription des){ fCfgMap.remove(des.getId()); fIsModified = true; @@ -411,35 +417,40 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon fSettingCfgInfo.configurationRemoved(des); } + @Override public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); - + ((CConfigurationDescription)cfg).removeConfiguration(); } + @Override public void setActiveConfiguration( ICConfigurationDescription cfg) throws WriteAccessException { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); if(cfg == null) throw new NullPointerException(); - + fActiveCfgInfo.setConfiguration(cfg); - + if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE) fSettingCfgInfo.setConfiguration(cfg); } - + + @Override public IProject getProject() { return fProject; } + @Override public ICStorageElement getStorage(String moduleId, boolean create) throws CoreException { return getStorageBase().getStorage(moduleId, create); } + @Override public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException, CoreException { return getStorageBase().importStorage(id, el); } @@ -448,40 +459,48 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon // return getStorageBase().containsStorage(id); // } + @Override public ICSettingObject[] getChildSettings() { return getConfigurations(); } + @Override public ICConfigurationDescription getConfiguration() { return null; } + @Override public String getId() { //TODO: return null; } + @Override public final int getType() { return ICSettingBase.SETTING_PROJECT; } + @Override public String getName() { return fProject.getName(); } + @Override public ICSettingContainer getParent() { return null; } + @Override public boolean isValid() { return /*fProject.exists() &&*/ fCfgMap.size() > 0; } + @Override public void updateChild(CDataProxy child, boolean write) { if(write){ try { String oldId = child.getId(); - CConfigurationDescription cfgDes = ((CConfigurationDescription)child); + CConfigurationDescription cfgDes = ((CConfigurationDescription)child); cfgDes.doWritable(); updateMap(cfgDes, oldId); } catch (CoreException e) { @@ -489,7 +508,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } } } - + void updateMap(CConfigurationDescription des, String oldId){ if(!oldId.equals(des.getId())){ fCfgMap.remove(oldId); @@ -500,17 +519,17 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon public ICStorageElement getRootStorageElement() throws CoreException { if (fRootStorageElement == null) throw ExceptionFactory.createCoreException("CProjectDescription ICStorageElement == null"); //$NON-NLS-1$ - + // if(fRootStorageElement == null){ // fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly()); // } return fRootStorageElement; } - + // ICStorageElement doGetCachedRootStorageElement(){ // return fRootStorageElement; // } - + ICSettingsStorage getStorageBase() throws CoreException{ if(fStorage == null) // fStorage = new CStorage((InternalXmlStorageElement)getRootStorageElement()); @@ -518,6 +537,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return fStorage; } + @Override public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -525,7 +545,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon configurationCreated(cfg); return cfg; } - + public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{ if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -534,10 +554,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return cfg; } + @Override public boolean isModified() { if(fIsModified) return true; - + if(fActiveCfgInfo.fIsCfgModified) return true; @@ -556,10 +577,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return false; } - + private void setModified(boolean modified){ fIsModified = modified; - + if(!modified){ fActiveCfgInfo.fIsCfgModified = false; @@ -571,10 +592,12 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } } + @Override public boolean isReadOnly() { return fIsReadOnly && !(fIsLoading || fIsApplying); } + @Override public void setReadOnly(boolean readOnly, boolean keepModify) { fIsReadOnly = readOnly; try { @@ -587,14 +610,16 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon public ICSettingObject getChildSettingById(String id) { return getConfigurationById(id); } - + + @Override public ICConfigurationDescription getDefaultSettingConfiguration(){ if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE) return getActiveConfiguration(); - + return fSettingCfgInfo.getConfiguration(); } + @Override public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -602,24 +627,27 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon throw new NullPointerException(); fSettingCfgInfo.setConfiguration(cfg); - + if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE) fActiveCfgInfo.setConfiguration(cfg); } + @Override public Object getSessionProperty(QualifiedName name) { return fPropertiesMap.get(name); } + @Override public void setSessionProperty(QualifiedName name, Object value) { if(value != null) fPropertiesMap.put(name, value); else fPropertiesMap.remove(name); - + fIsModified = true; } + @Override public void removeStorage(String id) throws CoreException { getStorageBase().removeStorage(id); } @@ -627,7 +655,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon void switchToCachedAppliedData(CProjectDescription appliedCache){ if(fIsReadOnly) return; - + ICConfigurationDescription[] cfgs = appliedCache.getConfigurations(); for(int i = 0; i < cfgs.length; i++){ CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache)cfgs[i]; @@ -641,14 +669,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } } } - + // boolean checkPersistCfgChanges(boolean force){ // boolean stored = false; // stored |= checkPersistActiveCfg(force); // stored |= checkPersistSettingCfg(force); // return stored; // } - + boolean checkPersistActiveCfg(String oldId, boolean force){ return fActiveCfgInfo.store(oldId, force); } @@ -669,30 +697,36 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return fPrefs; } + @Override public int getConfigurationRelations() { return fPrefs.getConfigurationRelations(); } + @Override public boolean isDefaultConfigurationRelations() { return fPrefs.isDefaultConfigurationRelations(); } + @Override public void setConfigurationRelations(int status) { fPrefs.setConfigurationRelations(status); } + @Override public void useDefaultConfigurationRelations() { fPrefs.useDefaultConfigurationRelations(); } + @Override public boolean isCdtProjectCreating() { return fIsCreating; } + @Override public void setCdtProjectCreated() { if(!fIsCreating) return; - + if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -703,9 +737,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon public void touch() throws WriteAccessException { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); - + fIsModified = true; } - - + + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java index d1b58c260d1..45bd1fb3b02 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionDelta.java @@ -29,7 +29,7 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { private static final int KIND_MASK = 3; private static final int FLAGS_OFFSET = 2; - + public CProjectDescriptionDelta(ICSettingObject newSetting, ICSettingObject oldSetting){ fNewSetting = newSetting; fOldSetting = oldSetting; @@ -44,46 +44,52 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { setDeltaKind(REMOVED); } } - + void addChild(CProjectDescriptionDelta child){ fChildList.add(child); child.setParent(this); } - + private void setParent(CProjectDescriptionDelta parent){ fParent = parent; } + @Override public ICDescriptionDelta[] getChildren() { return fChildList.toArray(new CProjectDescriptionDelta[fChildList.size()]); } + @Override public ICSettingObject getOldSetting() { return fOldSetting; } + @Override public ICSettingObject getSetting() { return fSetting; } + @Override public int getSettingType() { return fSetting.getType(); } + @Override public ICDescriptionDelta getParent() { return fParent; } - + public boolean isEmpty(){ - return fChildList.size() == 0 - && getDeltaKind() == CHANGED + return fChildList.size() == 0 + && getDeltaKind() == CHANGED && getChangeFlags() == 0; } + @Override public int getChangeFlags() { return (fStatus & (~KIND_MASK)) >> FLAGS_OFFSET; } - + void addChangeFlags(int flags){ flags |= getChangeFlags(); setChangeFlags(flags); @@ -102,10 +108,12 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { fStatus = (fStatus & (~KIND_MASK)) | (kind & KIND_MASK); } + @Override public int getDeltaKind() { return fStatus & KIND_MASK; } + @Override public ICSettingObject getNewSetting() { return fNewSetting; } @@ -115,14 +123,17 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { checkSettingEntriesChangeFlag(); } + @Override public int getAddedEntriesKinds() { return fAddedLanguageEntriesKinds; } + @Override public int getRemovedEntriesKinds() { return fRemovedLanguageEntriesKinds; } + @Override public int getReorderedEntriesKinds() { return fReorderedLanguageEntriesKinds; } @@ -136,7 +147,7 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { fReorderedLanguageEntriesKinds = kinds; checkSettingEntriesChangeFlag(); } - + private void checkSettingEntriesChangeFlag(){ if(fAddedLanguageEntriesKinds != 0 || fRemovedLanguageEntriesKinds != 0 @@ -145,12 +156,12 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { else removeChangeFlags(SETTING_ENTRIES); } - + @SuppressWarnings("nls") private static String flagsToString(int flags) { StringBuilder str = new StringBuilder(); str.append(", flags=0x" + Integer.toHexString(flags)); - + str.append(":"); if ((flags&ACTIVE_CFG)!=0) str.append("ACTIVE_CFG|"); if ((flags&NAME)!=0) str.append("NAME|"); @@ -175,7 +186,7 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { if (str.charAt(str.length()-1)=='|') str.deleteCharAt(str.length()-1); return str.toString(); } - + /** * Helper method to make debugging easier. */ @@ -183,10 +194,10 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { @Override public String toString() { StringBuilder str = new StringBuilder(); - + String type = fSetting.getClass().getSimpleName(); str.append("[" + type + "]"); - + int kind = getDeltaKind(); str.append(", kind="+kind); switch (kind) { @@ -195,16 +206,16 @@ public class CProjectDescriptionDelta implements ICDescriptionDelta { case CHANGED: str.append(":CHANGED");break; default: str.append(":"); } - + str.append(flagsToString(getChangeFlags())); - + ICDescriptionDelta[] children = getChildren(); if (children==null) { str.append(", no children"); } else { str.append(", " + getChildren().length + " children"); } - + return str.toString(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index c23c8f9e6b9..2143b5e9488 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -188,6 +188,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { fRunnables.add(runnable); } + @Override public void run(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(fName, fRunnables.size()); @@ -245,6 +246,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer(){ + @Override public void updateChild(CDataProxy child, boolean write) { if(write){ try { @@ -255,6 +257,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } + @Override public ICSettingObject[] getChildSettings() { return fPreferenceMap.values().toArray(new CConfigurationDescriptionCache[fPreferenceMap.size()]); } @@ -396,6 +399,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { CProjectDescriptionStorageManager.getInstance().shutdown(); } + @Override public ICProjectDescription getProjectDescription(IProject project, boolean write) { return getProjectDescription(project, true, write); } @@ -407,6 +411,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return getProjectDescription(project, flags); } + @Override public ICProjectDescription getProjectDescription(IProject project, int flags) { try { return getProjectDescriptionInternal(project, flags); @@ -419,7 +424,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } /** - * Base method for getting a Project's Description + * Base method for getting a Project's Description * @param project * @param flags * @return ICProjectDescription @@ -428,7 +433,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { private ICProjectDescription getProjectDescriptionInternal(IProject project, int flags) throws CoreException { AbstractCProjectDescriptionStorage storage = getProjectDescriptionStorage(project); return storage.getProjectDescription(flags, new NullProgressMonitor()); - } + } /** * Run the workspace modification in the current thread using the workspace scheduling rule @@ -510,6 +515,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { private static void runAtomic(final IWorkspaceRunnable r, ISchedulingRule rule, IProgressMonitor monitor) throws CoreException{ IWorkspace wsp = ResourcesPlugin.getWorkspace(); wsp.run(new IWorkspaceRunnable(){ + @Override public void run(IProgressMonitor monitor) throws CoreException { try { r.run(monitor); @@ -521,6 +527,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { }, rule, IWorkspace.AVOID_UPDATE, monitor); } + @Override public void updateProjectDescriptions(IProject[] projects, IProgressMonitor monitor) throws CoreException{ if(monitor == null) monitor = new NullProgressMonitor(); @@ -542,6 +549,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { fi[0] = num; runWspModification(new IWorkspaceRunnable(){ + @Override public void run(IProgressMonitor monitor) throws CoreException { monitor.beginTask(SettingsModelMessages.getString("CProjectDescriptionManager.13"), fi[0]); //$NON-NLS-1$ @@ -605,10 +613,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { fConverters = dess; } + @Override public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException{ return createProjectDescription(project, loadIfExists, false); } + @Override public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists, boolean creating) throws CoreException{ int flags = ICProjectDescriptionManager.GET_WRITABLE | ICProjectDescriptionManager.GET_CREATE_DESCRIPTION; flags |= loadIfExists ? 0 : ICProjectDescriptionManager.GET_EMPTY_PROJECT_DESCRIPTION; @@ -634,6 +644,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return provider; } + @Override public ICProjectDescription getProjectDescription(IProject project){ return getProjectDescription(project, true); } @@ -811,10 +822,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return false; } + @Override public void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException { setProjectDescription(project, des, false, null); } + @Override public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException { int flags = force ? SET_FORCE : 0; setProjectDescription(project, des, flags, monitor); @@ -826,6 +839,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** ThreadLocal flag to let CDescriptor know whether already in a setProjectDescription */ ThreadLocal settingProjectDescription = new ThreadLocal(){@Override protected Boolean initialValue() {return false;}}; + @Override public void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) throws CoreException { try { settingProjectDescription.set(true); @@ -2164,10 +2178,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { * Methods for manipulating the set of project description listeners */ + @Override public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes) { fListeners.add(new ListenerDescriptor(listener, eventTypes)); } + @Override public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener) { for (ListenerDescriptor listenerDescriptor : fListeners) { if (listenerDescriptor.fListener.equals(listener)) { @@ -2202,6 +2218,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } + @Override public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId) throws CoreException { return getPreferenceConfiguration(buildSystemId, true); } @@ -2215,6 +2232,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } + @Override public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) throws CoreException { ICConfigurationDescription des = getLoaddedPreference(buildSystemId); if(des == null){ @@ -2244,6 +2262,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return des; } + @Override public void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws CoreException{ if(!needSavePreference(buildSystemId, des)) return; @@ -2448,10 +2467,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return false; } + @Override public boolean isNewStyleProject(IProject project){ return isNewStyleProject(getProjectDescription(project, false)); } + @Override public boolean isNewStyleProject(ICProjectDescription des){ if(des == null) return false; @@ -2594,7 +2615,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { if(!langDatasEqual(parentLData, childLData)) return true; } - + return false; } @@ -2651,6 +2672,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } + @Override public ICProjectDescriptionWorkspacePreferences getProjectDescriptionWorkspacePreferences( boolean write) { if(fPreferences == null){ @@ -2670,6 +2692,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return prefs; } + @Override public boolean setProjectDescriptionWorkspacePreferences(ICProjectDescriptionWorkspacePreferences prefs, boolean updateProjects, IProgressMonitor monitor) { @@ -2741,6 +2764,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.14")); //$NON-NLS-1$ } + @Override public void updateExternalSettingsProviders(String[] ids, IProgressMonitor monitor){ ExtensionContainerFactory.updateReferencedProviderIds(ids, monitor); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java index 5663d181eb2..0851488f26c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java @@ -20,7 +20,7 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe private static final int DEFAULT_RELATIONS = CONFIGS_INDEPENDENT; private boolean fIsReadOnly; private boolean fIsModified; - + private Integer fConfigRelations; private CProjectDescriptionPreferences fSuperPreference; @@ -40,21 +40,22 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe if(el.getAttribute(ATTR_CONFIG_RELATIONS) != null) fConfigRelations = new Integer(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, DEFAULT_RELATIONS)); } - + this.fSuperPreference = superPreference; } - + protected CProjectDescriptionPreferences getSuperPreferences(){ if(isReadOnly()) return fSuperPreference; return (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false); } - + void serialize(ICStorageElement el){ if(fConfigRelations != null) CDataUtil.setInteger(el, ATTR_CONFIG_RELATIONS, fConfigRelations.intValue()); } - + + @Override public int getConfigurationRelations() { if(fConfigRelations != null) return fConfigRelations.intValue(); @@ -64,56 +65,59 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe return DEFAULT_RELATIONS; } + @Override public boolean isDefaultConfigurationRelations() { return fConfigRelations == null; } + @Override public void setConfigurationRelations(int status) { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); if(fConfigRelations != null && fConfigRelations.intValue() == status) return; - + fConfigRelations = new Integer(status); fIsModified = true; } + @Override public void useDefaultConfigurationRelations() { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); - + if(fConfigRelations == null) return; - + fConfigRelations = null; fIsModified = true; } public boolean isModified(){ return fIsModified - || (fSuperPreference != null + || (fSuperPreference != null && !fSuperPreference.settingsEqual((CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false))); } - + void setModified(boolean modified){ fIsModified = modified; } - + public boolean isReadOnly(){ return fIsReadOnly; } - + void setReadOnly(boolean readOnly){ fIsReadOnly = readOnly; } - + public boolean settingsEqual(CProjectDescriptionPreferences other){ if(isDefaultConfigurationRelations() != other.isDefaultConfigurationRelations()) return false; if(getConfigurationRelations() != other.getConfigurationRelations()) return false; - + return true; } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java index 1efb5adccab..d75d4215a85 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSetting.java @@ -20,20 +20,23 @@ public class CTargetPlatformSetting extends CDataProxy implements super(data, cfg, cfg); } + @Override public final int getType() { return SETTING_TARGET_PLATFORM; } + @Override public String[] getBinaryParserIds() { CTargetPlatformData data = getTargetPlatformData(false); return data.getBinaryParserIds(); } + @Override public void setBinaryParserIds(String[] ids) { CTargetPlatformData data = getTargetPlatformData(true); data.setBinaryParserIds(ids); } - + private CTargetPlatformData getTargetPlatformData(boolean write){ return (CTargetPlatformData)getData(write); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java index f86d9d76b68..330f7bea97c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CTargetPlatformSettingCache.java @@ -21,23 +21,26 @@ public class CTargetPlatformSettingCache extends CDefaultTargetPlatformData private CConfigurationDescriptionCache fCfgCache; CTargetPlatformSettingCache(CTargetPlatformData base, CConfigurationDescriptionCache cfgCache){ fId = base.getId(); - + fCfgCache = cfgCache; - + fCfgCache.addTargetPlatformSetting(this); - + copyDataFrom(base); } - - + + + @Override public ICConfigurationDescription getConfiguration() { return fCfgCache; } + @Override public ICSettingContainer getParent() { return fCfgCache; } + @Override public boolean isReadOnly() { return true; } @@ -46,7 +49,7 @@ public class CTargetPlatformSettingCache extends CDefaultTargetPlatformData public void setBinaryParserIds(String[] ids) { if(!fCfgCache.isInitializing()) throw ExceptionFactory.createIsReadOnlyException(); - + super.setBinaryParserIds(ids); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java index 0eac0c0c420..4a733d7480f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java @@ -7,7 +7,7 @@ * * Contributors: * Intel Corporation - Initial API and implementation - * James Blackburn (Broadcom Corp.) + * James Blackburn (Broadcom Corp.) *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; @@ -34,10 +34,10 @@ import org.eclipse.core.runtime.CoreException; /** * A class responsible for persisting CDT Projects and Configuration IDs as referenced - * by other configurations in other projects. + * by other configurations in other projects. * The user controls this via RefsTab. This External settings factory listens * for CProjectDescription model changes and notifies the {@link CExternalSettingsManager}, - * which is a listener, of changes to the set of external settings. + * which is a listener, of changes to the set of external settings. * {@link ICConfigurationDescription#setReferenceInfo(Map)} and {@link ICConfigurationDescription#getReferenceInfo()} */ public class CfgExportSettingContainerFactory extends @@ -57,20 +57,20 @@ public class CfgExportSettingContainerFactory extends private CfgExportSettingContainerFactory(){ } - + public static CfgExportSettingContainerFactory getInstance(){ if(fInstance == null) fInstance = new CfgExportSettingContainerFactory(); return fInstance; } - + @Override public void startup(){ - CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADED); } - + @Override public void shutdown(){ CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); @@ -84,7 +84,7 @@ public class CfgExportSettingContainerFactory extends final private String fId; final private String fProjName, fCfgId; final private CExternalSetting[] prevSettings; - + CfgRefContainer(String containerId, String projName, String cfgId, CExternalSetting[] previousSettings){ fId = containerId; fProjName = projName; @@ -98,9 +98,9 @@ public class CfgExportSettingContainerFactory extends if (project.isAccessible()) { ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); if(des != null){ - ICConfigurationDescription cfg = fCfgId.length() != 0 ? + ICConfigurationDescription cfg = fCfgId.length() != 0 ? des.getConfigurationById(fCfgId) : des.getActiveConfiguration(); - + if(cfg != null){ CExternalSetting[] es; ICExternalSetting[] ies = cfg.getExternalSettings(); @@ -146,7 +146,7 @@ public class CfgExportSettingContainerFactory extends private static CContainerRef createContainerRef(String projName, String cfgId){ return new CContainerRef(FACTORY_ID, createId(projName, cfgId)); } - + public static Map getReferenceMap(ICConfigurationDescription cfg){ CContainerRef[] refs = CExternalSettingsManager.getInstance().getReferences(cfg, FACTORY_ID); Map map = new LinkedHashMap(); @@ -164,15 +164,15 @@ public class CfgExportSettingContainerFactory extends public static void setReferenceMap(ICConfigurationDescription cfg, Map map){ Map oldRefs = getReferenceMap(cfg); Map newRefs = new LinkedHashMap(map); - + // We need to preserve order. The API we have with the external settings manager allows us to - // add and remove individual items. + // add and remove individual items. // In the future this could be fixed, but for the moment, remove and replace all the referenced items // from the first item that doens't match. Iterator> oldIter = oldRefs.entrySet().iterator(); Iterator> newIter = newRefs.entrySet().iterator(); - + while (oldIter.hasNext() && newIter.hasNext()) { Map.Entry oldEntry = oldIter.next(); Map.Entry newEntry = newIter.next(); @@ -209,7 +209,7 @@ public class CfgExportSettingContainerFactory extends private static String[] parseId(String id) throws CoreException { if(id == null) throw new NullPointerException(); - + String projName, cfgId; int index = id.indexOf(DELIMITER); if(index != -1){ @@ -219,10 +219,10 @@ public class CfgExportSettingContainerFactory extends projName = id; cfgId = ACTIVE_CONFIG_ID; } - + if((projName = projName.trim()).length() == 0) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CfgExportSettingContainerFactory.2")); //$NON-NLS-1$ - + return new String[]{projName, cfgId}; } @@ -230,6 +230,7 @@ public class CfgExportSettingContainerFactory extends * Notify the ExternalSettingManager that there's been a change in the configuration which may require referencing configs to update * their cache of the external settings */ + @Override public void handleEvent(CProjectDescriptionEvent event) { switch(event.getEventType()){ case CProjectDescriptionEvent.LOADED: { @@ -255,9 +256,9 @@ public class CfgExportSettingContainerFactory extends case CProjectDescriptionEvent.APPLIED: String[] ids = getContainerIds(event.getProjectDelta()); if(ids.length != 0){ - CExternalSettingsContainerChangeInfo[] changeInfos = + CExternalSettingsContainerChangeInfo[] changeInfos = new CExternalSettingsContainerChangeInfo[ids.length]; - + for(int i = 0; i < changeInfos.length; i++){ changeInfos[i] = new CExternalSettingsContainerChangeInfo( CExternalSettingsContainerChangeInfo.CONTAINER_CONTENTS, @@ -268,7 +269,7 @@ public class CfgExportSettingContainerFactory extends } } } - + /** * Returns the set of containers (Project configurations) (project_name;config_id) for the project descriptions * reported as changed by the ICDescriptionDelta @@ -279,7 +280,7 @@ public class CfgExportSettingContainerFactory extends if(delta == null) return new String[0]; int deltaKind = delta.getDeltaKind(); - + Set cfgIds = new HashSet(); switch(deltaKind){ case ICDescriptionDelta.ADDED: @@ -305,7 +306,7 @@ public class CfgExportSettingContainerFactory extends if(ids.length != 0){ String projName = ((ICProjectDescription)delta.getSetting()).getProject().getName(); int i = 0; - for (String config : cfgIds) + for (String config : cfgIds) ids[i++] = createId(projName, config); } return ids; @@ -327,7 +328,7 @@ public class CfgExportSettingContainerFactory extends break; case ICDescriptionDelta.CHANGED: int changeFlags = delta.getChangeFlags(); - if((changeFlags & + if((changeFlags & (ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED | ICDescriptionDelta.EXTERNAL_SETTINGS_REMOVED)) != 0){ c.add(delta.getSetting().getId()); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java index 012f0764dcc..76e09779b87 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgProxyCache.java @@ -22,19 +22,22 @@ import org.eclipse.core.runtime.IPath; public class CfgProxyCache implements IProxyCache { private HashMap fProxyMap = new HashMap(); private PathSettingsContainer fPathContainer; - + CfgProxyCache(PathSettingsContainer pathDesContainer){ fPathContainer = pathDesContainer; fPathContainer.addContainerListener(new IPathSettingsContainerListener(){ + @Override public void aboutToRemove(PathSettingsContainer container) { CDataProxy proxy = (CDataProxy)container.getValue(); if(proxy != null) fProxyMap.remove(proxy.getId()); } + @Override public void containerAdded(PathSettingsContainer container) { } + @Override public void containerValueChanged(PathSettingsContainer container, Object oldValue) { CDataProxy proxy = (CDataProxy)container.getValue(); if(proxy != null) @@ -44,13 +47,15 @@ public class CfgProxyCache implements IProxyCache { } } + @Override public void containerPathChanged(PathSettingsContainer container, IPath oldPath, boolean childrenMoved) { // TODO Auto-generated method stub - + } }); } - + + @Override public void addCachedProxy(CDataProxy proxy) { if(proxy instanceof IInternalResourceDescription){ IInternalResourceDescription des = (IInternalResourceDescription)proxy; @@ -63,34 +68,41 @@ public class CfgProxyCache implements IProxyCache { } } + @Override public void clear() { fPathContainer.removeChildren(); fProxyMap.clear(); } + @Override public CDataProxy[] getCachedProxies() { Collection c = fProxyMap.values(); return c.toArray(new CDataProxy[c.size()]); } + @Override public CDataProxy getCachedProxy(String id) { return fProxyMap.get(id); } + @Override public void removeCachedProxy(String id) { CDataProxy proxy = fProxyMap.get(id); removeCachedProxy(proxy); } + @Override @SuppressWarnings("unchecked") public Map getCachedProxiesMap() { return (Map)fProxyMap.clone(); } + @Override public CDataProxy getCachedProxy(CDataObject data) { return getCachedProxy(data.getId()); } + @Override public void removeCachedProxy(CDataProxy proxy) { if(proxy instanceof IInternalResourceDescription){ fPathContainer.removeChildContainer(((IInternalResourceDescription)proxy).getCachedPath()); @@ -110,18 +122,18 @@ public class CfgProxyCache implements IProxyCache { // proxy = (CDataProxy)proxyIter.next(); // if(data.getType() != proxy.getType()) // continue; -// +// // switch(data.getType()){ // case ICSettingBase.SETTING_TARGET_PLATFORM: // case ICSettingBase.SETTING_FILE: // case ICSettingBase.SETTING_FOLDER: //// if(((CResourceData)data).getPath().equals(((CResourceDescription)proxy).getPath())) // } -// +// // if(result == null) // result = new HashMap(); -// -// +// +// // } // } // } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java index 20046c07108..5c402931f3d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryContainer.java @@ -28,15 +28,18 @@ public class ConfigBasedPathEntryContainer implements IPathEntryContainer { public ConfigBasedPathEntryContainer(IPathEntry entries[]){ this.fEntries = entries.clone(); } - + + @Override public String getDescription() { return "Configuration Description info container"; //$NON-NLS-1$ } + @Override public IPath getPath() { return CONTAINER_PATH; } + @Override public IPathEntry[] getPathEntries() { return fEntries.clone(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java index 804bcd4cc90..2b557be5f47 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java @@ -60,6 +60,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) */ + @Override public void addPathEntryStoreListener(IPathEntryStoreListener listener) { fListeners.add(listener); } @@ -67,6 +68,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) */ + @Override public void removePathEntryStoreListener(IPathEntryStoreListener listener) { fListeners.remove(listener); } @@ -83,6 +85,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc /* (non-Javadoc) * @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject) */ + @Override public void close() { PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED); IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()]; @@ -93,19 +96,23 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); } + @Override public IProject getProject() { return fProject; } + @Override @Deprecated public ICExtensionReference getExtensionReference() { return null; } + @Override public ICConfigExtensionReference getConfigExtensionReference() { return null; } + @Override public IPathEntry[] getRawPathEntries() throws CoreException { ICConfigurationDescription cfg = getIndexCfg(fProject); List[] es = getEntries(fProject, cfg); @@ -118,6 +125,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc return new IPathEntry[0]; } + @Override public void setRawPathEntries(IPathEntry[] entries) throws CoreException { ICConfigurationDescription cfg = getIndexCfg(fProject); List es[] = getEntries(fProject, cfg); @@ -162,6 +170,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc } } + @Override public void handleEvent(CProjectDescriptionEvent event) { IProject project = event.getProject(); if(!fProject.equals(project)) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java index 2a5b536b634..f6317eb69e9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java @@ -75,6 +75,7 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP return fProject; } + @Override public IScannerInfo getScannerInformation(IResource resource) { if(!fInited) updateProjCfgInfo(CProjectDescriptionManager.getInstance().getProjectDescription(fProject, false)); @@ -262,12 +263,14 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP return values; } + @Override public void subscribe(IResource resource, IScannerInfoChangeListener listener) { // TODO Auto-generated method stub } + @Override public void unsubscribe(IResource resource, IScannerInfoChangeListener listener) { // TODO Auto-generated method stub @@ -278,6 +281,7 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); } + @Override public void handleEvent(CProjectDescriptionEvent event) { if(!event.getProject().equals(fProject)) return; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionStorageType.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionStorageType.java index d33264ddf9e..06e6cfef99f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionStorageType.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICProjectDescriptionStorageType.java @@ -95,16 +95,18 @@ public interface ICProjectDescriptionStorageType { return false; return true; } + @Override public boolean createsCProjectXMLFile() { return storageType.createsCProjectXMLFile(); } + @Override public AbstractCProjectDescriptionStorage getProjectDescriptionStorage(CProjectDescriptionStorageTypeProxy type, IProject project, Version version) { return storageType.getProjectDescriptionStorage(type, project, version); } private static Version getVersion(IConfigurationElement element, String id, Version defaultValue) throws IllegalArgumentException{ String value = element.getAttribute(id); - if (value==null) + if (value==null) return defaultValue; Version v; try { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java index 61221d2225d..3dae04ee5d9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MapProxyCache.java @@ -26,6 +26,7 @@ public class MapProxyCache implements IProxyCache { return fMap; } + @Override public CDataProxy[] getCachedProxies() { Map map = getMap(false); if(map != null){ @@ -35,6 +36,7 @@ public class MapProxyCache implements IProxyCache { return new CDataProxy[0]; } + @Override public CDataProxy getCachedProxy(String id) { Map map = getMap(false); if(map != null) @@ -42,29 +44,35 @@ public class MapProxyCache implements IProxyCache { return null; } + @Override public void removeCachedProxy(String id) { Map map = getMap(false); if(map != null) map.remove(id); } + @Override public void clear() { fMap.clear(); } + @Override public void addCachedProxy(CDataProxy proxy) { getMap(true).put(proxy.getId(), proxy); } + @Override @SuppressWarnings("unchecked") public Map getCachedProxiesMap() { return (Map)getMap(true).clone(); } + @Override public CDataProxy getCachedProxy(CDataObject data) { return getCachedProxy(data.getId()); } + @Override public void removeCachedProxy(CDataProxy proxy) { removeCachedProxy(proxy.getId()); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java index a6838481d1c..653b0c662bd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/MultiConfigDescription.java @@ -64,6 +64,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#create(java.lang.String, java.lang.String) */ + @Override public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException { if (DEBUG) @@ -74,6 +75,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#createExternalSetting(java.lang.String[], java.lang.String[], java.lang.String[], org.eclipse.cdt.core.settings.model.ICSettingEntry[]) */ + @Override public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIds, String[] extensions, ICSettingEntry[] entries) throws WriteAccessException { @@ -85,6 +87,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#createFileDescription(org.eclipse.core.runtime.IPath, org.eclipse.cdt.core.settings.model.ICResourceDescription) */ + @Override public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException { @@ -95,6 +98,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#createFolderDescription(org.eclipse.core.runtime.IPath, org.eclipse.cdt.core.settings.model.ICFolderDescription) */ + @Override public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) throws CoreException, WriteAccessException { @@ -106,6 +110,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#get(java.lang.String) */ + @Override public ICConfigExtensionReference[] get(String extensionPointID) { if (DEBUG) System.out.println("Bad multi access: MultiConfigDescription.get()"); //$NON-NLS-1$ @@ -115,27 +120,31 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#getBuildSetting() */ + @Override public ICBuildSetting getBuildSetting() { if (DEBUG) System.out.println("Bad multi access: MultiConfigDescription.getBuildSetting()"); //$NON-NLS-1$ return null; } + @Override public String[][] getErrorParserIDs() { - String[][] out = new String[fCfgs.length][]; + String[][] out = new String[fCfgs.length][]; for (int i=0; i lst = new ArrayList(); - for (int i=0; i lst = new ArrayList(); - for (int i=0; i getReferenceInfo() { if (DEBUG) System.out.println("Bad multi access: MultiConfigDescription.getReferenceInfo()"); //$NON-NLS-1$ @@ -247,6 +267,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#getResolvedSourceEntries() */ + @Override public ICSourceEntry[] getResolvedSourceEntries() { return new ICSourceEntry[0]; } @@ -254,6 +275,7 @@ public class MultiConfigDescription extends MultiItemsHolder implements /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#getResourceDescription(org.eclipse.core.runtime.IPath, boolean) */ + @Override public ICResourceDescription getResourceDescription(IPath path, boolean isForFolder) { ArrayList lst = new ArrayList(); @@ -281,13 +303,14 @@ public class MultiConfigDescription extends MultiItemsHolder implements return new MultiFileDescription( lst.toArray(new ICFileDescription[lst.size()])); } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.settings.model.ICConfigurationDescription#getResourceDescriptions() */ + @Override public ICResourceDescription[] getResourceDescriptions() { ArrayList lst = new ArrayList(); - for (int i=0; i refs) throws WriteAccessException { for (int i=0; i comp) { ICLanguageSetting[][] ls = new ICLanguageSetting[fRess.length][]; for (int i=0; i incs, boolean toAll) { for (int i=0; i 0){ @@ -116,6 +123,7 @@ public class ProxyProvider implements IProxyProvider { return proxies; } + @Override public void cacheValues() { if(!fProxiesCached || !fScope.isStatic()){ fillCache(); @@ -123,6 +131,7 @@ public class ProxyProvider implements IProxyProvider { } } + @Override public void invalidateCache() { fProxiesCached = false; CDataProxy[] proxies = fCache.getCachedProxies(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceChangeHandler.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceChangeHandler.java index 63684384157..84f5161df5c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceChangeHandler.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceChangeHandler.java @@ -76,6 +76,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements /** Map of moved & removed resources: 'from' -> 'to'; 'to' may be null for removed resources */ Map fMovedResources = new HashMap(); + @Override public void handleProjectClose(IProject project) { fMngr.projectClosedRemove(project); } @@ -121,6 +122,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements return updatedList != null ? updatedList.toArray(new ICSourceEntry[updatedList.size()]) : null; } + @Override public boolean handleResourceMove(IResource fromRc, IResource toRc) { boolean proceed = true; IProject fromProject = fromRc.getProject(); @@ -135,7 +137,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements break; case IResource.FOLDER: case IResource.FILE: - // Only handle move in the same project + // Only handle move in the same project // TODO: should we treat this as a remove? if (!toProject.equals(fromProject)) break; @@ -163,6 +165,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements return des; } + @Override public boolean handleResourceRemove(IResource rc) { boolean proceed = true; IProject project = rc.getProject(); @@ -182,6 +185,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements return proceed; } + @Override public void done() { // If the resource's project was moved / removed, don't consider the path for source entry removal for (Iterator it = fMovedResources.keySet().iterator(); it.hasNext() ; ) { @@ -198,6 +202,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements // Run it in the Workspace, so we don't trip Bug 311189 CProjectDescriptionManager.runWspModification(new IWorkspaceRunnable(){ + @Override public void run(IProgressMonitor monitor) throws CoreException { for (Map.Entry entry : fMovedResources.entrySet()) { IResource from = entry.getKey(); @@ -209,7 +214,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements if (to == null) { if (from.exists()) continue; - // Workaround for platform Bug 317783 + // Workaround for platform Bug 317783 if (from.getWorkspace().validateFiltered(from).isOK()) { URI uri = from.getLocationURI(); if (uri != null && EFS.getStore(uri).fetchInfo().exists()) @@ -283,6 +288,7 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements /* (non-Javadoc) * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext) */ + @Override public void saving(ISaveContext context) throws CoreException { //Request a resource delta to be used on next activation. context.needDelta(); @@ -291,18 +297,21 @@ public class ResourceChangeHandler extends ResourceChangeHandlerBase implements /* (non-Javadoc) * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext) */ + @Override public void doneSaving(ISaveContext context) { } /* (non-Javadoc) * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext) */ + @Override public void prepareToSave(ISaveContext context) throws CoreException { } /* (non-Javadoc) * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext) */ + @Override public void rollback(ISaveContext context) { } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java index 6cca262c6a1..20c96ff05fb 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ResourceDescriptionHolder.java @@ -24,7 +24,7 @@ import org.eclipse.core.runtime.IPath; public class ResourceDescriptionHolder { private PathSettingsContainer fPathSettingContainer; private boolean fIncludeCurrent; - + public ResourceDescriptionHolder(PathSettingsContainer pathContainer, boolean includeCurrent){ fPathSettingContainer = pathContainer; @@ -37,11 +37,11 @@ public class ResourceDescriptionHolder { return (ICResourceDescription)container.getValue(); return null; } - + public IPath getCurrentPath(){ return fPathSettingContainer.getPath(); } - + public void setCurrentPath(IPath path){ //TODO: do we need to move children here? fPathSettingContainer.setPath(path, true); @@ -51,11 +51,12 @@ public class ResourceDescriptionHolder { PathSettingsContainer container = fPathSettingContainer.getChildContainer(path, true, true); container.setValue(des); } - + public ICResourceDescription[] getResourceDescriptions(final int kind){ final List list = new ArrayList(); fPathSettingContainer.accept(new IPathSettingsContainerVisitor(){ + @Override public boolean visit(PathSettingsContainer container) { ICResourceDescription des = (ICResourceDescription)container.getValue(); if((container != fPathSettingContainer || fIncludeCurrent) @@ -64,14 +65,14 @@ public class ResourceDescriptionHolder { } return true; } - + }); - + if(kind == ICSettingBase.SETTING_FILE) return list.toArray(new ICFileDescription[list.size()]); else if(kind == ICSettingBase.SETTING_FOLDER) return list.toArray(new ICFolderDescription[list.size()]); - + return list.toArray(new ICResourceDescription[list.size()]); } @@ -79,11 +80,12 @@ public class ResourceDescriptionHolder { final List list = new ArrayList(); fPathSettingContainer.accept(new IPathSettingsContainerVisitor(){ + @Override public boolean visit(PathSettingsContainer container) { list.add(container.getValue()); return true; } - + }); return list.toArray(new ICResourceDescription[list.size()]); } @@ -91,32 +93,32 @@ public class ResourceDescriptionHolder { public void removeResurceDescription(IPath path){ fPathSettingContainer.removeChildContainer(path); } - + public ICResourceDescription getCurrentResourceDescription(){ return (ICResourceDescription)fPathSettingContainer.getValue(); } - + public ICResourceDescription[] getDirectChildren(){ PathSettingsContainer dc[] = fPathSettingContainer.getDirectChildren(); ICResourceDescription rcDess[] = new ICResourceDescription[dc.length]; - + for(int i = 0; i < dc.length; i++){ rcDess[i] = (ICResourceDescription)dc[i].getValue(); } - + return rcDess; } - + // public ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, IPath paths[]){ // if(paths == null || paths.length == 0) // paths = new IPath[]{new Path("")}; //$NON-NLS-1$ -// +// //// Set set = new HashSet(paths.length); // PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); // IPath pi, pj; // List entriesList = new ArrayList(paths.length); // IPath projPath = project != null ? project.getFullPath() : null; -// +// // for(int i = 0; i < paths.length; i++){ // pi = paths[i]; //// set.clear(); @@ -129,7 +131,7 @@ public class ResourceDescriptionHolder { // cr.getChildContainer(pj, true, true); // } // } -// +// // PathSettingsContainer children[] = fPathSettingContainer.getDirectChildrenForPath(pi); // for(int k = 0; k < children.length; k++){ // PathSettingsContainer child = children[k]; @@ -138,14 +140,14 @@ public class ResourceDescriptionHolder { // IPath parentExclusionPath = parentExclusion.getPath(); // if(parentExclusionPath.segmentCount() > 0 && !parentExclusionPath.equals(childPath) && parentExclusionPath.isPrefixOf(childPath)) // continue; -// +// // ICResourceDescription rcDes = (ICResourceDescription)child.getValue(); // if(rcDes.isExcluded()){ //// set.add(rcDes.getPath()); // cr.getChildContainer(childPath, true, true); // } // } -// +// // PathSettingsContainer exclusions[] = cr.getChildren(false); //// IPath exlusionPaths[] = new IPath[set.size()]; // IPath exlusionPaths[] = new IPath[exclusions.length]; @@ -165,14 +167,14 @@ public class ResourceDescriptionHolder { // // return (ICSourceEntry[])entriesList.toArray(new ICSourceEntry[entriesList.size()]); // } - + public ICFolderDescription getParentFolderDescription(){ PathSettingsContainer parent = fPathSettingContainer.getParentContainer(); if(parent != null) return (ICFolderDescription)parent.getValue(); return null; } - + public static IPath normalizePath(IPath path){ return path.makeRelative(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java index 89e13e57c98..e314ffce39b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java @@ -32,12 +32,13 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements super(project, CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); } + @Override public IScannerInfo getScannerInformation(IResource resource) { providerRequested(); return fProvider.getScannerInformation(resource); } - - + + protected void notifyInfoListeners(IResource rc, IScannerInfo info) { // Call in the cavalry List listeners = getListeners().get(rc); @@ -51,13 +52,14 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements } } - + /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.core.resources.IResource, * org.eclipse.cdt.core.parser.IScannerInfoChangeListener) */ + @Override public synchronized void subscribe(IResource resource, IScannerInfoChangeListener listener) { if (resource == null || listener == null) { return; @@ -89,10 +91,11 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.core.resources.IResource, * org.eclipse.cdt.core.parser.IScannerInfoChangeListener) */ + @Override public synchronized void unsubscribe(IResource resource, IScannerInfoChangeListener listener) { if (resource == null || listener == null) { return; @@ -107,6 +110,7 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements } } + @Override public void changeNotification(IResource rc, IScannerInfo info) { notifyInfoListeners(rc, info); } @@ -134,7 +138,7 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements fProvider = provider; provider.subscribe(getProject(), this); } - + @Override protected void postProcessProviderChange(Object newProvider, Object oldProvider) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SettingsContext.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SettingsContext.java index fcaf631fffd..3bc353f3a1c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SettingsContext.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SettingsContext.java @@ -21,21 +21,22 @@ import org.eclipse.core.runtime.IProgressMonitor; public final class SettingsContext implements IModificationContext{ private static final int USER_FLAGS_MASK = 0x0000ffff; public static final int CFG_DATA_CACHED = 1 << 15; - + private IProjectDescription fEDes; private IProject fProject; private CompositeWorkspaceRunnable fRunnable; private int fFlags; - - + + public SettingsContext(IProject project){ fProject = project; } + @Override public IProject getProject(){ return fProject; } - + void init(CConfigurationDescriptionCache cfg){ int flags = 0; if(cfg.getBaseCache() != null) @@ -48,16 +49,18 @@ public final class SettingsContext implements IModificationContext{ if(eDes == null && create){ if(fProject == null) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("SettingsContext.0")); //$NON-NLS-1$ - + eDes = fProject.getDescription(); } return eDes; } - + + @Override public IProjectDescription getEclipseProjectDescription() throws CoreException{ return getEclipseProjectDescription(true); } - + + @Override public void setEclipseProjectDescription(IProjectDescription des) throws CoreException { if(fEDes == null) @@ -71,28 +74,30 @@ public final class SettingsContext implements IModificationContext{ fRunnable = new CompositeWorkspaceRunnable(null); return fRunnable; } - + + @Override public void addWorkspaceRunnable(IWorkspaceRunnable runnable){ getCompositeWorkspaceRunnable(true).add(runnable); } - + public IWorkspaceRunnable createOperationRunnable() { CompositeWorkspaceRunnable result = new CompositeWorkspaceRunnable(null); - + IWorkspaceRunnable r = getSetEclipseProjectDescriptionRunnable(); if(r != null) result.add(r); r = getCompositeWorkspaceRunnable(false); if(r != null) result.add(r); - + return result.isEmpty() ? null : result; } - + private IWorkspaceRunnable getSetEclipseProjectDescriptionRunnable(){ if(fEDes != null){ return new IWorkspaceRunnable(){ + @Override public void run(IProgressMonitor monitor) throws CoreException { fProject.setDescription(fEDes, monitor); @@ -106,12 +111,14 @@ public final class SettingsContext implements IModificationContext{ return fFlags; } + @Override public void setConfigurationSettingsFlags(int flags) { - //system flags are read only; + //system flags are read only; flags &= USER_FLAGS_MASK; fFlags |= flags; } + @Override public boolean isBaseDataCached() { return (fFlags & CFG_DATA_CACHED) != 0; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SynchronizedStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SynchronizedStorageElement.java index 25ff82ac532..b8385ac9036 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SynchronizedStorageElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SynchronizedStorageElement.java @@ -76,7 +76,7 @@ public class SynchronizedStorageElement implements ICStorageElement { public static SynchronizedStorageElement synchronizedElement(ICStorageElement el, Object lock) { return new SynchronizedStorageElement(el, lock); } - + /** * @return the lock used to synchronize this SynchronizedStorage and its children */ @@ -85,18 +85,21 @@ public class SynchronizedStorageElement implements ICStorageElement { } + @Override public void clear() { synchronized (fLock) { fEl.clear(); } } + @Override public ICStorageElement createChild(String name) { synchronized (fLock) { return new SynchronizedStorageElement(fEl.createChild(name), fLock); } } + @Override public ICStorageElement createCopy() throws UnsupportedOperationException, CoreException { synchronized (fLock) { @@ -104,6 +107,7 @@ public class SynchronizedStorageElement implements ICStorageElement { } } + @Override public boolean equals(ICStorageElement other) { synchronized (fLock) { if (other instanceof SynchronizedStorageElement) @@ -112,24 +116,28 @@ public class SynchronizedStorageElement implements ICStorageElement { } } + @Override public String getAttribute(String name) { synchronized (fLock) { return fEl.getAttribute(name); } } + @Override public String[] getAttributeNames() { synchronized (fLock) { return fEl.getAttributeNames(); } } + @Override public ICStorageElement[] getChildren() { synchronized (fLock) { return createSynchronizedChildren(fEl.getChildren()); } } + @Override public ICStorageElement[] getChildrenByName(String name) { synchronized (fLock) { return createSynchronizedChildren(fEl.getChildrenByName(name)); @@ -143,12 +151,14 @@ public class SynchronizedStorageElement implements ICStorageElement { return synchChildren; } + @Override public String getName() { synchronized (fLock) { return fEl.getName(); } } + @Override public ICStorageElement getParent() { synchronized (fLock) { if (fEl.getParent() == null || @@ -158,24 +168,28 @@ public class SynchronizedStorageElement implements ICStorageElement { } } + @Override public String getValue() { synchronized (fLock) { return fEl.getValue(); } } + @Override public boolean hasAttribute(String name) { synchronized (fLock) { return fEl.hasAttribute(name); } } + @Override public boolean hasChildren() { synchronized (fLock) { return fEl.hasChildren(); } } + @Override public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException { synchronized (fLock) { @@ -183,12 +197,14 @@ public class SynchronizedStorageElement implements ICStorageElement { } } + @Override public void removeAttribute(String name) { synchronized (fLock) { fEl.removeAttribute(name); } } + @Override public void removeChild(ICStorageElement el) { synchronized (fLock) { if (el instanceof SynchronizedStorageElement) @@ -197,12 +213,14 @@ public class SynchronizedStorageElement implements ICStorageElement { } } + @Override public void setAttribute(String name, String value) { synchronized (fLock) { fEl.setAttribute(name, value); } } + @Override public void setValue(String value) { synchronized (fLock) { fEl.setValue(value); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java index a7ef3579cca..8ad92ba26c8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java @@ -155,14 +155,16 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto fElement = el; } + @Override public void run(IProgressMonitor monitor) throws CoreException { JobChangeAdapter notifyJobCanceller = new NotifyJobCanceller(); try { // See Bug 249951 & Bug 310007 Job.getJobManager().addJobChangeListener(notifyJobCanceller); - // Ensure we can check a null-job into the workspace + // Ensure we can check a null-job into the workspace // i.e. if notification is currently in progress wait for it to finish... ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { } }, null, IWorkspace.AVOID_UPDATE, null); @@ -172,7 +174,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto ((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes); } finally { serializingLock.release(); - Job.getJobManager().removeJobChangeListener(notifyJobCanceller); + Job.getJobManager().removeJobChangeListener(notifyJobCanceller); } } @@ -313,7 +315,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto // the suggested solution is to use modStamp + modTime // // Both values are cached in resourceInfo, so this is fast. - return resource.getModificationStamp() + resource.getLocalTimeStamp(); + return resource.getModificationStamp() + resource.getLocalTimeStamp(); } /** @@ -736,6 +738,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto // try refreshing final Throwable[] t = new Throwable[1]; Job job = CProjectDescriptionManager.runWspModification(new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { try { rscFile.refreshLocal(IResource.DEPTH_ZERO, null); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorageFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorageFactory.java index c3b6a2e1b67..202afc37850 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorageFactory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorageFactory.java @@ -21,10 +21,12 @@ import org.osgi.framework.Version; */ public class XmlProjectDescriptionStorageFactory implements ICProjectDescriptionStorageType { + @Override public AbstractCProjectDescriptionStorage getProjectDescriptionStorage(CProjectDescriptionStorageTypeProxy type, IProject project, Version version) { return new XmlProjectDescriptionStorage(type, project, version); } + @Override public boolean createsCProjectXMLFile() { return true; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorage.java index b599f7d22f4..7f693007f43 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorage.java @@ -74,6 +74,7 @@ public class XmlStorage implements ICSettingsStorage { } } + @Override public boolean isReadOnly(){ return fIsReadOnly; } @@ -127,6 +128,7 @@ public class XmlStorage implements ICSettingsStorage { return getStorage(id, false) != null; } + @Override public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException { if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -173,6 +175,7 @@ public class XmlStorage implements ICSettingsStorage { } } + @Override public ICStorageElement getStorage(String id, boolean create){ initChildren(); @@ -199,6 +202,7 @@ public class XmlStorage implements ICSettingsStorage { return child; } + @Override public void removeStorage(String id){ initChildren(); InternalXmlStorageElement se = fStorageElementMap.remove(id); @@ -208,7 +212,7 @@ public class XmlStorage implements ICSettingsStorage { throw ExceptionFactory.createIsReadOnlyException(); synchronized (fLock) { - synchronized (se.fLock){ + synchronized (se.fLock){ fIsDirty = true; Node nextSibling = se.fElement.getNextSibling(); fElement.removeChild(se.fElement); @@ -223,6 +227,7 @@ public class XmlStorage implements ICSettingsStorage { } } + @Override public boolean isModified(){ if(fIsDirty) return true; @@ -236,6 +241,7 @@ public class XmlStorage implements ICSettingsStorage { return false; } + @Override public void setReadOnly(boolean readOnly, boolean keepModify){ fIsReadOnly = readOnly; fIsDirty &= keepModify; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java index 148ce441030..91b62ed3a2b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java @@ -40,7 +40,7 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class XmlStorageElement implements ICStorageElement { - + protected static final String[] emptyStringList = new String[0]; // Lock to prevent concurrent access to XML DOM which isn't thread-safe for read (Bug 319245) @@ -72,11 +72,11 @@ public class XmlStorageElement implements ICStorageElement { if(attributeFilters != null && attributeFilters.length != 0) fAttributeFilters = attributeFilters.clone(); - + if(childFilters != null && childFilters.length != 0) fChildFilters = childFilters.clone(); } - + /** * Create ICStorageElement children from Xml tree */ @@ -98,7 +98,7 @@ public class XmlStorageElement implements ICStorageElement { fChildrenCreated = true; } } - + private XmlStorageElement createAddChild(Element element, boolean alowReferencingParent, String[] attributeFilters, @@ -109,7 +109,7 @@ public class XmlStorageElement implements ICStorageElement { return child; } } - + protected XmlStorageElement createChild(Element element, boolean alowReferencingParent, String[] attributeFilters, @@ -117,6 +117,7 @@ public class XmlStorageElement implements ICStorageElement { return new XmlStorageElement(element, this, attributeFilters, childFilters); } + @Override public ICStorageElement[] getChildren() { return getChildren(XmlStorageElement.class); } @@ -141,6 +142,7 @@ public class XmlStorageElement implements ICStorageElement { } } + @Override public ICStorageElement[] getChildrenByName(String name) { synchronized (fLock) { createChildren(); @@ -151,7 +153,8 @@ public class XmlStorageElement implements ICStorageElement { return children.toArray(new ICStorageElement[children.size()]); } } - + + @Override public boolean hasChildren() { synchronized (fLock) { createChildren(); @@ -159,10 +162,12 @@ public class XmlStorageElement implements ICStorageElement { } } + @Override public ICStorageElement getParent() { return fParent; } + @Override public String getAttribute(String name) { synchronized (fLock) { if(isPropertyAlowed(name) && fElement.hasAttribute(name)) @@ -170,13 +175,14 @@ public class XmlStorageElement implements ICStorageElement { } return null; } - + + @Override public boolean hasAttribute(String name) { synchronized (fLock) { return fElement.hasAttribute(name); } } - + private boolean isPropertyAlowed(String name){ if(fAttributeFilters != null){ return checkString(name, fAttributeFilters); @@ -201,6 +207,7 @@ public class XmlStorageElement implements ICStorageElement { return true; } + @Override public void removeChild(ICStorageElement el) { if(el instanceof XmlStorageElement){ ICStorageElement[] children = getChildren(); @@ -224,9 +231,10 @@ public class XmlStorageElement implements ICStorageElement { } } } - + } + @Override public void removeAttribute(String name) { synchronized (fLock) { if(isPropertyAlowed(name)) @@ -234,13 +242,15 @@ public class XmlStorageElement implements ICStorageElement { } } + @Override public void setAttribute(String name, String value) { synchronized (fLock) { if(isPropertyAlowed(name)) fElement.setAttribute(name, value); } } - + + @Override public void clear(){ synchronized (fLock) { createChildren(); @@ -268,7 +278,7 @@ public class XmlStorageElement implements ICStorageElement { } } - public ICStorageElement createChild(String name, + public ICStorageElement createChild(String name, boolean alowReferencingParent, String[] attributeFilters, String[] childFilters) { @@ -281,16 +291,19 @@ public class XmlStorageElement implements ICStorageElement { } } + @Override public String getName() { synchronized (fLock) { return fElement.getNodeName(); } } + @Override public ICStorageElement createChild(String name) { return createChild(name, true, null, null); } + @Override public String getValue() { Text text = getTextChild(); if(text != null) @@ -298,6 +311,7 @@ public class XmlStorageElement implements ICStorageElement { return null; } + @Override public void setValue(String value) { Text text = getTextChild(); synchronized (fLock) { @@ -315,7 +329,7 @@ public class XmlStorageElement implements ICStorageElement { } } } - + private Text getTextChild(){ synchronized (fLock) { NodeList nodes = fElement.getChildNodes(); @@ -330,16 +344,17 @@ public class XmlStorageElement implements ICStorageElement { return text; } } - + + @Override public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException { return addChild(el, true, null, null); } - public ICStorageElement addChild(ICStorageElement el, + public ICStorageElement addChild(ICStorageElement el, boolean alowReferencingParent, String[] attributeFilters, String[] childFilters) throws UnsupportedOperationException { - + if(!isChildAlowed(el.getName())) return null; @@ -362,7 +377,7 @@ public class XmlStorageElement implements ICStorageElement { throw new UnsupportedOperationException(); } } - + public String[] getAttributeFilters(){ if(fAttributeFilters != null) return fAttributeFilters.clone(); @@ -375,18 +390,19 @@ public class XmlStorageElement implements ICStorageElement { return emptyStringList; } + @Override public boolean equals(ICStorageElement el){ if(!getName().equals(el.getName())) return false; - + if (!valuesMatch(getValue(), el.getValue())) return false; - + String[] attrs = getAttributeNames(); String[] otherAttrs = el.getAttributeNames(); if(attrs.length != otherAttrs.length) return false; - + if(attrs.length != 0){ Set set = new HashSet(Arrays.asList(attrs)); set.removeAll(Arrays.asList(otherAttrs)); @@ -399,21 +415,21 @@ public class XmlStorageElement implements ICStorageElement { } } - - + + XmlStorageElement[] children = (XmlStorageElement[])getChildren(); ICStorageElement[] otherChildren = el.getChildren(); - + if(children.length != otherChildren.length) return false; - + if(children.length != 0){ for(int i = 0; i < children.length; i++){ if(!children[i].equals(otherChildren[i])) return false; } } - + return true; } @@ -427,6 +443,7 @@ public class XmlStorageElement implements ICStorageElement { } } + @Override public String[] getAttributeNames() { synchronized (fLock) { NamedNodeMap nodeMap = fElement.getAttributes(); @@ -441,12 +458,13 @@ public class XmlStorageElement implements ICStorageElement { return list.toArray(new String[list.size()]); } } - + + @Override public ICStorageElement createCopy() throws UnsupportedOperationException, CoreException { Element newEl = createXmlElementCopy(); return new XmlStorageElement(newEl, null, fAttributeFilters, fChildFilters); } - + protected Element createXmlElementCopy() throws CoreException { try { @@ -465,7 +483,7 @@ public class XmlStorageElement implements ICStorageElement { newXmlEl = (Element)node; } } - + } else { newXmlEl = (Element)importAddNode(doc, fElement); } @@ -485,7 +503,7 @@ public class XmlStorageElement implements ICStorageElement { } else { node = doc.importNode(node, true); } - + return doc.appendChild(node); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2.java index 09c487c4439..386d30609f4 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2.java @@ -89,6 +89,7 @@ public class XmlProjectDescriptionStorage2 extends XmlProjectDescriptionStorage final boolean[] needReload = new boolean[] { false }; try { project.getFolder(STORAGE_FOLDER_NAME).accept(new IResourceProxyVisitor() { + @Override public boolean visit(IResourceProxy proxy) throws CoreException { if (modificationMap.containsKey(proxy.getName())) { long modStamp = getModificationStamp(proxy.requestResource()); @@ -136,7 +137,7 @@ public class XmlProjectDescriptionStorage2 extends XmlProjectDescriptionStorage currEl.getAttribute(EXTERNAL_CELEMENT_KEY), reCreate, createEmptyIfNotFound, readOnly); // Update the modification stamp - modificationMap.put(currEl.getAttribute(EXTERNAL_CELEMENT_KEY), + modificationMap.put(currEl.getAttribute(EXTERNAL_CELEMENT_KEY), getModificationStamp(project.getFolder(STORAGE_FOLDER_NAME).getFile(currEl.getAttribute(EXTERNAL_CELEMENT_KEY)))); ICStorageElement currParent = currEl.getParent(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2Factory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2Factory.java index 457fcd54482..29167aeae19 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2Factory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml2/XmlProjectDescriptionStorage2Factory.java @@ -22,10 +22,12 @@ import org.osgi.framework.Version; */ public class XmlProjectDescriptionStorage2Factory implements ICProjectDescriptionStorageType { + @Override public AbstractCProjectDescriptionStorage getProjectDescriptionStorage(CProjectDescriptionStorageTypeProxy type, IProject project, Version version) { return new XmlProjectDescriptionStorage2(type, project, version); } + @Override public boolean createsCProjectXMLFile() { return true; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCacheEnumerator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCacheEnumerator.java index 3d9fc9e7aba..0e9073d47f4 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCacheEnumerator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/LRUCacheEnumerator.java @@ -13,16 +13,16 @@ package org.eclipse.cdt.internal.core.util; import java.util.Enumeration; /** - * The LRUCacheEnumerator returns its elements in + * The LRUCacheEnumerator returns its elements in * the order they are found in the LRUCache, with the * most recent elements first. * - * Once the enumerator is created, elements which are later added + * Once the enumerator is created, elements which are later added * to the cache are not returned by the enumerator. However, - * elements returned from the enumerator could have been closed + * elements returned from the enumerator could have been closed * by the cache. * - * This class is similar to the JDT LRUCacheEnumerator class. + * This class is similar to the JDT LRUCacheEnumerator class. */ public class LRUCacheEnumerator implements Enumeration { /** @@ -35,7 +35,7 @@ public class LRUCacheEnumerator implements Enumeration { * Value returned by nextElement(); */ public T fValue; - + /** * Next element */ @@ -57,12 +57,14 @@ public class LRUCacheEnumerator implements Enumeration { /** * Returns true if more elements exist. */ + @Override public boolean hasMoreElements() { return fElementQueue != null; } /** * Returns the next element. */ + @Override public T nextElement() { T temp = fElementQueue.fValue; fElementQueue = fElementQueue.fNext; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/AbstractCExtension.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/AbstractCExtension.java index cb589465b3b..c797dae67a9 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/AbstractCExtension.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/AbstractCExtension.java @@ -23,17 +23,19 @@ public abstract class AbstractCExtension extends PlatformObject implements ICExt /** * Returns the project for which this extension is defined. - * + * * @return the project */ + @Override public final IProject getProject() { return fProject; } - + /** * May return null! * @deprecated Use {@link #getConfigExtensionReference()} instead. */ + @Override @Deprecated public final ICExtensionReference getExtensionReference() { if (extensionRef == null) { @@ -60,10 +62,11 @@ public abstract class AbstractCExtension extends PlatformObject implements ICExt * Returns the extension reference this extension was created from. * @since 5.2 */ + @Override public final ICConfigExtensionReference getConfigExtensionReference() { return fCfgExtensionRef; } - + // internal stuff /** * @noreference This method is not intended to be referenced by clients. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 344c406447f..cb10cbfe991 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -88,7 +88,7 @@ import com.ibm.icu.text.MessageFormat; /** * CCorePlugin is the life-cycle owner of the core plug-in, and starting point for access to many core APIs. - * + * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. */ @@ -112,15 +112,15 @@ public class CCorePlugin extends Plugin { public final static String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; //$NON-NLS-1$ public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$ public final static String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$ - + public static final String INDEX_SIMPLE_ID = "CIndex"; //$NON-NLS-1$ public static final String INDEX_UNIQ_ID = PLUGIN_ID + "." + INDEX_SIMPLE_ID; //$NON-NLS-1$ - + public static final String INDEXER_SIMPLE_ID = "CIndexer"; //$NON-NLS-1$ public static final String INDEXER_UNIQ_ID = PLUGIN_ID + "." + INDEXER_SIMPLE_ID; //$NON-NLS-1$ public static final String PREF_INDEXER = "indexer"; //$NON-NLS-1$ public static final String DEFAULT_INDEXER = IPDOMManager.ID_FAST_INDEXER; - + /** * Name of the extension point for contributing an error parser */ @@ -140,8 +140,8 @@ public class CCorePlugin extends Plugin { public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$ private final static String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$ - private final static String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$ - + private final static String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$ + /** * Name of the extension point for contributing a source code formatter */ @@ -152,7 +152,7 @@ public class CCorePlugin extends Plugin { * @see #getDefaultOptions */ public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$ - + /** * IContentType id for C Source Unit */ @@ -177,7 +177,7 @@ public class CCorePlugin extends Plugin { * IContentType id for Binary Files */ public final static String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$ - + /** * Possible configurable option value. * @see #getDefaultOptions() @@ -210,11 +210,11 @@ public class CCorePlugin extends Plugin { private volatile CProjectDescriptionManager fNewCProjectDescriptionManager; private CoreModel fCoreModel; - + private PDOMManager pdomManager; private CdtVarPathEntryVariableManager fPathEntryVariableManager; - + private final class NullConsole implements IConsole { private ConsoleOutputStream nullStream = new ConsoleOutputStream() { @Override @@ -227,14 +227,18 @@ public class CCorePlugin extends Plugin { public void write(int c) throws IOException { } }; + @Override public void start(IProject project) { } + @Override public ConsoleOutputStream getOutputStream() { return nullStream; } + @Override public ConsoleOutputStream getInfoStream() { - return nullStream; + return nullStream; } + @Override public ConsoleOutputStream getErrorStream() { return nullStream; } @@ -251,7 +255,7 @@ public class CCorePlugin extends Plugin { } /** - * Returns the shared working copies currently registered for the default buffer factory. + * Returns the shared working copies currently registered for the default buffer factory. * @since 5.1 */ public static IWorkingCopy[] getSharedWorkingCopies() { @@ -288,7 +292,7 @@ public class CCorePlugin extends Plugin { public static IPositionTrackerManager getPositionTrackerManager() { return PositionTrackerManager.getInstance(); } - + public static CCorePlugin getDefault() { return fgCPlugin; } @@ -301,17 +305,17 @@ public class CCorePlugin extends Plugin { public void stop(BundleContext context) throws Exception { try { pdomManager.shutdown(); - + PositionTrackerManager.getInstance().uninstall(); - + // if (fDescriptorManager != null) { // fDescriptorManager.shutdown(); // } - + if (fCoreModel != null) { fCoreModel.shutdown(); } - + if (cdtLog != null) { cdtLog.shutdown(); } @@ -322,7 +326,7 @@ public class CCorePlugin extends Plugin { fNewCProjectDescriptionManager.shutdown(); ResourceLookup.shutdown(); - + savePluginPreferences(); } finally { super.stop(context); @@ -341,7 +345,7 @@ public class CCorePlugin extends Plugin { configurePluginDebugOptions(); PositionTrackerManager.getInstance().install(); ResourceLookup.startup(); - + // new project model needs to register the resource listener first. CProjectDescriptionManager descManager = CProjectDescriptionManager.getInstance(); final Job post1 = descManager.startup(); @@ -355,7 +359,7 @@ public class CCorePlugin extends Plugin { pdomManager = new PDOMManager(); final Job post2= pdomManager.startup(); - + // bug 186755, when started after the platform has been started the job manager // is no longer suspended. So we have to start a job at the very end to make // sure we don't trigger a concurrent plug-in activation from within the job. @@ -369,14 +373,14 @@ public class CCorePlugin extends Plugin { * These options allow to configure the behavior 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 CCorePlugin for each of the option ID and + * + * Helper constants have been defined on CCorePlugin for each of the option ID and * their possible constant values. - * + * * Note: more options might be added in further releases. *
      * RECOGNIZED OPTIONS:
-     * 
+     *
      * CORE / Specify Default Source Encoding Format
      *    Get the encoding format for translated sources. This setting is read-only, it is equivalent
      *    to 'ResourcesPlugin.getEncoding()'.
@@ -384,7 +388,7 @@ public class CCorePlugin extends Plugin {
      *     - possible values:   { any of the supported encoding names}.
      *     - default:           
      * 
- * + * * @return a mutable map containing the default settings of all known options * (key type: String; value type: String) * @see #setOptions @@ -395,20 +399,20 @@ public class CCorePlugin extends Plugin { // see #initializeDefaultPluginPreferences() for changing default settings Preferences preferences = getDefault().getPluginPreferences(); HashSet optionNames = CModelManager.OptionNames; - + // get preferences set to their default for (String propertyName : preferences.defaultPropertyNames()){ if (optionNames.contains(propertyName)) defaultOptions.put(propertyName, preferences.getDefaultString(propertyName)); - } + } // get preferences not set to their default for (String propertyName : preferences.propertyNames()) { - if (optionNames.contains(propertyName)) + if (optionNames.contains(propertyName)) defaultOptions.put(propertyName, preferences.getDefaultString(propertyName)); - } + } // get encoding through resource plugin - defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); - + defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); + return defaultOptions; } @@ -418,13 +422,13 @@ public class CCorePlugin extends Plugin { *

* 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 CCorePlugin#getDefaultOptions */ public static String getOption(String optionName) { - + if (CORE_ENCODING.equals(optionName)){ return ResourcesPlugin.getEncoding(); } @@ -434,15 +438,15 @@ public class CCorePlugin extends Plugin { } 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 + * + * @return table of current settings of all options * (key type: String; value type: String) * @see CCorePlugin#getDefaultOptions */ @@ -454,19 +458,19 @@ public class CCorePlugin extends Plugin { if (plugin != null) { Preferences preferences = plugin.getPluginPreferences(); HashSet optionNames = CModelManager.OptionNames; - + // get preferences set to their default for (String propertyName : preferences.defaultPropertyNames()){ if (optionNames.contains(propertyName)){ options.put(propertyName, preferences.getDefaultString(propertyName)); } - } + } // get preferences not set to their default for (String propertyName : preferences.propertyNames()){ if (optionNames.contains(propertyName)){ options.put(propertyName, preferences.getString(propertyName).trim()); } - } + } // get encoding through resource plugin options.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); } @@ -474,19 +478,19 @@ public class CCorePlugin extends Plugin { } /** - * Sets the current table of options. All and only the options explicitly included in the given table + * 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 CCorePlugin#getDefaultOptions */ public static void setOptions(HashMap newOptions) { - + // see #initializeDefaultPluginPreferences() for changing default settings Preferences preferences = getDefault().getPluginPreferences(); @@ -499,11 +503,11 @@ public class CCorePlugin extends Plugin { String value = newOptions.get(key); preferences.setValue(key, value); } - + // persist options getDefault().savePluginPreferences(); - } - + } + /** * Create CDT console adapter for build console defined as an extension. @@ -511,7 +515,7 @@ public class CCorePlugin extends Plugin { * If the console class is instance of {@link ICConsole} it is initialized * with context id, name and icon to be shown in the list of consoles in the * Console view. - * + * * @param extConsoleId - console id defined in the extension point. * @param contextId - context menu id in the Console view. A caller needs to define * a distinct one for own use. @@ -523,7 +527,7 @@ public class CCorePlugin extends Plugin { * * URL iconUrl = CUIPlugin.getDefault().getBundle().getEntry("icons/obj16/flask.png"); * - * + * * @return CDT console adapter. */ private IConsole getConsole(String extConsoleId, String contextId, String name, URL iconUrl) { @@ -555,7 +559,7 @@ public class CCorePlugin extends Plugin { * Create CDT console adapter. * The adapter serves as a bridge between core plugin and UI console API in a way that * a user can create a UI console from plugins having no dependencies to UI. - * + * * @param id - id of the console specified in extension point to instantiate * console adapter. * @return CDT console adapter. @@ -568,7 +572,7 @@ public class CCorePlugin extends Plugin { * Create CDT console adapter for build console. A new instance of class * {@code org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole} is created * and initialized with the parameters. - * + * * @param contextId - context menu id in the Console view. A caller needs to define * a distinct one for own use. * @param name - name of console to appear in the list of consoles in context menu @@ -582,9 +586,9 @@ public class CCorePlugin extends Plugin { *
* {@code iconUrl} can be null, in that case the default image is used. * See {@code org.eclipse.cdt.internal.ui.buildconsole.BuildConsole(IBuildConsoleManager, String, String, URL)} - * + * * @return CDT console adapter. - * + * * @since 5.3 */ public IConsole getBuildConsole(String contextId, String name, URL iconUrl) { @@ -658,7 +662,7 @@ public class CCorePlugin extends Plugin { log(e); // wrong binary parser definition ? } if (parser != null) { - list.add(parser); + list.add(parser); } } parsers = new IBinaryParser[list.size()]; @@ -707,7 +711,7 @@ public class CCorePlugin extends Plugin { public static IIndexManager getIndexManager() { return getDefault().pdomManager; } - + public IPathEntryVariableManager getPathEntryVariableManager() { return fPathEntryVariableManager; } @@ -722,7 +726,7 @@ public class CCorePlugin extends Plugin { /** * Please use {@link #getProjectDescription(IProject, boolean)} to fetch the - * ICProjectDescription for the project. And use {@link ICProjectDescription#getConfigurations()} + * ICProjectDescription for the project. And use {@link ICProjectDescription#getConfigurations()} * to get an array of ICConfigurationDescriptions, which have similar API to ICDescriptor, * allowing you to store settings and configure extensions at the Configuration level * rather than at the project level. @@ -752,9 +756,9 @@ public class CCorePlugin extends Plugin { /** * @deprecated Settings should be set per ICConfigurationDescription rather than - * global to the project. Please use {@link #getProjectDescription(IProject, boolean)} - * to fetch the ICProjectDescription for the project. And use - * {@link ICProjectDescription#getConfigurations()} to get an array of + * global to the project. Please use {@link #getProjectDescription(IProject, boolean)} + * to fetch the ICProjectDescription for the project. And use + * {@link ICProjectDescription#getConfigurations()} to get an array of * ICConfigurationDescriptions, which have similar API to ICDescriptor, * allowing you to store settings and configure extensions at the Configuration level * rather than at the project level. @@ -783,6 +787,7 @@ public class CCorePlugin extends Plugin { throws CoreException, OperationCanceledException { getWorkspace().run(new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { try { if (monitor == null) { @@ -792,11 +797,11 @@ public class CCorePlugin extends Plugin { if (!projectHandle.exists()) { projectHandle.create(description, new SubProgressMonitor(monitor, 1)); } - + if (monitor.isCanceled()) { throw new OperationCanceledException(); } - + // Open first. projectHandle.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1)); @@ -827,6 +832,7 @@ public class CCorePlugin extends Plugin { throws CoreException, OperationCanceledException { getWorkspace().run(new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { try { if (monitor == null) { @@ -836,11 +842,11 @@ public class CCorePlugin extends Plugin { if (!projectHandle.exists()) { projectHandle.create(description, new SubProgressMonitor(monitor, 1)); } - + if (monitor.isCanceled()) { throw new OperationCanceledException(); } - + // Open first. projectHandle.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1)); @@ -848,7 +854,7 @@ public class CCorePlugin extends Plugin { // Add C Nature ... does not add duplicates CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1)); - + if(bsId != null){ ICProjectDescription projDes = createProjectDescription(projectHandle, true); ICConfigurationDescription cfgs[] = projDes.getConfigurations(); @@ -859,14 +865,14 @@ public class CCorePlugin extends Plugin { break; } } - + if(cfg == null){ ICConfigurationDescription prefCfg = getPreferenceConfiguration(bsId); if(prefCfg != null){ cfg = projDes.createConfiguration(CDataUtil.genId(prefCfg.getId()), prefCfg.getName(), prefCfg); } } - + if(cfg != null){ setProjectDescription(projectHandle, projDes); } @@ -882,9 +888,9 @@ public class CCorePlugin extends Plugin { /** * Method convertProjectFromCtoCC converts * a C Project to a C++ Project - * The newProject MUST, not be null, already have a C Nature + * The newProject MUST, not be null, already have a C Nature * && must NOT already have a C++ Nature - * + * * @param projectHandle * @param monitor * @throws CoreException @@ -894,15 +900,15 @@ public class CCorePlugin extends Plugin { if ((projectHandle != null) && projectHandle.hasNature(CProjectNature.C_NATURE_ID) && !projectHandle.hasNature(CCProjectNature.CC_NATURE_ID)) { - // Add C++ Nature ... does not add duplicates + // Add C++ Nature ... does not add duplicates CCProjectNature.addCCNature(projectHandle, monitor); } } /** - * Method to convert a project to a C nature + * Method to convert a project to a C nature * All checks should have been done externally - * (as in the Conversion Wizards). + * (as in the Conversion Wizards). * This method blindly does the conversion. */ public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID) @@ -928,7 +934,7 @@ public class CCorePlugin extends Plugin { } /** - * Method to convert a project to a C++ nature + * Method to convert a project to a C++ nature */ public void convertProjectToCC(IProject projectHandle, IProgressMonitor monitor, String projectID) throws CoreException { @@ -975,14 +981,14 @@ public class CCorePlugin extends Plugin { } } } - if ( defaultContributor != null) { + if ( defaultContributor != null) { return (IProcessList) defaultContributor.createExecutableExtension("class"); //$NON-NLS-1$ } } return null; - + } - + /** * @deprecated since CDT 6.1. Use {@link ErrorParserManager#getErrorParserAvailableIds()} instead * @return array of error parsers ids @@ -992,7 +998,7 @@ public class CCorePlugin extends Plugin { ErrorParserExtensionManager.loadErrorParserExtensions(); return ErrorParserExtensionManager.getErrorParserAvailableIds(); } - + /** * @deprecated since CDT 6.1. Use {@link ErrorParserManager#getErrorParserCopy(String)} instead * @param id - id of error parser @@ -1017,7 +1023,7 @@ public class CCorePlugin extends Plugin { provider = (IScannerInfoProvider)project.getSessionProperty(scannerInfoProviderName); if (provider != null) return provider; - + // Next search the extension registry to see if a provider is registered with a build command IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint point = registry.getExtensionPoint(SCANNER_INFO_PROVIDER2); @@ -1037,7 +1043,7 @@ public class CCorePlugin extends Plugin { } } } - + // Default to the proxy if (provider == null) provider = fNewCProjectDescriptionManager.getScannerInfoProviderProxy(project); @@ -1046,13 +1052,13 @@ public class CCorePlugin extends Plugin { // Bug 313725: When project is being closed, don't report an error. if (!project.isOpen()) return null; - + log(e); } - + return provider; } - + /** * Helper function, returning the content type for a filename * Same as:
@@ -1064,7 +1070,7 @@ public class CCorePlugin extends Plugin {
 	public static IContentType getContentType(String filename) {
 		return CContentTypes.getContentType(null, filename);
 	}
-	
+
 	/**
 	 * Returns the content type for a filename. The method respects
 	 * project specific content type definitions. The lookup prefers case-
@@ -1076,7 +1082,7 @@ public class CCorePlugin extends Plugin {
 	public static IContentType getContentType(IProject project, String filename) {
 		return CContentTypes.getContentType(project, filename);
 	}
-	
+
 	/**
 	 * Tests whether the given project uses its project specific content types.
 	 */
@@ -1091,7 +1097,7 @@ public class CCorePlugin extends Plugin {
 		CContentTypes.setUseProjectSpecificContentTypes(project, val);
 	}
 
-	
+
 
 	private static final String MODEL = CCorePlugin.PLUGIN_ID + "/debug/model" ; //$NON-NLS-1$
 	private static final String PARSER = CCorePlugin.PLUGIN_ID + "/debug/parser" ; //$NON-NLS-1$
@@ -1104,7 +1110,7 @@ public class CCorePlugin extends Plugin {
 	 * Configure the plug-in with respect to option settings defined in ".options" file
 	 */
 	public void configurePluginDebugOptions() {
-		
+
 		if(CCorePlugin.getDefault().isDebugging()) {
 			String option = Platform.getDebugOption(PARSER);
 			if(option != null) Util.VERBOSE_PARSER = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@@ -1114,13 +1120,13 @@ public class CCorePlugin extends Plugin {
 
 			option = Platform.getDebugOption(SCANNER);
 			if( option != null ) Util.VERBOSE_SCANNER = option.equalsIgnoreCase("true"); //$NON-NLS-1$
-			
+
 			option = Platform.getDebugOption(MODEL);
 			if(option != null) Util.VERBOSE_MODEL = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
-			
+
 			option = Platform.getDebugOption(DELTA);
 			if(option != null) Util.VERBOSE_DELTA= option.equalsIgnoreCase("true") ; //$NON-NLS-1$
-			
+
 		}
 	}
 
@@ -1133,7 +1139,7 @@ public class CCorePlugin extends Plugin {
 	public boolean useStructuralParseMode() {
 		return getPluginPreferences().getBoolean(PREF_USE_STRUCTURAL_PARSE_MODE);
 	}
-	
+
 	/**
 	 * @deprecated use {@link ITranslationUnit} or {@link ILanguage} to construct ASTs, instead.
 	 */
@@ -1145,11 +1151,11 @@ public class CCorePlugin extends Plugin {
 	public ICdtVariableManager getCdtVariableManager(){
 		return CdtVariableManager.getDefault();
 	}
-	
+
 	public IEnvironmentVariableManager getBuildEnvironmentManager(){
 		return EnvironmentVariableManager.getDefault();
 	}
-	
+
 	public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId) throws CoreException{
 		return fNewCProjectDescriptionManager.getPreferenceConfiguration(buildSystemId);
 	}
@@ -1157,14 +1163,14 @@ public class CCorePlugin extends Plugin {
 	public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) throws CoreException{
 		return fNewCProjectDescriptionManager.getPreferenceConfiguration(buildSystemId, write);
 	}
-	
+
 	public void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws CoreException {
 		fNewCProjectDescriptionManager.setPreferenceConfiguration(buildSystemId, des);
 	}
-	
+
 	/**
 	 * this method is a full equivalent to createProjectDescription(IProject, boolean, false).
-	 * 
+	 *
 	 * @see #createProjectDescription(IProject, boolean, boolean)
 	 */
 	public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException{
@@ -1173,7 +1179,7 @@ public class CCorePlugin extends Plugin {
 
 	/**
 	 * the method creates and returns a writable project description
-	 * 
+	 *
 	 * @param project project for which the project description is requested
 	 * @param loadIfExists if true the method first tries to load and return the project description
 	 * from the settings file (.cproject)
@@ -1181,42 +1187,42 @@ public class CCorePlugin extends Plugin {
 	 * @param creating if true the created project description will be contain the true "isCdtProjectCreating" state.
 	 * NOTE: in case the project already contains the project description AND its "isCdtProjectCreating" is false
 	 * the resulting description will be created with the false "isCdtProjectCreating" state
-	 * 
-	 * NOTE: changes made to the returned project description will not be applied until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called 
+	 *
+	 * NOTE: changes made to the returned project description will not be applied until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
 	 * @return {@link ICProjectDescription}
 	 * @throws CoreException
 	 */
 	public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists, boolean creating) throws CoreException{
 		return fNewCProjectDescriptionManager.createProjectDescription(project, loadIfExists, creating);
 	}
-	
+
 	/**
 	 * returns the project description associated with this project or null if the project does not contain the
-	 * CDT data associated with it. 
-	 * 
+	 * CDT data associated with it.
+	 *
 	 * this is a convenience method fully equivalent to getProjectDescription(project, true)
 	 * see {@link #getProjectDescription(IProject, boolean)} for more detail
 	 * @param project
 	 * @return a writable copy of the ICProjectDescription or null if the project does not contain the
-	 * CDT data associated with it. 
+	 * CDT data associated with it.
 	 * Note: changes to the project description will not be reflected/used by the core
 	 * until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
-	 * 
+	 *
 	 * @see #getProjectDescription(IProject, boolean)
 	 */
 	public ICProjectDescription getProjectDescription(IProject project){
 		return fNewCProjectDescriptionManager.getProjectDescription(project);
 	}
-	
+
 	/**
 	 * this method is called to save/apply the project description
 	 * the method should be called to apply changes made to the project description
-	 * returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)} 
-	 * 
+	 * returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)}
+	 *
 	 * @param project
 	 * @param des
 	 * @throws CoreException
-	 * 
+	 *
 	 * @see #getProjectDescription(IProject, boolean)
 	 * @see #createProjectDescription(IProject, boolean)
 	 */
@@ -1230,30 +1236,30 @@ public class CCorePlugin extends Plugin {
 
 	/**
 	 * returns the project description associated with this project or null if the project does not contain the
-	 * CDT data associated with it. 
-	 * 
+	 * CDT data associated with it.
+	 *
 	 * @param project project for which the description is requested
-	 * @param write if true, the writable description copy is returned. 
+	 * @param write if true, the writable description copy is returned.
 	 * If false the cached read-only description is returned.
-	 * 
+	 *
 	 * CDT core maintains the cached project description settings. If only read access is needed to description,
 	 * then the read-only project description should be obtained.
 	 * This description always operates with cached data and thus it is better to use it for performance reasons
 	 * All set* calls to the read-only description result in the {@link WriteAccessException}
-	 * 
+	 *
 	 * When the writable description is requested, the description copy is created.
 	 * Changes to this description will not be reflected/used by the core and Build System untill the
 	 * {@link #setProjectDescription(IProject, ICProjectDescription)} is called
 	 *
-	 * Each getProjectDescription(project, true) returns a new copy of the project description 
-	 * 
+	 * Each getProjectDescription(project, true) returns a new copy of the project description
+	 *
 	 * The writable description uses the cached data untill the first set call
 	 * after that the description communicates directly to the Build System
 	 * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension
 	 * This ensures the Core<->Build System settings integrity
-	 * 
+	 *
 	 * @return {@link ICProjectDescription} or null if the project does not contain the
-	 * CDT data associated with it. 
+	 * CDT data associated with it.
 	 */
 	public ICProjectDescription getProjectDescription(IProject project, boolean write){
 		return fNewCProjectDescriptionManager.getProjectDescription(project, write);
@@ -1261,17 +1267,17 @@ public class CCorePlugin extends Plugin {
 
 	/**
 	 * forces the cached data of the specified projects to be re-calculated.
-	 * if the projects argument is null al projects 
+	 * if the projects argument is null al projects
 	 * within the workspace are updated
-	 * 
+	 *
 	 * @param projects
 	 * @param monitor
-	 * @throws CoreException 
+	 * @throws CoreException
 	 */
 	public void updateProjectDescriptions(IProject projects[], IProgressMonitor monitor) throws CoreException{
 		fNewCProjectDescriptionManager.updateProjectDescriptions(projects, monitor);
 	}
-	
+
 	/**
 	 * Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
 	 */
@@ -1285,18 +1291,18 @@ public class CCorePlugin extends Plugin {
 	public boolean isNewStyleProject(ICProjectDescription des){
 		return fNewCProjectDescriptionManager.isNewStyleProject(des);
 	}
-	
+
 	public ICProjectDescriptionManager getProjectDescriptionManager(){
 		return fNewCProjectDescriptionManager;
 	}
-	
+
 	/**
-	 * @return editable User-variable's supplier 
+	 * @return editable User-variable's supplier
 	 */
 	public static IUserVarSupplier getUserVarSupplier() {
 		return UserVarSupplier.getInstance();
 	}
-	
+
 	// NON-API
 
 	/**
@@ -1306,14 +1312,14 @@ public class CCorePlugin extends Plugin {
 		super();
 		fgCPlugin = this;
 	}
-	
+
 	/**
 	 * @noreference This method is not intended to be referenced by clients.
 	 */
 	public static void log(String e) {
 		log(createStatus(e));
 	}
-	
+
 	/**
 	 * @noreference This method is not intended to be referenced by clients.
 	 */
@@ -1325,13 +1331,13 @@ public class CCorePlugin extends Plugin {
 			log("Error: " + msg, e); //$NON-NLS-1$
 		}
 	}
-	
+
 	/**
 	 * @noreference This method is not intended to be referenced by clients.
 	 */
 	public static void log(String message, Throwable e) {
 		Throwable nestedException;
-		if (e instanceof CModelException 
+		if (e instanceof CModelException
 				&& (nestedException = ((CModelException)e).getException()) != null) {
 			e = nestedException;
 		}
@@ -1351,14 +1357,14 @@ public class CCorePlugin extends Plugin {
 	public static IStatus createStatus(String msg, Throwable e) {
 		return new Status(IStatus.ERROR, PLUGIN_ID, msg, e);
 	}
-	
+
 	/**
 	 * @noreference This method is not intended to be referenced by clients.
 	 */
 	public static void log(IStatus status) {
 		getDefault().getLog().log(status);
 	}
-	
+
 	/**
 	 * @deprecated use getIndexManager().
 	 * @noreference This method is not intended to be referenced by clients.
@@ -1371,7 +1377,7 @@ public class CCorePlugin extends Plugin {
 	/**
 	 * Returns preference controlling whether source roots are shown at the top of projects
 	 * or embedded within the resource tree of projects when they are not top level folders.
-	 * 
+	 *
 	 * @return boolean preference value
 	 * @since 5.2
 	 */
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
index 53632d51c3c..980fe8a4124 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
@@ -4,7 +4,7 @@
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * Contributors:
  *     QNX Software Systems - Initial API and implementation
  *     IBM Corporation
@@ -50,7 +50,7 @@ public class CProjectNature implements IProjectNature {
 
 	/**
 	 * Utility method for adding a nature to a project.
-	 * 
+	 *
 	 * @param project
 	 *            the project to add the nature
 	 * @param natureId
@@ -58,7 +58,7 @@ public class CProjectNature implements IProjectNature {
 	 * @param monitor
 	 *            a progress monitor to indicate the duration of the operation,
 	 *            or null if progress reporting is not required.
-	 *  
+	 *
 	 */
 	public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
 	    try {
@@ -77,11 +77,11 @@ public class CProjectNature implements IProjectNature {
     		description.setNatureIds(newNatures);
     		project.setDescription(description, monitor);
 		}
-		
+
 		catch (CoreException e) {
 			CCorePlugin.log(e);
 		}
-		
+
 		finally {
 			monitor.done();
 		}
@@ -89,7 +89,7 @@ public class CProjectNature implements IProjectNature {
 
 	/**
 	 * Utility method for removing a project nature from a project.
-	 * 
+	 *
 	 * @param project
 	 *            the project to remove the nature from
 	 * @param natureId
@@ -110,18 +110,21 @@ public class CProjectNature implements IProjectNature {
 	/**
 	 * @see IProjectNature#configure
 	 */
+	@Override
 	public void configure() throws CoreException {
 	}
 
 	/**
 	 * @see IProjectNature#deconfigure
 	 */
+	@Override
 	public void deconfigure() throws CoreException {
 	}
 
 	/**
 	 * @see IProjectNature#getProject
 	 */
+	@Override
 	public IProject getProject() {
 		return fProject;
 	}
@@ -129,6 +132,7 @@ public class CProjectNature implements IProjectNature {
 	/**
 	 * @see IProjectNature#setProject
 	 */
+	@Override
 	public void setProject(IProject project) {
 		fProject = project;
 	}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java
index 40c43625fd2..a0f99e68736 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java
@@ -32,7 +32,7 @@ public class CommandLauncher implements ICommandLauncher {
 	public final static int ILLEGAL_COMMAND = ICommandLauncher.ILLEGAL_COMMAND;
 	public final static int OK = ICommandLauncher.OK;
 
-	
+
 	protected Process fProcess;
 	protected boolean fShowCommand;
 	protected String[] fCommandArgs;
@@ -61,6 +61,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#showCommand(boolean)
 	 */
+	@Override
 	public void showCommand(boolean show) {
 		fShowCommand = show;
 	}
@@ -68,6 +69,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#getErrorMessage()
 	 */
+	@Override
 	public String getErrorMessage() {
 		return fErrorMessage;
 	}
@@ -75,6 +77,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#setErrorMessage(java.lang.String)
 	 */
+	@Override
 	public void setErrorMessage(String error) {
 		fErrorMessage = error;
 	}
@@ -82,6 +85,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#getCommandArgs()
 	 */
+	@Override
 	public String[] getCommandArgs() {
 		return fCommandArgs;
 	}
@@ -89,6 +93,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#getEnvironment()
 	 */
+	@Override
 	public Properties getEnvironment() {
 		return EnvironmentReader.getEnvVars();
 	}
@@ -96,6 +101,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#getCommandLine()
 	 */
+	@Override
 	public String getCommandLine() {
 		return getCommandLine(getCommandArgs());
 	}
@@ -119,12 +125,12 @@ public class CommandLauncher implements ICommandLauncher {
 		try {
 			// add platform specific arguments (shell invocation)
 			fCommandArgs = constructCommandArray(commandPath.toOSString(), args);
-			
+
 			File file = null;
-			
+
 			if(changeToDirectory != null)
 				file = changeToDirectory.toFile();
-			
+
 			fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, file);
 			fErrorMessage = ""; //$NON-NLS-1$
 		} catch (IOException e) {
@@ -133,21 +139,22 @@ public class CommandLauncher implements ICommandLauncher {
 		}
 		return fProcess;
 	}
-	
+
 	/**
 	 * @since 5.1
 	 * @see org.eclipse.cdt.core.ICommandLauncher#execute(IPath, String[], String[], IPath, IProgressMonitor)
 	 */
+	@Override
 	public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, IProgressMonitor monitor) throws CoreException {
 		try {
 			// add platform specific arguments (shell invocation)
 			fCommandArgs = constructCommandArray(commandPath.toOSString(), args);
-			
+
 			File file = null;
-			
+
 			if(changeToDirectory != null)
 				file = changeToDirectory.toFile();
-			
+
 			fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, file);
 			fErrorMessage = ""; //$NON-NLS-1$
 		} catch (IOException e) {
@@ -160,6 +167,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#waitAndRead(java.io.OutputStream, java.io.OutputStream)
 	 */
+	@Override
 	public int waitAndRead(OutputStream out, OutputStream err) {
 		if (fShowCommand) {
 			printCommandLine(out);
@@ -177,6 +185,7 @@ public class CommandLauncher implements ICommandLauncher {
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.ICommandLauncher#waitAndRead(java.io.OutputStream, java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor)
 	 */
+	@Override
 	public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
 		if (fShowCommand) {
 			printCommandLine(output);
@@ -237,11 +246,12 @@ public class CommandLauncher implements ICommandLauncher {
 		return buf.toString();
 	}
 
-	
+
 	/**
 	 * @since 5.1
 	 * @see org.eclipse.cdt.core.ICommandLauncher#getProject()
 	 */
+	@Override
 	public IProject getProject() {
 		return fProject;
 	}
@@ -250,6 +260,7 @@ public class CommandLauncher implements ICommandLauncher {
 	 * @since 5.1
 	 * @see org.eclipse.cdt.core.ICommandLauncher#setProject(org.eclipse.core.resources.IProject)
 	 */
+	@Override
 	public void setProject(IProject project) {
 		fProject = project;
 	}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java
index 862c790ea04..65ea2af5837 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java
@@ -4,13 +4,13 @@
  *  are made available under the terms of the Eclipse Public License v1.0
  *  which accompanies this distribution, and is available at
  *  http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  *  Contributors:
  *     IBM Corporation - initial API and implementation
  *     Sergey Prigogin (Google)
  *     James Blackburn (Broadcom) - Bug 247838
  *     Andrew Gvozdev (Quoin Inc)
- *     Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation  
+ *     Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
  *******************************************************************************/
 package org.eclipse.cdt.core;
 
@@ -43,11 +43,11 @@ import org.eclipse.core.runtime.URIUtil;
 import org.osgi.service.prefs.BackingStoreException;
 
 /**
- * The purpose of ErrorParserManager is to delegate the work of error parsing 
+ * The purpose of ErrorParserManager is to delegate the work of error parsing
  * build output to {@link IErrorParser}s, assist in finding {@link IResource}s, and
  * help create appropriate error/warning/info markers to be displayed
  * by the Problems view.
- * 
+ *
  * @noextend This class is not intended to be subclassed by clients.
  */
 public class ErrorParserManager extends OutputStream {
@@ -58,7 +58,7 @@ public class ErrorParserManager extends OutputStream {
 	 */
 	@Deprecated
 	public final static String PREF_ERROR_PARSER = CCorePlugin.PLUGIN_ID + ".errorOutputParser"; //$NON-NLS-1$
-	
+
 	/**
 	 * Delimiter for error parsers presented in one string.
 	 * @since 5.2
@@ -93,7 +93,7 @@ public class ErrorParserManager extends OutputStream {
 
 	/**
 	 * Constructor.
-	 * 
+	 *
 	 * @param builder - project builder.
 	 */
 	public ErrorParserManager(ACBuilder builder) {
@@ -102,7 +102,7 @@ public class ErrorParserManager extends OutputStream {
 
 	/**
 	 * Constructor.
-	 * 
+	 *
 	 * @param project - project being built.
 	 * @param markerGenerator - marker generator able to create markers.
 	 */
@@ -112,7 +112,7 @@ public class ErrorParserManager extends OutputStream {
 
 	/**
 	 * Constructor.
-	 * 
+	 *
 	 * @param project - project being built.
 	 * @param markerGenerator - marker generator able to create markers.
 	 * @param parsersIDs - array of error parsers' IDs.
@@ -123,24 +123,24 @@ public class ErrorParserManager extends OutputStream {
 
 	/**
 	 * Constructor.
-	 * 
+	 *
 	 * @param project - project being built.
-	 * @param workingDirectory - IPath location of the working directory of where the build is performed. 
+	 * @param workingDirectory - IPath location of the working directory of where the build is performed.
 	 * @param markerGenerator - marker generator able to create markers.
 	 * @param parsersIDs - array of error parsers' IDs.
 	 * @deprecated use {@link #ErrorParserManager(IProject, URI, IMarkerGenerator, String[])} instead
 	 */
 	@Deprecated
 	public ErrorParserManager(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator, String[] parsersIDs) {
-		this(project, (workingDirectory == null || workingDirectory.isEmpty()) ? null : org.eclipse.core.filesystem.URIUtil.toURI(workingDirectory), 
+		this(project, (workingDirectory == null || workingDirectory.isEmpty()) ? null : org.eclipse.core.filesystem.URIUtil.toURI(workingDirectory),
 				markerGenerator, parsersIDs);
 	}
 
 	/**
 	 * URI based constructor.
-	 * 
+	 *
 	 * @param project - project being built.
-	 * @param baseDirectoryURI - absolute location URI of working directory of where the build is performed. 
+	 * @param baseDirectoryURI - absolute location URI of working directory of where the build is performed.
 	 * @param markerGenerator - marker generator able to create markers.
 	 * @param parsersIDs - array of error parsers' IDs.
 	 * @since 5.1
@@ -205,7 +205,7 @@ public class ErrorParserManager extends OutputStream {
 	 * {@link #pushDirectory} and {@link #popDirectory} are used to change working directory
 	 * from where file name is searched (see {@link #findFileInWorkspace}).
 	 * The intention is to handle make output of commands "pushd dir" and "popd".
-	 * 
+	 *
 	 * @param dir - another directory level to keep in stack -- corresponding to 'pushd'.
 	 */
 	public void pushDirectory(IPath dir) {
@@ -227,7 +227,7 @@ public class ErrorParserManager extends OutputStream {
 	 * {@link #pushDirectoryURI} and {@link #popDirectoryURI} are used to change working directory
 	 * from where file name is searched (see {@link #findFileInWorkspace}).
 	 * The intention is to handle make output of commands "pushd dir" and "popd".
-	 * 
+	 *
 	 * @param dir - another directory level to keep in stack -- corresponding to 'pushd'.
 	 * @since 5.1
 	 */
@@ -244,7 +244,7 @@ public class ErrorParserManager extends OutputStream {
 	 * {@link #pushDirectory} and {@link #popDirectory} are used to change working directory
 	 * from where file name is searched (see {@link #findFileInWorkspace}).
 	 * The intention is to handle make output of commands "pushd" and "popd".
-	 * 
+	 *
 	 * @return previous build directory location corresponding 'popd' command.
 	 * @deprecated use {@link #popDirectoryURI()} instead
 	 */
@@ -257,7 +257,7 @@ public class ErrorParserManager extends OutputStream {
 	 * {@link #pushDirectoryURI(URI)} and {@link #popDirectoryURI()} are used to change working directory
 	 * from where file name is searched (see {@link #findFileInWorkspace(IPath)}).
 	 * The intention is to handle make output of commands "pushd" and "popd".
-	 * 
+	 *
 	 * @return previous build directory location corresponding 'popd' command.
 	 * @since 5.1
 	 */
@@ -284,13 +284,14 @@ public class ErrorParserManager extends OutputStream {
 	 * kept by {@code ErrorParserManager}.
 	 * @param parent - project.
 	 * @param result - resulting collection of files.
-	 * 
+	 *
 	 * @deprecated Use {@link #findFileName} for searches.
 	 */
 	@Deprecated
 	protected void collectFiles(IProject parent, final List result) {
 		try {
 			parent.accept(new IResourceProxyVisitor() {
+				@Override
 				public boolean visit(IResourceProxy proxy) {
 					if (proxy.getType() == IResource.FILE) {
 						result.add(proxy.requestResource());
@@ -312,7 +313,7 @@ public class ErrorParserManager extends OutputStream {
 		lineCounter++;
 
 		ProblemMarkerInfo marker=null;
-		
+
 outer:
 		for (IErrorParser[] parsers : fErrorParsers.values()) {
 			for (IErrorParser parser : parsers) {
@@ -363,21 +364,21 @@ outer:
 		}
 		outputLine(line, marker);
 	}
-	
-	/** 
-	 * Conditionally output line to outputStream. If stream 
+
+	/**
+	 * Conditionally output line to outputStream. If stream
 	 * supports error markers, use it, otherwise use conventional stream
 	 */
 	private void outputLine(String line, ProblemMarkerInfo marker) {
 		String l = line + "\n";  //$NON-NLS-1$
-		if ( outputStream == null ) return; 
+		if ( outputStream == null ) return;
 		try {
 			if ( marker != null && outputStream instanceof IErrorMarkeredOutputStream ) {
 				IErrorMarkeredOutputStream s = (IErrorMarkeredOutputStream) outputStream;
 				s.write(l, marker);
-			} else {		
+			} else {
 				byte[] b = l.getBytes();
-				outputStream.write(b, 0, b.length);			
+				outputStream.write(b, 0, b.length);
 			}
 		} catch (IOException e) {
 			CCorePlugin.log(e);
@@ -409,7 +410,7 @@ outer:
 	 * @return - file in the workspace or {@code null}.
 	 */
 	public IFile findFileName(String partialLoc) {
-		if (partialLoc.equals(cachedFileName) && cachedWorkingDirectory != null && 
+		if (partialLoc.equals(cachedFileName) && cachedWorkingDirectory != null &&
 				org.eclipse.core.filesystem.URIUtil.equals(getWorkingDirectoryURI(), cachedWorkingDirectory))
 			return cachedFile;
 
@@ -452,7 +453,7 @@ outer:
 
 	/**
 	 * Find exact match in the workspace. If path is not absolute search is done in working directory.
-	 * 
+	 *
 	 * @param path - file path.
 	 * @return - file in the workspace or {@code null} if such a file doesn't exist
 	 */
@@ -472,7 +473,7 @@ outer:
 
 	/**
 	 * Find exact match in the workspace. If path is not absolute search is done in the current working directory.
-	 * 
+	 *
 	 * @param uri - absolute or relative URI to resolve.
 	 * @return - file in the workspace or {@code null} if such a file doesn't exist
 	 * @since 5.1
@@ -490,7 +491,7 @@ outer:
 	/**
 	 * @param fileName - file name.
 	 * @return {@code true} if the project contains more than one file with the given name.
-	 * 
+	 *
 	 * @deprecated Use {@link #findFileName} for searches.
 	 */
 	@Deprecated
@@ -501,11 +502,11 @@ outer:
 	/**
 	 * Called by the error parsers to find an IFile for a given
 	 * external filesystem 'location'
-	 * 
+	 *
 	 * @param filePath - file path.
-	 * @return IFile representing the external location, or null if one 
+	 * @return IFile representing the external location, or null if one
 	 *         couldn't be found.
-	 * 
+	 *
 	 * @deprecated Use {@link #findFileName} for searches.
 	 */
 	@Deprecated
@@ -542,7 +543,7 @@ outer:
 
 	/**
 	 * Add marker to the list of error markers.
-	 * 
+	 *
 	 * @param file - resource to add the new marker.
 	 * @param lineNumber - line number of the error.
 	 * @param desc - description of the error.
@@ -555,7 +556,7 @@ outer:
 
 	/**
 	 * Add marker to the list of error markers.
-	 * 
+	 *
 	 * @param file - resource to add the new marker.
 	 * @param lineNumber - line number of the error.
 	 * @param desc - description of the error.
@@ -574,7 +575,7 @@ outer:
 
 	/**
 	 * Add the given marker to the list of error markers.
-	 * 
+	 *
 	 * @param problemMarkerInfo - The marker to be added.
 	 * @since 5.4
 	 */
@@ -596,7 +597,7 @@ outer:
 	/**
 	 * Method setOutputStream.
 	 * Note: you have to close this stream explicitly
-	 * don't rely on ErrorParserManager.close(). 
+	 * don't rely on ErrorParserManager.close().
 	 * @param os - output stream
 	 */
 	public void setOutputStream(OutputStream os) {
@@ -604,9 +605,9 @@ outer:
 	}
 
 	/**
-	 * Method getOutputStream. 
+	 * Method getOutputStream.
 	 * Note: you have to close this stream explicitly
-	 * don't rely on ErrorParserManager.close(). 
+	 * don't rely on ErrorParserManager.close().
 	 * @return OutputStream
 	 */
 	public OutputStream getOutputStream() {
@@ -616,8 +617,8 @@ outer:
 
 	/**
 	 * @see java.io.OutputStream#close()
-	 * Note: don't rely on this method to close underlying OutputStream, 
-	 * close it explicitly 
+	 * Note: don't rely on this method to close underlying OutputStream,
+	 * close it explicitly
 	 */
 	@Override
 	public synchronized void close() throws IOException {
@@ -660,7 +661,7 @@ outer:
 
 	// This method examines contents of currentLine buffer
 	// if it contains whole line this line is checked by error
-	// parsers (processLine method). 
+	// parsers (processLine method).
 	// If flush is true rest of line is checked by error parsers.
 	private void checkLine(boolean flush) {
 		String buffer = currentLine.toString();
@@ -688,7 +689,7 @@ outer:
 	/**
 	 * @deprecated as of 5.2. This method is no longer reporting problems.
 	 *  The problem markers are generated after processing each line.
-	 * 
+	 *
 	 * @return {@code true} if detected a problem indicating that build failed.
 	 *         The semantics of the return code is inconsistent. As far as build is concerned
 	 *         there is no difference between errors
@@ -720,7 +721,7 @@ outer:
 			// On Windows "C:/folder/" -> "/C:/folder/"
 			if (path.isAbsolute() && uriString.charAt(0) != IPath.SEPARATOR)
 			    uriString = IPath.SEPARATOR + uriString;
-			
+
 			return EFSExtensionManager.getDefault().createNewURIFromPath(baseURI, uriString);
 	}
 
@@ -752,7 +753,7 @@ outer:
 
 	/**
 	 * @return {@code true} if errors attributed to resources detected
-	 * 
+	 *
 	 * @deprecated The semantics of this function is inconsistent. As far as build is concerned
 	 *         there is no difference between errors
 	 *         {@link IMarkerGenerator#SEVERITY_ERROR_RESOURCE} and
@@ -837,7 +838,7 @@ outer:
 	public static IErrorParserNamed getErrorParserExtensionCopy(String id) {
 		return ErrorParserExtensionManager.getErrorParserCopy(id, true);
 	}
-	
+
 	/**
 	 * @param ids - array of error parser IDs
 	 * @return error parser IDs delimited with error parser delimiter ";"
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java
index 52e9f972a77..13e94048c90 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java
@@ -14,35 +14,35 @@ package org.eclipse.cdt.core;
 import java.math.BigInteger;
 
 /**
- * Represents C/C++ address in CDT. All implementors of this interface should be 
- * immutable, i.e. all methods should not modify objects, they should return 
+ * Represents C/C++ address in CDT. All implementors of this interface should be
+ * immutable, i.e. all methods should not modify objects, they should return
  * new object.
- * 
- * Please see Addr32 and Addr64 classes to see how this interface should 
+ *
+ * Please see Addr32 and Addr64 classes to see how this interface should
  * be extended
  */
 public interface IAddress extends Comparable {
 	/**
-	 * Adds offset to address and returns new address object 
-	 * which is the result  
+	 * Adds offset to address and returns new address object
+	 * which is the result
 	 * @param offset to add
 	 * @return the new address
 	 */
 	IAddress add(BigInteger offset);
-	
+
 	/**
-	 * Adds offset to address and returns new address object 
-	 * which is the result  
-	 * 

Note: This method has an offset limit of Long.MAX and Long.MIN, which under some addressing schems + * Adds offset to address and returns new address object + * which is the result + *

Note: This method has an offset limit of Long.MAX and Long.MIN, which under some addressing schems * may impose an unnesseary limitation, see IAddressa.add(BigInteger offset) to handle larger offsets. * @param offset to add * @return the new address */ IAddress add(long offset); - + /** - * Returns maximal offset possible for address. The offset - * should be Identicall for all addresses of given class. + * Returns maximal offset possible for address. The offset + * should be Identicall for all addresses of given class. * @return the max offset for this address class */ BigInteger getMaxOffset(); @@ -53,12 +53,12 @@ public interface IAddress extends Comparable { * @return distance to address */ BigInteger distanceTo(IAddress other); - + /** * Returns the value of the address. */ BigInteger getValue(); - + /** * Returns whether this address equals the given object. * @@ -66,8 +66,9 @@ public interface IAddress extends Comparable { * @return true if the addresses are equivalent, * and false if they are not */ + @Override boolean equals(Object addr); - + /** * Return true if address is zero, i.e. minimal possible * @return true is address is zero @@ -79,7 +80,7 @@ public interface IAddress extends Comparable { * @return true if address is maximal */ boolean isMax(); - + /** * Converts address to string as an unsigned number with given radix * @param radix to use for strng conversion @@ -91,38 +92,39 @@ public interface IAddress extends Comparable { * Identical to toString(10) * @return a string representation of address using a radix of 10 */ + @Override String toString(); /** - * Converts address to the hex representation with '0x' prefix and - * with all leading zeros. The length of returned string should be - * the same for all addresses of given class. I.e. 10 for 32-bit + * Converts address to the hex representation with '0x' prefix and + * with all leading zeros. The length of returned string should be + * the same for all addresses of given class. I.e. 10 for 32-bit * addresses and 18 for 64-bit addresses */ String toHexAddressString(); /** - * Converts address to the binary representation with '0b' prefix and - * with all leading zeros. The length of returned string should be - * the same for all addresses of given class. I.e. 34 for 32-bit + * Converts address to the binary representation with '0b' prefix and + * with all leading zeros. The length of returned string should be + * the same for all addresses of given class. I.e. 34 for 32-bit * addresses and 66 for 64-bit addresses */ String toBinaryAddressString(); /** - * Returns amount of symbols in hex representation. Is identical to + * Returns amount of symbols in hex representation. Is identical to * toHexAddressString().length(). It is present for perfomance purpose. - * + * * @return the nmber os chararcter symbols to represent this address in hex. */ int getCharsNum(); - + /** * Returns the address size in bytes. - * - * @return the number of bytes required to hold this address. + * + * @return the number of bytes required to hold this address. */ int getSize(); - + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java index 1c499322fe6..3249989761f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariable.java @@ -16,7 +16,7 @@ import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; /** * This is the trivial implementation of the IBuildMacro used internaly by the MBS - * + * * @since 3.0 */ public class CdtVariable implements ICdtVariable { @@ -26,7 +26,7 @@ public class CdtVariable implements ICdtVariable { protected String fStringListValue[]; protected CdtVariable(){ - + } public CdtVariable(String name, int type, String value){ @@ -40,7 +40,7 @@ public class CdtVariable implements ICdtVariable { fType = type; fStringListValue = value; } - + public CdtVariable(ICdtVariable var){ fName = var.getName(); fType = var.getValueType(); @@ -56,6 +56,7 @@ public class CdtVariable implements ICdtVariable { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getName() */ + @Override public String getName() { return fName; } @@ -63,6 +64,7 @@ public class CdtVariable implements ICdtVariable { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getMacroValueType() */ + @Override public int getValueType() { return fType; } @@ -70,16 +72,18 @@ public class CdtVariable implements ICdtVariable { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringValue() */ + @Override public String getStringValue() throws CdtVariableException { if(CdtVariableResolver.isStringListVariable(fType)) throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_NOT_STRING,fName,null,fName); - + return fStringValue; } /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringListValue() */ + @Override public String[] getStringListValue() throws CdtVariableException { if(!CdtVariableResolver.isStringListVariable(fType)) throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_NOT_STRINGLIST,fName,null,fName); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java index 4fe7f5e0884..6b8e83af898 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java @@ -15,8 +15,8 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; /** - * This class implements the IBuildMacroStatus interface - * + * This class implements the IBuildMacroStatus interface + * * @since 3.0 */ public class CdtVariableStatus extends Status implements ICdtVariableStatus { @@ -29,7 +29,7 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { // private static final String STATUS_MACRO_NOT_STRINGLIST = STATUS + ".macro.not.stringlist"; //$NON-NLS-1$ // private static final String STATUS_ERROR = STATUS + ".error"; //$NON-NLS-1$ // private static final String VALUE_UNDEFINED = PREFIX + ".value.undefined"; //$NON-NLS-1$ - + private String fMacroName; private String fExpression; private String fReferencedName; @@ -38,23 +38,23 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { // private Object fContext; /** - * + * * @param severity as documented in {@link IStatus} * @param code as provided by {@link ICdtVariableStatus}. * @param message message, can be null. In this case the default message will * be generated base upon the other status info * @param exception a low-level exception, or null if not - * applicable + * applicable * @param macroName the name of the build macro whose resolution caused this status creation or null if none * @param expression the string whose resolution caused this status creation or null if none * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none */ - public CdtVariableStatus(int severity, - int code, - String message, - Throwable exception, + public CdtVariableStatus(int severity, + int code, + String message, + Throwable exception, String macroName, - String expression, + String expression, String referencedName//, // int contextType, // Object contextData @@ -73,22 +73,22 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { /** * Creates status with the IStatus.ERROR severity - * + * * @param code one of the IBuildMacroStatus.TYPE_xxx statusses * @param message message, can be null. In this case the default message will * be generated base upon the other status info * @param exception a low-level exception, or null if not - * applicable + * applicable * @param macroName the name of the build macro whose resolution caused this status creation or null if none * @param expression the string whose resolutinon caused caused this status creation or null if none * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none */ - public CdtVariableStatus( - int code, - String message, - Throwable exception, - String macroName, - String expression, + public CdtVariableStatus( + int code, + String message, + Throwable exception, + String macroName, + String expression, String referencedName//, // int contextType, // Object contextData @@ -99,16 +99,16 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { /** * Creates status with the IStatus.ERROR severity and with the default message - * + * * @param code one of the IBuildMacroStatus.TYPE_xxx statusses * @param macroName the name of the build macro whose resolution caused this status creation or null if none * @param expression the string whose resolutinon caused caused this status creation or null if none * @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none */ - public CdtVariableStatus( - int code, - String macroName, - String expression, + public CdtVariableStatus( + int code, + String macroName, + String expression, String referencedName//, // int contextType, // Object contextData @@ -118,7 +118,7 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { /** * generates and returns the default status message based upon then status data - * + * * @return String */ protected String generateMessage(){ @@ -172,6 +172,7 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getMacroName() */ + @Override public String getVariableName() { return fMacroName; } @@ -179,6 +180,7 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getExpression() */ + @Override public String getExpression() { return fExpression; } @@ -186,6 +188,7 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus#getReferencedName() */ + @Override public String getReferencedMacroName() { return fReferencedName; } @@ -203,7 +206,7 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus { // public Object getContextData() { // return fContextData; // } - - + + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java index de52791e5c5..b12ab8d5661 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java @@ -22,10 +22,10 @@ import org.eclipse.core.resources.IStorage; /** * @author jcamelon - * + * * This class serves as the manager of the AST/DOM mechanisms for the CDT. - * It should be eventually added to CCorePlugin for startup. - * + * It should be eventually added to CCorePlugin for startup. + * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. * @deprecated This class does not take into account language mappings. Use @@ -33,19 +33,19 @@ import org.eclipse.core.resources.IStorage; */ @Deprecated public class CDOM implements IASTServiceProvider { - + /** * Singleton - Constructor is private. */ - private CDOM() + private CDOM() { } - + /** * instance is the singleton. */ private static CDOM instance = new CDOM(); - + /** * accessor for singleton instance * @return instance @@ -54,34 +54,34 @@ public class CDOM implements IASTServiceProvider { { return instance; } - - /** - * Currently, only one AST Service is provided. - */ - private IASTServiceProvider defaultService = new InternalASTServiceProvider(); - + /** + * Currently, only one AST Service is provided. + */ + private IASTServiceProvider defaultService = new InternalASTServiceProvider(); + + /** * @return IASTServiceProvider, the mechanism for obtaining an AST */ public IASTServiceProvider getASTService() { - //CDOM itself is not so much "the" AST service as it acts as a proxy + //CDOM itself is not so much "the" AST service as it acts as a proxy //to different AST services //Should we see the need to provide an extension point for this //rather than purely proxying the calls to IASTServiceProvider#* - //we would have to do some discovery and co-ordination on behalf of the + //we would have to do some discovery and co-ordination on behalf of the //client return this; } - + /** * Constant PARSE_SAVED_RESOURCES - Parse saved resources in the workspace */ - public static final int PARSE_SAVED_RESOURCES = 0; + public static final int PARSE_SAVED_RESOURCES = 0; /** * Constant PARSE_WORKING_COPY_WITH_SAVED_INCLUSIONS - Parse working copy for - * translation unit, saved resources for all header files. + * translation unit, saved resources for all header files. */ public static final int PARSE_WORKING_COPY_WITH_SAVED_INCLUSIONS = 1; /** @@ -89,26 +89,26 @@ public class CDOM implements IASTServiceProvider { * header files and the file in question as a translation unit. */ public static final int PARSE_WORKING_COPY_WHENEVER_POSSIBLE = 2; - - + + /** * provider is registered by the UI as a IWorkingCopyProvider. */ private IWorkingCopyProvider provider; - + /** * This is the factory function that returns an ICodeReaderFactory instance based upon the key provided. - * + * * @param key one of PARSE_SAVED_RESOURCES, PARSE_WORKING_COPY_WITH_SAVED_INCLUSIONS, PARSE_WORKING_COPY_WHENEVER_POSSIBLE * @return an implementation that works according to the key specified or null for an invalid key */ public ICodeReaderFactory getCodeReaderFactory( int key ) { - //TODO - eventually these factories will need to hook into the + //TODO - eventually these factories will need to hook into the //CodeReader caches switch( key ) { - case PARSE_SAVED_RESOURCES: + case PARSE_SAVED_RESOURCES: return SavedCodeReaderFactory.getInstance(); case PARSE_WORKING_COPY_WITH_SAVED_INCLUSIONS: return new PartialWorkingCopyCodeReaderFactory(provider, null); @@ -121,65 +121,74 @@ public class CDOM implements IASTServiceProvider { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit(org.eclipse.core.resources.IFile) */ - public IASTTranslationUnit getTranslationUnit(IFile fileToParse) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IFile fileToParse) throws UnsupportedDialectException { //TODO - At this time, we purely delegate blindly - //In the future, we may need to delegate based upon context provided + //In the future, we may need to delegate based upon context provided return defaultService.getTranslationUnit(fileToParse); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit(org.eclipse.core.resources.IFile, org.eclipse.cdt.core.dom.ICodeReaderFactory) */ - public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { //TODO - At this time, we purely delegate blindly - //In the future, we may need to delegate based upon context provided + //In the future, we may need to delegate based upon context provided return defaultService.getTranslationUnit(fileToParse, fileCreator ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit(org.eclipse.core.resources.IFile, org.eclipse.cdt.core.dom.ICodeReaderFactory, org.eclipse.cdt.core.dom.IParserConfiguration) */ - public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator, IParserConfiguration configuration) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator, IParserConfiguration configuration) throws UnsupportedDialectException { //TODO - At this time, we purely delegate blindly - //In the future, we may need to delegate based upon context provided + //In the future, we may need to delegate based upon context provided return defaultService.getTranslationUnit(fileToParse, fileCreator, configuration ); } - - public IASTCompletionNode getCompletionNode(IFile fileToParse, int offset, + + @Override + public IASTCompletionNode getCompletionNode(IFile fileToParse, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { //TODO - At this time, we purely delegate blindly - //In the future, we may need to delegate based upon context provided + //In the future, we may need to delegate based upon context provided return defaultService.getCompletionNode(fileToParse, offset, fileCreator); } - public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, + @Override + public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { //TODO - At this time, we purely delegate blindly - //In the future, we may need to delegate based upon context provided + //In the future, we may need to delegate based upon context provided return defaultService.getCompletionNode(fileToParse, project, offset, fileCreator); } /** * This method allows a UI component to register its IWorkingCopyProvider to the CDOM. - * + * * @param workingCopyProvider - UI components buffer manager */ public void setWorkingCopyProvider(IWorkingCopyProvider workingCopyProvider) { this.provider = workingCopyProvider; } - public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { return defaultService.getTranslationUnit( fileToParse, project, fileCreator ); } - public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project) throws UnsupportedDialectException { return defaultService.getTranslationUnit( fileToParse, project ); } + @Override public IASTTranslationUnit getTranslationUnit(IFile fileToParse, boolean parseComments) throws UnsupportedDialectException { return defaultService.getTranslationUnit(fileToParse, parseComments); } + @Override public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator, boolean parseComments) throws UnsupportedDialectException { return defaultService.getTranslationUnit(fileToParse, fileCreator, parseComments); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvironmentVariable.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvironmentVariable.java index 1d60dd5944d..624a41602e5 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvironmentVariable.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/EnvironmentVariable.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; /** * A trivial implementation of {@link IEnvironmentVariable} - * + * * @since 3.0 */ public class EnvironmentVariable implements IEnvironmentVariable, Cloneable { @@ -27,7 +27,7 @@ public class EnvironmentVariable implements IEnvironmentVariable, Cloneable { protected String fValue; protected String fDelimiter; protected int fOperation; - + public EnvironmentVariable(String name, String value, int op, String delimiter) { fName = SafeStringInterner.safeIntern(name); fOperation = op; @@ -45,31 +45,35 @@ public class EnvironmentVariable implements IEnvironmentVariable, Cloneable { public EnvironmentVariable(String name){ this(name,null,ENVVAR_REPLACE,null); } - + public EnvironmentVariable(String name, String value){ - this(name,value,ENVVAR_REPLACE,null); + this(name,value,ENVVAR_REPLACE,null); } public EnvironmentVariable(String name, String value, String delimiter){ - this(name,value,ENVVAR_REPLACE,delimiter); - } - - public EnvironmentVariable(IEnvironmentVariable var){ - this(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter()); + this(name,value,ENVVAR_REPLACE,delimiter); } + public EnvironmentVariable(IEnvironmentVariable var){ + this(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter()); + } + + @Override public String getName(){ return fName; } + @Override public String getValue(){ return fValue; } + @Override public int getOperation(){ return fOperation; } + @Override public String getDelimiter(){ return fDelimiter; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/AbstractErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/AbstractErrorParser.java index 05fef4b509a..1e5c57799f9 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/AbstractErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/AbstractErrorParser.java @@ -20,16 +20,17 @@ import org.eclipse.cdt.core.IErrorParser; */ public class AbstractErrorParser implements IErrorParser { private ErrorPattern[] patterns; - + protected AbstractErrorParser(ErrorPattern[] patterns) { this.patterns = patterns; } - + /** * @param line - line of the input * @param manager - error parsers manager * @return true if error parser recognized and accepted line, false otherwise */ + @Override public boolean processLine(String line, ErrorParserManager manager) { for (int i = 0; i < patterns.length; ++i) { if (patterns[i].processLine(line, manager)) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/ErrorParserNamedWrapper.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/ErrorParserNamedWrapper.java index bf43ffb47a6..57fb981e6b3 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/ErrorParserNamedWrapper.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/ErrorParserNamedWrapper.java @@ -43,6 +43,7 @@ public class ErrorParserNamedWrapper implements IErrorParserNamed { /* (non-Javadoc) * @see org.eclipse.cdt.core.IErrorParser#processLine(java.lang.String, org.eclipse.cdt.core.ErrorParserManager) */ + @Override public boolean processLine(String line, ErrorParserManager epm) { return fErrorParser.processLine(line, epm); } @@ -50,6 +51,7 @@ public class ErrorParserNamedWrapper implements IErrorParserNamed { /* (non-Javadoc) * @see org.eclipse.cdt.core.IErrorParserNamed#getId() */ + @Override public String getId() { return fId; } @@ -57,6 +59,7 @@ public class ErrorParserNamedWrapper implements IErrorParserNamed { /* (non-Javadoc) * @see org.eclipse.cdt.core.IErrorParserNamed#getName() */ + @Override public String getName() { return fName; } @@ -71,6 +74,7 @@ public class ErrorParserNamedWrapper implements IErrorParserNamed { /* (non-Javadoc) * @see org.eclipse.cdt.core.IErrorParserNamed#setId(java.lang.String) */ + @Override public void setId(String id) { this.fId = id; } @@ -78,6 +82,7 @@ public class ErrorParserNamedWrapper implements IErrorParserNamed { /* (non-Javadoc) * @see org.eclipse.cdt.core.IErrorParserNamed#setName(java.lang.String) */ + @Override public void setName(String name) { this.fName = name; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/RegexErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/RegexErrorParser.java index ed2841f6ad1..c4e125021db 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/RegexErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/errorparsers/RegexErrorParser.java @@ -61,6 +61,7 @@ public class RegexErrorParser implements IErrorParserNamed { * * @param id of error parser */ + @Override public void setId(String id) { fId = id; } @@ -70,6 +71,7 @@ public class RegexErrorParser implements IErrorParserNamed { * * @param name of error parser */ + @Override public void setName(String name) { fName = name; } @@ -110,6 +112,7 @@ public class RegexErrorParser implements IErrorParserNamed { /** * @return id of error parser */ + @Override public String getId() { return fId; } @@ -117,6 +120,7 @@ public class RegexErrorParser implements IErrorParserNamed { /** * @return name of error parser */ + @Override public String getName() { return fName; } @@ -137,6 +141,7 @@ public class RegexErrorParser implements IErrorParserNamed { * @param epManager - error parsers manager * @return true if error parser recognized and accepted line, false otherwise */ + @Override public boolean processLine(String line, ErrorParserManager epManager) { for (RegexErrorPattern pattern : fPatterns) try { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/CodeReaderCache.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/CodeReaderCache.java index 5a16eb8821d..fbdf808bca8 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/CodeReaderCache.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/CodeReaderCache.java @@ -35,7 +35,7 @@ import org.eclipse.core.runtime.jobs.Job; /** * This is the CodeReaderBuffer used to cache CodeReaders for the ICodeReaderFactory * when working with saved copies (primarily SavedCodeReaderFactory). - * + * * @author dsteffle * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. @@ -46,12 +46,12 @@ public class CodeReaderCache implements ICodeReaderCache { * The string used to identify this CodeReaderCache. Mainly used for preferences. */ public static final String CODE_READER_BUFFER = CCorePlugin.PLUGIN_ID + ".codeReaderCache"; //$NON-NLS-1$ - + /** * The default size of the cache in MB. */ public static final int DEFAULT_CACHE_SIZE_IN_MB = 64; - + /** * A String value of the default size of the cache. */ @@ -62,21 +62,21 @@ public class CodeReaderCache implements ICodeReaderCache { private class UpdateCodeReaderCacheListener implements IResourceChangeListener { ICodeReaderCache c = null; - + /** - * Create the UpdateCodeReaderCacheListener used to dispatch events to remove CodeReaders + * Create the UpdateCodeReaderCacheListener used to dispatch events to remove CodeReaders * from the cache when a resource is changed and detected in Eclipse. * @param cache */ public UpdateCodeReaderCacheListener(ICodeReaderCache cache) { this.c = cache; } - + private class RemoveCacheJob extends Job { private static final String REMOVE_CACHE = "Remove Cache"; //$NON-NLS-1$ ICodeReaderCache cache1 = null; IResourceChangeEvent event = null; - + /** * Create a RemoveCacheJob used to run as a separate thread to remove a CodeReader from the cache. */ @@ -85,7 +85,7 @@ public class CodeReaderCache implements ICodeReaderCache { this.cache1 = cache; this.event = event; } - + @Override protected IStatus run(IProgressMonitor monitor) { if (event.getSource() instanceof IWorkspace && event.getDelta() != null) { @@ -94,7 +94,7 @@ public class CodeReaderCache implements ICodeReaderCache { event = null; return Status.OK_STATUS; } - + private void removeKeys(IResourceDelta[] deltas) { for (IResourceDelta delta : deltas) { if (delta.getResource().getType() == IResource.PROJECT || delta.getResource().getType() == IResource.FOLDER) { @@ -104,58 +104,60 @@ public class CodeReaderCache implements ICodeReaderCache { } } } - + private void removeKey(String key) { if (key != null && cache1 != null) cache1.remove(key); } - + } - + /** * Identifies when a resource was chaned and schedules a new RemoveCacheJob. */ + @Override public void resourceChanged(IResourceChangeEvent event) { if (c instanceof CodeReaderCache) new RemoveCacheJob(c, event).schedule(); } } - + /** * Creates a CodeReaderCache and sets the size of the CodeReaderCache in MB. Creating a new - * CodeReaderCache also adds an UpdateCodeReaderCacheListener to the workspace so that when + * CodeReaderCache also adds an UpdateCodeReaderCacheListener to the workspace so that when * a resource is changed then the CodeReader for that resource is removed from this cache. - * + * * @param size initial size of the CodeReaderCache in terms of MB */ public CodeReaderCache(int size) { cache = new CodeReaderLRUCache(size * MB_TO_KB_FACTOR); } - + @Override protected void finalize() throws Throwable { flush(); super.finalize(); } - + /** * Get a CodeReader from the cache. The key is the char[] filename of the CodeReader to retrieve. * @param key the path of the CodeReader to retrieve */ + @Override public synchronized CodeReader get(String key) { CodeReader result = null; - if (cache.getSpaceLimit() > 0) + if (cache.getSpaceLimit() > 0) result= cache.get(key); - + if (result != null) return result; - + // for efficiency: check File.exists before ParserUtil#createReader() // bug 100947 fix: don't want to attempt to create a code reader if there is no file for the key final File jfile = new File(key); if (!(jfile.exists())) return null; - + try { IResource file = ParserUtil.getResourceForFilename(key); if (file instanceof IFile) { @@ -163,7 +165,7 @@ public class CodeReaderCache implements ICodeReaderCache { result= InternalParserUtil.createWorkspaceFileReader(key, (IFile) file, cache); } result= InternalParserUtil.createExternalFileReader(key, cache); - if (cache.getSpaceLimit() > 0) + if (cache.getSpaceLimit() > 0) put(result); return result; @@ -173,29 +175,30 @@ public class CodeReaderCache implements ICodeReaderCache { } return null; } - + /** - * @throws IOException - * @throws CoreException + * @throws IOException + * @throws CoreException * @since 5.1 */ + @Override public CodeReader get(String key, IIndexFileLocation ifl) throws CoreException, IOException { CodeReader result = null; - if (cache.getSpaceLimit() > 0) + if (cache.getSpaceLimit() > 0) result= cache.get(key); - + if (result != null) return result; - + result= InternalParserUtil.createCodeReader(ifl, cache); - if (cache.getSpaceLimit() > 0) + if (cache.getSpaceLimit() > 0) put(result); return result; } /** - * Put a CodeReader into the Cache. + * Put a CodeReader into the Cache. * @param key * @param value * @return @@ -208,7 +211,7 @@ public class CodeReaderCache implements ICodeReaderCache { } return cache.put(String.valueOf(value.filename), value); } - + /** * Sets the max cache size of this cache in terms of MB. * @param size @@ -216,13 +219,14 @@ public class CodeReaderCache implements ICodeReaderCache { public void setCacheSize(int size) { cache.setSpaceLimit(size * MB_TO_KB_FACTOR); } - - + + /** - * Removes the CodeReader from the cache corresponding to the path specified by the key and + * Removes the CodeReader from the cache corresponding to the path specified by the key and * returns the CodeReader that was removed. If no CodeReader is removed then null is returned. - * @param key + * @param key */ + @Override public synchronized CodeReader remove(String key) { CodeReader removed= cache.remove(key); if (cache.isEmpty()) { @@ -231,14 +235,16 @@ public class CodeReaderCache implements ICodeReaderCache { } return removed; } - + /** * Returns the current size of the cache. For the CodeReaderCache this is in MB. */ + @Override public int getCurrentSpace() { - return cache.getCurrentSpace(); + return cache.getCurrentSpace(); } + @Override public void flush() { cache.flush(); if (ResourcesPlugin.getWorkspace() != null) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java index 48e34fbf771..8c51de85ba6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java @@ -50,6 +50,7 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa super(); } + @Override public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) { ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(file, lineNumber, errorDesc, severity, errorVar, null); addMarker(problemMarkerInfo); @@ -58,6 +59,7 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa /* * callback from Output Parser */ + @Override public void addMarker(ProblemMarkerInfo problemMarkerInfo) { try { IResource markerResource = problemMarkerInfo.file ; @@ -85,7 +87,7 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa } } } - + String type = problemMarkerInfo.getType(); if (type == null) type = ICModelMarker.C_MODEL_PROBLEM_MARKER; @@ -137,19 +139,19 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa } return IMarker.SEVERITY_ERROR; } - + public static boolean needAllConfigBuild() { return prefs.getBoolean(CCorePreferenceConstants.PREF_BUILD_ALL_CONFIGS); } - + public static void setAllConfigBuild(boolean enable) { - prefs.setValue(CCorePreferenceConstants.PREF_BUILD_ALL_CONFIGS, enable); + prefs.setValue(CCorePreferenceConstants.PREF_BUILD_ALL_CONFIGS, enable); } - + /** * Preference for building configurations only when there are resource changes within Eclipse or * when there are changes in its references. - * @return true if configurations will be build when project resource changes within Eclipse + * @return true if configurations will be build when project resource changes within Eclipse * false otherwise * @since 5.1 */ @@ -157,7 +159,7 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa //bug 219337 return prefs.getBoolean(CCorePreferenceConstants.PREF_BUILD_CONFIGS_RESOURCE_CHANGES); } - + /** * Preference for building configurations only when there are resource changes within Eclipse or * when there are changes in its references. @@ -165,9 +167,9 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa * @since 5.1 */ public static void setBuildConfigResourceChanges(boolean enable) { - prefs.setValue(CCorePreferenceConstants.PREF_BUILD_CONFIGS_RESOURCE_CHANGES, enable); + prefs.setValue(CCorePreferenceConstants.PREF_BUILD_CONFIGS_RESOURCE_CHANGES, enable); } - + @SuppressWarnings("nls") private static String kindToString(int kind) { return (kind==IncrementalProjectBuilder.AUTO_BUILD ? "AUTO_BUILD" @@ -176,17 +178,17 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa : kind==IncrementalProjectBuilder.INCREMENTAL_BUILD ? "INCREMENTAL_BUILD" : "[unknown kind]")+"="+kind; } - + @SuppressWarnings("nls") private String cfgIdToNames(String strIds) { IProject project = getProject(); ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project, false); if (prjDesc==null) return strIds; - + if (strIds==null) return "Active=" + prjDesc.getActiveConfiguration().getName(); - + String[] ids = strIds.split("\\|"); String names=""; for (String id : ids) { @@ -196,7 +198,7 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa name = cfgDesc.getName(); else name = id; - + if (names.length()>0) names=names+","; names = names + name; @@ -208,7 +210,7 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa /** * For debugging purpose only. Prints events on the debug console. - * + * * @since 5.2 */ @SuppressWarnings("nls") @@ -223,7 +225,7 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa ); } } - + @Override // This method is overridden with no purpose but to track events in debug mode protected void clean(IProgressMonitor monitor) throws CoreException { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/EFSFileStorage.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/EFSFileStorage.java index 3c3a9b83d59..9b497dac7dc 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/EFSFileStorage.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/EFSFileStorage.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -25,7 +25,7 @@ import org.eclipse.core.runtime.PlatformObject; /** * A storage object which is backed by an EFS resource. - * + * * @author crecoskie * @since 5.0 * @@ -34,14 +34,15 @@ public class EFSFileStorage extends PlatformObject implements IStorage { private URI locationURI; private InputStream inputStream; - + public EFSFileStorage(URI locationURI) { this.locationURI = locationURI; } - + /* (non-Javadoc) * @see org.eclipse.core.resources.IStorage#getContents() */ + @Override public InputStream getContents() throws CoreException { if (inputStream == null) { @@ -59,6 +60,7 @@ public class EFSFileStorage extends PlatformObject implements IStorage { /* (non-Javadoc) * @see org.eclipse.core.resources.IStorage#getFullPath() */ + @Override public IPath getFullPath() { return URIUtil.toPath(locationURI); } @@ -66,6 +68,7 @@ public class EFSFileStorage extends PlatformObject implements IStorage { /* (non-Javadoc) * @see org.eclipse.core.resources.IStorage#getName() */ + @Override public String getName() { IFileStore fileStore = null; try { @@ -79,13 +82,14 @@ public class EFSFileStorage extends PlatformObject implements IStorage { if (fileStore != null) { return fileStore.getName(); } - + return null; } /* (non-Javadoc) * @see org.eclipse.core.resources.IStorage#isReadOnly() */ + @Override public boolean isReadOnly() { IFileStore fileStore = null; try { @@ -97,18 +101,18 @@ public class EFSFileStorage extends PlatformObject implements IStorage { if (fileStore != null) { IFileInfo info = fileStore.fetchInfo(); - + if(info != null) return info.getAttribute(EFS.ATTRIBUTE_READ_ONLY); } - + return false; } - + /** * Returns the location URI corresponding to the EFS resource that * backs this storage. - * + * * @return URI */ public URI getLocationURI() { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java index 02db0cf968d..1ed47e4c26f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java @@ -30,9 +30,10 @@ import org.eclipse.core.runtime.Status; public class FileStorage extends PlatformObject implements IStorage { IPath path; InputStream in = null; - + + @Override public InputStream getContents() throws CoreException { - if (in == null) { + if (in == null) { try { return new FileInputStream(path.toFile()); } catch (FileNotFoundException e) { @@ -46,6 +47,7 @@ public class FileStorage extends PlatformObject implements IStorage { /** * @see IStorage#getFullPath */ + @Override public IPath getFullPath() { return this.path; } @@ -53,6 +55,7 @@ public class FileStorage extends PlatformObject implements IStorage { /** * @see IStorage#getName */ + @Override public String getName() { return this.path.lastSegment(); } @@ -60,6 +63,7 @@ public class FileStorage extends PlatformObject implements IStorage { /** * @see IStorage#isReadOnly() */ + @Override public boolean isReadOnly() { return true; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java index 723b8155a34..4297cc3f0e8 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -47,14 +47,14 @@ import org.eclipse.core.runtime.jobs.MultiRule; * project may have a set of resources associated with it that are the set of resources to be refreshed. An * exclusion mechanism exists that allows for one to specify arbitrarily complicated, nested logic that * determines whether or not a given resource is refreshed according to previously specified rules. - * + * * EXPERIMENTAL. This class or interface has been added as part of a work in progress. There * is no guarantee that this API will work or that it will remain the same. Please do not use this API without * consulting with the CDT team. - * + * * @author crecoskie * @since 5.3 - * + * */ public class RefreshScopeManager { @@ -106,6 +106,7 @@ public class RefreshScopeManager { ResourcesPlugin.getWorkspace().addResourceChangeListener( new IResourceChangeListener() { + @Override public void resourceChanged(IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.PRE_CLOSE @@ -130,6 +131,7 @@ public class RefreshScopeManager { try { delta.accept(new IResourceDeltaVisitor() { + @Override public boolean visit(IResourceDelta delta) throws CoreException { if (delta.getResource() instanceof IProject) { IProject project = (IProject) delta.getResource(); @@ -326,6 +328,7 @@ public class RefreshScopeManager { } } + @Override public void run(IProgressMonitor monitor) throws CoreException { List resourcesToRefresh = getResourcesToRefresh(project); @@ -355,7 +358,7 @@ public class RefreshScopeManager { /** * Returns the set of resources that should be refreshed for a project. These resources might have * associated exclusions. - * + * * @param project * @return List */ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerInfo.java index 37df57e7153..0b5fae7cfe4 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerInfo.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerInfo.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.parser.IExtendedScannerInfo; * #@noinstantiate This class is not intended to be instantiated by clients. Note * that protected constructor won't allow to instantiate this class * outside the package anyway, so it is not really API. - * + * * @deprecated Since CDT 4.0 not used for the "new style" projects. */ @Deprecated @@ -50,30 +50,35 @@ public class ScannerInfo implements IExtendedScannerInfo { } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths() */ + @Override public synchronized String[] getIncludePaths() { return fSystemIncludePaths; } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths() */ + @Override public synchronized Map getDefinedSymbols() { return fMacroMap; } + @Override public String[] getMacroFiles() { return fMacroFiles; } + @Override public String[] getIncludeFiles() { return fIncludeFiles; } + @Override public String[] getLocalIncludePath() { return fLocalIncludePaths; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java index 68dca092569..9295514553e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java @@ -37,10 +37,10 @@ import org.eclipse.core.runtime.IPath; /** * Provides scanner information from {@link PathEntryManager}. - * + * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. - * + * * @deprecated Since CDT 4.0 replaced by {@link ScannerInfoProviderProxy}. Still * used as a default for projects created by earlier CDT versions. */ @@ -51,9 +51,9 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP private static Map> listeners; private static ScannerProvider fProvider; - + // Map of the cache scannerInfos - + public static synchronized IScannerInfoProvider getInstance() { if ( fProvider == null) { fProvider = new ScannerProvider(); @@ -91,9 +91,10 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource) */ + @Override public IScannerInfo getScannerInformation(IResource resource) { IPath resPath = resource.getFullPath(); @@ -109,10 +110,10 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP } } String[] localIncludes = new String[localCount]; - String[] systemIncludes = new String[systemCount]; + String[] systemIncludes = new String[systemCount]; for (int i = 0, j = 0, k = 0; i < includeEntries.length; ++i) { if (includeEntries[i].isSystemInclude()) { - systemIncludes[j++] = includeEntries[i].getFullIncludePath().toOSString(); + systemIncludes[j++] = includeEntries[i].getFullIncludePath().toOSString(); } else { localIncludes[k++] = includeEntries[i].getFullIncludePath().toOSString(); } @@ -147,10 +148,11 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.core.resources.IResource, * org.eclipse.cdt.core.parser.IScannerInfoChangeListener) */ + @Override public synchronized void subscribe(IResource resource, IScannerInfoChangeListener listener) { if (resource == null || listener == null) { return; @@ -172,10 +174,11 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.core.resources.IResource, * org.eclipse.cdt.core.parser.IScannerInfoChangeListener) */ + @Override public synchronized void unsubscribe(IResource resource, IScannerInfoChangeListener listener) { if (resource == null || listener == null) { return; @@ -193,6 +196,7 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent) */ + @Override public void elementChanged(ElementChangedEvent event) { try { processDelta(event.getDelta()); @@ -202,7 +206,7 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP protected boolean isPathEntryChange(ICElementDelta delta) { int flags= delta.getFlags(); - return (delta.getKind() == ICElementDelta.CHANGED && + return (delta.getKind() == ICElementDelta.CHANGED && ((flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0 || (flags & ICElementDelta.F_CHANGED_PATHENTRY_MACRO) != 0 || (flags & ICElementDelta.F_PATHENTRY_REORDER) !=0)); @@ -223,7 +227,7 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP IScannerInfo info = getScannerInformation(res); notifyInfoListeners(project, info); } - + ICElementDelta[] affectedChildren= delta.getAffectedChildren(); for (ICElementDelta element2 : affectedChildren) { processDelta(element2); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java index dfc73365cd6..e0749fefd6b 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptor.java @@ -157,6 +157,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { fCfgExtRef = cfgRef; } + @Override public ICExtension createExtension() throws CoreException { AbstractCExtension cExtension = null; IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(fCfgExtRef, CEXTENSION_NAME, false); @@ -166,18 +167,22 @@ final public class CConfigBasedDescriptor implements ICDescriptor { return cExtension; } + @Override public ICDescriptor getCDescriptor() { return CConfigBasedDescriptor.this; } + @Override public String getExtension() { return fCfgExtRef.getExtensionPoint(); } + @Override public String getExtensionData(String key) { return fCfgExtRef.getExtensionData(key); } + @Override public IConfigurationElement[] getExtensionElements() throws CoreException { IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(fCfgExtRef, CEXTENSION_NAME, false); @@ -186,10 +191,12 @@ final public class CConfigBasedDescriptor implements ICDescriptor { return new IConfigurationElement[0]; } + @Override public String getID() { return fCfgExtRef.getID(); } + @Override public void setExtensionData(String key, String value) throws CoreException { if(!CDataUtil.objectsEqual(fCfgExtRef.getExtensionData(key), value)){ @@ -286,6 +293,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptor#create(java.lang.String, java.lang.String) */ + @Override public ICExtensionReference create(String extensionPoint, String id) throws CoreException { try { fLock.acquire(); @@ -356,6 +364,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * FIXME re-add caching (the current behaviour mirrors the previous behaviour -- just tidier) * @return an array of ICExtenionReference */ + @Override public ICExtensionReference[] get(String extensionPoint) { try { fLock.acquire(); @@ -380,6 +389,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptor#get(java.lang.String, boolean) */ + @Override public ICExtensionReference[] get(String extensionPoint, boolean update) throws CoreException { try { fLock.acquire(); @@ -399,6 +409,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptor#getPlatform() */ + @Override public String getPlatform() { try { fLock.acquire(); @@ -412,6 +423,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptor#getProject() */ + @Override public IProject getProject() { try { fLock.acquire(); @@ -429,6 +441,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * returned ICStorageElement. We must allow this as this is how the existing implementation * behaves. */ + @Override public ICStorageElement getProjectStorageElement(String id) throws CoreException { try { fLock.acquire(); @@ -460,6 +473,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * Currently relies on the fact that the only implementation if ICStorageElement * in the core is XmlStorageElement. */ + @Override public Element getProjectData(String id) throws CoreException { try { fLock.acquire(); @@ -484,6 +498,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { final Element xmlEl = ((XmlStorageElement)el).fElement; // This proxy synchronizes the storage element's root XML Element el = new XmlStorageElement((Element)Proxy.newProxyInstance(Element.class.getClassLoader(), new Class[]{Element.class}, new InvocationHandler(){ + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Method realMethod = xmlEl.getClass().getMethod(method.getName(), method.getParameterTypes()); // Now just execute the method @@ -493,6 +508,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { if (method.getName().equals("getParentNode")) { //$NON-NLS-1$ final Node parent = (Node)realMethod.invoke(xmlEl, args); Node parentProxy = (Node)Proxy.newProxyInstance(Node.class.getClassLoader(), new Class[]{Node.class}, new InvocationHandler(){ + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Method realMethod = parent.getClass().getMethod(method.getName(), method.getParameterTypes()); synchronized (xmlEl) { @@ -535,6 +551,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { } } + @Override public ICStorageElement removeProjectStorageElement(String id) throws CoreException { try { fLock.acquire(); @@ -544,6 +561,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { } } + @Override public ICOwnerInfo getProjectOwner() { try { fLock.acquire(); @@ -553,6 +571,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { } } + @Override public void remove(ICExtensionReference extension) throws CoreException { try { fLock.acquire(); @@ -584,6 +603,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { } } + @Override public void remove(String extensionPoint) throws CoreException { try { fLock.acquire(); @@ -611,6 +631,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptor#saveProjectData() */ + @Override public void saveProjectData() throws CoreException { try { fLock.acquire(); @@ -631,6 +652,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor { * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptor#getConfigurationDescription() */ + @Override public ICConfigurationDescription getConfigurationDescription() { try { fLock.acquire(); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java index b07af955b82..0e9094e9f0f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java @@ -133,6 +133,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#configure(org.eclipse.core.resources.IProject, java.lang.String) */ + @Override public void configure(IProject project, String id) throws CoreException { if (id.equals(NULLCOwner.getOwnerID())) { IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, @@ -206,6 +207,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#convert(org.eclipse.core.resources.IProject, java.lang.String) */ + @Override public void convert(IProject project, String id) throws CoreException { CConfigBasedDescriptor dr = findDescriptor(project, false); if(dr == null) @@ -225,6 +227,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#getDescriptor(org.eclipse.core.resources.IProject) */ + @Override public ICDescriptor getDescriptor(IProject project) throws CoreException { return getDescriptor(project, true); } @@ -233,6 +236,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#getDescriptor(org.eclipse.core.resources.IProject, boolean) */ + @Override public ICDescriptor getDescriptor(IProject project, boolean create) throws CoreException { return findDescriptor(project, create); } @@ -241,6 +245,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#addDescriptorListener(org.eclipse.cdt.core.ICDescriptorListener) */ + @Override public void addDescriptorListener(ICDescriptorListener listener) { fListeners.add(listener); } @@ -249,6 +254,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#removeDescriptorListener(org.eclipse.cdt.core.ICDescriptorListener) */ + @Override public void removeDescriptorListener(ICDescriptorListener listener) { fListeners.remove(listener); } @@ -258,6 +264,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#runDescriptorOperation(org.eclipse.core.resources.IProject, org.eclipse.cdt.core.ICDescriptorOperation, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException { CConfigBasedDescriptor dr = findDescriptor(project, true); @@ -287,6 +294,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager * (non-Javadoc) * @see org.eclipse.cdt.core.ICDescriptorManager#runDescriptorOperation(org.eclipse.core.resources.IProject, org.eclipse.cdt.core.settings.model.ICProjectDescription, org.eclipse.cdt.core.ICDescriptorOperation, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void runDescriptorOperation(IProject project, ICProjectDescription des, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException { // Ensure that only one of these is running on the project at any one time... @@ -440,6 +448,7 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager if (fDescriptionListener != null) return; fDescriptionListener = new ICProjectDescriptionListener(){ + @Override public void handleEvent(CProjectDescriptionEvent event) { doHandleEvent(event); } @@ -579,12 +588,14 @@ final public class CConfigBasedDescriptorManager implements ICDescriptorManager for (final ICDescriptorListener listener : fListeners) { SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$ CCorePlugin.log(status); } + @Override public void run() throws Exception { listener.descriptorChanged(event); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java index 0c025aa12c4..33388970aaa 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CExtensionDescriptor.java @@ -22,14 +22,16 @@ public class CExtensionDescriptor implements ICExtensionDescriptor { fElement = el; } + @Override public String getId() { return fElement.getAttribute(ATTRIBUTE_ID); } + @Override public String getName() { return fElement.getAttribute(ATTRIBUTE_NAME); } - + public IConfigurationElement getConfigurationElement(){ return fElement; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/COwner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/COwner.java index eb56f14b26d..79d5bf4b3df 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/COwner.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/COwner.java @@ -24,14 +24,17 @@ public class COwner implements ICOwnerInfo { fConfig = config; } + @Override public String getID() { return fConfig.getOwnerID(); } + @Override public String getName() { return fConfig.getName(); } + @Override public String getPlatform() { return fConfig.getPlatform(); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java index 6f30438be9e..d3472ae3cd4 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java @@ -55,13 +55,15 @@ public class CdtVarPathEntryVariableManager implements super(new VarContextInfo(), "", " "); //$NON-NLS-1$ //$NON-NLS-2$ } } - + private class VarContextInfo implements IVariableContextInfo { + @Override public IVariableContextInfo getNext() { return null; } + @Override public ICdtVariableSupplier[] getSuppliers() { return new ICdtVariableSupplier[]{fVarSupplier}; } @@ -70,17 +72,18 @@ public class CdtVarPathEntryVariableManager implements public boolean equals(Object obj) { if(obj == this) return true; - + if(!(obj instanceof VarContextInfo)) return false; - + return true; } - + } - + private class VarSupplier implements ICdtVariableSupplier { + @Override public ICdtVariable getVariable(String macroName, IVariableContextInfo context) { ICdtVariable var = fUserVarSupplier.getMacro(macroName, ICoreVariableContextInfo.CONTEXT_WORKSPACE, null); @@ -89,6 +92,7 @@ public class CdtVarPathEntryVariableManager implements return null; } + @Override public ICdtVariable[] getVariables(IVariableContextInfo context) { ICdtVariable vars[] = fUserVarSupplier.getMacros(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null); List list = new ArrayList(); @@ -98,21 +102,22 @@ public class CdtVarPathEntryVariableManager implements } return list.toArray(new ICdtVariable[list.size()]); } - + } - - - + + + public CdtVarPathEntryVariableManager(){ fListeners = Collections.synchronizedSet(new HashSet()); fUserVarSupplier.addListener(this); } + @Override public IPath getValue(String name) { ICdtVariable var = fUserVarSupplier.getMacro(name, ICoreVariableContextInfo.CONTEXT_WORKSPACE, null); return getVariablePath(var); } - + public static IPath getVariablePath(ICdtVariable var){ if(var != null){ switch(var.getValueType()){ @@ -139,16 +144,17 @@ public class CdtVarPathEntryVariableManager implements public static boolean isPathEntryVariable(ICdtVariable var, ICConfigurationDescription cfg, ICdtVariableManager mngr){ if(mngr.isUserVariable(var, cfg)) return false; - + if(!mngr.isUserVariable(var, null)) return false; - + if(getVariablePath(var) == null) return false; - + return true; } + @Override public String[] getVariableNames() { ICdtVariable[] vars = fUserVarSupplier.getMacros(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null); ArrayList list = new ArrayList(); @@ -159,38 +165,41 @@ public class CdtVarPathEntryVariableManager implements return list.toArray(new String[list.size()]); } + @Override public boolean isDefined(String name) { return getValue(name) != null; } + @Override public IPath resolvePath(IPath path) { if(path == null) return null; - + String str = path.toPortableString(); - + try { str = CdtVariableResolver.resolveToString(str, fSubstitutor); } catch (CdtVariableException e) { CCorePlugin.log(e); } - + return new Path(str); } + @Override public void setValue(String name, IPath value) throws CoreException { if(value != null) fUserVarSupplier.createMacro(name, ICdtVariable.VALUE_PATH_ANY, value.toString(), ICoreVariableContextInfo.CONTEXT_WORKSPACE, null); else fUserVarSupplier.deleteMacro(name, ICoreVariableContextInfo.CONTEXT_WORKSPACE, null); - + fUserVarSupplier.storeWorkspaceVariables(false); } - + /** * Fires a property change event corresponding to a change to the * current value of the variable with the given name. - * + * * @param name the name of the variable, to be used as the variable * in the event object * @param value the current value of the path variable or null if @@ -206,16 +215,18 @@ public class CdtVarPathEntryVariableManager implements private void fireVariableChangeEvent(String name, IPath value, int type) { if (this.fListeners.size() == 0) return; - // use a separate collection to avoid interference of simultaneous additions/removals + // use a separate collection to avoid interference of simultaneous additions/removals Object[] listenerArray = this.fListeners.toArray(); final PathEntryVariableChangeEvent pve = new PathEntryVariableChangeEvent(this, name, value, type); for (int i = 0; i < listenerArray.length; ++i) { final IPathEntryVariableChangeListener l = (IPathEntryVariableChangeListener) listenerArray[i]; ISafeRunnable job = new ISafeRunnable() { + @Override public void handleException(Throwable exception) { // already being logged in Platform#run() } + @Override public void run() throws Exception { l.pathVariableChanged(pve); } @@ -223,10 +234,11 @@ public class CdtVarPathEntryVariableManager implements SafeRunner.run(job); } } - + /** * @see org.eclipse.cdt.core.resources.IPathEntryVariableManager#addChangeListener(IPathEntryVariableChangeListener) */ + @Override public void addChangeListener(IPathEntryVariableChangeListener listener) { fListeners.add(listener); } @@ -235,37 +247,39 @@ public class CdtVarPathEntryVariableManager implements * @see org.eclipse.cdt.core.resources. * IPathEntryVariableManager#removeChangeListener(IPathEntryVariableChangeListener) */ + @Override public void removeChangeListener(IPathEntryVariableChangeListener listener) { fListeners.remove(listener); } + @Override public void variablesChanged(VariableChangeEvent event) { ICdtVariable[] added = event.getAddedVariables(); ICdtVariable[] removed = event.getRemovedVariables(); ICdtVariable[] changed = event.getChangedVariables(); - + if(added.length != 0){ fireEvent(added, PathEntryVariableChangeEvent.VARIABLE_CREATED); } - + if(removed.length != 0){ fireEvent(removed, PathEntryVariableChangeEvent.VARIABLE_DELETED); } - + if(changed.length != 0){ fireEvent(changed, PathEntryVariableChangeEvent.VARIABLE_CHANGED); } } - + private void fireEvent(ICdtVariable vars[], int type){ for (ICdtVariable var : vars) { IPath path = getVariablePath(var); if(path != null) fireVariableChangeEvent(var.getName(), path, type); } - + } - + public void startup(){ } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/LocalProjectScope.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/LocalProjectScope.java index 12bb864c5ac..58baa74aa63 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/LocalProjectScope.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/LocalProjectScope.java @@ -56,14 +56,17 @@ public class LocalProjectScope implements IScopeContext { fContext= projectName; } + @Override public IPath getLocation() { return null; } + @Override public String getName() { return SCOPE; } + @Override public IEclipsePreferences getNode(String qualifier) { return InstanceScope.INSTANCE.getNode(qualifier + QUALIFIER_EXT + fContext); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableManager.java index 2c6da363a89..30ab3259a43 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableManager.java @@ -33,7 +33,7 @@ import org.eclipse.core.runtime.SafeRunner; /** - * Core's implementation of IPathEntryVariableManager. + * Core's implementation of IPathEntryVariableManager. */ public class PathEntryVariableManager implements IPathEntryVariableManager { @@ -44,16 +44,16 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { /** * Constructor for the class. - * + * * The current manager implementation is not used any more * Instead the CdtVarPathEntryVariableManager is used that actually wraps the CdtVariables contributed at workspace level - * + * * NOTE: all PathEntryVariableManager functionality remains workable with the new - * CdtVarPathEntryVariableManager. We could either remove this class or copy the contents of the + * CdtVarPathEntryVariableManager. We could either remove this class or copy the contents of the * CdtVarPathEntryVariableManager to this class to preserve internal class name for better backward compatibility. - * - * - */ + * + * + */ private PathEntryVariableManager() { this.listeners = Collections.synchronizedSet(new HashSet()); this.preferences = CCorePlugin.getDefault().getPluginPreferences(); @@ -64,9 +64,10 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { * and then calls #getValue using that key, they will get the value back for * that. But then if they try and call #setValue using the same key it will throw * an exception. We may want to revisit this behaviour in the future. - * + * * @see org.eclipse.cdt.core.resources.IPathEntryVariableManager#getValue(String) */ + @Override public IPath getValue(String varName) { String key = getKeyForName(varName); String value = preferences.getString(key); @@ -76,13 +77,14 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { /** * @see org.eclipse.cdt.core.resources.IPathEntryVariableManager#setValue(String, IPath) */ + @Override public void setValue(String varName, IPath newValue) throws CoreException { //if the location doesn't have a device, see if the OS will assign one if (newValue != null && newValue.isAbsolute() && newValue.getDevice() == null) { newValue = new Path(newValue.toFile().getAbsolutePath()); } int eventType; - // read previous value and set new value atomically in order to generate the right event + // read previous value and set new value atomically in order to generate the right event synchronized (this) { IPath currentValue = getValue(varName); boolean variableExists = currentValue != null; @@ -115,6 +117,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { /** * @see org.eclipse.cdt.core.resources.IPathEntryVariableManager#resolvePath(IPath) */ + @Override public IPath resolvePath(IPath path) { if (path == null || path.segmentCount() == 0) { return path; @@ -130,7 +133,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { /** * Fires a property change event corresponding to a change to the * current value of the variable with the given name. - * + * * @param name the name of the variable, to be used as the variable * in the event object * @param value the current value of the path variable or null if @@ -146,16 +149,18 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { private void fireVariableChangeEvent(String name, IPath value, int type) { if (this.listeners.size() == 0) return; - // use a separate collection to avoid interference of simultaneous additions/removals + // use a separate collection to avoid interference of simultaneous additions/removals Object[] listenerArray = this.listeners.toArray(); final PathEntryVariableChangeEvent pve = new PathEntryVariableChangeEvent(this, name, value, type); for (int i = 0; i < listenerArray.length; ++i) { final IPathEntryVariableChangeListener l = (IPathEntryVariableChangeListener) listenerArray[i]; ISafeRunnable job = new ISafeRunnable() { + @Override public void handleException(Throwable exception) { // already being logged in Platform#run() } + @Override public void run() throws Exception { l.pathVariableChanged(pve); } @@ -167,6 +172,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { /** * @see org.eclipse.core.resources.IPathVariableManager#getPathVariableNames() */ + @Override public String[] getVariableNames() { List result = new LinkedList(); String[] names = preferences.propertyNames(); @@ -183,6 +189,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { * @see org.eclipse.cdt.core.resources. * IPathEntryVariableManager#addChangeListener(IPathEntryVariableChangeListener) */ + @Override public void addChangeListener(IPathEntryVariableChangeListener listener) { listeners.add(listener); } @@ -191,6 +198,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { * @see org.eclipse.cdt.core.resources. * IPathEntryVariableManager#removeChangeListener(IPathEntryVariableChangeListener) */ + @Override public void removeChangeListener(IPathEntryVariableChangeListener listener) { listeners.remove(listener); } @@ -198,6 +206,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { /** * @see org.eclipse.core.resources.IPathVariableManager#isDefined(String) */ + @Override public boolean isDefined(String varName) { return getValue(varName) != null; } @@ -221,7 +230,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { char ch = prev; boolean inMacro = false; boolean inSingleQuote = false; - + for (int i = 0; i < variable.length(); i++) { ch = variable.charAt(i); switch (ch) { @@ -230,7 +239,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { inSingleQuote = !inSingleQuote; } break; - + case '$' : if (!inSingleQuote && prev != '\\') { if (i < variable.length() && variable.indexOf('}', i) > 0) { @@ -244,7 +253,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { } } break; - + case '}' : if (inMacro) { inMacro = false; @@ -263,7 +272,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager { } break; } /* switch */ - + if (!inMacro) { sb.append(ch); } else { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableResolver.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableResolver.java index ed7c48f3d44..9608a151ec2 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableResolver.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PathEntryVariableResolver.java @@ -26,6 +26,7 @@ public class PathEntryVariableResolver implements IDynamicVariableResolver { super(); } + @Override public String resolveValue(IDynamicVariable variable, String argument) throws CoreException { if (argument == null) { throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.getResourceString("PathEntryVariableResolver.0"), null)); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java index feefb5b9815..bafff7faa3f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core; @@ -28,7 +28,7 @@ public class PositionTracker implements IPositionConverter { private Node fAboveRoot = new Node(0, 0, 0); private PositionTracker fFollowedBy = null; private long fTimeStamp; - + /** * Resets the tracker to a state reflecting no changes. */ @@ -45,7 +45,7 @@ public class PositionTracker implements IPositionConverter { } /** - * Notifies the tracker of the insertion of characters. + * Notifies the tracker of the insertion of characters. * It is assumed that character get inserted before the offset. * @param offset offset of the character in front of which insertion occurs. * @param count amount of characters inserted. @@ -61,7 +61,7 @@ public class PositionTracker implements IPositionConverter { /** * Notifies the tracker of the removal of characters. - * delete(0,1) removes the first character, + * delete(0,1) removes the first character, * for convenience delete(1,-1) does the same. * @param offset offset of the first character deleted. * @param count amount of characters deleted. @@ -88,7 +88,7 @@ public class PositionTracker implements IPositionConverter { public synchronized int historicOffset(int currentOffset) { return historicOffset(currentOffset, true); } - + private synchronized int historicOffset(int currentOffset, boolean nextOnDelete) { int orig = currentOffset; if (fFollowedBy != null) { @@ -106,7 +106,7 @@ public class PositionTracker implements IPositionConverter { public synchronized int currentOffset(int historicOffset) { return currentOffset(historicOffset, true); } - + private synchronized int currentOffset(int historicOffset, boolean nextOnDelete) { int current = fAboveRoot.calculateCurrentOffset(historicOffset, 0, nextOnDelete); if (fFollowedBy != null) { @@ -116,7 +116,7 @@ public class PositionTracker implements IPositionConverter { } /** - * Makes this tracker final. Future changes are tracked by the tracker + * Makes this tracker final. Future changes are tracked by the tracker * supplied and will be taken into acoount when converting positions. * @param inFavourOf tracker that tracks changes from now on. */ @@ -142,7 +142,7 @@ public class PositionTracker implements IPositionConverter { public synchronized boolean isModified() { return fAboveRoot.fLeft != null || fAboveRoot.fRight!=null; } - + public synchronized long getTimeStamp() { return fTimeStamp; } @@ -166,10 +166,11 @@ public class PositionTracker implements IPositionConverter { return fAboveRoot.countNodes(); } - public synchronized IRegion actualToHistoric(IRegion actualPosition) { + @Override + public synchronized IRegion actualToHistoric(IRegion actualPosition) { int actual= actualPosition.getOffset(); int len= actualPosition.getLength(); - + int historic= historicOffset(actual, true); if (len > 0) { len= historicOffset(actual+len-1, false) - historic + 1; @@ -178,10 +179,11 @@ public class PositionTracker implements IPositionConverter { return new Region(historic, len); } - public synchronized IRegion historicToActual(IRegion historicPosition) { + @Override + public synchronized IRegion historicToActual(IRegion historicPosition) { int historic= historicPosition.getOffset(); int len= historicPosition.getLength(); - + int actual= currentOffset(historic, true); if (len > 0) { len= currentOffset(historic+len-1, false) - actual + 1; @@ -189,7 +191,7 @@ public class PositionTracker implements IPositionConverter { assert len >= 0; return new Region(actual, len); } - + /** * Nodes implementing a red black binary tree. * @author markus.schorn@windriver.com diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java index 654fcff0d43..da4d5a99383 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core; import java.util.Iterator; @@ -19,13 +19,13 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentListener; class PositionTrackerChain implements IDocumentListener { - public static final int LINKED_LIST_SIZE = 64; + public static final int LINKED_LIST_SIZE = 64; public static final int LINKED_LIST_ENTRY_SIZE = 32; public static int MEMORY_SIZE= 32 + LINKED_LIST_SIZE; - + private static final int MAX_DEPTH = 100; // 100 saves private static final long MAX_AGE = 24 * 60 * 60 * 1000; // one day - + private LinkedList fTrackers= new LinkedList(); private PositionTracker fActiveTracker; private IDocument fDocument; @@ -33,7 +33,7 @@ class PositionTrackerChain implements IDocumentListener { public PositionTrackerChain(long timestamp) { createCheckpoint(timestamp); } - + public int createCheckpoint(long timestamp) { // travel in time while (fActiveTracker != null && fActiveTracker.getTimeStamp() >= timestamp) { @@ -51,7 +51,7 @@ class PositionTrackerChain implements IDocumentListener { PositionTracker newTracker= new PositionTracker(); newTracker.setTimeStamp(timestamp); fTrackers.add(newTracker); - + if (fActiveTracker != null) { fActiveTracker.retire(newTracker); retiredMemsize= fActiveTracker.getMemorySize() + LINKED_LIST_ENTRY_SIZE; @@ -60,7 +60,7 @@ class PositionTrackerChain implements IDocumentListener { checkTrackerLimits(); return retiredMemsize; } - + private void checkTrackerLimits() { while (fTrackers.size() >= MAX_DEPTH) { fTrackers.removeFirst(); @@ -74,7 +74,7 @@ class PositionTrackerChain implements IDocumentListener { iter.remove(); } } - + /* (non-Javadoc) * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent) */ @@ -155,14 +155,16 @@ class PositionTrackerChain implements IDocumentListener { } } - public void documentAboutToBeChanged(DocumentEvent event) { + @Override + public void documentAboutToBeChanged(DocumentEvent event) { update(event); } - public void documentChanged(DocumentEvent event) { + @Override + public void documentChanged(DocumentEvent event) { // react before updateing the document } - + public IDocument getCurrentDocument() { return fDocument; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java index 09f225562e8..653ecfd05b6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core; import java.net.URI; @@ -34,7 +34,7 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf private static final int HASHMAP_ENTRY_SIZE = 56; private static final int MAX_MEMORY= 1024*512; // 512 kbytes private static final int MAX_MEMORY_AFTER_CLEANUP= (MAX_MEMORY * 7) / 10; // 70% of MAX_MEMORY - + private static PositionTrackerManager sManager= new PositionTrackerManager(); public static PositionTrackerManager getInstance() { return sManager; @@ -49,7 +49,7 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf * the location as URI for non-local non-workspace files. */ private HashMap fPositionTrackerMap; - + private PositionTrackerManager() { fPositionTrackerMap= new HashMap(); } @@ -60,7 +60,7 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf mgr.addFileBufferListener(this); } } - + public synchronized void uninstall() { if (--fInstalled == 0) { FileBuffers.getTextFileBufferManager().removeFileBufferListener(this); @@ -69,36 +69,46 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf } } - public void bufferCreated(IFileBuffer buffer) { + @Override + public void bufferCreated(IFileBuffer buffer) { if (buffer instanceof ITextFileBuffer) { createCheckpoint((ITextFileBuffer) buffer); } } - public void bufferDisposed(IFileBuffer buffer) { + @Override + public void bufferDisposed(IFileBuffer buffer) { if (buffer instanceof ITextFileBuffer) { resetToLastCheckpoint((ITextFileBuffer) buffer); } } - public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) { + @Override + public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) { if (!isDirty && buffer instanceof ITextFileBuffer) { createCheckpoint((ITextFileBuffer) buffer); } } - public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) { + @Override + public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) { if (isStateValidated && !buffer.isDirty()) { bufferCreated(buffer); } } - - public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {} - public void bufferContentReplaced(IFileBuffer buffer) {} - public void underlyingFileMoved(IFileBuffer buffer, IPath path) {} - public void underlyingFileDeleted(IFileBuffer buffer) {} - public void stateChangeFailed(IFileBuffer buffer) {} - public void stateChanging(IFileBuffer buffer) {} + + @Override + public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {} + @Override + public void bufferContentReplaced(IFileBuffer buffer) {} + @Override + public void underlyingFileMoved(IFileBuffer buffer, IPath path) {} + @Override + public void underlyingFileDeleted(IFileBuffer buffer) {} + @Override + public void stateChangeFailed(IFileBuffer buffer) {} + @Override + public void stateChanging(IFileBuffer buffer) {} private synchronized void createCheckpoint(ITextFileBuffer buffer) { final Object bufferKey= getKey(buffer); @@ -117,7 +127,7 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf runCleanup(); } } - + private Object getKey(ITextFileBuffer buffer) { Object key= buffer.getLocation(); if (key == null) { @@ -143,7 +153,7 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf } } } - + private synchronized void runCleanup() { fMemoryCounter= 0; for (PositionTrackerChain chain : fPositionTrackerMap.values()) { @@ -168,7 +178,7 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf break; } } - } + } } private synchronized void addChain(SortedMap> map, PositionTrackerChain chain) { @@ -187,18 +197,20 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf /** * {@inheritDoc} */ - public synchronized IPositionConverter findPositionConverter(IFile file, long timestamp) { + @Override + public synchronized IPositionConverter findPositionConverter(IFile file, long timestamp) { PositionTrackerChain chain= fPositionTrackerMap.get(file.getFullPath()); if (chain != null) { return chain.findTrackerAt(timestamp); } return null; } - + /** * {@inheritDoc} */ - public synchronized IPositionConverter findPositionConverter(IPath externalLocation, long timestamp) { + @Override + public synchronized IPositionConverter findPositionConverter(IPath externalLocation, long timestamp) { PositionTrackerChain chain= fPositionTrackerMap.get(externalLocation); if (chain != null) { return chain.findTrackerAt(timestamp); @@ -209,28 +221,30 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf /** * {@inheritDoc} */ - public synchronized IPositionConverter findPositionConverter(ITranslationUnit tu, long timestamp) { + @Override + public synchronized IPositionConverter findPositionConverter(ITranslationUnit tu, long timestamp) { IFile file= (IFile) tu.getResource(); if (file != null) { return findPositionConverter(file, timestamp); - } + } IPath location= tu.getLocation(); if (location != null) { return findPositionConverter(location, timestamp); } - + URI locationURI = tu.getLocationURI(); if (locationURI != null) { return findPositionConverter(locationURI, timestamp); } - + return null; } - + /** * {@inheritDoc} */ - public synchronized IPositionConverter findPositionConverter(URI locationURI, long timestamp) { + @Override + public synchronized IPositionConverter findPositionConverter(URI locationURI, long timestamp) { PositionTrackerChain chain= fPositionTrackerMap.get(locationURI); if (chain == null) { IPath path= URIUtil.toPath(locationURI); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/SystemBuildConsole.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/SystemBuildConsole.java index 7ac9c1958cc..f1e2a46fc89 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/SystemBuildConsole.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/SystemBuildConsole.java @@ -24,14 +24,14 @@ import org.eclipse.core.runtime.CoreException; public class SystemBuildConsole implements IConsole { final ConsoleOutputStream out; final ConsoleOutputStream err; - + public SystemBuildConsole() { out = new ConsoleOutputStream() { @Override public synchronized void write(byte[] b, int off, int len) throws java.io.IOException { System.out.write(b, off, len); } - + @Override public synchronized void write(int c) throws java.io.IOException { System.out.write(c); @@ -42,7 +42,7 @@ public class SystemBuildConsole implements IConsole { public synchronized void write(byte[] b, int off, int len) throws java.io.IOException { System.err.write(b, off, len); } - + @Override public synchronized void write(int c) throws java.io.IOException { System.err.write(c); @@ -50,17 +50,21 @@ public class SystemBuildConsole implements IConsole { }; } + @Override public void start(IProject project) { } + @Override public ConsoleOutputStream getOutputStream() throws CoreException { return out; } + @Override public ConsoleOutputStream getInfoStream() throws CoreException { return out; } + @Override public ConsoleOutputStream getErrorStream() throws CoreException { return err; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java index 133c6021a6b..e52dc31bc1b 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java @@ -32,25 +32,26 @@ import org.eclipse.core.variables.IStringVariable; */ public class CdtVariableManager implements ICdtVariableManager { static private CdtVariableManager fDefault; - + public static final UserDefinedVariableSupplier fUserDefinedMacroSupplier = UserDefinedVariableSupplier.getInstance(); public static final BuildSystemVariableSupplier fBuildSystemVariableSupplier = BuildSystemVariableSupplier.getInstance(); public static final EnvironmentVariableSupplier fEnvironmentMacroSupplier = EnvironmentVariableSupplier.getInstance(); public static final CdtMacroSupplier fCdtMacroSupplier = CdtMacroSupplier.getInstance(); public static final EclipseVariablesVariableSupplier fEclipseVariablesMacroSupplier = EclipseVariablesVariableSupplier.getInstance(); - + protected CdtVariableManager(){ - + } - + public static CdtVariableManager getDefault(){ if(fDefault == null) fDefault = new CdtVariableManager(); - return fDefault; + return fDefault; } /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#getMacro(java.lang.String, int, java.lang.Object, boolean) */ + @Override public ICdtVariable getVariable(String macroName, ICConfigurationDescription cfg) { if(cfg instanceof CConfigurationDescriptionCache){ StorableCdtVariables macros = ((CConfigurationDescriptionCache)cfg).getCachedVariables(); @@ -61,7 +62,7 @@ public class CdtVariableManager implements ICdtVariableManager { return SupplierBasedCdtVariableManager.getVariable(macroName, getMacroContextInfo(type,cfg),true); } - + private IVariableContextInfo getVariableContextInfo(ICConfigurationDescription cfg){ int type = getContextType(cfg); return getMacroContextInfo(type,cfg); @@ -70,6 +71,7 @@ public class CdtVariableManager implements ICdtVariableManager { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#getMacros(int, java.lang.Object, boolean) */ + @Override public ICdtVariable[] getVariables(ICConfigurationDescription cfg) { if(cfg instanceof CConfigurationDescriptionCache){ StorableCdtVariables macros = ((CConfigurationDescriptionCache)cfg).getCachedVariables(); @@ -91,7 +93,7 @@ public class CdtVariableManager implements ICdtVariableManager { return info.getSuppliers(); return null; } - + public IVariableContextInfo getMacroContextInfo( int contextType, Object contextData){ @@ -104,6 +106,7 @@ public class CdtVariableManager implements ICdtVariableManager { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#convertStringListToString(java.lang.String[], java.lang.String) */ + @Override public String convertStringListToString(String[] value, String listDelimiter) { return CdtVariableResolver.convertStringListToString(value,listDelimiter); } @@ -111,33 +114,36 @@ public class CdtVariableManager implements ICdtVariableManager { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveValue(java.lang.String, java.lang.String, java.lang.String, int, java.lang.Object) */ + @Override public String resolveValue(String value, String nonexistentMacrosValue, String listDelimiter, ICConfigurationDescription cfg) throws CdtVariableException { - + IVariableContextInfo info = getMacroContextInfo(getContextType(cfg),cfg); if(info != null) return CdtVariableResolver.resolveToString(value, getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter)); return null; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValue(java.lang.String, java.lang.String, int, java.lang.Object) */ + @Override public String[] resolveStringListValue(String value, String nonexistentMacrosValue, String listDelimiter, ICConfigurationDescription cfg) throws CdtVariableException { - + IVariableContextInfo info = getMacroContextInfo(getContextType(cfg),cfg); if(info != null) - return CdtVariableResolver.resolveToStringList(value,getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter)); + return CdtVariableResolver.resolveToStringList(value,getMacroSubstitutor(info,nonexistentMacrosValue, listDelimiter)); return null; } /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#isStringListValue(java.lang.String) */ + @Override public boolean isStringListValue(String value, ICConfigurationDescription cfg) throws CdtVariableException { try { CdtVariableResolver.resolveToStringList(value,getMacroSubstitutor(getMacroContextInfo(getContextType(cfg), cfg)," ",null)); //$NON-NLS-1$ @@ -151,6 +157,7 @@ public class CdtVariableManager implements ICdtVariableManager { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#checkIntegrity(int, java.lang.Object) */ + @Override public void checkVariableIntegrity(ICConfigurationDescription cfg) throws CdtVariableException { @@ -167,7 +174,7 @@ public class CdtVariableManager implements ICdtVariableManager { if(info != null) CdtVariableResolver.checkIntegrity(info,subst); } - + private int getContextType(ICConfigurationDescription des){ if(des != null) return ICoreVariableContextInfo.CONTEXT_CONFIGURATION; @@ -181,6 +188,7 @@ public class CdtVariableManager implements ICdtVariableManager { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider#resolveStringListValues(java.lang.String[], java.lang.String, java.lang.String, int, java.lang.Object) */ + @Override public String[] resolveStringListValues(String[] value, String nonexistentMacrosValue, String listDelimiter, ICConfigurationDescription cfg) throws CdtVariableException { IVariableContextInfo info = getMacroContextInfo(getContextType(cfg),cfg); if(info != null) @@ -189,32 +197,33 @@ public class CdtVariableManager implements ICdtVariableManager { return null; } + @Override public boolean isEnvironmentVariable(ICdtVariable variable, ICConfigurationDescription cfg) { if(variable instanceof EnvironmentVariableSupplier.EnvVarMacro) return true; - + IVariableContextInfo info = getVariableContextInfo(cfg); ICdtVariable var = fEnvironmentMacroSupplier.getVariable(variable.getName(), info); if(var != null && variablesEqual(var, variable)) return true; - + return false; } - + private static boolean variablesEqual(ICdtVariable var1, ICdtVariable var2){ if(CDataUtil.objectsEqual(var1, var2)) return true; - + if(var1 == null || var2 == null) return false; - + if(var1.getValueType() != var2.getValueType()) return false; - + if(!var1.getName().equals(var2.getName())) return false; - + try { if(CdtVariableResolver.isStringListVariable(var1.getValueType())){ String[] v1 = var1.getStringListValue(); @@ -228,10 +237,11 @@ public class CdtVariableManager implements ICdtVariableManager { } catch (CdtVariableException e){ return false; } - + return true; } + @Override public IStringVariable toEclipseVariable(ICdtVariable variable, ICConfigurationDescription cfg) { if(variable instanceof EclipseVariablesVariableSupplier.EclipseVarMacro){ @@ -240,14 +250,15 @@ public class CdtVariableManager implements ICdtVariableManager { return null; } + @Override public boolean isUserVariable(ICdtVariable variable, ICConfigurationDescription cfg) { if(!(variable instanceof StorableCdtVariable)) return false; - + if(cfg != null) return UserDefinedVariableSupplier.getInstance().containsVariable(ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfg, variable); - + return UserDefinedVariableSupplier.getInstance().containsVariable(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null, variable); } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java index 78c5e7b32d8..193721e588a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CoreMacroSupplierBase.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo; public abstract class CoreMacroSupplierBase implements ICdtVariableSupplier { + @Override public ICdtVariable getVariable(String macroName, IVariableContextInfo context) { if(context instanceof ICoreVariableContextInfo){ ICoreVariableContextInfo info = (ICoreVariableContextInfo)context; @@ -23,9 +24,10 @@ public abstract class CoreMacroSupplierBase implements ICdtVariableSupplier { } return null; } - + protected abstract ICdtVariable getMacro(String name, int type, Object data); + @Override public ICdtVariable[] getVariables(IVariableContextInfo context) { if(context instanceof ICoreVariableContextInfo){ ICoreVariableContextInfo info = (ICoreVariableContextInfo)context; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java index 61f02f18f56..504734d6309 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java @@ -18,7 +18,7 @@ import org.eclipse.core.resources.ResourcesPlugin; /** * This is the default implementation of the IMacroContextInfo - * + * * @since 3.0 */ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { @@ -26,12 +26,12 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { private ICdtVariableSupplier fSuppliers[]; private int fType; private Object fData; - + public DefaultVariableContextInfo(int type, Object data){ fType = type; fData = data; } - + protected DefaultVariableContextInfo(int type, Object data, ICdtVariableSupplier suppliers[]){ fType = type; fData = data; @@ -63,7 +63,7 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { case CONTEXT_INSTALLATIONS: if(data == null){ return new ICdtVariableSupplier[]{ - CdtVariableManager.fCdtMacroSupplier + CdtVariableManager.fCdtMacroSupplier }; } break; @@ -81,6 +81,7 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getContextType() */ + @Override public int getContextType() { return fType; } @@ -88,6 +89,7 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getContextData() */ + @Override public Object getContextData() { return fData; } @@ -95,6 +97,7 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getSuppliers() */ + @Override public ICdtVariableSupplier[] getSuppliers() { if(fSuppliers == null) fSuppliers = getSuppliers(fType, fData); @@ -104,6 +107,7 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo#getNext() */ + @Override public IVariableContextInfo getNext() { switch(fType){ case CONTEXT_CONFIGURATION: diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EclipseVariablesVariableSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EclipseVariablesVariableSupplier.java index a6f03c0824a..2ec40dc0bb8 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EclipseVariablesVariableSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/EclipseVariablesVariableSupplier.java @@ -32,7 +32,7 @@ import org.eclipse.osgi.util.NLS; /** * This supplier suplies the macros that represent the Eclipse variables - * + * * @since 3.0 */ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { @@ -40,13 +40,13 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { private static final Pattern RESOURCE_VARIABLE_PATTERN= Pattern.compile("(project|resource|container)_(loc|path|name)"); //$NON-NLS-1$ // private static final String VAR_PREFIX = "${"; //$NON-NLS-1$ -// private static final char VAR_SUFFIX = '}'; - private static final char COLON = ':'; - +// private static final char VAR_SUFFIX = '}'; + private static final char COLON = ':'; + private static EclipseVariablesVariableSupplier fInstance; - + private EclipseVariablesVariableSupplier(){ - + } public static EclipseVariablesVariableSupplier getInstance(){ @@ -54,12 +54,12 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { fInstance = new EclipseVariablesVariableSupplier(); return fInstance; } - + public class EclipseVarMacro extends CdtVariable { private IStringVariable fVariable; private String fArgument; private boolean fInitialized; - + private EclipseVarMacro(IStringVariable var){ this(var,null); } @@ -94,7 +94,7 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { } return fStringValue; } - + private void loadValue(IStringVariable var) throws CdtVariableException { if(var instanceof IDynamicVariable){ IDynamicVariable dynamicVar = (IDynamicVariable)var; @@ -106,16 +106,16 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { } }else fStringValue = null; - + }else if(var instanceof IValueVariable){ if(fArgument == null) fStringValue = ((IValueVariable)var).getValue(); else fStringValue = null; } - + } - + public IStringVariable getVariable(){ return fVariable; } @@ -124,6 +124,7 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object) */ + @Override public ICdtVariable getVariable(String macroName, IVariableContextInfo info) { return getVariable(macroName); } @@ -134,7 +135,7 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { // return null; if(macroName == null || "".equals(macroName)) //$NON-NLS-1$ return null; - + String varName = null; String param = null; IStringVariable var = null; @@ -145,14 +146,14 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { varName = macroName.substring(0,index); param = macroName.substring(index+1); } - + if(varName != null){ IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager(); var = mngr.getValueVariable(varName); if(var == null) var = mngr.getDynamicVariable(varName); } - + if(var != null) return new EclipseVarMacro(var,param); return null; @@ -161,6 +162,7 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacros(int, java.lang.Object) */ + @Override public ICdtVariable[] getVariables(IVariableContextInfo info) { return getVariables(); } @@ -178,7 +180,7 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { map.put(name,var); } } - + IValueVariable valVars[] = mngr.getValueVariables(); for (IValueVariable valVar : valVars) map.put(valVar.getName(),valVar); @@ -188,7 +190,7 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { Iterator iter = collection.iterator(); for(int i = 0; i < macros.length ; i++) macros[i] = new EclipseVarMacro(iter.next()); - + return macros; } @@ -202,7 +204,7 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier { || name.endsWith("_prompt") //$NON-NLS-1$ || name.equals("selected_text"); //$NON-NLS-1$ } - + private static boolean canExpandVariable(String name, String argument) { if (argument == null && RESOURCE_VARIABLE_PATTERN.matcher(name).matches()) { return false; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java index 72e7504d386..956f9f214b5 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java @@ -25,7 +25,7 @@ import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; /** * This class represents the set of Build Macros that could be loaded * and stored in XML - * + * * @since 3.0 * */ @@ -35,13 +35,13 @@ public class StorableCdtVariables implements IStorableCdtVariables { private boolean fIsDirty = false; private boolean fIsChanged = false; private boolean fIsReadOnly; - + private HashMap getMap(){ if(fMacros == null) fMacros = new HashMap(); return fMacros; } - + public StorableCdtVariables(boolean readOnly) { fIsReadOnly = readOnly; } @@ -64,14 +64,14 @@ public class StorableCdtVariables implements IStorableCdtVariables { load(element); fIsReadOnly = readOnly; } - + private void load(ICStorageElement element){ // fExpandInMakefile = TRUE.equals(element.getAttribute(EXPAND_ENVIRONMENT_MACROS)); - + ICStorageElement nodeList[] = element.getChildren(); for (int i = 0; i < nodeList.length; ++i) { ICStorageElement node = nodeList[i]; - String name = node.getName(); + String name = node.getName(); if (StorableCdtVariable.STRING_MACRO_ELEMENT_NAME.equals(name)) { addMacro(new StorableCdtVariable(node)); } @@ -82,7 +82,7 @@ public class StorableCdtVariables implements IStorableCdtVariables { fIsDirty = false; fIsChanged = false; } - + public void serialize(ICStorageElement element){ if(fMacros != null){ for (ICdtVariable v : fMacros.values()){ @@ -102,10 +102,11 @@ public class StorableCdtVariables implements IStorableCdtVariables { String name = macro.getName(); if(name == null) return; - + getMap().put(name,macro); } + @Override public ICdtVariable createMacro(String name, int type, String value){ if(name == null || "".equals(name = name.trim()) || CdtVariableResolver.isStringListVariable(type)) //$NON-NLS-1$ return null; @@ -119,7 +120,7 @@ public class StorableCdtVariables implements IStorableCdtVariables { } return macro; } - + public ICdtVariable checkMacro(String name, int type, String value){ if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -140,7 +141,7 @@ public class StorableCdtVariables implements IStorableCdtVariables { } return null; } - + public ICdtVariable checkMacro(String name, int type, String value[]){ if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -169,11 +170,11 @@ public class StorableCdtVariables implements IStorableCdtVariables { } return null; } - + /* * sets the storable macros to hold the geven number of macros * all macros that are present in the store but not included in the given array - * will be removed + * will be removed */ public void setMacros(ICdtVariable macros[]){ if(fIsReadOnly) @@ -195,7 +196,8 @@ public class StorableCdtVariables implements IStorableCdtVariables { createMacros(macros); } } - + + @Override public void createMacros(ICdtVariable macros[]){ if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -203,11 +205,13 @@ public class StorableCdtVariables implements IStorableCdtVariables { createMacro(macro); } } - + + @Override public boolean isEmpty(){ return fMacros == null || fMacros.isEmpty(); } + @Override public ICdtVariable createMacro(ICdtVariable copy){ if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -216,7 +220,7 @@ public class StorableCdtVariables implements IStorableCdtVariables { return null; int type = copy.getValueType(); - + ICdtVariable macro = null; try{ if(CdtVariableResolver.isStringListVariable(type)){ @@ -245,6 +249,7 @@ public class StorableCdtVariables implements IStorableCdtVariables { return macro; } + @Override public ICdtVariable createMacro(String name, int type, String value[]){ if(name == null || "".equals(name = name.trim()) || !CdtVariableResolver.isStringListVariable(type)) //$NON-NLS-1$ return null; @@ -261,17 +266,17 @@ public class StorableCdtVariables implements IStorableCdtVariables { /** * Returns the "dirty" state for this set of macros. - * If the dirty state is true, that means that the macros + * If the dirty state is true, that means that the macros * is out of synch with the repository and the macros need to be serialized. *

* The dirty state is automatically set to false when the macros are serialized - * by calling the serialize() method - * @return boolean + * by calling the serialize() method + * @return boolean */ public boolean isDirty(){ return fIsDirty; } - + /** * sets the "dirty" state for this set of macros. * @see org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables#isDirty() @@ -280,23 +285,24 @@ public class StorableCdtVariables implements IStorableCdtVariables { public void setDirty(boolean dirty){ fIsDirty = dirty; } - + /** * Returns the "change" state for this set of macros. * The "change" state represents whether the macros were changed or not. * This state is not reset when the serialize() method is called * Users can use this state to monitor whether the macros were changed or not. - * The "change" state can be reset only by calling the setChanged(false) method + * The "change" state can be reset only by calling the setChanged(false) method * @return boolean */ + @Override public boolean isChanged(){ return fIsChanged; } - + /* public boolean isExpanded(){ return fExpandInMakefile; } -*/ +*/ /* public void setExpanded(boolean expand){ if(fExpandInMakefile != expand){ fExpandInMakefile = expand; @@ -305,7 +311,7 @@ public class StorableCdtVariables implements IStorableCdtVariables { fIsChanged = true; } } -*/ +*/ /** * sets the "change" state for this set of macros. * @see org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables#isChanged() @@ -315,17 +321,18 @@ public class StorableCdtVariables implements IStorableCdtVariables { fIsChanged = changed; } + @Override public ICdtVariable getMacro(String name){ if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$ return null; - + ICdtVariable var = getMap().get(name); if(var == null){ int indx = name.indexOf(':'); if(indx != -1){ String baseName = name.substring(0, indx); ICdtVariable tmp = getMap().get(baseName); - if(tmp != null + if(tmp != null && CdtVariableManager.getDefault().toEclipseVariable(tmp, null) != null){ var = EclipseVariablesVariableSupplier.getInstance().getVariable(name); } @@ -333,12 +340,14 @@ public class StorableCdtVariables implements IStorableCdtVariables { } return var; } - + + @Override public ICdtVariable[] getMacros(){ - Collection macros = getMap().values(); + Collection macros = getMap().values(); return macros.toArray(new ICdtVariable[macros.size()]); } - + + @Override public ICdtVariable deleteMacro(String name){ if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -354,7 +363,8 @@ public class StorableCdtVariables implements IStorableCdtVariables { return macro; } - + + @Override public boolean deleteAll(){ if(fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); @@ -367,15 +377,16 @@ public class StorableCdtVariables implements IStorableCdtVariables { } return false; } - + + @Override public boolean contains(ICdtVariable var){ ICdtVariable curVar = getMacro(var.getName()); if(curVar == null) return false; - + if(new VarKey(curVar, false).equals(new VarKey(var, false))) return true; - + return false; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserVarSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserVarSupplier.java index d6294657eb8..43d345bdbb9 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserVarSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserVarSupplier.java @@ -18,13 +18,13 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.variables.IDynamicVariable; /** - * Wrapper for UserDefinedMacroSupplier methods + * Wrapper for UserDefinedMacroSupplier methods * Note that only config-level macros are supported. */ public class UserVarSupplier implements IUserVarSupplier { private static final int CTX = ICoreVariableContextInfo.CONTEXT_CONFIGURATION; private static UserVarSupplier sup = null; - + /** * @return an instance of this class. */ @@ -33,10 +33,11 @@ public class UserVarSupplier implements IUserVarSupplier { sup = new UserVarSupplier(); return sup; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.cdtvariables.IUserVarSupplier#createMacro(org.eclipse.cdt.core.cdtvariables.ICdtVariable, int, java.lang.Object) */ + @Override public ICdtVariable createMacro(ICdtVariable copy, ICConfigurationDescription contextData) { return CdtVariableManager.fUserDefinedMacroSupplier.createMacro(copy, CTX, contextData); } @@ -44,6 +45,7 @@ public class UserVarSupplier implements IUserVarSupplier { /* (non-Javadoc) * @see org.eclipse.cdt.core.cdtvariables.IUserVarSupplier#createMacro(java.lang.String, int, java.lang.String, java.lang.Object) */ + @Override public ICdtVariable createMacro(String macroName, int type, String value, ICConfigurationDescription contextData) { return CdtVariableManager.fUserDefinedMacroSupplier.createMacro(macroName, type, value, CTX, contextData); @@ -52,6 +54,7 @@ public class UserVarSupplier implements IUserVarSupplier { /* (non-Javadoc) * @see org.eclipse.cdt.core.cdtvariables.IUserVarSupplier#createMacro(java.lang.String, int, java.lang.String[], java.lang.Object) */ + @Override public ICdtVariable createMacro(String macroName, int type, String[] value, ICConfigurationDescription contextData) { return CdtVariableManager.fUserDefinedMacroSupplier.createMacro(macroName, type, value, CTX, contextData); @@ -60,6 +63,7 @@ public class UserVarSupplier implements IUserVarSupplier { /* (non-Javadoc) * @see org.eclipse.cdt.core.cdtvariables.IUserVarSupplier#deleteAll(java.lang.Object) */ + @Override public void deleteAll(ICConfigurationDescription contextData) { CdtVariableManager.fUserDefinedMacroSupplier.deleteAll(CTX, contextData); } @@ -67,6 +71,7 @@ public class UserVarSupplier implements IUserVarSupplier { /* (non-Javadoc) * @see org.eclipse.cdt.core.cdtvariables.IUserVarSupplier#deleteMacro(java.lang.String, java.lang.Object) */ + @Override public ICdtVariable deleteMacro(String name, ICConfigurationDescription contextData) { return CdtVariableManager.fUserDefinedMacroSupplier.deleteMacro(name, CTX, contextData); } @@ -74,33 +79,39 @@ public class UserVarSupplier implements IUserVarSupplier { /* (non-Javadoc) * @see org.eclipse.cdt.core.cdtvariables.IUserVarSupplier#getMacros(java.lang.Object) */ + @Override public ICdtVariable[] getMacros(ICConfigurationDescription contextData) { return CdtVariableManager.fUserDefinedMacroSupplier.getMacros(CTX, contextData); } + @Override public void setMacros(ICdtVariable[] m, ICConfigurationDescription contextData) { CdtVariableManager.fUserDefinedMacroSupplier.setMacros(m, CTX, contextData); } /* check whether variable is dynamic */ + @Override public boolean isDynamic(ICdtVariable v) { if (v instanceof EclipseVariablesVariableSupplier.EclipseVarMacro) { EclipseVariablesVariableSupplier.EclipseVarMacro evar = (EclipseVariablesVariableSupplier.EclipseVarMacro)v; if (evar.getVariable() instanceof IDynamicVariable) return true; - } + } return false; } - + + @Override public void storeWorkspaceVariables(boolean force) { CdtVariableManager.fUserDefinedMacroSupplier.storeWorkspaceVariables(force); } + @Override public IStorableCdtVariables getWorkspaceVariablesCopy() { return CdtVariableManager.fUserDefinedMacroSupplier.getWorkspaceVariablesCopy(); } + @Override public boolean setWorkspaceVariables(IStorableCdtVariables vars) throws CoreException { if (vars instanceof StorableCdtVariables) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/AbstractCodeReaderFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/AbstractCodeReaderFactory.java index 7b2c900a45f..30ccb166f42 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/AbstractCodeReaderFactory.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/AbstractCodeReaderFactory.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom; import java.io.IOException; @@ -29,7 +29,8 @@ public abstract class AbstractCodeReaderFactory implements ICodeReaderFactory, I public AbstractCodeReaderFactory(IIncludeFileResolutionHeuristics heuristics) { fHeuristics= heuristics; } - + + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Class adapter) { if (adapter.isAssignableFrom(IIncludeFileResolutionHeuristics.class)) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java index ff8a9cf10e5..6aeeefe6519 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM - Initial API and implementation *******************************************************************************/ @@ -73,37 +73,40 @@ public class InternalASTServiceProvider implements IASTServiceProvider { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit() */ - public IASTTranslationUnit getTranslationUnit(IFile fileToParse) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IFile fileToParse) throws UnsupportedDialectException { return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, SavedCodeReaderFactory.getInstance(), null); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit(org.eclipse.cdt.core.dom.ICodeReaderFactory) */ - public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, null); } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit(org.eclipse.cdt.core.dom.ICodeReaderFactory, org.eclipse.cdt.core.dom.IParserConfiguration) */ - public IASTTranslationUnit getTranslationUnit( + @Override + public IASTTranslationUnit getTranslationUnit( IFile fileToParse, ICodeReaderFactory fileCreator, IParserConfiguration configuration) throws UnsupportedDialectException { return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, configuration); } - - public IASTTranslationUnit getTranslationUnit( - String filename, IResource infoProvider, ICodeReaderFactory fileCreator, IParserConfiguration configuration) throws UnsupportedDialectException + + public IASTTranslationUnit getTranslationUnit( + String filename, IResource infoProvider, ICodeReaderFactory fileCreator, IParserConfiguration configuration) throws UnsupportedDialectException { IProject project = infoProvider.getProject(); IScannerInfo scanInfo = null; - + if( configuration == null ) { IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); if (provider != null){ IScannerInfo buildScanInfo = provider.getScannerInformation(infoProvider); - + if (buildScanInfo != null) scanInfo = buildScanInfo; else @@ -112,7 +115,7 @@ public class InternalASTServiceProvider implements IASTServiceProvider { } else scanInfo = configuration.getScannerInfo(); - + CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(filename); if( reader == null ) return null; @@ -128,30 +131,30 @@ public class InternalASTServiceProvider implements IASTServiceProvider { scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION; else scannerExtensionConfiguration = C_GNU_SCANNER_EXTENSION; - scanner= createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, l, ParserFactory.createDefaultLogService(), + scanner= createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, l, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, fileCreator); //assume GCC if( l == ParserLanguage.C ) parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), new GCCParserExtensionConfiguration() ); else - parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), new GPPParserExtensionConfiguration() ); + parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), new GPPParserExtensionConfiguration() ); } else { String dialect = configuration.getParserDialect(); - if( dialect.equals( dialects[0]) || dialect.equals( dialects[2])) - scanner= createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.C, + if( dialect.equals( dialects[0]) || dialect.equals( dialects[2])) + scanner= createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.C, ParserUtil.getScannerLogService(), C_GNU_SCANNER_EXTENSION, fileCreator); else if( dialect.equals( dialects[1] ) || dialect.equals( dialects[3] )) - scanner = createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, + scanner = createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, ParserUtil.getScannerLogService(), CPP_GNU_SCANNER_EXTENSION, fileCreator); else throw new UnsupportedDialectException(); - + if( dialect.equals( dialects[0])) { ICParserExtensionConfiguration config = new ANSICParserExtensionConfiguration(); - parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config ); + parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config ); } else if( dialect.equals( dialects[1] )) { @@ -161,12 +164,12 @@ public class InternalASTServiceProvider implements IASTServiceProvider { else if( dialect.equals( dialects[2])) { ICParserExtensionConfiguration config = new GCCParserExtensionConfiguration(); - parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config ); + parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config ); } else if( dialect.equals( dialects[3])) { ICPPParserExtensionConfiguration config = new GPPParserExtensionConfiguration(); - parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config ); + parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), config ); } } // Parse @@ -178,16 +181,18 @@ public class InternalASTServiceProvider implements IASTServiceProvider { return null; } + @Override public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { return getCompletionNode(fileToParse.getFullPath().toOSString(), project, offset, fileCreator); } - - public IASTCompletionNode getCompletionNode(IFile fileToParse, int offset, + + @Override + public IASTCompletionNode getCompletionNode(IFile fileToParse, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { return getCompletionNode(fileToParse.getLocation().toOSString(), fileToParse, offset, fileCreator); } - + public IASTCompletionNode getCompletionNode(String filename, IResource infoProvider, int offset, ICodeReaderFactory fileCreator) throws UnsupportedDialectException { // Get the scanner info @@ -213,10 +218,10 @@ public class InternalASTServiceProvider implements IASTServiceProvider { else scannerExtensionConfiguration = C_GNU_SCANNER_EXTENSION; - IScanner scanner= createScanner(reader, scanInfo, ParserMode.COMPLETION_PARSE, l, + IScanner scanner= createScanner(reader, scanInfo, ParserMode.COMPLETION_PARSE, l, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, fileCreator); scanner.setContentAssistMode(offset); - + // assume GCC ISourceCodeParser parser = null; if (l == ParserLanguage.C) @@ -227,7 +232,7 @@ public class InternalASTServiceProvider implements IASTServiceProvider { parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETION_PARSE, ParserUtil.getParserLogService(), new GPPParserExtensionConfiguration()); - + // Run the parse and return the completion node parser.parse(); IASTCompletionNode node = parser.getCompletionNode(); @@ -239,10 +244,10 @@ public class InternalASTServiceProvider implements IASTServiceProvider { IScannerExtensionConfiguration scanConfig, ICodeReaderFactory fileCreator) { return new CPreprocessor(FileContent.adapt(reader), scanInfo, lang, log, scanConfig, IncludeFileContentProvider.adapt(fileCreator)); } - + /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.core.dom.IASTServiceProvider#getSupportedDialects() */ public String[] getSupportedDialects() { @@ -265,7 +270,7 @@ public class InternalASTServiceProvider implements IASTServiceProvider { } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) { return ParserLanguage.CPP; } else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) { - return ParserLanguage.C; + return ParserLanguage.C; } else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) { isSource[0]= true; return ParserLanguage.C; @@ -277,18 +282,22 @@ public class InternalASTServiceProvider implements IASTServiceProvider { return ParserLanguage.CPP; } - public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project, ICodeReaderFactory fileCreator) throws UnsupportedDialectException{ + @Override + public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project, ICodeReaderFactory fileCreator) throws UnsupportedDialectException{ return getTranslationUnit( fileToParse.getFullPath().toOSString(), project, fileCreator, null); } - public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project) throws UnsupportedDialectException { + @Override + public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project) throws UnsupportedDialectException { return getTranslationUnit( fileToParse.getFullPath().toOSString(), project, SavedCodeReaderFactory.getInstance(), null); } + @Override public IASTTranslationUnit getTranslationUnit(IFile fileToParse, boolean parseComments) throws UnsupportedDialectException { return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, SavedCodeReaderFactory.getInstance(), null); } + @Override public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator, boolean parseComments) throws UnsupportedDialectException { return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, null); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/NullCodeReaderFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/NullCodeReaderFactory.java index 4a488aa8dcb..7843d923d30 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/NullCodeReaderFactory.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/NullCodeReaderFactory.java @@ -36,11 +36,12 @@ public class NullCodeReaderFactory extends AbstractCodeReaderFactory { /* * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String) */ + @Override public CodeReader createCodeReaderForInclusion(String path) { return new CodeReader(path, EMPTY_CHARS); } - + @Override public CodeReader createCodeReaderForInclusion(IIndexFileLocation ifl, String astPath) { return new CodeReader(astPath, EMPTY_CHARS); @@ -49,6 +50,7 @@ public class NullCodeReaderFactory extends AbstractCodeReaderFactory { /* * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForTranslationUnit(java.lang.String) */ + @Override public CodeReader createCodeReaderForTranslationUnit(String path) { return new CodeReader(path, EMPTY_CHARS); } @@ -56,6 +58,7 @@ public class NullCodeReaderFactory extends AbstractCodeReaderFactory { /* * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getCodeReaderCache() */ + @Override public ICodeReaderCache getCodeReaderCache() { return null; } @@ -63,6 +66,7 @@ public class NullCodeReaderFactory extends AbstractCodeReaderFactory { /* * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getUniqueIdentifier() */ + @Override public int getUniqueIdentifier() { // is this used somewhere? return 7; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/PartialWorkingCopyCodeReaderFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/PartialWorkingCopyCodeReaderFactory.java index ea34d4d7d5d..fa67cb37fc5 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/PartialWorkingCopyCodeReaderFactory.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/PartialWorkingCopyCodeReaderFactory.java @@ -46,21 +46,23 @@ public class PartialWorkingCopyCodeReaderFactory extends AbstractCodeReaderFacto /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getUniqueIdentifier() */ - public int getUniqueIdentifier() { + @Override + public int getUniqueIdentifier() { return CDOM.PARSE_WORKING_COPY_WITH_SAVED_INCLUSIONS; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForTranslationUnit(java.lang.String) */ - public CodeReader createCodeReaderForTranslationUnit(String path) { + @Override + public CodeReader createCodeReaderForTranslationUnit(String path) { return checkWorkingCopyThenCache(path); } public CodeReader createCodeReaderForTranslationUnit(ITranslationUnit tu) { return new CodeReader(tu.getPath().toOSString(), tu.getContents()); } - + protected CodeReader checkWorkingCopyThenCache(String path) { char [] buffer = ParserUtil.findWorkingCopyBuffer( path, createWorkingCopyIterator() ); if( buffer != null ) @@ -71,11 +73,12 @@ public class PartialWorkingCopyCodeReaderFactory extends AbstractCodeReaderFacto /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String) */ - public CodeReader createCodeReaderForInclusion(String path) { + @Override + public CodeReader createCodeReaderForInclusion(String path) { return cache.get( path ); } - + @Override public CodeReader createCodeReaderForInclusion(IIndexFileLocation ifl, String astPath) throws CoreException, IOException { @@ -90,6 +93,7 @@ public class PartialWorkingCopyCodeReaderFactory extends AbstractCodeReaderFacto /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getCodeReaderCache() */ + @Override public ICodeReaderCache getCodeReaderCache() { return cache; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/SavedCodeReaderFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/SavedCodeReaderFactory.java index 0f43aaabee2..6c0d6a2610f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/SavedCodeReaderFactory.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/SavedCodeReaderFactory.java @@ -30,19 +30,19 @@ public class SavedCodeReaderFactory extends AbstractCodeReaderFactory { private static ICodeReaderCache cache; private static SavedCodeReaderFactory instance = new SavedCodeReaderFactory(null); - + public static SavedCodeReaderFactory getInstance() { return instance; } - + public static SavedCodeReaderFactory createInstance(IIncludeFileResolutionHeuristics heuristics) { return new SavedCodeReaderFactory(heuristics); } - - + + private SavedCodeReaderFactory(IIncludeFileResolutionHeuristics heuristics) { super(heuristics); - + if (cache == null) { int size= CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB; final CCorePlugin corePlugin = CCorePlugin.getDefault(); @@ -73,14 +73,16 @@ public class SavedCodeReaderFactory extends AbstractCodeReaderFactory { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getUniqueIdentifier() */ - public int getUniqueIdentifier() { + @Override + public int getUniqueIdentifier() { return CDOM.PARSE_SAVED_RESOURCES; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForTranslationUnit(java.lang.String) */ - public CodeReader createCodeReaderForTranslationUnit(String path) { + @Override + public CodeReader createCodeReaderForTranslationUnit(String path) { return cache.get(path); } @@ -91,10 +93,11 @@ public class SavedCodeReaderFactory extends AbstractCodeReaderFactory { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String) */ - public CodeReader createCodeReaderForInclusion(String path) { + @Override + public CodeReader createCodeReaderForInclusion(String path) { return cache.get(path); } - + @Override public CodeReader createCodeReaderForInclusion(IIndexFileLocation ifl, String astPath) throws CoreException, IOException { @@ -104,6 +107,7 @@ public class SavedCodeReaderFactory extends AbstractCodeReaderFactory { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String) */ + @Override public ICodeReaderCache getCodeReaderCache() { return cache; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSystemEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSystemEnvironmentSupplier.java index 1f46fb431fd..d8ff3abcc2b 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSystemEnvironmentSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/BuildSystemEnvironmentSupplier.java @@ -25,7 +25,7 @@ import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor; /** * This is the Environment Variable Supplier used to supply variables * defined by the tool-integrator - * + * * @since 3.0 */ public class BuildSystemEnvironmentSupplier implements @@ -34,8 +34,8 @@ public class BuildSystemEnvironmentSupplier implements /** * EnvironmentVariableProvider passed to the tool-integrator provided * suppliers. - * Accepts only contexts lower than the one passed to a suppler - * + * Accepts only contexts lower than the one passed to a suppler + * * @since 3.0 */ private class ExtensionEnvVarProvider extends EnvironmentVariableManager{ @@ -46,13 +46,13 @@ public class BuildSystemEnvironmentSupplier implements private Object fStartData; private IVariableContextInfo fStartMacroContextInfo; private boolean fStartMacroInfoInitialized; - + public ExtensionEnvVarProvider(Object level){ fStartLevel = level; fStartType = getMacroContextTypeFromContext(level); fStartData = level; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable(java.lang.String, java.lang.Object, boolean) */ @@ -68,7 +68,7 @@ public class BuildSystemEnvironmentSupplier implements public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros) { return filterVariables(super.getVariables(cfg,resolveMacros)); } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getContextInfo(java.lang.Object) */ @@ -77,16 +77,16 @@ public class BuildSystemEnvironmentSupplier implements IEnvironmentContextInfo startInfo = getStartInfo(); if(level == fStartLevel) return startInfo; - + IEnvironmentContextInfo info = super.getContextInfo(level); if(info == null) return null; - + if(checkParentContextRelation(startInfo,info)) return info; return null; } - + protected IEnvironmentContextInfo getStartInfo(){ if(fStartInfo == null && !fStartInitialized){ IEnvironmentContextInfo info = super.getContextInfo(fStartLevel); @@ -103,12 +103,12 @@ public class BuildSystemEnvironmentSupplier implements } return fStartInfo; } - + @Override public IVariableSubstitutor getVariableSubstitutor(IVariableContextInfo info, String inexistentMacroValue, String listDelimiter){ return super.getVariableSubstitutor(getSubstitutorMacroContextInfo(info),inexistentMacroValue,listDelimiter); } - + protected IVariableContextInfo getSubstitutorMacroContextInfo(IVariableContextInfo info){ IVariableContextInfo startInfo = getStartMacroContextInfo(); if(info == null) @@ -120,12 +120,12 @@ public class BuildSystemEnvironmentSupplier implements coreInfo.getContextData() == fStartData) return startInfo; } - + if(SupplierBasedCdtVariableManager.checkParentContextRelation(startInfo,info)) return info; return null; } - + protected IVariableContextInfo getStartMacroContextInfo(){ if(fStartMacroContextInfo == null && !fStartMacroInfoInitialized){ final IVariableContextInfo info = getMacroContextInfoForContext(fStartLevel); @@ -136,7 +136,7 @@ public class BuildSystemEnvironmentSupplier implements ICdtVariableSupplier suppliers[] = info.getSuppliers(); return filterValidMacroSuppliers(suppliers); } - + @Override public IVariableContextInfo getNext() { return info.getNext(); @@ -149,16 +149,17 @@ public class BuildSystemEnvironmentSupplier implements return fStartMacroContextInfo; } } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable() */ + @Override public IEnvironmentVariable getVariable(String name, Object context) { if(context == null) return null; if((name = getValidName(name)) == null) return null; - + if(context instanceof ICConfigurationDescription){ ICConfigurationDescription cfg = (ICConfigurationDescription)context; if (cfg.getBuildSetting() == null) @@ -174,6 +175,7 @@ public class BuildSystemEnvironmentSupplier implements /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables() */ + @Override public IEnvironmentVariable[] getVariables(Object context) { if(context == null) return new IEnvironmentVariable[0]; @@ -187,7 +189,7 @@ public class BuildSystemEnvironmentSupplier implements return new IEnvironmentVariable[0]; variables = supplier.getVariables(new ExtensionEnvVarProvider(context)); } - + return filterVariables(variables); } @@ -200,34 +202,34 @@ public class BuildSystemEnvironmentSupplier implements if(suppliers[i] == this) break; } - - + + if(i >= suppliers.length) return null; - + int startNum = i + 1; - ICoreEnvironmentVariableSupplier validSuppliers[] = + ICoreEnvironmentVariableSupplier validSuppliers[] = new ICoreEnvironmentVariableSupplier[suppliers.length - startNum]; - + for(i = startNum, j = 0; i < suppliers.length; i++, j++) validSuppliers[j] = suppliers[i]; - + return validSuppliers; } - + protected String getValidName(String name){ name = EnvVarOperationProcessor.normalizeName(name); if(name == null) return null; return name; } - + protected IEnvironmentVariable[] filterVariables(IEnvironmentVariable variables[]){ return EnvVarOperationProcessor.filterVariables(variables,null); } - + protected ICdtVariableSupplier[] filterValidMacroSuppliers(ICdtVariableSupplier suppliers[]){ if(suppliers == null) return null; @@ -237,24 +239,25 @@ public class BuildSystemEnvironmentSupplier implements if(suppliers[i] instanceof EnvironmentVariableSupplier) break; } - - + + if(i >= suppliers.length) return suppliers; - + int startNum = i + 1; - ICdtVariableSupplier validSuppliers[] = + ICdtVariableSupplier validSuppliers[] = new ICdtVariableSupplier[suppliers.length - startNum]; - + for(i = startNum, j = 0; i < suppliers.length; i++, j++) validSuppliers[j] = suppliers[i]; - + return validSuppliers; } + @Override public boolean appendEnvironment(Object context) { - // TODO + // TODO return true; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java index 56a5f7315b7..d2d6371ff77 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ContributedEnvironment.java @@ -42,7 +42,7 @@ public class ContributedEnvironment implements IContributedEnvironment{ break; } } - + if(i != suppliers.length){ ICoreEnvironmentVariableSupplier tmp[] = new ICoreEnvironmentVariableSupplier[suppliers.length - 1]; if(i != 0) @@ -51,7 +51,7 @@ public class ContributedEnvironment implements IContributedEnvironment{ System.arraycopy(suppliers, i+1, tmp, i, tmp.length - i); suppliers = tmp; } - + fSuppliers = suppliers; } return fSuppliers; @@ -65,11 +65,12 @@ public class ContributedEnvironment implements IContributedEnvironment{ return null; } } - + public IEnvironmentContextInfo getContextInfo(Object context){ return new ContributedEnvContextInfo(fMngr.getDefaultContextInfo(context)); } - + + @Override public IEnvironmentVariable[] getVariables(ICConfigurationDescription des){ EnvVarCollector cr = EnvironmentVariableManager.getVariables(getContextInfo(des), true); if(cr != null){ @@ -87,22 +88,26 @@ public class ContributedEnvironment implements IContributedEnvironment{ } return new EnvVarDescriptor[0]; } - + + @Override public IEnvironmentVariable getVariable(String name, ICConfigurationDescription des){ EnvVarDescriptor varDes = EnvironmentVariableManager.getVariable(name, getContextInfo(des), true); if(varDes != null) return EnvironmentVariableManager.getVariable(name, new DefaultEnvironmentContextInfo(des), true); return null; } - + + @Override public boolean appendEnvironment(ICConfigurationDescription des){ return EnvironmentVariableManager.fUserSupplier.appendContributedEnvironment(des); } + @Override public void setAppendEnvironment(boolean append, ICConfigurationDescription des){ EnvironmentVariableManager.fUserSupplier.setAppendContributedEnvironment(append, des); } + @Override public IEnvironmentVariable addVariable(String name, String value, int op, @@ -114,36 +119,41 @@ public class ContributedEnvironment implements IContributedEnvironment{ -1, EnvironmentVariableManager.fUserSupplier); } - + + @Override public void addVariables(IEnvironmentVariable[] vars, ICConfigurationDescription des) { for (IEnvironmentVariable v : vars) addVariable(v, des); } - + + @Override public IEnvironmentVariable addVariable(IEnvironmentVariable var, ICConfigurationDescription des) { - return addVariable(var.getName(), - var.getValue(), - var.getOperation(), - var.getDelimiter(), + return addVariable(var.getName(), + var.getValue(), + var.getOperation(), + var.getDelimiter(), des); } - + + @Override public IEnvironmentVariable removeVariable(String name, ICConfigurationDescription des){ return EnvironmentVariableManager.fUserSupplier.deleteVariable(name, des); } - + + @Override public void restoreDefaults(ICConfigurationDescription des){ EnvironmentVariableManager.fUserSupplier.restoreDefaults(des); } - + + @Override public boolean isUserVariable(ICConfigurationDescription des, IEnvironmentVariable var){ if(var instanceof EnvVarDescriptor) return ((EnvVarDescriptor)var).getSupplier() == EnvironmentVariableManager.fUserSupplier; return false; } - + public String getOrigin(IEnvironmentVariable var) { if(var instanceof EnvVarDescriptor) { ICoreEnvironmentVariableSupplier sup = ((EnvVarDescriptor)var).getSupplier(); @@ -159,10 +169,10 @@ public class ContributedEnvironment implements IContributedEnvironment{ } return Messages.getString("ContributedEnvironment.3"); //$NON-NLS-1$ } - + public void serialize(ICProjectDescription des){ EnvironmentVariableManager.fUserSupplier.storeProjectEnvironment(des, false); } - + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java index 0fc462884ca..9f3cf8c98eb 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java @@ -15,29 +15,29 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; /** * The default implementation of the IContextInfo used by the Environment Variable Provider * Used to represent the Configuration, Project, Workspace and Eclipse environment contexts - * + * * @since 3.0 */ public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{ private Object fContextObject; private ICoreEnvironmentVariableSupplier fContextSuppliers[]; - + /** * This constructor is used to create the default context info given a context object - * + * * @param context */ public DefaultEnvironmentContextInfo(Object context){ fContextObject = context; } - + protected DefaultEnvironmentContextInfo(Object context, ICoreEnvironmentVariableSupplier suppliers[]){ fContextSuppliers = suppliers; fContextObject = context; } - + /* - * answers the list of suppliers that should be used for the given context + * answers the list of suppliers that should be used for the given context */ protected ICoreEnvironmentVariableSupplier[] getSuppliers(Object context){ ICoreEnvironmentVariableSupplier suppliers[]; @@ -47,10 +47,11 @@ public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{ suppliers = new ICoreEnvironmentVariableSupplier[]{EnvironmentVariableManager.fUserSupplier, EnvironmentVariableManager.fEclipseSupplier}; return suppliers; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext() */ + @Override public IEnvironmentContextInfo getNext(){ DefaultEnvironmentContextInfo next = null; if(fContextObject instanceof ICConfigurationDescription) { @@ -60,23 +61,25 @@ public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{ } return next; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getSuppliers() */ + @Override public ICoreEnvironmentVariableSupplier[] getSuppliers(){ if(fContextSuppliers == null) fContextSuppliers = getSuppliers(fContextObject); return fContextSuppliers; } - + protected void setSuppliers(ICoreEnvironmentVariableSupplier suppliers[]){ fContextSuppliers = suppliers; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getContext() */ + @Override public Object getContext(){ return fContextObject; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EclipseEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EclipseEnvironmentSupplier.java index 357aa83e05c..4b9b803d81e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EclipseEnvironmentSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EclipseEnvironmentSupplier.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.utils.spawner.EnvironmentReader; /** * This is the Environment Variable Supplier used to supply variables * defined in eclipse environment - * + * * @since 3.0 */ public class EclipseEnvironmentSupplier implements ICoreEnvironmentVariableSupplier { @@ -28,6 +28,7 @@ public class EclipseEnvironmentSupplier implements ICoreEnvironmentVariableSuppl /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable() */ + @Override public IEnvironmentVariable getVariable(String name, Object context) { if(context == null){ String value = EnvironmentReader.getEnvVar(name); @@ -41,6 +42,7 @@ public class EclipseEnvironmentSupplier implements ICoreEnvironmentVariableSuppl /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables() */ + @Override public IEnvironmentVariable[] getVariables(Object context) { if(context == null){ Properties values = EnvironmentReader.getEnvVars(); @@ -59,6 +61,7 @@ public class EclipseEnvironmentSupplier implements ICoreEnvironmentVariableSuppl return null; } + @Override public boolean appendEnvironment(Object context) { return true; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarDescriptor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarDescriptor.java index ec620f2b3b5..7e8bd7d82ce 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarDescriptor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarDescriptor.java @@ -17,14 +17,14 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable; * this class represents the environment variable-relaed information. * That is the context for which the variable is defined and the supplier * that supplies the variable - * + * */ public class EnvVarDescriptor implements IEnvironmentVariable{ private IEnvironmentVariable fVariable; private IEnvironmentContextInfo fContextInfo; private int fSupplierNum; private ICoreEnvironmentVariableSupplier fSupplier; - + public EnvVarDescriptor(IEnvironmentVariable variable, IEnvironmentContextInfo contextInfo, int supplierNum, ICoreEnvironmentVariableSupplier supplier){ fVariable = variable; fContextInfo = contextInfo; @@ -43,19 +43,23 @@ public class EnvVarDescriptor implements IEnvironmentVariable{ public IEnvironmentVariable getOriginalVariable() { return fVariable; } - + + @Override public String getName() { return fVariable.getName(); } + @Override public String getValue() { return fVariable.getValue(); } - + + @Override public int getOperation() { return fVariable.getOperation(); } + @Override public String getDelimiter() { return fVariable.getDelimiter(); } @@ -71,11 +75,11 @@ public class EnvVarDescriptor implements IEnvironmentVariable{ public void setVariable(IEnvironmentVariable variable) { fVariable = variable; } - + public ICoreEnvironmentVariableSupplier getSupplier(){ return fSupplier; } - + /* public String getResolvedValue(int contextType, Object contextData){ String value = null; if(getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE){ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java index fcaf7df3f30..3afa4960024 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java @@ -35,7 +35,7 @@ import org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor; /** * This class implements the IEnvironmentVariableProvider interface and provides all * build environment funvtionality to the MBS - * + * * @since 3.0 * */ @@ -44,15 +44,15 @@ public class EnvironmentVariableManager implements private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$ private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$ - + private static EnvironmentVariableManager fInstance = null; // private EnvVarVariableSubstitutor fVariableSubstitutor; - + public static final UserDefinedEnvironmentSupplier fUserSupplier = new UserDefinedEnvironmentSupplier(); public static final BuildSystemEnvironmentSupplier fExternalSupplier = new BuildSystemEnvironmentSupplier(); public static final EclipseEnvironmentSupplier fEclipseSupplier = new EclipseEnvironmentSupplier(); - + private ContributedEnvironment fContributedEnvironment; public class EnvVarVariableSubstitutor extends SupplierBasedCdtVariableSubstitutor { @@ -66,7 +66,7 @@ public class EnvironmentVariableManager implements super(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue); fDefaultDelimiter = listDelimiter; } - + public IEnvironmentVariable resolveVariable(EnvVarDescriptor var) throws CdtVariableException { String value; if(var == null || (value = var.getValue()) == null || value.length() == 0 || var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE) @@ -83,14 +83,14 @@ public class EnvironmentVariableManager implements removeResolvedMacro(var.getName()); return new EnvironmentVariable(var.getName(),value,var.getOperation(),var.getDelimiter()); } - + protected IVariableContextInfo getVarMacroContextInfo(EnvVarDescriptor var){ IEnvironmentContextInfo info = var.getContextInfo(); if(info != null) return getMacroContextInfoForContext(info.getContext()); return null; } - + protected int getVarMacroSupplierNum(EnvVarDescriptor var, IVariableContextInfo varMacroInfo){ int varSupplierNum = -1; ICdtVariableSupplier macroSuppliers[] = varMacroInfo.getSuppliers(); @@ -113,7 +113,7 @@ public class EnvironmentVariableManager implements fInstance = new EnvironmentVariableManager(); return fInstance; } - + /* * returns a variable of a given name or null * the context information is taken from the contextInfo passed @@ -124,12 +124,12 @@ public class EnvironmentVariableManager implements if(contextInfo == null) return null; - if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null) + if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null) return null; IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo); - + if(!includeParentLevels){ ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers(); boolean bVarFound = false; @@ -147,29 +147,29 @@ public class EnvironmentVariableManager implements IEnvironmentContextInfo varContextInfo = null; int varSupplierNum = -1; ICoreEnvironmentVariableSupplier varSupplier = null; - + for(int i = infos.length-1 ; i >=0 ; i-- ) { IEnvironmentContextInfo info = infos[i]; ICoreEnvironmentVariableSupplier suppliers[] = info.getSuppliers(); - + for(int j = suppliers.length-1 ; j >= 0 ; j-- ) { ICoreEnvironmentVariableSupplier supplier = suppliers[j]; IEnvironmentVariable var = supplier.getVariable(variableName,info.getContext()); - + if(var == null) continue; - + varContextInfo = info; varSupplierNum = j; varSupplier = supplier; - + if(variable == null) variable = var; else variable = EnvVarOperationProcessor.performOperation(variable,var); } } - + if(variable != null){ // if(variable.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE) // return null; @@ -177,31 +177,32 @@ public class EnvironmentVariableManager implements } return null; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable() */ + @Override public IEnvironmentVariable getVariable(String variableName, ICConfigurationDescription cfg, boolean resolveMacros) { if(variableName == null || "".equals(variableName)) //$NON-NLS-1$ return null; - + IEnvironmentContextInfo info = getContextInfo(cfg); EnvVarDescriptor var = getVariable(variableName,info,true); - + if(var != null && var.getOperation() != IEnvironmentVariable.ENVVAR_REMOVE){ return resolveMacros ? calculateResolvedVariable(var,info) : var; } return null; } - + IEnvironmentContextInfo getDefaultContextInfo(Object level){ DefaultEnvironmentContextInfo info = new DefaultEnvironmentContextInfo(level); if(info.getSuppliers() == null) return null; return info; } - + /* * returns the context info that should be used for the given level * or null if the the given level is not supported @@ -212,7 +213,7 @@ public class EnvironmentVariableManager implements getDefaultContextInfo(level) : fContributedEnvironment.getContextInfo(level); return getDefaultContextInfo(level); } - + /* * returns a list of defined variables. * the context information is taken from the contextInfo passed @@ -222,10 +223,10 @@ public class EnvironmentVariableManager implements boolean includeParentLevels) { if(contextInfo == null) return null; - + IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo); HashSet set = null; - + if(!includeParentLevels){ ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers(); set = new HashSet(); @@ -245,13 +246,13 @@ public class EnvironmentVariableManager implements if(set.size() == 0) return new EnvVarCollector(); } - + EnvVarCollector envVarSet = new EnvVarCollector(); - + for(int i = infos.length-1 ; i >=0 ; i-- ) { IEnvironmentContextInfo info = infos[i]; ICoreEnvironmentVariableSupplier suppliers[] = info.getSuppliers(); - + for(int j = suppliers.length-1 ; j >= 0 ; j-- ) { ICoreEnvironmentVariableSupplier supplier = suppliers[j]; if(!supplier.appendEnvironment(info.getContext())){ @@ -262,7 +263,7 @@ public class EnvironmentVariableManager implements if(set != null){ List varList = new ArrayList(); Iterator iter = set.iterator(); - + while(iter.hasNext()){ IEnvironmentVariable var = supplier.getVariable(iter.next(),info.getContext()); if(var != null) @@ -277,24 +278,25 @@ public class EnvironmentVariableManager implements } } - return envVarSet; + return envVarSet; } /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables() */ + @Override public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros) { - - + + IEnvironmentContextInfo info = getContextInfo(cfg); EnvVarCollector varSet = getVariables(info,true); - + EnvVarDescriptor vars[] = varSet != null ? varSet.toArray(false) : null; if(vars != null){ if(!resolveMacros) return vars; - + IEnvironmentVariable resolved[] = new IEnvironmentVariable[vars.length]; for(int i = 0; i < vars.length; i++) resolved[i] = calculateResolvedVariable(vars[i], info); @@ -302,7 +304,7 @@ public class EnvironmentVariableManager implements } return new EnvVarDescriptor[0]; } - + /* * returns an array of the IContextInfo that holds the context informations * starting from the one passed to this method and including all subsequent parents @@ -310,27 +312,28 @@ public class EnvironmentVariableManager implements public static IEnvironmentContextInfo[] getAllContextInfos(IEnvironmentContextInfo contextInfo){ if(contextInfo == null) return null; - + List list = new ArrayList(); - + list.add(contextInfo); - + while((contextInfo = contextInfo.getNext()) != null) list.add(contextInfo); - + return list.toArray(new IEnvironmentContextInfo[list.size()]); } - + private boolean isWin32(){ String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$ if (os.startsWith("windows ")) //$NON-NLS-1$ return true; return false; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getDefaultDelimiter() */ + @Override public String getDefaultDelimiter() { return isWin32() ? DELIMITER_WIN32 : DELIMITER_UNIX; } @@ -338,10 +341,11 @@ public class EnvironmentVariableManager implements /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#isVariableCaseSensitive() */ + @Override public boolean isVariableCaseSensitive() { return !isWin32(); } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getSuppliers() */ @@ -351,7 +355,7 @@ public class EnvironmentVariableManager implements return info.getSuppliers(); return null; } - + /* * returns true if the first passed contextInfo is the child of the second one */ @@ -366,12 +370,12 @@ public class EnvironmentVariableManager implements }while((enumInfo = enumInfo.getNext()) != null); return false; } - + public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IEnvironmentContextInfo info){ if(des == null || info == null) return null; - return calculateResolvedVariable(des,getVariableSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$ + return calculateResolvedVariable(des,getVariableSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$ } public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IVariableSubstitutor sub){ @@ -389,20 +393,20 @@ public class EnvironmentVariableManager implements } catch (CdtVariableException e){ } return var; - + } - + protected int getMacroContextTypeFromContext(Object context){ if(context instanceof ICConfigurationDescription) return ICoreVariableContextInfo.CONTEXT_CONFIGURATION; else return ICoreVariableContextInfo.CONTEXT_WORKSPACE; } - + public ICoreVariableContextInfo getMacroContextInfoForContext(Object context){ return new DefaultVariableContextInfo(getMacroContextTypeFromContext(context),context); } - + public IVariableSubstitutor getVariableSubstitutor(IVariableContextInfo info, String inexistentMacroValue, String listDelimiter){ return new EnvVarVariableSubstitutor(info,inexistentMacroValue,listDelimiter); // if(fVariableSubstitutor == null) @@ -419,9 +423,10 @@ public class EnvironmentVariableManager implements // return fVariableSubstitutor; } + @Override public IContributedEnvironment getContributedEnvironment() { return fContributedEnvironment; } - - + + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java index a2061c16e0a..98457612b79 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/UserDefinedEnvironmentSupplier.java @@ -38,7 +38,7 @@ import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; /** - * This is the Environment Variable Supplier used to supply and persist user + * This is the Environment Variable Supplier used to supply and persist user * defined variables. Variables are stored in the context of a CDT {@link ICConfigurationDescription}, * or, globally at the {@link IWorkspace} level. * @@ -52,8 +52,8 @@ import org.osgi.service.prefs.Preferences; * * @since 3.0 */ -public class UserDefinedEnvironmentSupplier extends - StorableEnvironmentLoader +public class UserDefinedEnvironmentSupplier extends + StorableEnvironmentLoader implements ICoreEnvironmentVariableSupplier{ public static final String NODENAME = "environment"; //$NON-NLS-1$ @@ -74,46 +74,46 @@ public class UserDefinedEnvironmentSupplier extends private IEnvironmentVariable fVar; private boolean fNameOnly; private int fCode; - + VarKey(IEnvironmentVariable var, boolean nameOnly){ fVar = var; fNameOnly = nameOnly; } - + public IEnvironmentVariable getVariable(){ - return fVar; + return fVar; } @Override public boolean equals(Object obj) { if(obj == this) return true; - + if(!(obj instanceof VarKey)) return false; - + VarKey other = (VarKey)obj; - + IEnvironmentVariable otherVar = other.fVar; - + if(fVar == otherVar) return true; - + if(!CDataUtil.objectsEqual(fVar.getName(), otherVar.getName())) return false; if(fNameOnly) return true; - + if(fVar.getOperation() != otherVar.getOperation()) return false; if(!CDataUtil.objectsEqual(fVar.getValue(), otherVar.getValue())) return false; - + if(!CDataUtil.objectsEqual(fVar.getDelimiter(),otherVar.getDelimiter())) return false; - + return true; } @@ -122,38 +122,38 @@ public class UserDefinedEnvironmentSupplier extends int code = fCode; if(code == 0){ code = 47; - + String tmp = fVar.getName(); if(tmp != null) code += tmp.hashCode(); - + if(fNameOnly) return code; - + code += fVar.getOperation(); - + tmp = fVar.getValue(); if(tmp != null) code += tmp.hashCode(); - + tmp = fVar.getDelimiter(); if(tmp != null) code += tmp.hashCode(); - + fCode = code; } return code; } - + } public StorableEnvironment getEnvironment(Object context){ return getEnvironment(context,true); } - + protected StorableEnvironment getEnvironment(Object context, boolean forceLoad){ // if(context == null) // return null; - + StorableEnvironment env = null; if(context instanceof IInternalCCfgInfo){ try { @@ -172,7 +172,7 @@ public class UserDefinedEnvironmentSupplier extends fWorkspaceVariables = loadEnvironment(context, false); env = fWorkspaceVariables; } - + return env; } @@ -185,10 +185,12 @@ public class UserDefinedEnvironmentSupplier extends final String name = cfg.getId(); if(name != null) serializeInfo = new ISerializeInfo(){ + @Override public Preferences getNode(){ return getConfigurationNode(cfg.getProjectDescription()); } + @Override public String getPrefName(){ return name; } @@ -199,10 +201,12 @@ public class UserDefinedEnvironmentSupplier extends final String name = PREFNAME_WORKSPACE; if (prefs != null) serializeInfo = new ISerializeInfo(){ + @Override public Preferences getNode(){ return prefs; } - + + @Override public String getPrefName(){ return name; } @@ -210,42 +214,42 @@ public class UserDefinedEnvironmentSupplier extends } return serializeInfo; } - + private Preferences getConfigurationNode(ICProjectDescription projDes){ Preferences prefNode = getProjectNode(projDes); if(prefNode == null) return null; - + return prefNode.node(NODENAME_CFG); } - + private Preferences getProjectNode(ICProjectDescription projDes){ if(projDes == null) return null; IProject project = projDes.getProject(); if(!project.exists()) return null; - + Preferences prefNode = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID); if(prefNode == null) return null; - + return prefNode.node(NODENAME); } - + private Preferences getWorkspaceNode(){ Preferences prefNode = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID); if(prefNode == null) return null; - + return prefNode.node(NODENAME); } - + public void checkInexistentConfigurations(ICProjectDescription projDes){ Preferences prefNode = getConfigurationNode(projDes); if(prefNode == null) return; - + try{ String ids[] = prefNode.keys(); boolean found = false; @@ -255,97 +259,97 @@ public class UserDefinedEnvironmentSupplier extends found = true; } } - + if(found) prefNode.flush(); } catch(BackingStoreException e){ } } - + public void storeWorkspaceEnvironment(boolean force){ if(fWorkspaceVariables != null){ try{ storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force, true); } catch(CoreException e){ - + } } } - + public StorableEnvironment getWorkspaceEnvironmentCopy(){ - StorableEnvironment envVar = getEnvironment(null); + StorableEnvironment envVar = getEnvironment(null); return new StorableEnvironment(envVar, false); } - + public boolean setWorkspaceEnvironment(StorableEnvironment env){ StorableEnvironment oldEnv = getEnvironment(null); - + fWorkspaceVariables = new StorableEnvironment(env, false); - + EnvironmentChangeEvent event = createEnvironmentChangeEvent(fWorkspaceVariables.getVariables(), oldEnv.getVariables()); - + storeWorkspaceEnvironment(true); - + // updateProjectInfo(null); - + return event != null; } - + static EnvironmentChangeEvent createEnvironmentChangeEvent(IEnvironmentVariable[] newVars, IEnvironmentVariable[] oldVars){ IEnvironmentVariable[] addedVars = null, removedVars = null, changedVars = null; - + if(oldVars == null || oldVars.length == 0){ if(newVars != null && newVars.length != 0) - addedVars = newVars.clone(); + addedVars = newVars.clone(); } else if(newVars == null || newVars.length == 0){ removedVars = oldVars.clone(); } else { HashSet newSet = new HashSet(newVars.length); HashSet oldSet = new HashSet(oldVars.length); - + for (IEnvironmentVariable newVar : newVars) { newSet.add(new VarKey(newVar, true)); } - + for (IEnvironmentVariable oldVar : oldVars) { oldSet.add(new VarKey(oldVar, true)); } - + @SuppressWarnings("unchecked") HashSet newSetCopy = (HashSet)newSet.clone(); - + newSet.removeAll(oldSet); oldSet.removeAll(newSetCopy); - + if(newSet.size() != 0){ addedVars = varsFromKeySet(newSet); } - + if(oldSet.size() != 0){ removedVars = varsFromKeySet(oldSet); } - + newSetCopy.removeAll(newSet); - + HashSet modifiedSet = new HashSet(newSetCopy.size()); for (VarKey key : newSetCopy) { modifiedSet.add(new VarKey(key.getVariable(), false)); } - + for (IEnvironmentVariable oldVar : oldVars) { modifiedSet.remove(new VarKey(oldVar, false)); } - + if(modifiedSet.size() != 0) - changedVars = varsFromKeySet(modifiedSet); + changedVars = varsFromKeySet(modifiedSet); } - + if(addedVars != null || removedVars != null || changedVars != null) return new EnvironmentChangeEvent(addedVars, removedVars, changedVars); return null; } - + static IEnvironmentVariable[] varsFromKeySet(Set set){ IEnvironmentVariable vars[] = new IEnvironmentVariable[set.size()]; int i = 0; @@ -353,24 +357,24 @@ public class UserDefinedEnvironmentSupplier extends VarKey key = iter.next(); vars[i] = key.getVariable(); } - + return vars; } - + public void storeProjectEnvironment(ICProjectDescription des, boolean force){ ICConfigurationDescription cfgs[] = des.getConfigurations(); for (ICConfigurationDescription cfg : cfgs) { storeEnvironment(cfg, force, false); } - + Preferences node = getProjectNode(des); try { node.flush(); } catch (BackingStoreException e) { } } - + private void storeEnvironment(Object context, boolean force, boolean flush){ StorableEnvironment env = getEnvironment(context, false); if(env != null){ @@ -384,6 +388,7 @@ public class UserDefinedEnvironmentSupplier extends /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable() */ + @Override public IEnvironmentVariable getVariable(String name, Object context) { if(getValidName(name) == null) return null; @@ -397,6 +402,7 @@ public class UserDefinedEnvironmentSupplier extends /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables() */ + @Override public IEnvironmentVariable[] getVariables(Object context) { StorableEnvironment env = getEnvironment(context); if(env == null) @@ -420,7 +426,7 @@ public class UserDefinedEnvironmentSupplier extends } /** - * Add an environment variable 'override'. This variable won't be persisted but will instead + * Add an environment variable 'override'. This variable won't be persisted but will instead * replace / remove / prepend / append any existing environment variable with the same name. * This change is not persisted and remains for the current eclipse session. * @@ -428,7 +434,7 @@ public class UserDefinedEnvironmentSupplier extends * @param value Environment variable value * @param op one of the IBuildEnvironmentVariable.ENVVAR_* operation types * @param delimiter delimiter to use or null for default - * @return Overriding IEnvironmentVariable or null if name is not valid + * @return Overriding IEnvironmentVariable or null if name is not valid */ public IEnvironmentVariable createOverrideVariable(String name, String value, int op, String delimiter) { if (getValidName(name) == null) @@ -460,7 +466,7 @@ public class UserDefinedEnvironmentSupplier extends } return var; } - + public void deleteAll(Object context){ StorableEnvironment env = getEnvironment(context); if(env == null) @@ -470,22 +476,22 @@ public class UserDefinedEnvironmentSupplier extends // updateProjectInfo(context); } } - + public void setVariables(IEnvironmentVariable vars[], Object context){ StorableEnvironment env = getEnvironment(context); if(env == null) return; - + env.setVariales(vars); if(env.isChanged()){ // updateProjectInfo(context); env.setChanged(false); } } - + // protected void updateProjectInfo(Object context){ // } - + // protected void cfgVarsModified(ICConfigurationDescription cfg){ // cfg.setRebuildState(true); // EnvironmentVariableProvider.getDefault().checkBuildPathVariables(cfg); @@ -502,18 +508,19 @@ public class UserDefinedEnvironmentSupplier extends // } return name; } - + protected IEnvironmentVariable[] filterVariables(IEnvironmentVariable variables[]){ return EnvVarOperationProcessor.filterVariables(variables,null); } + @Override public boolean appendEnvironment(Object context) { StorableEnvironment env = getEnvironment(context); if(env == null) return true; return env.appendEnvironment(); } - + public boolean appendContributedEnvironment(Object context){ StorableEnvironment env = getEnvironment(context); if(env == null) @@ -521,21 +528,21 @@ public class UserDefinedEnvironmentSupplier extends return env.appendContributedEnvironment(); } - + public void setAppendEnvironment(boolean append, Object context) { StorableEnvironment env = getEnvironment(context); if(env != null){ env.setAppendEnvironment(append); } } - + public void setAppendContributedEnvironment(boolean append, Object context){ StorableEnvironment env = getEnvironment(context); if(env != null){ env.setAppendContributedEnvironment(append); } } - + public void restoreDefaults(Object context){ StorableEnvironment env = getEnvironment(context); if(env != null){ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java index c08ca43d547..47a46759f93 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java @@ -31,11 +31,11 @@ public class ParserLogService extends AbstractParserLogService implements ICance private final boolean fIsTracing; private final boolean fIsTracingExceptions; private final ICanceler fCanceler; - + public ParserLogService(DebugLogConstants constant) { this(constant, null); } - + public ParserLogService(DebugLogConstants constant, ICanceler canceler) { topic = constant; if (CCorePlugin.getDefault() == null) { @@ -58,10 +58,10 @@ public class ParserLogService extends AbstractParserLogService implements ICance public boolean isTracing(String option) { return "true".equals(Platform.getDebugOption(option)); //$NON-NLS-1$ } - + @Override public void traceLog(String option, String message) { - if (isTracing(option)) + if (isTracing(option)) System.out.println(message); } @@ -74,7 +74,7 @@ public class ParserLogService extends AbstractParserLogService implements ICance public boolean isTracing() { return fIsTracing; } - + @Override public boolean isTracingExceptions() { return fIsTracingExceptions; @@ -83,6 +83,7 @@ public class ParserLogService extends AbstractParserLogService implements ICance /* * @see org.eclipse.cdt.internal.core.util.ICanceler#setCancelable(org.eclipse.cdt.internal.core.util.ICancelable) */ + @Override public void setCancelable(ICancelable cancelable) { if (fCanceler != null) { fCanceler.setCancelable(cancelable); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookup.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookup.java index 93bb3b66d86..4cabd11b6c2 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookup.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookup.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.resources; import java.net.URI; @@ -28,18 +28,18 @@ public class ResourceLookup { public static void startup() { lookupTree.startup(); } - + public static void shutdown() { lookupTree.shutdown(); } - + /** - * Searches for files with the given location suffix. - * - * At this point the method works for sources and headers (no other content types), only. - * This is done to use less memory and can be changed if necessary. + * Searches for files with the given location suffix. + * + * At this point the method works for sources and headers (no other content types), only. + * This is done to use less memory and can be changed if necessary. * For linked resource files, the name of the link target is relevant. - * + * * @param locationSuffix the suffix to match, always used as relative path. * @param projects the projects to search * @param ignoreCase whether or not to ignore case when comparing the suffix. @@ -47,10 +47,10 @@ public class ResourceLookup { public static IFile[] findFilesByName(IPath locationSuffix, IProject[] projects, boolean ignoreCase) { return lookupTree.findFilesByName(locationSuffix, projects, ignoreCase); } - + /** * Uses a lookup-tree that finds resources for locations using the canonical representation - * of the path. + * of the path. */ public static IFile[] findFilesForLocationURI(URI location) { return lookupTree.findFilesForLocationURI(location); @@ -58,7 +58,7 @@ public class ResourceLookup { /** * Uses a lookup-tree that finds resources for locations using the canonical representation - * of the path. The method does not work for files where the name (last segment) of the + * of the path. The method does not work for files where the name (last segment) of the * resources differs from the name of the location. */ public static IFile[] findFilesForLocation(IPath location) { @@ -68,7 +68,7 @@ public class ResourceLookup { /** * Uses {@link #findFilesForLocationURI(URI)} and selects the most relevant file * from the result. Files form the first project, from cdt-projects and those on source - * roots are preferred, see {@link FileRelevance}. + * roots are preferred, see {@link FileRelevance}. * @param location an URI for the location of the files to search for. * @param preferredProject a project to be preferred over others, or null. * @return a file for the location in one of the given projects, or null. @@ -81,7 +81,7 @@ public class ResourceLookup { /** * Uses {@link #findFilesForLocation(IPath)} and selects the most relevant file * from the result. Files form the preferred project, from cdt-projects and those on source - * roots are preferred, see {@link FileRelevance}. + * roots are preferred, see {@link FileRelevance}. * @param location a path for the location of the files to search for. * @param preferredProject a project to be preferred over others, or null. * @return a file for the location or null. @@ -105,7 +105,7 @@ public class ResourceLookup { IFile file = files[i]; int relevance= FileRelevance.getRelevance(file, preferredProject); if (best == null || relevance > bestRelevance || - (relevance == bestRelevance && + (relevance == bestRelevance && best.getFullPath().toString().compareTo(file.getFullPath().toString()) > 0)) { bestRelevance= relevance; best= file; @@ -124,33 +124,34 @@ public class ResourceLookup { */ public static void sortFilesByRelevance(IFile[] filesToSort, final IProject preferredProject) { Collections.sort(Arrays.asList(filesToSort), new Comparator() { + @Override public int compare(IFile f1, IFile f2) { int r1= FileRelevance.getRelevance(f1, preferredProject); int r2= FileRelevance.getRelevance(f2, preferredProject); - + if (r1 > r2) return -1; if (r1 < r2) return 1; - + return f1.getFullPath().toString().compareTo(f2.getFullPath().toString()); } }); } - /** + /** * For testing, only. */ public static void dump() { lookupTree.dump(); } - /** + /** * For testing, only. */ public static void unrefNodeMap() { lookupTree.unrefNodeMap(); } - /** + /** * For testing, only. */ public static void simulateNodeMapCollection() { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookupTree.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookupTree.java index 1bc29c1256a..cb83aeeec43 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookupTree.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/ResourceLookupTree.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.resources; import java.lang.ref.SoftReference; @@ -51,28 +51,28 @@ import org.eclipse.core.runtime.jobs.Job; /** * Allows for looking up resources by location or name. When using this class 100 bytes per resource - * are needed. Therefore the support is limited to header-files int non-cdt projects and all files + * are needed. Therefore the support is limited to header-files int non-cdt projects and all files * except non-cdt-files in CDT projects. * * The information for a project is initialized when first requested and then it is kept up to date * using a resource change listener. No memory is used, as long as the class is not used. * When information is not used for more than 10 minutes, the data-structures will be held via a weak * reference, only and are subject to garbage collection. - * + * * The node map stores a map from hash-code of file-names to nodes. * A node contains the name of a file plus a link to the parent resource. From that we can compute * the resource path and obtain further information via the resource. */ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisitor, IResourceProxyVisitor { private static final int UNREF_DELAY = 10 * 60000; // 10 min - + private static final boolean VISIT_CHILDREN = true; private static final boolean SKIP_CHILDREN = false; private static final IFile[] NO_FILES = new IFile[0]; - private static final int TRIGGER_RECALC= - IResourceDelta.TYPE | IResourceDelta.REPLACED | + private static final int TRIGGER_RECALC= + IResourceDelta.TYPE | IResourceDelta.REPLACED | IResourceDelta.LOCAL_CHANGED | IResourceDelta.OPEN; - + private static class Extensions { private final boolean fInvert; private final Set fExtensions; @@ -85,21 +85,21 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit final int idx= filename.lastIndexOf('.'); if (idx < 0) return true; - + return fExtensions.contains(filename.substring(idx+1).toUpperCase()) != fInvert; } } - + private static class Node { final Node fParent; final char[] fResourceName; final boolean fHasFileLocationName; final boolean fIsFileLinkTarget; - + boolean fDeleted; boolean fHasChildren; int fCanonicHash; - + Node(Node parent, char[] name, boolean hasFileLocationName, boolean isFileLinkTarget) { fParent= parent; fResourceName= name; @@ -109,7 +109,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit parent.fHasChildren= true; } } - + private final Object fLock= new Object(); private final Job fUnrefJob; private SoftReference> fNodeMapRef; @@ -121,7 +121,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit private Node fRootNode; private boolean fNeedCleanup; private Node fLastFolderNode; - + public ResourceLookupTree() { fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {}; fFileExtensions= new HashMap(); @@ -152,6 +152,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit /** * Handle resource change notifications. */ + @Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta= event.getDelta(); synchronized (fLock) { @@ -178,31 +179,32 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } } } - + /** * Handles resource change notifications by visiting the delta. */ + @Override public boolean visit(IResourceDelta delta) throws CoreException { assert Thread.holdsLock(fLock); - + final IResource res= delta.getResource(); if (res instanceof IWorkspaceRoot) return VISIT_CHILDREN; - + if (res instanceof IProject) { // project not yet handled final String name = res.getName(); final Extensions exts= fFileExtensions.get(name); if (exts == null) return SKIP_CHILDREN; - + switch (delta.getKind()) { case IResourceDelta.ADDED: // new projects should not yet be part of the tree case IResourceDelta.REMOVED: fFileExtensions.remove(name); remove(res); return SKIP_CHILDREN; - + case IResourceDelta.CHANGED: if ((delta.getFlags() & (TRIGGER_RECALC | IResourceDelta.DESCRIPTION)) != 0) { fFileExtensions.remove(name); @@ -214,13 +216,13 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit fCurrentExtensions= exts; return VISIT_CHILDREN; } - + // file or folder switch (delta.getKind()) { case IResourceDelta.ADDED: add(res); return SKIP_CHILDREN; - + case IResourceDelta.CHANGED: if ((delta.getFlags() & TRIGGER_RECALC) != 0) { remove(res); @@ -228,9 +230,9 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit return SKIP_CHILDREN; } return VISIT_CHILDREN; - + case IResourceDelta.REMOVED: - + remove(res); return SKIP_CHILDREN; } @@ -243,7 +245,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ private void add(IResource res) { assert Thread.holdsLock(fLock); - + if (res instanceof IFile) { final String resName = res.getName(); String linkedName= null; @@ -257,7 +259,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } else { createFileNode(res.getFullPath(), linkedName); } - } + } } } else if (fCurrentExtensions.isRelevant(resName)) { createFileNode(res.getFullPath(), null); @@ -270,16 +272,17 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } } } - + /** * Add a resource tree by using a resource proxy visitor. */ + @Override public boolean visit(IResourceProxy proxy) throws CoreException { if (proxy.getType() == IResource.FILE) { if (fCurrentExtensions.isRelevant(proxy.getName())) { if (proxy.isLinked()) { IResource res= proxy.requestResource(); - if (res instanceof IFile) { + if (res instanceof IFile) { add(res); } return true; @@ -290,7 +293,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit return true; } - + public void unrefNodeMap() { synchronized (fLock) { fNodeMap= null; @@ -309,7 +312,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ private void initializeProjects(IProject[] projects) { assert Thread.holdsLock(fLock); - + if (fNodeMap == null) { if (fNodeMapRef != null) { fNodeMap= fNodeMapRef.get(); @@ -322,7 +325,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } } fUnrefJob.cancel(); - fUnrefJob.schedule(UNREF_DELAY); + fUnrefJob.schedule(UNREF_DELAY); for (IProject project : projects) { if (project.isOpen() && !fFileExtensions.containsKey(project.getName())) { @@ -347,7 +350,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit * Initializes file-extensions and node map */ private void initFileExtensions() { - + if (fDefaultExtensions == null) { HashSet cdtContentTypes= new HashSet(); String[] registeredContentTypes= CoreModel.getRegistedContentTypeIds(); @@ -373,14 +376,14 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit outer: for (IContentType ctt : ctts) { IContentType basedOn= ctt; while (basedOn != null) { - if (cdtContentTypes.contains(basedOn.getId())) + if (cdtContentTypes.contains(basedOn.getId())) continue outer; basedOn= basedOn.getBaseType(); } // this is a non-cdt content type addFileSpecs(ctt, nonCDTExtensions); } - // Bug 323659: In case there is another content type for a cdt file-extension we need + // Bug 323659: In case there is another content type for a cdt file-extension we need // to remove it. nonCDTExtensions.removeAll(cdtExtensions); fCDTProjectExtensions= new Extensions(nonCDTExtensions, true); @@ -424,7 +427,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ private Node createNode(char[][] segments, int segmentCount, boolean hasFileLocationName, boolean isFileLinkTarget) { assert Thread.holdsLock(fLock); - + if (segmentCount == 0) return fRootNode; @@ -432,10 +435,10 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (isNodeForSegments(fLastFolderNode, segments, segmentCount, isFileLinkTarget)) return fLastFolderNode; } - + final char[] name= segments[segmentCount-1]; final int hash= hashCode(name); - + // search for existing node Object obj= fNodeMap.get(hash); @@ -456,7 +459,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit nodes= (Node[]) obj; for (len=0; len < nodes.length; len++) { Node node = nodes[len]; - if (node == null) + if (node == null) break; if (isNodeForSegments(node, segments, segmentCount, isFileLinkTarget)) { if (!hasFileLocationName) @@ -465,12 +468,12 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } } } - } + } final Node parent= createNode(segments, segmentCount-1, false, false); Node node= new Node(parent, name, hasFileLocationName, isFileLinkTarget); if (nodes == null) { fNodeMap.put(hash, node); - } else { + } else { if (len == nodes.length) { Node[] newNodes= new Node[len+2]; System.arraycopy(nodes, 0, newNodes, 0, len); @@ -479,7 +482,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } nodes[len]= node; } - + if (!hasFileLocationName) fLastFolderNode= node; return node; @@ -490,10 +493,10 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ private boolean isNodeForSegments(Node node, char[][] segments, int segmentLength, boolean isFileLinkTarget) { assert Thread.holdsLock(fLock); - + if (node.fIsFileLinkTarget != isFileLinkTarget) return false; - + while(segmentLength > 0 && node != null) { if (!CharArrayUtils.equals(segments[--segmentLength], node.fResourceName)) return false; @@ -501,25 +504,25 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } return node == fRootNode; } - + /** * Remove a resource from the tree */ private void remove(IResource res) { assert Thread.holdsLock(fLock); - + final char[] name= res.getName().toCharArray(); final int hash= hashCode(name); - + Object obj= fNodeMap.get(hash); if (obj == null) return; - + final IPath fullPath= res.getFullPath(); final int segmentCount= fullPath.segmentCount(); if (segmentCount == 0) return; - + final char[][]segments= toCharArrayArray(fullPath.segments(), null); if (obj instanceof Node) { final Node node= (Node) obj; @@ -538,7 +541,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (!node.fDeleted && isNodeForSegments(node, segments, segmentCount, false)) { remove(nodes, i); - if (nodes[0] == null) + if (nodes[0] == null) fNodeMap.remove(hash); node.fDeleted= true; @@ -553,7 +556,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit private void remove(Node[] nodes, int i) { int idx= lastValid(nodes, i); - if (idx > 0) { + if (idx > 0) { nodes[i]= nodes[idx]; nodes[idx]= null; } @@ -563,9 +566,9 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit int right= nodes.length-1; while (left < right) { int mid= (left+right+1)/2; // ==> mid > left - if (nodes[mid] == null) + if (nodes[mid] == null) right= mid-1; - else + else left= mid; } return right; @@ -574,7 +577,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit private void cleanup() { assert Thread.holdsLock(fLock); fLastFolderNode= null; - + for (Iterator iterator = fNodeMap.values().iterator(); iterator.hasNext();) { Object obj= iterator.next(); if (obj instanceof Node) { @@ -589,7 +592,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (node == null) { if (j==0) { iterator.remove(); - } + } break; } if (!isDeleted(node)) { @@ -605,7 +608,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } } } - + private boolean isDeleted(Node node) { while(node != null) { if (node.fDeleted) @@ -663,8 +666,8 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (result.length > 0) return result; } - } - + } + // fall back to platform functionality return adapter.platformsFindFilesForLocation(location); } @@ -687,7 +690,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit final int segCount= relativeLocation.segmentCount(); if (segCount < 1) return NO_FILES; - + final String name= relativeLocation.lastSegment(); Node[] candidates; @@ -699,7 +702,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit return NO_FILES; } candidates= convert(obj); - } + } String suffix= relativeLocation.toString(); while(suffix.startsWith("../")) { //$NON-NLS-1$ suffix= suffix.substring(3); @@ -710,7 +713,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } return extractMatchesForName(candidates, name, suffix, ignoreCase, prjset); } - + /** * Selects the actual matches for the list of candidate nodes. */ @@ -718,7 +721,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit final char[] n1= name.toCharArray(); final int namelen = n1.length; int resultIdx= 0; - + if (ignoreCase) { for (int j = 0; j < namelen; j++) { n1[j]= Character.toUpperCase(n1[j]); @@ -734,7 +737,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (namelen == n2.length) { for (int j = 0; j < n2.length; j++) { final char c= ignoreCase ? Character.toUpperCase(n2[j]) : n2[j]; - if (c != n1[j]) + if (c != n1[j]) continue outer; } final IFile file= root.getFile(createPath(node)); @@ -742,19 +745,19 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (loc != null) { String path= loc.getPath(); final int len= path.length(); - if (len >= suffixLen && + if (len >= suffixLen && suffix.regionMatches(ignoreCase, 0, path, len-suffixLen, suffixLen)) { - if (result == null) + if (result == null) result= new IFile[candidates.length-i]; result[resultIdx++]= root.getFile(createPath(node)); - } + } } } } } if (result==null) return NO_FILES; - + if (resultIdx < result.length) { IFile[] copy= new IFile[resultIdx]; System.arraycopy(result, 0, copy, 0, resultIdx); @@ -784,7 +787,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit return createPath(node.fParent).append(new String(node.fResourceName)); } - + /** * Selects the actual matches from the list of candidates */ @@ -800,21 +803,21 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit final T loc= adapter.getLocation(file); if (loc != null) { if (!loc.equals(location)) { - if (searchPath == null) + if (searchPath == null) continue; - + if (node.fCanonicHash != 0 && node.fCanonicHash != searchPath.hashCode()) continue; - + final String candPath= adapter.getCanonicalPath(loc); if (candPath == null) continue; - + node.fCanonicHash= candPath.hashCode(); if (!candPath.equals(searchPath)) continue; } - if (result == null) + if (result == null) result= new IFile[candidates.length-i]; result[resultIdx++]= root.getFile(createPath(node)); } @@ -822,7 +825,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } if (result==null) return NO_FILES; - + if (resultIdx < result.length) { IFile[] copy= new IFile[resultIdx]; System.arraycopy(result, 0, copy, 0, resultIdx); @@ -836,7 +839,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit List lines= new ArrayList(); synchronized (fLock) { for (Object object : fNodeMap.values()) { - Node[] nodes= convert(object); + Node[] nodes= convert(object); for (final Node node : nodes) { if (node == null) { break; @@ -857,7 +860,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit private String toString(Node node) { if (node == fRootNode) return ""; - + return toString(node.fParent) + "/" + new String(node.fResourceName); } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java index a33b23a9fd9..df2a4d6c5bd 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java @@ -89,24 +89,25 @@ public class ErrorParserExtensionManager { // - then deprecated ones // - then contributed by test plugin // inside the same category sort by parser name + @Override public int compare(IErrorParserNamed errorParser1, IErrorParserNamed errorParser2) { final String TEST_PLUGIN_ID="org.eclipse.cdt.core.tests"; //$NON-NLS-1$ final String DEPRECATED=CCorePlugin.getResourceString("CCorePlugin.Deprecated"); //$NON-NLS-1$ - + boolean isTestPlugin1 = errorParser1.getId().startsWith(TEST_PLUGIN_ID); boolean isTestPlugin2 = errorParser2.getId().startsWith(TEST_PLUGIN_ID); if (isTestPlugin1==true && isTestPlugin2==false) return 1; if (isTestPlugin1==false && isTestPlugin2==true) return -1; - + boolean isDeprecated1 = errorParser1.getName().contains(DEPRECATED); boolean isDeprecated2 = errorParser2.getName().contains(DEPRECATED); if (isDeprecated1==true && isDeprecated2==false) return 1; if (isDeprecated1==false && isDeprecated2==true) return -1; - + return errorParser1.getName().compareTo(errorParser2.getName()); } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java index 4ec4476aaa9..202a470214b 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -18,6 +18,7 @@ import org.eclipse.core.resources.IFile; public class GASErrorParser implements IErrorParser { + @Override public boolean processLine(String line, ErrorParserManager eoParser) { // cc -c x.c // Only when the previous line sasys Assembler diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java index cb349c045d6..3f90c106e9a 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.core.templateengine; import java.io.IOException; import java.net.URL; -import com.ibm.icu.text.MessageFormat; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; @@ -28,13 +27,15 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import com.ibm.icu.text.MessageFormat; + /** - * TemplateCore class is responsible providing the non-UI part of template and - * initiating process part of Template Engine. This is created per TemplateDescriptor basis. + * TemplateCore class is responsible providing the non-UI part of template and + * initiating process part of Template Engine. This is created per TemplateDescriptor basis. * Once The Template is created it creates a TemplateDescriptor for the XML file name given. * Template class extends this class with additional UI elements that are part of the template. - * + * * @since 4.0 */ public class TemplateCore { @@ -42,13 +43,14 @@ public class TemplateCore { private static final String LABEL = "label"; //$NON-NLS-1$ private static final String ID = "id"; //$NON-NLS-1$ private static final String TYPE = "type"; //$NON-NLS-1$ - + private static Map templateCache = new HashMap(); public static final Comparator TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR = new Comparator() { + @Override public int compare(TemplateCore t1, TemplateCore t2) { return String.CASE_INSENSITIVE_ORDER.compare(t1.getTemplateId(), t2.getTemplateId()); - } + } }; private TemplateDescriptor templateDescriptor; @@ -61,7 +63,7 @@ public class TemplateCore { private String templateId; private String templateType; private boolean fireDirtyEvents; - + /** * @param templateInfo may not be null * @throws TemplateInitializationException @@ -114,7 +116,7 @@ public class TemplateCore { /** * This is the List of IDs from TemplateDescriptor with "attribute" Persist * as "true" - * + * * @return Vector of IDs. */ public List getPersistTrueIDs() { @@ -135,7 +137,7 @@ public class TemplateCore { public TemplateDescriptor getTemplateDescriptor() { return templateDescriptor; } - + /** * @return String, which contains the description */ @@ -155,7 +157,7 @@ public class TemplateCore { } return templateId; } - + /** * @return String, which contains the id of the template */ @@ -165,7 +167,7 @@ public class TemplateCore { } return templateType; } - + /** * @return String, which contains the Label */ @@ -175,14 +177,14 @@ public class TemplateCore { } return TemplateEngineHelper.externalizeTemplateString(templateInfo, label); } - + /** * TemplateDescriptor for which, this Template is created. */ public TemplateProcessHandler getProcessHandler() { return processHandler; } - + @Override public String toString() { @@ -204,7 +206,7 @@ public class TemplateCore { * initializeProcessBlockList() will create the ProcessBlockList, * processPorcessBlockList() will invoke each process execution by assigning * resources to each process (Ref. ProcessResourceManager). - * @param monitor + * @param monitor */ public IStatus[] executeTemplateProcesses(IProgressMonitor monitor, final boolean showError) { setDirty(); @@ -218,10 +220,10 @@ public class TemplateCore { } return result[0]; } - + /** * Gets the Template - * + * * @param templateInfo * @throws TemplateInitializationException * @since 4.0 @@ -236,7 +238,7 @@ public class TemplateCore { return template; } } - + private static class ValueStore extends HashMap { private static final long serialVersionUID = -4523467333437879406L; private TemplateCore template; @@ -244,7 +246,7 @@ public class TemplateCore { ValueStore(TemplateCore template) { this.template = template; } - + @Override public String put(K key, String value) { value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), value); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java index 79975b4c509..7704816671d 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/IVariableContextInfo.java @@ -14,26 +14,27 @@ package org.eclipse.cdt.utils.cdtvariables; /** * This interface represents the context information. - * + * * @since 3.0 * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IVariableContextInfo { - + /** * Returns suppliers to be used for this context - * + * * @return IBuildMacroSupplier[] */ public ICdtVariableSupplier[] getSuppliers(); - + /** * Returns context info for the next lower-precedence context - * + * * @return IMacroContextInfo */ public IVariableContextInfo getNext(); - + + @Override public boolean equals(Object otherInfo); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java index 49576227c3c..ff128c1e4d9 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java @@ -31,11 +31,11 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor private String fListDelimiter; private String fIncorrectlyReferencedMacroValue; private Map fDelimiterMap; - + protected class ResolvedMacro extends CdtVariable{ private boolean fIsDefined; private boolean fIsList; - + public ResolvedMacro(String name){ super(name, VALUE_TEXT, (String)null); fIsDefined = false; @@ -58,14 +58,14 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor fIsDefined = true; fIsList = true; } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.macros.IBuildMacro#getStringValue() */ @Override public String getStringValue() throws CdtVariableException { // if(!fIsDefined) -// throw new BuildMacroException(BuildMacroException.TYPE_MACROS_UNDEFINED,fName); +// throw new BuildMacroException(BuildMacroException.TYPE_MACROS_UNDEFINED,fName); if(fIsList && fStringValue == null) fStringValue = stringListToString(fStringListValue); return fStringValue; @@ -86,7 +86,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor } return fStringListValue; } - + protected String getDelimiter(){ if(fDelimiterMap != null){ Object delimiter = fDelimiterMap.get(fName); @@ -95,7 +95,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor } return fListDelimiter; } - + protected String stringListToString(String values[]) throws CdtVariableException { String result = null; String delimiter; @@ -105,7 +105,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor else if(values.length == 1) result = values[0]; else if((delimiter = getDelimiter()) != null){ - StringBuffer buffer = new StringBuffer(); + StringBuffer buffer = new StringBuffer(); for(int i = 0; i < values.length; i++){ buffer.append(values[i]); if(i < values.length-1) @@ -113,17 +113,17 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor } result = buffer.toString(); } else { - ICdtVariableStatus eStatus = new SupplierBasedCdtVariableStatus(ICdtVariableStatus.TYPE_MACRO_NOT_STRING, - null, - null, + ICdtVariableStatus eStatus = new SupplierBasedCdtVariableStatus(ICdtVariableStatus.TYPE_MACRO_NOT_STRING, + null, + null, fName, fContextInfo); throw new CdtVariableException(eStatus); } - } + } return result; } - + public boolean isList(){ return fIsList; } @@ -132,7 +132,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor return fIsDefined; } } - + /* * describes the macro and the context where the macro was found */ @@ -143,7 +143,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor private boolean fInitialized; private int fSupplierNum; // private int fEnvSupplierNum; - + public MacroDescriptor(String name, IVariableContextInfo info){ fName = name; fInfo = info; @@ -166,12 +166,12 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor public MacroDescriptor getNext(){ return new MacroDescriptor(fName,getInfo(),getSupplierNum()+1); } - + public int getSupplierNum(){ init(); return fSupplierNum; } - + private void init(){ if(fInitialized) return; @@ -193,7 +193,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor init(); return fInfo; } - + public ICdtVariable getMacro(){ init(); return fMacro; @@ -221,7 +221,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor String result = null; ResolvedMacro value = getResolvedMacro(des); result = value.getStringValue(); - + return result; } @@ -236,10 +236,11 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToString(java.lang.String) */ + @Override public String resolveToString(String macroName) throws CdtVariableException { return resolveToString(new MacroDescriptor(macroName,fContextInfo)); } - + public void setMacroContextInfo(IVariableContextInfo info) throws CdtVariableException{ if(checkEqual(fContextInfo,info)) @@ -252,7 +253,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor protected ResolvedMacro getResolvedMacro(MacroDescriptor des) throws CdtVariableException { ResolvedMacro value = checkResolvingMacro(des); - + if(value == null) { try{ @@ -266,31 +267,32 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor } } } - + return value; } - + protected ResolvedMacro resolveMacro(MacroDescriptor des) throws CdtVariableException{ return des.fMacro != null ? resolveMacro(des.fMacro) : resolveMacro(des.fName); } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#resolveToStringList(java.lang.String) */ + @Override public String[] resolveToStringList(String macroName) throws CdtVariableException { return resolveToStringList(new MacroDescriptor(macroName,fContextInfo)); } - + protected ResolvedMacro resolveMacro(String macroName) throws CdtVariableException{ return resolveMacro(SupplierBasedCdtVariableManager.getVariable(macroName,fContextInfo,true)); } - + protected ResolvedMacro resolveParentMacro(MacroDescriptor macroDes) throws CdtVariableException{ MacroDescriptor des = macroDes.getNext(); ResolvedMacro macro = null; - + if(des != null){ try{ fMacroDescriptors.push(des); @@ -301,11 +303,11 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor } return macro; } - + protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException{ if(macro == null) return null; - + String macroName = macro.getName(); IVariableSubstitutor substitutor = this; @@ -318,7 +320,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor resolvedMacro = new ResolvedMacro(macroName,EMPTY_STRING); else{ String resolvedValues[][] = new String[unresolvedValues.length][]; - + for(int i = 0; i < unresolvedValues.length; i++){ try{ resolvedValues[i] = CdtVariableResolver.resolveToStringList(unresolvedValues[i],substitutor); @@ -338,14 +340,14 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor throw e; } } - + if(resolvedValues.length == 1) result = resolvedValues[0]; else{ List list = new ArrayList(); for (String[] resolvedValue : resolvedValues) list.addAll(Arrays.asList(resolvedValue)); - + result = list.toArray(new String[list.size()]); } resolvedMacro = new ResolvedMacro(macroName,result); @@ -362,7 +364,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor macro.getName(), status.getExpression(), status.getReferencedMacroName(), - fContextInfo); + fContextInfo); e = new CdtVariableException(eStatus); } } @@ -371,7 +373,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor } return resolvedMacro; } - + private ResolvedMacro checkResolvingMacro(MacroDescriptor des) throws CdtVariableException{ String name = des.fName; @@ -408,32 +410,32 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor } } } - + return value; } - + protected void addResolvedMacro(MacroDescriptor des, ResolvedMacro value){ String name = des.fName; fMacrosUnderResolution.remove(name); fResolvedMacros.put(name,value); fMacroDescriptors.pop(); } - + protected ResolvedMacro removeResolvedMacro(String name){ return fResolvedMacros.remove(name); } - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor#getMacroContextInfo() */ public IVariableContextInfo getMacroContextInfo(){ return fContextInfo; } - + public void reset() throws CdtVariableException{ if(fMacrosUnderResolution.size() != 0) throw new CdtVariableException(ICdtVariableStatus.TYPE_ERROR,(String)null,null,null); - + fResolvedMacros.clear(); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/PrefsStorableEnvironment.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/PrefsStorableEnvironment.java index a58c877d5ad..6742fa3df01 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/PrefsStorableEnvironment.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/PrefsStorableEnvironment.java @@ -24,11 +24,11 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.utils.envvar.StorableEnvironmentLoader.ISerializeInfo; import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor; import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; +import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; @@ -121,6 +121,7 @@ public class PrefsStorableEnvironment extends StorableEnvironment { private void addListener(IEclipsePreferences node) { try { node.accept(new IPreferenceNodeVisitor() { + @Override public boolean visit(IEclipsePreferences node) throws BackingStoreException { // {environment/{project|workspace/}config_name/variable/... node.addPreferenceChangeListener(PrefListener.this); @@ -163,11 +164,13 @@ public class PrefsStorableEnvironment extends StorableEnvironment { return retVal; } + @Override public void preferenceChange(PreferenceChangeEvent event) { prefsChanged = true; if (parentRef.get() == null) removeListener(); } + @Override public void added(NodeChangeEvent event) { prefsChanged = true; if (parentRef.get() == null) @@ -175,6 +178,7 @@ public class PrefsStorableEnvironment extends StorableEnvironment { else addListener((IEclipsePreferences)event.getChild()); } + @Override public void removed(NodeChangeEvent event) { prefsChanged = true; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java index 5c1f8984e9c..d82d5c10882 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java @@ -146,6 +146,7 @@ public class BuildPreferencePage extends PreferencePage implements IWorkbenchPre /** * @see IWorkbenchPreferencePage#init */ + @Override public void init(IWorkbench workbench) { } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java index 025f2dce1b1..3216a02b43b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java @@ -37,9 +37,9 @@ public class BuildConsole extends AbstractConsole { * error navigation (value "errorGroup"). */ public static final String ERROR_GROUP = "errorGroup"; //$NON-NLS-1$ - + /** - * Property constant indicating the color of a stream has changed. + * Property constant indicating the color of a stream has changed. */ public static final String P_STREAM_COLOR = CUIPlugin.PLUGIN_ID + ".CONSOLE_P_STREAM_COLOR"; //$NON-NLS-1$ @@ -55,7 +55,7 @@ public class BuildConsole extends AbstractConsole { /** * Constructor. - * + * * @param manager - build console manager. * @param name - name of console to appear in the list of consoles in context menu * in the Console view. @@ -67,7 +67,7 @@ public class BuildConsole extends AbstractConsole { /** * Constructor. - * + * * @param manager - build console manager. * @param name - name of console to appear in the list of consoles in context menu * in the Console view. @@ -87,12 +87,13 @@ public class BuildConsole extends AbstractConsole { fConsoleId = contextId; } + @Override public IPageBookViewPage createPage(IConsoleView view) { - fBuildConsolePage = new BuildConsolePage(view, this, fConsoleId); + fBuildConsolePage = new BuildConsolePage(view, this, fConsoleId); fCurrentBuildConsolePage = fBuildConsolePage; return fBuildConsolePage; } - + BuildConsolePage getPage() { return fBuildConsolePage; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java index 440a175ea99..6e194c1782d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.ui.IBuildConsoleManager; * before actually doing a build. */ public class BuildConsoleFactory implements IConsoleFactory { + @Override public void openConsole() { IBuildConsoleManager manager = CUIPlugin.getDefault().getConsoleManager(); if (manager instanceof BuildConsoleManager) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java index 8d24a8c1a7d..e22eea10461 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java @@ -94,22 +94,22 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang public Color getWarningBackgroundColor() { return problemWarningBackgroundColor; } - + public Color getInfoBackgroundColor() { return problemInfoBackgroundColor; } - + private BuildConsoleStreamDecorator infoStream; private BuildConsoleStreamDecorator outputStream; private BuildConsoleStreamDecorator errorStream; - + private String fName; private String fContextMenuId; static public final int BUILD_STREAM_TYPE_INFO = 0; static public final int BUILD_STREAM_TYPE_OUTPUT = 1; static public final int BUILD_STREAM_TYPE_ERROR = 2; - + static public final String DEFAULT_CONTEXT_MENU_ID = CUIPlugin.PLUGIN_ID + ".CDTBuildConsole"; //$NON-NLS-1$ private IProject fLastProject; @@ -185,9 +185,10 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /** * Traverses the delta looking for added/removed/changed launch * configuration files. - * + * * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent) */ + @Override public void resourceChanged(IResourceChangeEvent event) { IResource resource = event.getResource(); if (resource != null && resource.getType() == IResource.PROJECT) { @@ -241,7 +242,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /** * Create new build console. Subclasses may override to create a specialized * console. - * + * * @param name - name of console to appear in the list of consoles in context menu * in the Console view. * @param contextId - context menu id in the Console view. @@ -253,14 +254,14 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang protected BuildConsole createBuildConsole(String name, String contextId, final URL iconUrl) { return new BuildConsole(this, name, contextId, iconUrl); } - + /** * Start console activities. This will create a new console in the Console view, * create streams, color resources, register listeners etc. * Most work is done in UI thread. - * + * * Use {@link #shutdown()} after the console activity ends. - * + * * @param name - name of the console to appear in the Console view. * @param contextId - context menu id in the Console view. * @param iconUrl - icon to show in the context menu. @@ -280,9 +281,10 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /* * (non-Javadoc) - * + * * @see java.lang.Runnable#run() */ + @Override public void run() { // add console to the Console view fConsole = createBuildConsole(fName, fContextMenuId, iconUrl); @@ -311,9 +313,10 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /* * (non-Javadoc) - * + * * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ + @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); // colors @@ -364,9 +367,10 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang final BuildConsolePage p = BuildConsole.getCurrentPage(); if ( p == null ) return; final BuildConsoleViewer v = p.getViewer(); - if ( v == null ) return; + if ( v == null ) return; Display display = Display.getDefault(); display.asyncExec(new Runnable() { + @Override public void run() { v.getTextWidget().redraw(); } @@ -395,7 +399,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /** * Returns a background color instance based on data from a preference field. - * This is a workaround for black console bug 320723. + * This is a workaround for black console bug 320723. */ private Color createBackgroundColor(Display display, String preference) { IPreferenceStore preferenceStore = CUIPlugin.getDefault().getPreferenceStore(); @@ -411,16 +415,18 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /** * {@inheritDoc} */ + @Override public IConsole getConsole(IProject project) { return new MultiBuildConsoleAdapter(getProjectConsole(project), GlobalBuildConsoleManager.getGlobalConsole()); } /** * {@inheritDoc} - * + * * @return the console for the specified project. Returns {@code null} * if project is {@code null} or not accessible. */ + @Override public IConsole getProjectConsole(IProject project) { if (project==null || !project.isAccessible()) return null; @@ -431,9 +437,10 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.ui.IBuildConsoleManager#getLastBuiltProject() */ + @Override public IProject getLastBuiltProject() { return fLastProject; } @@ -453,15 +460,18 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /** * @return the document backing the build console for the specified project */ + @Override public IDocument getConsoleDocument(IProject project) { Assert.isNotNull(project); return getProjectConsolePartioner(project).getDocument(); } + @Override public void addConsoleListener(IBuildConsoleListener listener) { listeners.add(listener); } + @Override public void removeConsoleListener(IBuildConsoleListener listener) { listeners.remove(listener); } @@ -485,7 +495,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /** * Where the log for per-project console is kept. - * + * * @param project - the project. Cannot be {@code null}. * @return {@link URI} of build log or {@code null} if not available. */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java index b45a085fdac..490fa57fd43 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java @@ -114,6 +114,7 @@ public class BuildConsolePage extends Page // text selection listener private ISelectionChangedListener fTextListener = new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { updateSelectionDependentActions(); } @@ -176,6 +177,7 @@ public class BuildConsolePage extends Page return null; } + @Override public void consoleChange(final IBuildConsoleEvent event) { if (event.getType() == IBuildConsoleEvent.CONSOLE_START || event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE) { Control control = getControl(); @@ -188,6 +190,7 @@ public class BuildConsolePage extends Page * * @see java.lang.Runnable#run() */ + @Override public void run() { if (isAvailable()) { if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE && getProject() != event.getProject()) { @@ -222,6 +225,7 @@ public class BuildConsolePage extends Page manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager m) { contextMenuAboutToShow(m); } @@ -269,6 +273,7 @@ public class BuildConsolePage extends Page * * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ + @Override public void propertyChange(PropertyChangeEvent event) { final Object source = event.getSource(); final String property = event.getProperty(); @@ -279,6 +284,7 @@ public class BuildConsolePage extends Page Display display = getControl().getDisplay(); display.asyncExec(new Runnable() { + @Override public void run() { getViewer().getTextWidget().redraw(); } @@ -433,6 +439,7 @@ public class BuildConsolePage extends Page return false; } + @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { IProject newProject = convertSelectionToProject(selection); IProject oldProject = getProject(); @@ -522,6 +529,7 @@ public class BuildConsolePage extends Page /* (non-Javadoc) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ + @Override @SuppressWarnings("rawtypes") public Object getAdapter(Class required) { if (IFindReplaceTarget.class.equals(required)) { @@ -544,6 +552,7 @@ public class BuildConsolePage extends Page * * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent) */ + @Override public void textChanged(TextEvent event) { // update the find replace action if the document length is > 0 IUpdate findReplace = (IUpdate)fGlobalActions.get(ActionFactory.FIND.getId()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java index 774f6e82b46..80cdc119e30 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java @@ -21,21 +21,26 @@ import org.eclipse.ui.part.IPageBookViewPage; public class BuildConsolePageParticipant implements IConsolePageParticipant { private BuildConsole console; + @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { return null; } + @Override public void init(IPageBookViewPage page, IConsole console) { this.console = (BuildConsole)console; } + @Override public void dispose() { } + @Override public void activated() { BuildConsole.setCurrentPage(console.getPage()); } + @Override public void deactivated() { } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java index 648bed37d05..cf30082c092 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java @@ -240,6 +240,7 @@ public class BuildConsolePartitioner */ private void asyncProcessQueue() { Runnable r = new Runnable() { + @Override public void run() { StreamEntry entry; try { @@ -380,19 +381,23 @@ public class BuildConsolePartitioner checkOverflow(); } + @Override public void connect(IDocument document) { CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); } + @Override public void disconnect() { fDocument.setDocumentPartitioner(null); CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); killed = true; } + @Override public void documentAboutToBeChanged(DocumentEvent event) { } + @Override public boolean documentChanged(DocumentEvent event) { return documentChanged2(event) != null; } @@ -400,6 +405,7 @@ public class BuildConsolePartitioner /** * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes() */ + @Override public String[] getLegalContentTypes() { return new String[]{BuildConsolePartition.CONSOLE_PARTITION_TYPE}; } @@ -407,6 +413,7 @@ public class BuildConsolePartitioner /** * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int) */ + @Override public String getContentType(int offset) { ITypedRegion partition = getPartition(offset); if (partition != null) { @@ -419,6 +426,7 @@ public class BuildConsolePartitioner * @see org.eclipse.jface.text.IDocumentPartitioner#computePartitioning(int, * int) */ + @Override public ITypedRegion[] computePartitioning(int offset, int length) { if (offset == 0 && length == fDocument.getLength()) { return fPartitions.toArray(new ITypedRegion[fPartitions.size()]); @@ -440,6 +448,7 @@ public class BuildConsolePartitioner /** * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int) */ + @Override public ITypedRegion getPartition(int offset) { for (int i = 0; i < fPartitions.size(); i++) { ITypedRegion partition = fPartitions.get(i); @@ -452,6 +461,7 @@ public class BuildConsolePartitioner return null; } + @Override public IRegion documentChanged2(DocumentEvent event) { String text = event.getText(); if (getDocument().getLength() == 0) { @@ -555,16 +565,19 @@ public class BuildConsolePartitioner return this; } + @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty() == BuildConsolePreferencePage.PREF_BUILDCONSOLE_LINES) { setDocumentSize(BuildConsolePreferencePage.buildConsoleLines()); } } + @Override public void start(final IProject project) { Display display = CUIPlugin.getStandardDisplay(); if (display != null) { display.asyncExec(new Runnable() { + @Override public void run() { fLogStream = null; fLogURI = null; @@ -579,14 +592,17 @@ public class BuildConsolePartitioner } } + @Override public ConsoleOutputStream getOutputStream() throws CoreException { return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_OUTPUT)); } + @Override public ConsoleOutputStream getInfoStream() throws CoreException { return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_INFO)); } + @Override public ConsoleOutputStream getErrorStream() throws CoreException { return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_ERROR)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java index 7b309e6230a..ceb99d4f2ee 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java @@ -54,6 +54,7 @@ public class BuildConsoleViewer extends TextViewer * * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ + @Override public void documentAboutToBeChanged(DocumentEvent e) { } @@ -62,6 +63,7 @@ public class BuildConsoleViewer extends TextViewer * * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) */ + @Override public void documentChanged(DocumentEvent e) { revealEndOfDocument(); } @@ -168,6 +170,7 @@ public class BuildConsoleViewer extends TextViewer * * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent) */ + @Override public void lineGetStyle(LineStyleEvent event) { IDocument document = getDocument(); if (document == null) return; @@ -223,17 +226,21 @@ public class BuildConsoleViewer extends TextViewer } } + @Override public void mouseEnter(MouseEvent e) { getTextWidget().addMouseListener(this); } + @Override public void mouseExit(MouseEvent e) { getTextWidget().removeMouseListener(this); } + @Override public void mouseHover(MouseEvent e) { } + @Override public void mouseDoubleClick(MouseEvent e) { int offset = -1; try { @@ -244,12 +251,15 @@ public class BuildConsoleViewer extends TextViewer } } + @Override public void mouseDown(MouseEvent e) { } + @Override public void mouseUp(MouseEvent e) { } + @Override public void lineGetBackground(LineBackgroundEvent event) { IDocument document = getDocument(); if (document == null) return; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java index a5ce0891a46..7b3fed0a639 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.core.ProblemMarkerInfo; import org.eclipse.cdt.internal.core.IErrorMarkeredOutputStream; /** - * Output stream which put all output to BuildConsolePartitioner + * Output stream which put all output to BuildConsolePartitioner * and informs it when stream is closed */ public class BuildOutputStream extends ConsoleOutputStream implements IErrorMarkeredOutputStream { @@ -29,7 +29,7 @@ public class BuildOutputStream extends ConsoleOutputStream implements IErrorMark final BuildConsoleStreamDecorator fStream; private BuildConsolePartitioner fPartitioner; - public BuildOutputStream(BuildConsolePartitioner partitioner, + public BuildOutputStream(BuildConsolePartitioner partitioner, BuildConsoleStreamDecorator stream) { fPartitioner = partitioner; if (fPartitioner.getProject() == null) @@ -56,9 +56,10 @@ public class BuildOutputStream extends ConsoleOutputStream implements IErrorMark fPartitioner.appendToDocument(new String(b, off, len), fStream, null); } + @Override public void write(String s, ProblemMarkerInfo marker) throws IOException { fPartitioner.appendToDocument(s, fStream, marker); - + } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java index fb493943578..299264eaf76 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java @@ -29,13 +29,14 @@ import org.eclipse.cdt.internal.core.ICConsole; public class CBuildConsole implements ICConsole { IProject project; IBuildConsoleManager fConsoleManager; - + /** * Constructor for BuildConsole. */ public CBuildConsole() { } + @Override public void init(String contextId, String name, URL iconUrl) { if (contextId==null) fConsoleManager = CUIPlugin.getDefault().getConsoleManager(); @@ -45,28 +46,32 @@ public class CBuildConsole implements ICConsole { /** * Start the console for a given project. - * + * * @param project - the project to start the console. */ + @Override public void start(IProject project) { this.project = project; fConsoleManager.getConsole(project).start(project); } - + /** * @throws CoreException * @see org.eclipse.cdt.core.resources.IConsole#getOutputStream() */ + @Override public ConsoleOutputStream getOutputStream() throws CoreException { Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First); return fConsoleManager.getConsole(project).getOutputStream(); } + @Override public ConsoleOutputStream getInfoStream() throws CoreException { Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First); return fConsoleManager.getConsole(project).getInfoStream(); } + @Override public ConsoleOutputStream getErrorStream() throws CoreException { Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First); return fConsoleManager.getConsole(project).getErrorStream(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java index fd849762bbe..b0904d285d5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java @@ -12,9 +12,10 @@ package org.eclipse.cdt.internal.ui.buildconsole; import java.util.EventObject; -import org.eclipse.cdt.ui.IBuildConsoleEvent; import org.eclipse.core.resources.IProject; +import org.eclipse.cdt.ui.IBuildConsoleEvent; + public class ConsoleEvent extends EventObject implements IBuildConsoleEvent { /** @@ -31,10 +32,12 @@ public class ConsoleEvent extends EventObject implements IBuildConsoleEvent { fType = type; } + @Override public IProject getProject() { return fProject; } + @Override public int getType() { return fType; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java index a1798f637af..bbc2035a6a6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java @@ -23,6 +23,7 @@ public class ConsoleOutputTextStore implements ITextStore { /** * @see ITextStore#get(int) */ + @Override public char get(int pos) { return fBuffer.charAt(pos); } @@ -30,6 +31,7 @@ public class ConsoleOutputTextStore implements ITextStore { /** * @see ITextStore#get(int, int) */ + @Override public String get(int pos, int length) { return fBuffer.substring(pos, pos + length); } @@ -37,6 +39,7 @@ public class ConsoleOutputTextStore implements ITextStore { /** * @see ITextStore#getLength() */ + @Override public int getLength() { return fBuffer.length(); } @@ -44,6 +47,7 @@ public class ConsoleOutputTextStore implements ITextStore { /** * @see ITextStore#replace(int, int, String) */ + @Override public void replace(int pos, int length, String text) { if (text == null) { text = ""; //$NON-NLS-1$ @@ -54,6 +58,7 @@ public class ConsoleOutputTextStore implements ITextStore { /** * @see ITextStore#set(String) */ + @Override public void set(String text) { fBuffer = new StringBuffer(text); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java index 86769c03fcc..3918021af2d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java @@ -56,6 +56,7 @@ class MultiBuildConsoleAdapter implements IConsole { two.write(b, off, len); } + @Override public void write(String s, ProblemMarkerInfo marker) throws IOException { one.write(s, marker); two.write(s, marker); @@ -76,18 +77,22 @@ class MultiBuildConsoleAdapter implements IConsole { fGlobalConsole = globalConsole; } + @Override public void start(IProject project) { fProjectConsole.start(project); } + @Override public ConsoleOutputStream getOutputStream() throws CoreException { return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getOutputStream(), (BuildOutputStream)fGlobalConsole.getOutputStream()); } + @Override public ConsoleOutputStream getInfoStream() throws CoreException { return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getInfoStream(), (BuildOutputStream)fGlobalConsole.getInfoStream()); } + @Override public ConsoleOutputStream getErrorStream() throws CoreException { return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getErrorStream(), (BuildOutputStream)fGlobalConsole.getErrorStream()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java index 15a2c6de40c..dc51ac0aa26 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java @@ -47,6 +47,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate2#getMenu(org.eclipse.swt.widgets.Menu) */ + @Override public Menu getMenu(Menu parent) { Menu menu = new Menu(parent); addMenuListener(menu); @@ -56,6 +57,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control) */ + @Override public Menu getMenu(Control parent) { Menu menu = new Menu(parent); addMenuListener(menu); @@ -65,6 +67,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ + @Override public void dispose() { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); mngr.removeCProjectDescriptionListener(this); @@ -73,6 +76,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ + @Override public void init(IWorkbenchWindow window) { buildaction = new BuildGroup.CDTBuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -82,6 +86,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ + @Override public void run(IAction action) { buildaction.selectionChanged(new StructuredSelection(fProjects.toArray())); buildaction.run(); @@ -90,6 +95,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ + @Override public void selectionChanged(IAction action, ISelection selection) { if (actionMenuCache == null){ actionMenuCache = action; @@ -97,7 +103,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase onSelectionChanged(action, selection); updateBuildConfigMenuToolTip(action); } - + /** * Adds a listener to the given menu to re-populate it each time is is shown * @param menu The menu to add listener to @@ -115,7 +121,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase protected IAction makeAction(String sName, StringBuffer builder, int accel) { return new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1, buildaction); } - + /** * Update the tool tip based on the currently selected project and active configuration. * @param action - The build configuration menu to change the tool tip on @@ -140,6 +146,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase action.setToolTipText(toolTipText); } + @Override public void handleEvent(CProjectDescriptionEvent event) { if (actionMenuCache != null){ updateBuildConfigMenuToolTip(actionMenuCache); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java index 5556997d4b8..552fce26a50 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java @@ -23,12 +23,13 @@ import org.eclipse.ui.IWorkbenchPart; /** * This context menu action is used to change active build configuration for the project */ -public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase implements +public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase implements IMenuCreator, IObjectActionDelegate { - /** + /** * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { // do nothing } @@ -36,6 +37,7 @@ public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ + @Override public void run(IAction action) { // do nothing } @@ -43,6 +45,7 @@ public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ + @Override public void selectionChanged(IAction action, ISelection selection) { onSelectionChanged(action, selection); action.setMenuCreator(this); @@ -51,6 +54,7 @@ public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.jface.action.IMenuCreator#dispose() */ + @Override public void dispose() { // do nothing } @@ -58,6 +62,7 @@ public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) */ + @Override public Menu getMenu(Control parent) { // this method is never called return null; @@ -66,6 +71,7 @@ public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase /** * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) */ + @Override public Menu getMenu(Menu parent) { Menu menu = new Menu(parent); menu.addMenuListener(new MenuAdapter() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java index ddef08d0488..a9db075a9c0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.ui.newui.ManageConfigSelector; import org.eclipse.cdt.internal.ui.actions.ActionMessages; /** - * Action which changes active build configuration of the current project + * Action which changes active build configuration of the current project */ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase implements IWorkbenchWindowPulldownDelegate2 { @@ -36,6 +36,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp /** * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate2#getMenu(org.eclipse.swt.widgets.Menu) */ + @Override public Menu getMenu(Menu parent) { Menu menu = new Menu(parent); addMenuListener(menu); @@ -45,6 +46,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp /** * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control) */ + @Override public Menu getMenu(Control parent) { Menu menu = new Menu(parent); addMenuListener(menu); @@ -54,6 +56,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp /** * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ + @Override public void dispose() { // do nothing } @@ -61,6 +64,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp /** * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ + @Override public void init(IWorkbenchWindow window) { // do nothing } @@ -68,6 +72,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp /** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ + @Override public void run(IAction action) { IProject[] obs = fProjects.toArray(new IProject[fProjects.size()]); IConfigManager cm = ManageConfigSelector.getManager(obs); @@ -83,10 +88,11 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp /** * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ + @Override public void selectionChanged(IAction action, ISelection selection) { onSelectionChanged(action, selection); } - + /** * Adds a listener to the given menu to repopulate it each time is is shown * @param menu The menu to add listener to diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java index a5dcd316eb3..3f7cc69442d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java @@ -18,12 +18,12 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; import java.util.Stack; import java.util.StringTokenizer; import java.util.TreeSet; -import java.util.Map.Entry; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.action.Action; @@ -64,7 +64,7 @@ import org.eclipse.cdt.internal.ui.filters.NamePatternFilter; *

* This class may be instantiated; it is not intended to be subclassed. *

- * + * * @noextend This class is not intended to be subclassed by clients. * @since 2.0 */ @@ -75,7 +75,7 @@ public class CustomFiltersActionGroup extends ActionGroup { setText(FilterMessages.OpenCustomFiltersDialogAction_text); //setImageDescriptor(CPluginImages.DESC_CLCL_FILTER); } - + @Override public void run() { openDialog(); @@ -84,7 +84,7 @@ public class CustomFiltersActionGroup extends ActionGroup { /** * Menu contribution item which shows and lets check and uncheck filters. - * + * * @since 3.0 */ class FilterActionMenuContributionItem extends ContributionItem { @@ -97,7 +97,7 @@ public class CustomFiltersActionGroup extends ActionGroup { /** * Constructor for FilterActionMenuContributionItem. - * + * * @param actionGroup the action group * @param filterId the id of the filter * @param filterName the name of the filter @@ -137,7 +137,7 @@ public class CustomFiltersActionGroup extends ActionGroup { } }); } - + /* * @see org.eclipse.jface.action.IContributionItem#isDynamic() */ @@ -167,7 +167,7 @@ public class CustomFiltersActionGroup extends ActionGroup { private NamePatternFilter fPatternFilter; private Map fInstalledBuiltInFilters; - + private Map fEnabledFilterIds; private boolean fUserDefinedPatternsEnabled; private String[] fUserDefinedPatterns; @@ -176,33 +176,33 @@ public class CustomFiltersActionGroup extends ActionGroup { * * @since 3.0 */ - private Stack fLRUFilterIdsStack; + private Stack fLRUFilterIdsStack; /** * Handle to menu manager to dynamically update * the last recently used filters. - * + * * @since 3.0 */ private IMenuManager fMenuManager; /** * The menu listener which dynamically updates * the last recently used filters. - * + * * @since 3.0 */ private IMenuListener fMenuListener; /** * Filter Ids used in the last view menu invocation. - * + * * @since 3.0 */ private String[] fFilterIdsUsedInLastViewMenu; private HashMap fFilterDescriptorMap; private String fTargetId; - + /** * Creates a new CustomFiltersActionGroup. - * + * * @param part the view part that owns this action group * @param viewer the viewer to be filtered */ @@ -212,7 +212,7 @@ public class CustomFiltersActionGroup extends ActionGroup { /** * Creates a new CustomFiltersActionGroup. - * + * * @param ownerId the id of this action group's owner * @param viewer the viewer to be filtered */ @@ -226,10 +226,10 @@ public class CustomFiltersActionGroup extends ActionGroup { initializeWithPluginContributions(); initializeWithViewDefaults(); - + installFilters(); } - + /* * Method declared on ActionGroup. */ @@ -246,36 +246,36 @@ public class CustomFiltersActionGroup extends ActionGroup { ViewerFilter filter= fInstalledBuiltInFilters.get(filterName); if (filter == null) newFilters.add(filterName); - else if (isSelected(parent, element, contentProvider, filter)) + else if (isSelected(parent, element, contentProvider, filter)) newFilters.add(filterName); } if (newFilters.size() == enabledFilters.length) return new String[0]; return newFilters.toArray(new String[newFilters.size()]); } - + public void setFilters(String[] newFilters) { setEnabledFilterIds(newFilters); updateViewerFilters(true); } - + private boolean isSelected(Object parent, Object element, IContentProvider contentProvider, ViewerFilter filter) { if (contentProvider instanceof ITreeContentProvider) { // the element and all its parents have to be selected ITreeContentProvider provider = (ITreeContentProvider) contentProvider; while (element != null && !(element instanceof ICModel)) { - if (!filter.select(fViewer, parent, element)) + if (!filter.select(fViewer, parent, element)) return false; element= provider.getParent( element); } return true; - } + } return filter.select(fViewer, parent, element); } /** * Sets the enable state of the given filter. - * + * * @param filterId the id of the filter * @param state the filter state */ @@ -283,13 +283,13 @@ public class CustomFiltersActionGroup extends ActionGroup { // Renew filter id in LRU stack fLRUFilterIdsStack.remove(filterId); fLRUFilterIdsStack.add(0, filterId); - + fEnabledFilterIds.put(filterId, new Boolean(state)); storeViewDefaults(); - + updateViewerFilters(true); } - + private String[] getEnabledFilterIds() { Set enabledFilterIds= new HashSet(fEnabledFilterIds.size()); Iterator> iter= fEnabledFilterIds.entrySet().iterator(); @@ -303,7 +303,7 @@ public class CustomFiltersActionGroup extends ActionGroup { return enabledFilterIds.toArray(new String[enabledFilterIds.size()]); } - + private void setEnabledFilterIds(String[] enabledIds) { Iterator iter= fEnabledFilterIds.keySet().iterator(); while (iter.hasNext()) { @@ -321,17 +321,17 @@ public class CustomFiltersActionGroup extends ActionGroup { /** * Sets the recently changed filters. - * + * * @param changeHistory the change history * @since 3.0 */ private void setRecentlyChangedFilters(Stack changeHistory) { Stack oldestFirstStack= new Stack(); - + int length= Math.min(changeHistory.size(), MAX_FILTER_MENU_ENTRIES); for (int i= 0; i < length; i++) oldestFirstStack.push((changeHistory.pop()).getId()); - + length= Math.min(fLRUFilterIdsStack.size(), MAX_FILTER_MENU_ENTRIES - oldestFirstStack.size()); int NEWEST= 0; for (int i= 0; i < length; i++) { @@ -341,7 +341,7 @@ public class CustomFiltersActionGroup extends ActionGroup { } fLRUFilterIdsStack= oldestFirstStack; } - + private boolean areUserDefinedPatternsEnabled() { return fUserDefinedPatternsEnabled; } @@ -365,6 +365,7 @@ public class CustomFiltersActionGroup extends ActionGroup { fMenuManager= viewMenu; fMenuListener= new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager manager) { removePreviousLRUFilterActions(manager); addLRUFilterActions(manager); @@ -376,7 +377,7 @@ public class CustomFiltersActionGroup extends ActionGroup { void removePreviousLRUFilterActions(IMenuManager mm) { if (fFilterIdsUsedInLastViewMenu == null) return; - + for (String element : fFilterIdsUsedInLastViewMenu) mm.remove(element); } @@ -386,10 +387,10 @@ public class CustomFiltersActionGroup extends ActionGroup { fFilterIdsUsedInLastViewMenu= null; return; } - + SortedSet sortedFilters= new TreeSet(fLRUFilterIdsStack); String[] recentlyChangedFilterIds= sortedFilters.toArray(new String[sortedFilters.size()]); - + fFilterIdsUsedInLastViewMenu= new String[recentlyChangedFilterIds.length]; for (int i= 0; i < recentlyChangedFilterIds.length; i++) { String id= recentlyChangedFilterIds[i]; @@ -412,7 +413,7 @@ public class CustomFiltersActionGroup extends ActionGroup { fMenuManager.removeMenuListener(fMenuListener); super.dispose(); } - + private void initializeWithPluginContributions() { fUserDefinedPatterns= new String[0]; fUserDefinedPatternsEnabled= false; @@ -431,7 +432,7 @@ public class CustomFiltersActionGroup extends ActionGroup { } // ---------- viewer filter handling ---------- - + private void installFilters() { fInstalledBuiltInFilters= new HashMap(fEnabledFilterIds.size()); fPatternFilter= new NamePatternFilter(); @@ -449,7 +450,7 @@ public class CustomFiltersActionGroup extends ActionGroup { fViewer.refresh(); fViewer.getControl().setRedraw(true); } - + private void updateBuiltInFilters() { Set installedFilters= fInstalledBuiltInFilters.keySet(); Set filtersToAdd= new HashSet(fEnabledFilterIds.size()); @@ -464,7 +465,7 @@ public class CustomFiltersActionGroup extends ActionGroup { else if (!isEnabled && installedFilters.contains(id)) filtersToRemove.add(id); } - + // Install the filters FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId); for (FilterDescriptor filterDesc : filterDescs) { @@ -503,7 +504,7 @@ public class CustomFiltersActionGroup extends ActionGroup { } // ---------- view kind/defaults persistency ---------- - + private void initializeWithViewDefaults() { // get default values for view IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); @@ -515,7 +516,7 @@ public class CustomFiltersActionGroup extends ActionGroup { // XXX: Uncomment once bug 22533 is fixed. // if (!store.contains(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED))) // return; - + fUserDefinedPatternsEnabled= store.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED)); setUserDefinedPatterns(CustomFiltersDialog.convertFromString(store.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR)); @@ -525,7 +526,7 @@ public class CustomFiltersActionGroup extends ActionGroup { Boolean isEnabled= new Boolean(store.getBoolean(id)); fEnabledFilterIds.put(id, isEnabled); } - + fLRUFilterIdsStack.clear(); String lruFilterIds= store.getString(TAG_LRU_FILTERS); StringTokenizer tokenizer= new StringTokenizer(lruFilterIds, SEPARATOR); @@ -542,7 +543,7 @@ public class CustomFiltersActionGroup extends ActionGroup { // XXX: can be removed once bug 22533 is fixed. store.setValue(getPreferenceKey("TAG_DUMMY_TO_TEST_EXISTENCE"), "storedViewPreferences");//$NON-NLS-1$//$NON-NLS-2$ - + store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED), fUserDefinedPatternsEnabled); store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS), CustomFiltersDialog.convertToString(fUserDefinedPatterns ,SEPARATOR)); @@ -562,7 +563,7 @@ public class CustomFiltersActionGroup extends ActionGroup { } store.setValue(TAG_LRU_FILTERS, buf.toString()); } - + private String getPreferenceKey(String tag) { return "CustomFiltersActionGroup." + fTargetId + '.' + tag; //$NON-NLS-1$ } @@ -571,7 +572,7 @@ public class CustomFiltersActionGroup extends ActionGroup { /** * Saves the state of the custom filters in a memento. - * + * * @param memento the memento into which the state is saved */ public void saveState(IMemento memento) { @@ -599,7 +600,7 @@ public class CustomFiltersActionGroup extends ActionGroup { /** * Stores the last recently used filter Ids into * the given memento - * + * * @param memento the memento into which to store the LRU filter Ids * @since 3.0 */ @@ -630,9 +631,9 @@ public class CustomFiltersActionGroup extends ActionGroup { *

* Note: This method does not refresh the viewer. *

- * + * * @param memento the memento from which the state is restored - */ + */ public void restoreState(IMemento memento) { if (memento == null) return; @@ -647,13 +648,13 @@ public class CustomFiltersActionGroup extends ActionGroup { restoreUserDefinedPatterns(customFilters); restoreXmlDefinedFilters(customFilters); restoreLRUFilters(customFilters); - + updateViewerFilters(false); } private void restoreUserDefinedPatterns(IMemento memento) { IMemento userDefinedPatterns= memento.getChild(TAG_USER_DEFINED_PATTERNS); - if(userDefinedPatterns != null) { + if(userDefinedPatterns != null) { IMemento children[]= userDefinedPatterns.getChildren(TAG_CHILD); String[] patterns= new String[children.length]; for (int i = 0; i < children.length; i++) @@ -709,7 +710,7 @@ public class CustomFiltersActionGroup extends ActionGroup { fUserDefinedPatterns= userDefinedPatterns.toArray(new String[userDefinedPatterns.size()]); setUserDefinedPatternsEnabled(fUserDefinedPatternsEnabled && fUserDefinedPatterns.length > 0); } - + // ---------- dialog related code ---------- void openDialog() { @@ -719,7 +720,7 @@ public class CustomFiltersActionGroup extends ActionGroup { areUserDefinedPatternsEnabled(), fUserDefinedPatterns, getEnabledFilterIds()); - + if (dialog.open() == Window.OK) { setEnabledFilterIds(dialog.getEnabledFilterIds()); setUserDefinedPatternsEnabled(dialog.areUserDefinedPatternsEnabled()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java index eff1fc5e482..9239ce1d4c1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java @@ -49,19 +49,20 @@ import org.eclipse.cdt.internal.ui.actions.DeleteResConfigsHandler; /** * Action which deletes resource description. (If resource description is missing * one from parent is normally used) - * @deprecated as of CDT 8.0 now using {@link DeleteResConfigsHandler} + * @deprecated as of CDT 8.0 now using {@link DeleteResConfigsHandler} */ @Deprecated -public class DeleteResConfigsAction +public class DeleteResConfigsAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { protected ArrayList objects = null; - private ArrayList outData = null; + private ArrayList outData = null; + @Override public void selectionChanged(IAction action, ISelection selection) { objects = null; outData = null; - + if (!selection.isEmpty()) { // case for context menu if (selection instanceof IStructuredSelection) { @@ -78,7 +79,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { if (res != null) { IProject p = res.getProject(); if (!p.isOpen()) continue; - + if (!CoreModel.getDefault().isNewStyleProject(p)) continue; @@ -100,23 +101,24 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { } } } - } + } action.setEnabled(objects != null); } - + + @Override public void run(IAction action) { openDialog(); } - - + + private void openDialog() { - if (objects == null || objects.size() == 0) return; + if (objects == null || objects.size() == 0) return; // create list of configurations to delete - + ListSelectionDialog dialog = new ListSelectionDialog( - CUIPlugin.getActiveWorkbenchShell(), - objects, - createSelectionDialogContentProvider(), + CUIPlugin.getActiveWorkbenchShell(), + objects, + createSelectionDialogContentProvider(), new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0); dialog.setTitle(ActionMessages.DeleteResConfigsAction_1); if (dialog.open() == Window.OK) { @@ -136,12 +138,12 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { ICProjectDescription prjd; ICConfigurationDescription cfgd; ICResourceDescription rdesc; - + public ResCfgData(IResource res2, ICProjectDescription prjd2, ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) { res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2; } - + // performs deletion public void delete() { try { @@ -154,14 +156,15 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$ } } - - + + private IStructuredContentProvider createSelectionDialogContentProvider() { return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { if (outData != null) return outData.toArray(); - + outData = new ArrayList(); List ls = (List)inputElement; Iterator it = ls.iterator(); @@ -181,24 +184,31 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { if (cfgds != null) { for (ICConfigurationDescription cfgd : cfgds) { ICResourceDescription rd = cfgd.getResourceDescription(path, true); - if (rd != null) + if (rd != null) outData.add(new ResCfgData(res, prjd, cfgd, rd)); } } } return outData.toArray(); } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }; } - + + @Override public void dispose() { objects = null; } - + // doing nothing + @Override public void init(IWorkbenchWindow window) { } + @Override public Menu getMenu(Menu parent) { return null; } + @Override public Menu getMenu(Control parent) { return null; } + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) {} - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java index d9aeb99aaf5..656c4f51fa4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java @@ -54,17 +54,18 @@ import org.eclipse.cdt.internal.ui.newui.Messages; * @deprecated as of CDT 8.0 now using {@link ExcludeFromBuildHandler} */ @Deprecated -public class ExcludeFromBuildAction +public class ExcludeFromBuildAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { protected ArrayList objects = null; protected ArrayList cfgNames = null; + @Override public void selectionChanged(IAction action, ISelection selection) { objects = null; cfgNames = null; boolean cfgsOK = true; - + if (!selection.isEmpty()) { // case for context menu if (selection instanceof IStructuredSelection) { @@ -73,7 +74,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { for (int i=0; i(); objects.add(res); if (cfgNames == null) { cfgNames = new ArrayList(cfgds.length); - for (int j=0; j it = objects.iterator(); while (it.hasNext()) { @@ -174,11 +176,11 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { } } ArrayList lst = new ArrayList(); - for (int i=0; i 0) dialog.setInitialElementSelections(lst); - + if (dialog.open() == Window.OK) { Object[] selected = dialog.getResult(); // may be empty Iterator it2 = objects.iterator(); @@ -203,7 +205,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { try { CoreModel.getDefault().setProjectDescription(p, prjd); } catch (CoreException e) { - CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); + CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); } AbstractPage.updateViews(res); } @@ -212,17 +214,25 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { private IStructuredContentProvider createSelectionDialogContentProvider() { return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { return cfgNames.toArray(); } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }; } - + + @Override public void dispose() { objects = null; } - + // doing nothing + @Override public void init(IWorkbenchWindow window) { } + @Override public Menu getMenu(Menu parent) { return null; } + @Override public Menu getMenu(Control parent) { return null; } + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) {} } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java index 3b37dfda3a9..67b16f621dc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java @@ -99,12 +99,15 @@ public class FormatAllAction extends SelectionDispatchAction { */ public static class ObjectDelegate implements IObjectActionDelegate { private FormatAllAction fAction; + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { fAction= new FormatAllAction(targetPart.getSite()); } + @Override public void run(IAction action) { fAction.run(); } + @Override public void selectionChanged(IAction action, ISelection selection) { if (fAction == null) action.setEnabled(false); @@ -125,8 +128,8 @@ public class FormatAllAction extends SelectionDispatchAction { setText(ActionMessages.FormatAllAction_label); setToolTipText(ActionMessages.FormatAllAction_tooltip); setDescription(ActionMessages.FormatAllAction_description); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.FORMAT_ALL); + + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.FORMAT_ALL); } @@ -151,7 +154,7 @@ public class FormatAllAction extends SelectionDispatchAction { switch (elem.getElementType()) { case ICElement.C_UNIT: result.add(elem); - break; + break; case ICElement.C_CCONTAINER: collectTranslationUnits((ICContainer) elem, result); break; @@ -172,7 +175,7 @@ public class FormatAllAction extends SelectionDispatchAction { } return result.toArray(new ITranslationUnit[result.size()]); } - + private void collectTranslationUnits(ICProject project, Collection result) throws CModelException { ISourceRoot[] roots = project.getSourceRoots(); for (ISourceRoot root : roots) { @@ -195,7 +198,7 @@ public class FormatAllAction extends SelectionDispatchAction { } } } - } + } private boolean isEnabled(IStructuredSelection selection) { Object[] selected= selection.toArray(); @@ -218,7 +221,7 @@ public class FormatAllAction extends SelectionDispatchAction { } return false; } - + @Override public void run(ITextSelection selection) { } @@ -230,23 +233,23 @@ public class FormatAllAction extends SelectionDispatchAction { return; if (tus.length > 1) { int returnCode= OptionalMessageDialog.open("FormatAll", //$NON-NLS-1$ - getShell(), - ActionMessages.FormatAllAction_noundo_title, + getShell(), + ActionMessages.FormatAllAction_noundo_title, null, - ActionMessages.FormatAllAction_noundo_message, - MessageDialog.WARNING, - new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, + ActionMessages.FormatAllAction_noundo_message, + MessageDialog.WARNING, + new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0); - if (returnCode != OptionalMessageDialog.NOT_SHOWN && + if (returnCode != OptionalMessageDialog.NOT_SHOWN && returnCode != Window.OK ) return; } - + IStatus status= Resources.makeCommittable(getResources(tus), getShell()); if (!status.isOK()) { - ErrorDialog.openError(getShell(), ActionMessages.FormatAllAction_failedvalidateedit_title, ActionMessages.FormatAllAction_failedvalidateedit_message, status); + ErrorDialog.openError(getShell(), ActionMessages.FormatAllAction_failedvalidateedit_title, ActionMessages.FormatAllAction_failedvalidateedit_message, status); return; } - + runOnMultiple(tus); } @@ -264,35 +267,36 @@ public class FormatAllAction extends SelectionDispatchAction { */ public void runOnMultiple(final ITranslationUnit[] tus) { try { - String message= ActionMessages.FormatAllAction_status_description; + String message= ActionMessages.FormatAllAction_status_description; final MultiStatus status= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.OK, message, null); - + if (tus.length == 1) { EditorUtility.openInEditor(tus[0]); } - + PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) { doRunOnMultiple(tus, status, monitor); } })); // workspace lock if (!status.isOK()) { - String title= ActionMessages.FormatAllAction_multi_status_title; + String title= ActionMessages.FormatAllAction_multi_status_title; ErrorDialog.openError(getShell(), title, null, status); } } catch (InvocationTargetException e) { - ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message); + ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message); } catch (InterruptedException e) { // Canceled by user } catch (CoreException e) { - ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message); + ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message); } } private static Map getFomatterSettings(ICProject project) { return new HashMap(project.getOptions(true)); } - + private void doFormat(IDocument document, Map options) { final IFormattingContext context = new FormattingContext(); try { @@ -323,7 +327,7 @@ public class FormatAllAction extends SelectionDispatchAction { extension.startSequentialRewrite(false); } } - + @SuppressWarnings("deprecation") private void stopSequentialRewriteMode(IDocument document) { if (document instanceof IDocumentExtension4) { @@ -334,18 +338,18 @@ public class FormatAllAction extends SelectionDispatchAction { extension.stopSequentialRewrite(); } } - + private void doRunOnMultiple(ITranslationUnit[] tus, MultiStatus status, IProgressMonitor monitor) throws OperationCanceledException { if (monitor == null) { monitor= new NullProgressMonitor(); - } - monitor.setTaskName(ActionMessages.FormatAllAction_operation_description); - + } + monitor.setTaskName(ActionMessages.FormatAllAction_operation_description); + monitor.beginTask("", tus.length * 4); //$NON-NLS-1$ try { Map lastOptions= null; ICProject lastProject= null; - + for (int i= 0; i < tus.length; i++) { ITranslationUnit tu= tus[i]; IPath path= tu.getPath(); @@ -353,7 +357,7 @@ public class FormatAllAction extends SelectionDispatchAction { lastProject= tu.getCProject(); lastOptions= getFomatterSettings(lastProject); } - + ILanguage language= null; try { language= tu.getLanguage(); @@ -361,7 +365,7 @@ public class FormatAllAction extends SelectionDispatchAction { // use fallback CPP language= GPPLanguage.getDefault(); } - + // use working copy if available ITranslationUnit wc = CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(tu); if (wc != null) { @@ -374,18 +378,18 @@ public class FormatAllAction extends SelectionDispatchAction { if (monitor.isCanceled()) { throw new OperationCanceledException(); } - + ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); try { try { manager.connect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1)); - + monitor.subTask(path.makeRelative().toString()); ITextFileBuffer fileBuffer= manager.getTextFileBuffer(path, LocationKind.IFILE); boolean wasDirty = fileBuffer.isDirty(); - + formatTranslationUnit(fileBuffer, lastOptions); - + if (fileBuffer.isDirty() && !wasDirty) { fileBuffer.commit(new SubProgressMonitor(monitor, 2), false); } else { @@ -402,10 +406,11 @@ public class FormatAllAction extends SelectionDispatchAction { monitor.done(); } } - + private void formatTranslationUnit(final ITextFileBuffer fileBuffer, final Map options) { if (fileBuffer.isShared()) { getShell().getDisplay().syncExec(new Runnable() { + @Override public void run() { doFormat(fileBuffer.getDocument(), options); } @@ -414,5 +419,5 @@ public class FormatAllAction extends SelectionDispatchAction { doFormat(fileBuffer.getDocument(), options); // run in context thread } } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java index b6d5538316e..573ff899f32 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) - Adapted for CDT @@ -57,27 +57,27 @@ import org.eclipse.cdt.internal.ui.editor.SortLinesAction; /** * Action group that adds the source and generate actions to a part's context * menu and installs handlers for the corresponding global menu actions. - * + * *

* This class may be instantiated; it is not intended to be subclassed. *

- * + * * @noextend This class is not intended to be subclassed by clients. * @since 4.0 */ public class GenerateActionGroup extends ActionGroup implements ISelectionChangedListener { - + /** * Pop-up menu: id of the source sub menu (value org.eclipse.cdt.ui.source.menu). */ public static final String MENU_ID= "org.eclipse.cdt.ui.source.menu"; //$NON-NLS-1$ - + /** * Pop-up menu: id of the organize group of the source sub menu (value * organizeGroup). */ public static final String GROUP_ORGANIZE= "organizeGroup"; //$NON-NLS-1$ - + /** * Pop-up menu: id of the generate group of the source sub menu (value * generateGroup). @@ -107,13 +107,13 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange * editGroup). */ private static final String GROUP_EDIT= "editGroup"; //$NON-NLS-1$ - + private CEditor fEditor; private IWorkbenchSite fSite; private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE; private List fRegisteredSelectionListeners; private List fRefactorActions= new ArrayList(); - + private AddIncludeOnSelectionAction fAddInclude; // private OverrideMethodsAction fOverrideMethods; // private GenerateHashCodeEqualsAction fHashCodeEquals; @@ -126,14 +126,14 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange private AddBookmarkAction fAddBookmark; private AddTaskAction fAddTaskAction; // private ExternalizeStringsAction fExternalizeStrings; -// private CleanUpAction fCleanUp; -// +// private CleanUpAction fCleanUp; +// // private OrganizeIncludesAction fOrganizeIncludes; // private SortMembersAction fSortMembers; private SortLinesAction fSortLines; private FormatAllAction fFormatAll; // private CopyQualifiedNameAction fCopyQualifiedNameAction; -// +// private static final String QUICK_MENU_ID= "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$ private IHandlerActivation fQuickAccessHandlerActivation; @@ -145,7 +145,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange * Note: This constructor is for internal use only. Clients should not call this constructor. * @param editor the C editor * @param groupName the group name to add the action to - * + * * @noreference This constructor is not intended to be referenced by clients. */ public GenerateActionGroup(CEditor editor, String groupName) { @@ -153,11 +153,11 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange fSelectionProvider= fSite.getSelectionProvider(); fEditor= editor; fGroupName= groupName; - + fAddInclude= new AddIncludeOnSelectionAction(editor); fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE); editor.setAction("AddIncludeOnSelection", fAddInclude); //$NON-NLS-1$ - + // fOrganizeIncludes= new OrganizeIncludesAction(editor); // fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES); // editor.setAction("OrganizeIncludes", fOrganizeIncludes); //$NON-NLS-1$ @@ -169,7 +169,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange fSortLines= new SortLinesAction(editor); fSortLines.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_LINES); editor.setAction("SortLines", fSortLines); //$NON-NLS-1$ - + // IAction pastAction= editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE); // fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction); // fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID); @@ -178,11 +178,11 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange // fOverrideMethods= new OverrideMethodsAction(editor); // fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS); // editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$ -// +// fAddGetterSetter= new GettersAndSettersAction(editor); fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.GETTERS_AND_SETTERS); editor.setAction("org.eclipse.cdt.ui.refactor.getters.and.setters", fAddGetterSetter); //$NON-NLS-1$ - + fImplementMethod = new ImplementMethodAction(editor); fImplementMethod.setActionDefinitionId(ICEditorActionDefinitionIds.IMPLEMENT_METHOD); editor.setAction("org.eclipse.cdt.ui.refactor.implement.method", fImplementMethod); //$NON-NLS-1$ @@ -190,14 +190,14 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange // fAddDelegateMethods= new AddDelegateMethodsAction(editor); // fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS); // editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$ -// +// // fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor); // fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS); -// editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$ +// editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$ // // fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(editor); // fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS); -// editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$ +// editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$ // // fHashCodeEquals= new GenerateHashCodeEqualsAction(editor); // fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS); @@ -206,23 +206,23 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange // fAddCppDocStub= new AddJavaDocStubAction(editor); // fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT); // editor.setAction("AddJavadocComment", fAddCppDocStub); //$NON-NLS-1$ -// +// // fCleanUp= new CleanUpAction(editor); // fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP); // editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$ -// +// // fExternalizeStrings= new ExternalizeStringsAction(editor); // fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS); -// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$ -// +// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$ +// installQuickAccessAction(); } - + /** - * Creates a new GenerateActionGroup. The group - * requires that the selection provided by the page's selection provider + * Creates a new GenerateActionGroup. The group + * requires that the selection provided by the page's selection provider * is of type org.eclipse.jface.viewers.IStructuredSelection. - * + * * @param page the page that owns this action group */ public GenerateActionGroup(Page page) { @@ -232,10 +232,10 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange } /** - * Creates a new GenerateActionGroup. The group - * requires that the selection provided by the part's selection provider + * Creates a new GenerateActionGroup. The group + * requires that the selection provided by the part's selection provider * is of type org.eclipse.jface.viewers.IStructuredSelection. - * + * * @param part the view part that owns this action group */ public GenerateActionGroup(IViewPart part) { @@ -243,7 +243,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange installQuickAccessAction(); } - + /** * Creates a new GenerateActionGroup. The group requires * that the selection provided by the given selection provider is of type @@ -259,10 +259,10 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange fSite= site; fSelectionProvider= selectionProvider == null ? fSite.getSelectionProvider() : selectionProvider; ISelection selection= fSelectionProvider.getSelection(); - + // fOverrideMethods= new OverrideMethodsAction(site); // fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS); -// +// fAddGetterSetter = new GettersAndSettersAction(); fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.GETTERS_AND_SETTERS); fAddGetterSetter.setSite(fSite); @@ -275,10 +275,10 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange // fAddDelegateMethods= new AddDelegateMethodsAction(site); // fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS); -// +// // fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site); // fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS); -// +// // fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(site); // fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS); // @@ -287,32 +287,32 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange // // fAddCppDocStub= new AddJavaDocStubAction(site); // fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT); - + fAddBookmark= new AddBookmarkAction(site, true); fAddBookmark.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_BOOKMARK); - + fAddTaskAction= new AddTaskAction(site); fAddTaskAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_TASK); - + // fExternalizeStrings= new ExternalizeStringsAction(site); // fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS); -// +// // fOrganizeIncludes= new OrganizeIncludesAction(site); // fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES); -// +// // fSortMembers= new SortMembersAction(site); // fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS); -// +// fFormatAll= new FormatAllAction(site); fFormatAll.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT); -// +// // fCleanUp= new CleanUpAction(site); // fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP); - + // fOverrideMethods.update(selection); // fAddDelegateMethods.update(selection); -// fAddUnimplementedConstructors.update(selection); +// fAddUnimplementedConstructors.update(selection); // fGenerateConstructorUsingFields.update(selection); // fHashCodeEquals.update(selection); // fAddCppDocStub.update(selection); @@ -330,7 +330,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange fAddBookmark.setEnabled(false); fAddTaskAction.setEnabled(false); } - + // registerSelectionListener(fSelectionProvider, fOverrideMethods); // registerSelectionListener(fSelectionProvider, fAddDelegateMethods); // registerSelectionListener(fSelectionProvider, fAddUnimplementedConstructors); @@ -345,11 +345,11 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange // registerSelectionListener(fSelectionProvider, fSortMembers); registerSelectionListener(fSelectionProvider, fAddTaskAction); // registerSelectionListener(fSelectionProvider, fCleanUp); - + selectionChanged(new SelectionChangedEvent(fSelectionProvider, selection)); registerSelectionListener(fSelectionProvider, this); } - + private void installQuickAccessAction() { fHandlerService= (IHandlerService)fSite.getService(IHandlerService.class); if (fHandlerService != null) { @@ -369,9 +369,9 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange provider.addSelectionChangedListener(listener); fRegisteredSelectionListeners.add(listener); } - + /* - * The state of the editor owning this action group has changed. + * The state of the editor owning this action group has changed. * This method does nothing if the group's owner isn't an * editor. */ @@ -382,7 +382,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange Assert.isTrue(isEditorOwner()); } - /* + /* * Method declared in ActionGroup */ @Override @@ -390,8 +390,8 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange super.fillActionBars(actionBar); setGlobalActionHandlers(actionBar); } - - /* + + /* * Method declared in ActionGroup */ @Override @@ -416,7 +416,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange fillViewSubMenu(menu); } } - + private int fillEditorSubMenu(IMenuManager source) { int added= 0; source.add(new Separator(GROUP_COMMENT)); @@ -475,7 +475,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange return added; } - /* + /* * Method declared in ActionGroup */ @Override @@ -493,14 +493,14 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange fEditor= null; super.dispose(); } - + private void setGlobalActionHandlers(IActionBars actionBar) { actionBar.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, fAddInclude); // actionBar.setGlobalActionHandler(CdtActionConstants.OVERRIDE_METHODS, fOverrideMethods); actionBar.setGlobalActionHandler(CdtActionConstants.GETTERS_AND_SETTERS, fAddGetterSetter); actionBar.setGlobalActionHandler(CdtActionConstants.IMPLEMENT_METHOD, fImplementMethod); // actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_DELEGATE_METHODS, fAddDelegateMethods); -// actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors); +// actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors); // actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_CONSTRUCTOR_USING_FIELDS, fGenerateConstructorUsingFields); // actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_HASHCODE_EQUALS, fHashCodeEquals); // actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CPP_DOC_COMMENT, fAddCppDocStub); @@ -517,7 +517,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange // actionBar.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction); } } - + private int addAction(IMenuManager menu, IAction action) { if (action instanceof IUpdate) ((IUpdate)action).update(); @@ -526,8 +526,8 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange return 1; } return 0; - } - + } + private int addEditorAction(IMenuManager menu, String actionID) { if (fEditor == null) return 0; @@ -542,11 +542,11 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange } return 0; } - + private boolean isEditorOwner() { return fEditor != null; } - + private ICElement getCElement(ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; @@ -565,6 +565,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange * @since 5.2 * @noreference This method is not intended to be referenced by clients. */ + @Override public void selectionChanged(SelectionChangedEvent event) { ICElement celem = getCElement(event.getSelection()); for (RefactoringAction action : fRefactorActions) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java index 09c7ca0a352..113956a90c8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java @@ -27,10 +27,11 @@ import org.eclipse.cdt.ui.newui.ManageConfigSelector; /** * Action which lets to manage (add/remove etc.) build configurations of the project. */ -public class ManageConfigsAction +public class ManageConfigsAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { - IProject[] obs = null; - + IProject[] obs = null; + + @Override public void selectionChanged(IAction action, ISelection selection) { if (!selection.isEmpty()) { // case for context menu @@ -42,18 +43,24 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { } action.setEnabled(false); } - + + @Override public void run(IAction action) { IConfigManager cm = ManageConfigSelector.getManager(obs); if (cm != null && obs != null) cm.manage(obs, true); } - + + @Override public void dispose() { obs = null; } - + // doing nothing + @Override public void init(IWorkbenchWindow window) { } + @Override public Menu getMenu(Menu parent) { return null; } + @Override public Menu getMenu(Control parent) { return null; } + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) {} } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java index 69312e509df..887b39a8577 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java @@ -13,18 +13,18 @@ package org.eclipse.cdt.ui.actions; /** - * Action Group that contributes filter buttons for a view parts showing + * Action Group that contributes filter buttons for a view parts showing * methods and fields. Contributed filters are: hide fields, hide static * members and hide non-public members. *

- * The action group installs a filter on a structured viewer. The filter is connected - * to the actions installed in the view part's toolbar menu and is updated when the + * The action group installs a filter on a structured viewer. The filter is connected + * to the actions installed in the view part's toolbar menu and is updated when the * state of the buttons changes. *

*

* This class may be instantiated; it is not intended to be subclassed. *

- * + * * @noextend This class is not intended to be subclassed by clients. */ import java.util.ArrayList; @@ -56,57 +56,57 @@ public class MemberFilterActionGroup extends ActionGroup { * @since 5.1 */ public static final int FILTER_INACTIVE= MemberFilter.FILTER_INACTIVE; - + /** @deprecated Unsupported filter constant */ @Deprecated public static final int FILTER_LOCALTYPES= MemberFilter.FILTER_LOCALTYPES; - + /** * @deprecated we may choose to add more filters in future versions. */ @Deprecated public static final int ALL_FILTERS= FILTER_NONPUBLIC | FILTER_FIELDS | FILTER_STATIC; - + private static final String TAG_HIDEFIELDS= "hidefields"; //$NON-NLS-1$ private static final String TAG_HIDESTATIC= "hidestatic"; //$NON-NLS-1$ private static final String TAG_HIDENONPUBLIC= "hidenonpublic"; //$NON-NLS-1$ private static final String TAG_HIDEINACTIVE= "hideinactive"; //$NON-NLS-1$ - + private MemberFilterAction[] fFilterActions; private MemberFilter fFilter; - + StructuredViewer fViewer; private String fViewerId; private boolean fInViewMenu; - - + + /** * Creates a new MemberFilterActionGroup. - * + * * @param viewer the viewer to be filtered - * @param viewerId a unique id of the viewer. Used as a key to to store + * @param viewerId a unique id of the viewer. Used as a key to to store * the last used filter settings in the preference store */ public MemberFilterActionGroup(StructuredViewer viewer, String viewerId) { this(viewer, viewerId, false); } - + /** * Creates a new MemberFilterActionGroup. - * + * * @param viewer the viewer to be filtered - * @param viewerId a unique id of the viewer. Used as a key to to store + * @param viewerId a unique id of the viewer. Used as a key to to store * the last used filter settings in the preference store * @param inViewMenu if true the actions are added to the view * menu. If false they are added to the toobar. - * + * * @since 2.1 */ public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu) { fViewer= viewer; fViewerId= viewerId; fInViewMenu= inViewMenu; - + // get initial values IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); boolean doHideFields= store.getBoolean(getPreferenceKey(FILTER_FIELDS)); @@ -118,73 +118,73 @@ public class MemberFilterActionGroup extends ActionGroup { if (doHideFields) fFilter.addFilter(FILTER_FIELDS); if (doHideStatic) - fFilter.addFilter(FILTER_STATIC); + fFilter.addFilter(FILTER_STATIC); if (doHidePublic) - fFilter.addFilter(FILTER_NONPUBLIC); + fFilter.addFilter(FILTER_NONPUBLIC); if (doHideInactive) fFilter.addFilter(FILTER_INACTIVE); - + // fields String title= ActionMessages.MemberFilterActionGroup_hide_fields_label; String helpContext= ICHelpContextIds.FILTER_FIELDS_ACTION; MemberFilterAction hideFields= new MemberFilterAction(this, title, FILTER_FIELDS, helpContext, doHideFields); hideFields.setDescription(ActionMessages.MemberFilterActionGroup_hide_fields_description); hideFields.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_fields_tooltip); - CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS); - + CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS); + // static title= ActionMessages.MemberFilterActionGroup_hide_static_label; helpContext= ICHelpContextIds.FILTER_STATIC_ACTION; MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, doHideStatic); hideStatic.setDescription(ActionMessages.MemberFilterActionGroup_hide_static_description); hideStatic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_static_tooltip); - CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC); - + CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC); + // non-public title= ActionMessages.MemberFilterActionGroup_hide_nonpublic_label; helpContext= ICHelpContextIds.FILTER_PUBLIC_ACTION; MemberFilterAction hideNonPublic= new MemberFilterAction(this, title, FILTER_NONPUBLIC, helpContext, doHidePublic); hideNonPublic.setDescription(ActionMessages.MemberFilterActionGroup_hide_nonpublic_description); hideNonPublic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_nonpublic_tooltip); - CPluginImages.setImageDescriptors(hideNonPublic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC); + CPluginImages.setImageDescriptors(hideNonPublic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC); // inactive title= ActionMessages.MemberFilterActionGroup_hide_inactive_label; MemberFilterAction hideInactive= new MemberFilterAction(this, title, FILTER_INACTIVE, null, doHideInactive); hideInactive.setDescription(ActionMessages.MemberFilterActionGroup_hide_inactive_description); hideInactive.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_inactive_tooltip); - CPluginImages.setImageDescriptors(hideInactive, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE); + CPluginImages.setImageDescriptors(hideInactive, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE); // order corresponds to order in toolbar fFilterActions= new MemberFilterAction[] { hideFields, hideStatic, hideNonPublic, hideInactive }; - + fViewer.addFilter(fFilter); } - + /** * Creates a new MemberFilterActionGroup. - * + * * @param viewer the viewer to be filtered - * @param viewerId a unique id of the viewer. Used as a key to to store + * @param viewerId a unique id of the viewer. Used as a key to to store * the last used filter settings in the preference store * @param inViewMenu if true the actions are added to the view * menu. If false they are added to the toobar. * @param availableFilters Specifies which filter action should be contained. {@link #FILTER_NONPUBLIC}, * {@link #FILTER_STATIC}, {@link #FILTER_FIELDS}, {@link #FILTER_INACTIVE} - * or a combination of these constants are possible values. + * or a combination of these constants are possible values. */ - public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu, int availableFilters) { - + public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu, int availableFilters) { + fViewer= viewer; fViewerId= viewerId; fInViewMenu= inViewMenu; - + IPreferenceStore store= PreferenceConstants.getPreferenceStore(); fFilter= new MemberFilter(); - + String title, helpContext; ArrayList actions= new ArrayList(4); - + // fields int filterProperty= FILTER_FIELDS; if (isSet(filterProperty, availableFilters)) { @@ -200,7 +200,7 @@ public class MemberFilterActionGroup extends ActionGroup { CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, "fields_co.gif"); //$NON-NLS-1$ actions.add(hideFields); } - + // static filterProperty= FILTER_STATIC; if (isSet(filterProperty, availableFilters)) { @@ -216,7 +216,7 @@ public class MemberFilterActionGroup extends ActionGroup { CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, "static_co.gif"); //$NON-NLS-1$ actions.add(hideStatic); } - + // non-public filterProperty= FILTER_NONPUBLIC; if (isSet(filterProperty, availableFilters)) { @@ -250,7 +250,7 @@ public class MemberFilterActionGroup extends ActionGroup { // order corresponds to order in toolbar fFilterActions= actions.toArray(new MemberFilterAction[actions.size()]); - + fViewer.addFilter(fFilter); } @@ -261,17 +261,17 @@ public class MemberFilterActionGroup extends ActionGroup { private String getPreferenceKey(int filterProperty) { return "MemberFilterActionGroup." + fViewerId + '.' + String.valueOf(filterProperty); //$NON-NLS-1$ } - + /** * Sets the member filters. - * - * @param filterProperty the filter to be manipulated. Valid values are FILTER_FIELDS, - * FILTER_PUBLIC, FILTER_PRIVATE and FILTER_INACTIVE as defined by this action + * + * @param filterProperty the filter to be manipulated. Valid values are FILTER_FIELDS, + * FILTER_PUBLIC, FILTER_PRIVATE and FILTER_INACTIVE as defined by this action * group * @param set if true the given filter is installed. If false the * given filter is removed * . - */ + */ public void setMemberFilter(int filterProperty, boolean set) { setMemberFilters(new int[] {filterProperty}, new boolean[] {set}, true); } @@ -280,7 +280,7 @@ public class MemberFilterActionGroup extends ActionGroup { if (propertyKeys.length == 0) return; Assert.isTrue(propertyKeys.length == propertyValues.length); - + for (int i= 0; i < propertyKeys.length; i++) { int filterProperty= propertyKeys[i]; boolean set= propertyValues[i]; @@ -290,7 +290,7 @@ public class MemberFilterActionGroup extends ActionGroup { fFilter.removeFilter(filterProperty); } IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); - + for (int j= 0; j < fFilterActions.length; j++) { int currProperty= fFilterActions[j].getFilterProperty(); if (currProperty == filterProperty) { @@ -302,6 +302,7 @@ public class MemberFilterActionGroup extends ActionGroup { if (refresh) { fViewer.getControl().setRedraw(false); BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable() { + @Override public void run() { fViewer.refresh(); } @@ -312,18 +313,18 @@ public class MemberFilterActionGroup extends ActionGroup { /** * Returns true if the given filter is installed. - * - * @param filterProperty the filter to be tested. Valid values are FILTER_FIELDS, - * FILTER_PUBLIC, FILTER_PRIVATE and FILTER_INACTIVE + * + * @param filterProperty the filter to be tested. Valid values are FILTER_FIELDS, + * FILTER_PUBLIC, FILTER_PRIVATE and FILTER_INACTIVE * as defined by this action group - */ + */ public boolean hasMemberFilter(int filterProperty) { return fFilter.hasFilter(filterProperty); } - + /** * Saves the state of the filter actions in a memento. - * + * * @param memento the memento to which the state is saved */ public void saveState(IMemento memento) { @@ -332,14 +333,14 @@ public class MemberFilterActionGroup extends ActionGroup { memento.putString(TAG_HIDENONPUBLIC, String.valueOf(hasMemberFilter(FILTER_NONPUBLIC))); memento.putString(TAG_HIDEINACTIVE, String.valueOf(hasMemberFilter(FILTER_INACTIVE))); } - + /** * Restores the state of the filter actions from a memento. *

* Note: This method does not refresh the viewer. *

* @param memento the memento from which the state is restored - */ + */ public void restoreState(IMemento memento) { setMemberFilters( new int[] {FILTER_FIELDS, FILTER_STATIC, FILTER_NONPUBLIC, FILTER_INACTIVE}, @@ -350,7 +351,7 @@ public class MemberFilterActionGroup extends ActionGroup { Boolean.valueOf(memento.getString(TAG_HIDEINACTIVE)).booleanValue() }, false); } - + /* (non-Javadoc) * @see ActionGroup#fillActionBars(IActionBars) */ @@ -358,10 +359,10 @@ public class MemberFilterActionGroup extends ActionGroup { public void fillActionBars(IActionBars actionBars) { contributeToToolBar(actionBars.getToolBarManager()); } - + /** * Adds the filter actions to the given tool bar - * + * * @param tbm the tool bar to which the actions are added */ public void contributeToToolBar(IToolBarManager tbm) { @@ -372,10 +373,10 @@ public class MemberFilterActionGroup extends ActionGroup { tbm.add(fFilterActions[2]); // public tbm.add(fFilterActions[3]); // inactive } - + /** * Adds the filter actions to the given menu manager. - * + * * @param menu the menu manager to which the actions are added * @since 2.1 */ @@ -395,7 +396,7 @@ public class MemberFilterActionGroup extends ActionGroup { menu.add(fFilterActions[3]); // inactive } } - + /* (non-Javadoc) * @see ActionGroup#dispose() */ @@ -404,7 +405,7 @@ public class MemberFilterActionGroup extends ActionGroup { fFilterActions= null; fFilter= null; fViewer= null; - + super.dispose(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java index 8b3e33a619a..9cb75dce926 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java @@ -11,52 +11,50 @@ package org.eclipse.cdt.ui.actions; -import org.eclipse.swt.widgets.Shell; - +import org.eclipse.core.runtime.Assert; import org.eclipse.jface.action.Action; import org.eclipse.jface.text.ITextSelection; -import org.eclipse.core.runtime.Assert; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; - +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchSite; /** - * Action that dispatches the IAction#run() and the - * ISelectionChangedListener#selectionChanged - * according to the type of the selection. - * + * Action that dispatches the IAction#run() and the + * ISelectionChangedListener#selectionChanged + * according to the type of the selection. + * *
    *
  • if selection is of type ITextSelection then * run(ITextSelection) and selectionChanged(ITextSelection) - * is called.
  • + * is called. *
  • if selection is of type IStructuredSelection then * run(IStructuredSelection) and * selectionChanged(IStructuredSelection) is called.
  • *
  • default is to call run(ISelection) and * selectionChanged(ISelection).
  • *
- * + * *

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

- * + * * @noextend This class is not intended to be subclassed by clients. * @since 2.0 */ public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener { - + private IWorkbenchSite fSite; - + /** * Creates a new action with no text and no image. *

* Configure the action later using the set methods. *

- * + * * @param site the site this action is working on */ protected SelectionDispatchAction(IWorkbenchSite site) { @@ -66,7 +64,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti /** * Returns the site owning this action. - * + * * @return the site owning this action */ public IWorkbenchSite getSite() { @@ -75,9 +73,9 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti /** * Returns the selection provided by the site owning this action. - * + * * @return the site's selection - */ + */ public ISelection getSelection() { if (getSelectionProvider() != null) return getSelectionProvider().getSelection(); @@ -86,17 +84,17 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti /** * Returns the shell provided by the site owning this action. - * - * @return the site's shell + * + * @return the site's shell */ public Shell getShell() { return fSite.getShell(); } - + /** * Returns the selection provider managed by the site owning this action. - * - * @return the site's selection provider + * + * @return the site's selection provider */ public ISelectionProvider getSelectionProvider() { return fSite.getSelectionProvider(); @@ -106,7 +104,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti * Updates the action's enablement state according to the given selection. This * default implementation calls one of the selectionChanged * methods depending on the type of the passed selection. - * + * * @param selection the selection this action is working on */ public void update(ISelection selection) { @@ -116,7 +114,7 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti /** * Notifies this action that the given structured selection has changed. This default * implementation calls selectionChanged(ISelection selection). - * + * * @param selection the new selection */ public void selectionChanged(IStructuredSelection selection) { @@ -130,17 +128,17 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti public void run(IStructuredSelection selection) { run((ISelection)selection); } - + /** * Notifies this action that the given text selection has changed. This default * implementation calls selectionChanged(ISelection selection). - * + * * @param selection the new selection */ public void selectionChanged(ITextSelection selection) { selectionChanged((ISelection)selection); } - + /** * Executes this actions with the given text selection. This default implementation * calls run(ISelection selection). @@ -148,17 +146,17 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti public void run(ITextSelection selection) { run((ISelection)selection); } - + /** * Notifies this action that the given selection has changed. This default * implementation sets the action's enablement state to false. - * + * * @param selection the new selection */ public void selectionChanged(ISelection selection) { setEnabled(false); } - + /** * Executes this actions with the given selection. This default implementation * does nothing. @@ -173,10 +171,11 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti public void run() { dispatchRun(getSelection()); } - + /* (non-Javadoc) * Method declared on ISelectionChangedListener. */ + @Override public void selectionChanged(SelectionChangedEvent event) { dispatchSelectionChanged(event.getSelection()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java index f3368aeee9f..23980bb746d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java @@ -7,7 +7,7 @@ * * Contributors: * Intel Corporation - initial API and implementation - * QNX Software Systems - [272416] Rework the config sets dialog + * QNX Software Systems - [272416] Rework the config sets dialog *******************************************************************************/ package org.eclipse.cdt.ui.actions; @@ -27,38 +27,43 @@ import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog; /** */ public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener { - private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager(); + private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager(); private boolean enabled = true; - + private IWorkbenchWindow window; - + + @Override public void run(IAction action) { new WorkingSetConfigurationDialog(window.getShell()).open(); } - + + @Override public void selectionChanged(IAction action, ISelection selection) { checkWS(); if (action.isEnabled() != enabled) action.setEnabled(enabled); } + @Override public void dispose() { wsm.removePropertyChangeListener(this); - + } + @Override public void init(IWorkbenchWindow window) { this.window = window; wsm.addPropertyChangeListener(this); checkWS(); } - + private IWorkingSet[] checkWS() { IWorkingSet[] w = wsm.getWorkingSets(); if (w == null) - w = new IWorkingSet[0]; + w = new IWorkingSet[0]; enabled = w.length > 0; return w; } + @Override public void propertyChange(PropertyChangeEvent event) { checkWS(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java index d6dbf9f6efc..271c5a2c6c9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.ui.dialogs; -import org.eclipse.cdt.internal.ui.util.SWTUtil; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.DialogPage; @@ -21,11 +20,13 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.cdt.internal.ui.util.SWTUtil; + public abstract class AbstractCOptionPage extends DialogPage implements ICOptionPage { private boolean bIsValid = true; private ICOptionContainer fContainer; - + protected Button createPushButton(Composite parent, String label, Image image) { Button button = new Button(parent, SWT.PUSH); @@ -66,10 +67,11 @@ public abstract class AbstractCOptionPage extends DialogPage implements ICOption super(title, image); } + @Override public void setContainer(ICOptionContainer container) { fContainer = container; } - + protected ICOptionContainer getContainer() { return fContainer; } @@ -77,15 +79,19 @@ public abstract class AbstractCOptionPage extends DialogPage implements ICOption protected void setValid(boolean isValid) { bIsValid = isValid; } - + + @Override public boolean isValid() { return bIsValid; } + @Override public abstract void performApply(IProgressMonitor monitor) throws CoreException; + @Override public abstract void performDefaults(); - + + @Override public abstract void createControl(Composite parent); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java index 1b63765a6f3..8edd62c37e5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java @@ -17,15 +17,6 @@ import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.ErrorParserManager; -import org.eclipse.cdt.internal.ui.CUIMessages; -import org.eclipse.cdt.internal.ui.ICHelpContextIds; -import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField; -import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; -import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; -import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IExtension; @@ -42,6 +33,17 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ErrorParserManager; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.CUIMessages; +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; + public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { private static final String PREFIX = "ErrorParserBlock"; //$NON-NLS-1$ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$ @@ -57,9 +59,10 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField) */ + @Override public void dialogFieldChanged(DialogField field) { listDirty = true; } @@ -71,7 +74,7 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { * now be handled by extending classes, use * setErrorParserIDs(boolean)/saveErrorParserIDs() to handle * getting/setting of values. - * + * * @param prefs */ @Deprecated @@ -98,7 +101,7 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { /** * Returns a label provider for the error parsers - * + * * @return the content provider */ protected ILabelProvider getLabelProvider() { @@ -106,13 +109,13 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) */ @Override public String getText(Object element) { String name = mapParsers.get(element.toString()); - return name != null ? name : element.toString(); + return name != null ? name : element.toString(); } }; } @@ -146,7 +149,7 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { /** * To be implemented, abstract method. - * + * * @param project * @return String[] */ @@ -262,17 +265,17 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.ERROR_PARSERS_PAGE); String[] buttonLabels = new String[]{ - CUIMessages.AbstractErrorParserBlock_label_up, - CUIMessages.AbstractErrorParserBlock_label_down, + CUIMessages.AbstractErrorParserBlock_label_up, + CUIMessages.AbstractErrorParserBlock_label_down, /* 2 */ null, - CUIMessages.AbstractErrorParserBlock_label_selectAll, + CUIMessages.AbstractErrorParserBlock_label_selectAll, CUIMessages.AbstractErrorParserBlock_label_unselectAll }; fErrorParserList = new CheckedListDialogField(null, buttonLabels, getLabelProvider()); fErrorParserList.setDialogFieldListener(getFieldListenerAdapter()); - fErrorParserList.setLabelText(CUIMessages.AbstractErrorParserBlock_label_errorParsers); + fErrorParserList.setLabelText(CUIMessages.AbstractErrorParserBlock_label_errorParsers); fErrorParserList.setUpButtonIndex(0); fErrorParserList.setDownButtonIndex(1); fErrorParserList.setCheckAllButtonIndex(3); @@ -291,7 +294,7 @@ public abstract class AbstractErrorParserBlock extends AbstractCOptionPage { if (monitor == null) { monitor = new NullProgressMonitor(); } - monitor.beginTask(CUIMessages.AbstractErrorParserBlock_task_setErrorParser, 1); + monitor.beginTask(CUIMessages.AbstractErrorParserBlock_task_setErrorParser, 1); List elements = fErrorParserList.getElements(); int count = elements.size(); List list = new ArrayList(count); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java index cead283cc70..32cd236102b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java @@ -58,7 +58,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor) */ @Override @@ -70,7 +70,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { String addr2line = fAddr2LineCommandText.getText().trim(); String cppfilt = fCPPFiltCommandText.getText().trim(); - monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); + monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); IProject proj = getContainer().getProject(); if (proj != null) { ICConfigExtensionReference[] cext = null; @@ -131,7 +131,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() */ @Override @@ -155,18 +155,18 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ @Override public void createControl(Composite parent) { Group comp = new Group(parent, SWT.SHADOW_ETCHED_IN); - comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); + comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); comp.setLayout(new GridLayout(2, true)); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; - - Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_addr2lineCommand); + + Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_addr2lineCommand); GridData gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); @@ -174,12 +174,13 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER); fAddr2LineCommandText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { //updateLaunchConfigurationDialog(); } }); - Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); + Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); button.addSelectionListener(new SelectionAdapter() { @Override @@ -190,7 +191,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { private void handleAddr2LineButtonSelected() { FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(CUIMessages.BinaryParserPage_label_addr2lineCommand); + dialog.setText(CUIMessages.BinaryParserPage_label_addr2lineCommand); String command = fAddr2LineCommandText.getText().trim(); int lastSeparatorIndex = command.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { @@ -204,7 +205,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { } }); - label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); + label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); @@ -214,11 +215,12 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { fCPPFiltCommandText.setLayoutData(gd); fCPPFiltCommandText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { //updateLaunchConfigurationDialog(); } }); - button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse1); + button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse1); button.addSelectionListener(new SelectionAdapter() { @Override @@ -229,7 +231,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { private void handleCPPFiltButtonSelected() { FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); + dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); String command = fCPPFiltCommandText.getText().trim(); int lastSeparatorIndex = command.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { @@ -246,7 +248,7 @@ public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { setControl(comp); initialziedValues(); } - + private void initialziedValues() { String addr2line = null; String cppfilt = null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java index 2914de9da1f..027472a435d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java @@ -53,7 +53,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField; /** * @deprecated as of CDT 4.0. This tab was used to set preferences/properties * for 3.X style projects. - * + * * @noextend This class is not intended to be subclassed by clients. */ @Deprecated @@ -113,18 +113,21 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { super(CUIPlugin.getResourceString(LABEL)); setDescription(CUIPlugin.getResourceString(DESC)); String[] buttonLabels = new String[]{ - CUIMessages.BinaryParserBlock_button_up, - CUIMessages.BinaryParserBlock_button_down}; + CUIMessages.BinaryParserBlock_button_up, + CUIMessages.BinaryParserBlock_button_down}; IListAdapter listAdapter = new IListAdapter() { + @Override public void customButtonPressed(ListDialogField field, int index) { } + @Override public void selectionChanged(ListDialogField field) { handleBinaryParserChanged(); } + @Override public void doubleClicked(ListDialogField field) { } }; @@ -139,6 +142,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { }; binaryList.setDialogFieldListener(new IDialogFieldListener() { + @Override public void dialogFieldChanged(DialogField field) { if (getContainer() != null) { getContainer().updateContainer(); @@ -146,7 +150,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { } } }); - binaryList.setLabelText(CUIMessages.BinaryParserBlock_binaryParser); + binaryList.setLabelText(CUIMessages.BinaryParserBlock_binaryParser); binaryList.setUpButtonIndex(0); binaryList.setDownButtonIndex(1); initializeParserList(); @@ -201,9 +205,9 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { binaryList.setButtonsMinWidth(buttonBarWidth); // Add the Parser UI contribution. - + Composite parserGroup = new Composite(composite, SWT.NULL); - + GridData gd = new GridData(); gd.heightHint = converter.convertHorizontalDLUsToPixels(DEFAULT_HEIGHT); gd.horizontalAlignment = GridData.FILL; @@ -222,7 +226,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { if (monitor == null) { monitor = new NullProgressMonitor(); } - monitor.beginTask(CUIMessages.BinaryParserBlock_settingBinaryParser, 2); + monitor.beginTask(CUIMessages.BinaryParserBlock_settingBinaryParser, 2); List parsers = binaryList.getElements(); final List selected = new ArrayList(); // must do this to get proper order. for (int i = 0; i < parsers.size(); i++) { @@ -233,6 +237,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { if (getContainer().getProject() != null) { ICDescriptorOperation op = new ICDescriptorOperation() { + @Override public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException { if (initialSelected == null || !selected.equals(initialSelected)) { descriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID); @@ -283,7 +288,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { if (getContainer().getProject() != null) { try { - ICConfigExtensionReference[] ref = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(getContainer().getProject()); + ICConfigExtensionReference[] ref = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(getContainer().getProject()); initialSelected = new ArrayList(ref.length); for (ICConfigExtensionReference element : ref) { if (configMap.get(element.getID()) != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java index 31d214c4621..8f3dc9501ec 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java @@ -4,8 +4,8 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: + * + * Contributors: * Intel Corporation - Initial API and implementation * Anton Leherbauer (Wind River Systems) **********************************************************************/ @@ -43,7 +43,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; /** - * This class defines a project property page + * This class defines a project property page * for C/C++ project help settings configuration * @since 2.1 * @noextend This class is not intended to be subclassed by clients. @@ -51,16 +51,16 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; public class CHelpConfigurationPropertyPage extends PropertyPage implements IWorkbenchPreferencePage { private CHelpSettingsDisplay fCHelpSettingsDisplay; - + private class CHelpBookListLabelProvider extends LabelProvider { private ImageDescriptor fHelpProviderIcon; private ImageDescriptorRegistry fRegistry; - + public CHelpBookListLabelProvider() { fRegistry= CUIPlugin.getImageDescriptorRegistry(); fHelpProviderIcon= CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY); } - + @Override public String getText(Object element) { if (element instanceof CHelpBookDescriptor) { @@ -73,56 +73,58 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements public Image getImage(Object element) { if (element instanceof CHelpBookDescriptor) { return fRegistry.get(fHelpProviderIcon); - } + } return null; } } - + private class CHelpSettingsDisplay { private CheckedListDialogField fCHelpBookList; private IProject fProject; private CHelpBookDescriptor fCHelpBookDescriptors[]; - + public CHelpSettingsDisplay() { - + String[] buttonLabels= new String[] { /* 0 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_CheckAll, /* 1 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_UncheckAll }; - + fCHelpBookList= new CheckedListDialogField(null, buttonLabels, new CHelpBookListLabelProvider()); - fCHelpBookList.setLabelText(CUIMessages.CHelpConfigurationPropertyPage_HelpBooks); + fCHelpBookList.setLabelText(CUIMessages.CHelpConfigurationPropertyPage_HelpBooks); fCHelpBookList.setCheckAllButtonIndex(0); fCHelpBookList.setUncheckAllButtonIndex(1); } - + public Control createControl(Composite parent){ PixelConverter converter= new PixelConverter(parent); - + Composite composite= new Composite(parent, SWT.NONE); - + LayoutUtil.doDefaultLayout(composite, new DialogField[] { fCHelpBookList }, true); LayoutUtil.setHorizontalGrabbing(fCHelpBookList.getListControl(null), true); int buttonBarWidth= converter.convertWidthInCharsToPixels(24); fCHelpBookList.setButtonsMinWidth(buttonBarWidth); - + return composite; } - + public void init(final IResource resource) { if(!(resource instanceof IProject)) return; fProject = (IProject)resource; fCHelpBookDescriptors = CHelpProviderManager.getDefault().getCHelpBookDescriptors(new ICHelpInvocationContext(){ + @Override public IProject getProject(){return (IProject)resource;} + @Override public ITranslationUnit getTranslationUnit(){return null;} } ); List allTopicsList= Arrays.asList(fCHelpBookDescriptors); List enabledTopicsList= getEnabledEntries(allTopicsList); - + fCHelpBookList.setElements(allTopicsList); fCHelpBookList.setCheckedElements(enabledTopicsList); } @@ -138,11 +140,11 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements } return desList; } - + public void performOk(){ List list = fCHelpBookList.getElements(); final IProject project = fProject; - + for(int i = 0; i < list.size(); i++){ Object obj = list.get(i); if(obj != null && obj instanceof CHelpBookDescriptor){ @@ -150,12 +152,14 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements } } CHelpProviderManager.getDefault().serialize(new ICHelpInvocationContext(){ + @Override public IProject getProject(){return project;} + @Override public ITranslationUnit getTranslationUnit(){return null;} }); } } - + /* (non-Javadoc) * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ @@ -184,6 +188,7 @@ public class CHelpConfigurationPropertyPage extends PropertyPage implements /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ + @Override public void init(IWorkbench workbench) { // TODO Auto-generated method stub diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java index b0424b6c4e5..4547cbf212b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java @@ -9,7 +9,7 @@ * Markus Schorn - initial API and implementation * IBM Corporation * Sergey Prigogin (Google) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.ui.dialogs; import org.eclipse.core.runtime.CoreException; @@ -40,16 +40,17 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; /** * This OptionPage is used in the IndexerPreference page to allow for adjusting * various parsing related caches. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class CacheSizeBlock extends AbstractCOptionPage { private IntegerFieldEditor fDBLimitPct; private IntegerFieldEditor fDBAbsoluteLimit; private IntegerFieldEditor fCodeReaderLimit; - + private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { + @Override + public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(FieldEditor.IS_VALID)) { updateValidState(); } @@ -68,18 +69,18 @@ public class CacheSizeBlock extends AbstractCOptionPage { Composite composite = ControlFactory.createComposite(parent, 1); gl= (GridLayout)composite.getLayout(); gl.marginWidth= 0; - + gd= (GridData) composite.getLayoutData(); gd.grabExcessHorizontalSpace= false; gd.horizontalAlignment= GridData.FILL; setControl(composite); - + Group group= ControlFactory.createGroup(composite, DialogsMessages.CacheSizeBlock_cacheLimitGroup, 1); gd= (GridData) group.getLayoutData(); gd.grabExcessHorizontalSpace= true; gd.horizontalAlignment= GridData.FILL; - + Composite cacheComp= ControlFactory.createComposite(group, 3); Label dbCacheLabel= ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_indexDatabaseCache); @@ -87,24 +88,24 @@ public class CacheSizeBlock extends AbstractCOptionPage { fDBLimitPct.setValidRange(1, 75); Text control = fDBLimitPct.getTextControl(cacheComp); LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10)); - LayoutUtil.setHorizontalGrabbing(control, false); + LayoutUtil.setHorizontalGrabbing(control, false); ControlFactory.createLabel(cacheComp, "%"); //$NON-NLS-1$ fDBAbsoluteLimit= new IntegerFieldEditor(CCorePreferenceConstants.MAX_INDEX_DB_CACHE_SIZE_MB, DialogsMessages.CacheSizeBlock_absoluteLimit, cacheComp, 4); fDBAbsoluteLimit.setValidRange(1, 10000); control = fDBAbsoluteLimit.getTextControl(cacheComp); LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10)); - LayoutUtil.setHorizontalGrabbing(control, false); + LayoutUtil.setHorizontalGrabbing(control, false); ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_MB); - + Label codeReaderLabel= ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_headerFileCache); fCodeReaderLimit= new IntegerFieldEditor(CodeReaderCache.CODE_READER_BUFFER, DialogsMessages.CacheSizeBlock_absoluteLimit, cacheComp, 4); fCodeReaderLimit.setValidRange(1, 10000); control = fCodeReaderLimit.getTextControl(cacheComp); LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10)); - LayoutUtil.setHorizontalGrabbing(control, false); + LayoutUtil.setHorizontalGrabbing(control, false); ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_MB); - + gl= (GridLayout) cacheComp.getLayout(); gl.numColumns= 3; gl.makeColumnsEqualWidth= false; @@ -158,7 +159,7 @@ public class CacheSizeBlock extends AbstractCOptionPage { fDBLimitPct.store(); fDBAbsoluteLimit.store(); fCodeReaderLimit.store(); - + // code reader cache does not listen for pref-changes, help out: ICodeReaderCache cache = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_SAVED_RESOURCES).getCodeReaderCache(); if (cache instanceof CodeReaderCache) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java index c950f5abda8..1c447d70f6c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java @@ -61,7 +61,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor) */ @Override @@ -75,7 +75,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { String cygpath = fCygPathCommandText.getText().trim(); String nm = fNMCommandText.getText().trim(); - monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); + monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); IProject proj = getContainer().getProject(); if (proj != null) { String parserID = ""; //$NON-NLS-1$ @@ -134,7 +134,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() */ @Override @@ -166,19 +166,19 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ @Override public void createControl(Composite composite) { Group comp = new Group(composite, SWT.SHADOW_ETCHED_IN); - comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); - + comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); + comp.setLayout(new GridLayout(2, true)); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; - Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_addr2lineCommand); + Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_addr2lineCommand); GridData gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); @@ -186,12 +186,13 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER); fAddr2LineCommandText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { //updateLaunchConfigurationDialog(); } }); - Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); + Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); button.addSelectionListener(new SelectionAdapter() { @Override @@ -202,7 +203,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { private void handleAddr2LineButtonSelected() { FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(CUIMessages.BinaryParserPage_label_addr2lineCommand); + dialog.setText(CUIMessages.BinaryParserPage_label_addr2lineCommand); String command = fAddr2LineCommandText.getText().trim(); int lastSeparatorIndex = command.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { @@ -216,7 +217,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { } }); - label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); + label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); @@ -226,11 +227,12 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { fCPPFiltCommandText.setLayoutData(gd); fCPPFiltCommandText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { //updateLaunchConfigurationDialog(); } }); - button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse1); + button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse1); button.addSelectionListener(new SelectionAdapter() { @Override @@ -241,7 +243,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { private void handleCPPFiltButtonSelected() { FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); + dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); String command = fCPPFiltCommandText.getText().trim(); int lastSeparatorIndex = command.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { @@ -255,7 +257,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { } }); - label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cygpathCommand); + label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cygpathCommand); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); @@ -265,11 +267,12 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { fCygPathCommandText.setLayoutData(gd); fCygPathCommandText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { //updateLaunchConfigurationDialog(); } }); - button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse2); + button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse2); button.addSelectionListener(new SelectionAdapter() { @Override @@ -280,7 +283,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { private void handleCygPathButtonSelected() { FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(CUIMessages.BinaryParserPage_label_cygpathCommand); + dialog.setText(CUIMessages.BinaryParserPage_label_cygpathCommand); String command = fCygPathCommandText.getText().trim(); int lastSeparatorIndex = command.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { @@ -295,7 +298,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { }); - label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_nmCommand); + label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_nmCommand); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); @@ -305,11 +308,12 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { fNMCommandText.setLayoutData(gd); fNMCommandText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { //updateLaunchConfigurationDialog(); } }); - button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse2); + button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse2); button.addSelectionListener(new SelectionAdapter() { @Override @@ -320,7 +324,7 @@ public class CygwinPEBinaryParserPage extends AbstractCOptionPage { private void handleCygPathButtonSelected() { FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(CUIMessages.BinaryParserPage_label_nmCommand); + dialog.setText(CUIMessages.BinaryParserPage_label_nmCommand); String command = fNMCommandText.getText().trim(); int lastSeparatorIndex = command.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java index 952448df1b9..3b6a06b8645 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java @@ -58,7 +58,7 @@ import org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage; * This IndexerBlock is used in the MakeProjectWizardOptionPage and * the NewManagedProjectOptionPage to display the indexer options during the creation of * a new project. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class IndexerBlock extends AbstractCOptionPage { @@ -72,7 +72,7 @@ public class IndexerBlock extends AbstractCOptionPage { private static final String INDEXER_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.label" ); //$NON-NLS-1$ private static final String INDEXER_DESCRIPTION = CUIPlugin.getResourceString("BaseIndexerBlock.desc"); //$NON-NLS-1$ - + private PreferenceScopeBlock fPrefScopeBlock; private Button fEnableIndexer; private Combo fIndexersComboBox; @@ -89,18 +89,18 @@ public class IndexerBlock extends AbstractCOptionPage { private ControlEnableState fEnableState; private Group fBuildConfigGroup; private int fLastScope; - + public IndexerBlock(){ super(INDEXER_LABEL); setDescription(INDEXER_DESCRIPTION); initializeIndexerConfigMap(); } - + @Override public boolean isValid() { return super.isValid() && (fCurrentPage == null || fCurrentPage.isValid()); } - + @Override public String getErrorMessage() { String msg = super.getErrorMessage(); @@ -139,22 +139,24 @@ public class IndexerBlock extends AbstractCOptionPage { } return fPage; } - + public String getName() { if (fElement == null) - return NULL; - return fElement.getAttribute(ATTRIB_NAME); + return NULL; + return fElement.getAttribute(ATTRIB_NAME); } - + + @Override public String getLocalId() { if (fElement == null) - return NULL; + return NULL; return fElement.getAttribute(ATTRIB_ID); } + @Override public String getPluginId() { if (fElement == null) - return NULL; + return NULL; return fElement.getContributor().getName(); } } @@ -166,11 +168,11 @@ public class IndexerBlock extends AbstractCOptionPage { Composite composite = ControlFactory.createComposite(parent, 1); GridLayout layout= ((GridLayout)composite.getLayout()); layout.marginWidth= 0; - + GridData gd= (GridData) composite.getLayoutData(); gd.grabExcessHorizontalSpace= true; setControl(composite); - + if (getProject() != null || getContainer() instanceof ICOptionContainerExtension) { fPrefScopeBlock= new PreferenceScopeBlock(PREF_PAGE_ID) { @Override @@ -179,14 +181,14 @@ public class IndexerBlock extends AbstractCOptionPage { } }; fPrefScopeBlock.createControl(composite); - } + } fPreferenceContent= ControlFactory.createComposite(composite, 1); layout= (GridLayout)fPreferenceContent.getLayout(); layout.marginHeight= 0; layout.marginWidth= 0; gd= (GridData) fPreferenceContent.getLayoutData(); - gd.horizontalIndent= 0; + gd.horizontalIndent= 0; // add option to enable indexer final SelectionAdapter indexerChangeListener = new SelectionAdapter() { @@ -229,7 +231,7 @@ public class IndexerBlock extends AbstractCOptionPage { fUseActiveBuildButton.addSelectionListener(listener); fUseFixedBuildConfig.addSelectionListener(listener); } - + initializeScope(); initializeIndexerCombo(); initializeBuildConfigs(); @@ -245,13 +247,13 @@ public class IndexerBlock extends AbstractCOptionPage { if (prj != null) { if (IndexerPreferencePage.showBuildConfiguration()) { ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager(); - if (prjDescMgr.isNewStyleProject(prj)) + if (prjDescMgr.isNewStyleProject(prj)) return true; } } return false; } - + private void updateBuildConfigForScope(int scope) { if (fBuildConfigComboBox != null) { if (scope == IndexerPreferences.SCOPE_INSTANCE) { @@ -263,12 +265,12 @@ public class IndexerBlock extends AbstractCOptionPage { } updateBuildConfigEnablement(scope); } - } - + } + void updateBuildConfigEnablement(int scope) { if (fBuildConfigGroup == null) return; - + if (!fEnableIndexer.getSelection()) { ControlEnableState.disable(fBuildConfigGroup); } else { @@ -281,7 +283,7 @@ public class IndexerBlock extends AbstractCOptionPage { fBuildConfigGroup.setEnabled(notDerived || fixed); } } - + protected void setUseActiveBuildConfig(boolean useActive) { if (fBuildConfigComboBox != null) { if (useActive) { @@ -314,7 +316,7 @@ public class IndexerBlock extends AbstractCOptionPage { if (fPrefScopeBlock == null) { return; } - + int scope= proj == null ? IndexerPreferences.SCOPE_INSTANCE : IndexerPreferences.getScope(proj); switch(scope) { case IndexerPreferences.SCOPE_PROJECT_PRIVATE: @@ -379,11 +381,11 @@ public class IndexerBlock extends AbstractCOptionPage { } fBuildConfigComboBox.select(selectedIndex); } - + protected void onPreferenceScopeChange() { int scope= computeScope(); if (fCurrentProperties == null || scope == IndexerPreferences.SCOPE_INSTANCE - || (fLastScope == IndexerPreferences.SCOPE_INSTANCE + || (fLastScope == IndexerPreferences.SCOPE_INSTANCE && scope == IndexerPreferences.SCOPE_PROJECT_SHARED)) { Properties props= IndexerPreferences.getProperties(getProject(), scope); @@ -449,7 +451,7 @@ public class IndexerBlock extends AbstractCOptionPage { } return IndexerPreferences.SCOPE_INSTANCE; } - + private void setPage() { String indexerID= getSelectedIndexerID(); AbstractIndexerPage page = getIndexerPage(indexerID); @@ -461,16 +463,16 @@ public class IndexerBlock extends AbstractCOptionPage { fParent.layout(true); } } - + if (fCurrentPage != null){ fCurrentPage.setVisible(false); } - + if (page != null) { page.setProperties(fCurrentProperties); page.setVisible(true); } - + fCurrentPage= page; } @@ -478,11 +480,11 @@ public class IndexerBlock extends AbstractCOptionPage { * Adds all the contributed Indexer Pages to a map */ private void initializeIndexerConfigMap() { - fIndexerConfigMap = new HashMap(5); + fIndexerConfigMap = new HashMap(5); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.getPluginId(), "IndexerPage"); //$NON-NLS-1$ IConfigurationElement[] infos = extensionPoint.getConfigurationElements(); for (final IConfigurationElement info : infos) { - if (info.getName().equals(NODE_INDEXERUI)) { + if (info.getName().equals(NODE_INDEXERUI)) { final String id = info.getAttribute(ATTRIB_INDEXERID); if (id != null) { IndexerConfig config= new IndexerConfig(info); @@ -494,7 +496,7 @@ public class IndexerBlock extends AbstractCOptionPage { } fIndexerConfigMap.put(IPDOMManager.ID_NO_INDEXER, new IndexerConfig(new NullIndexerBlock())); } - + private String getIndexerName(String indexerID) { IndexerConfig configElement= fIndexerConfigMap.get(indexerID); if (configElement != null) { @@ -514,7 +516,7 @@ public class IndexerBlock extends AbstractCOptionPage { } return null; } - + @Override public void performApply(IProgressMonitor monitor) throws CoreException { int scope= computeScope(); @@ -535,11 +537,11 @@ public class IndexerBlock extends AbstractCOptionPage { } IndexerPreferences.setProperties(project, scope, props); } - + if (project != null) { IndexerPreferences.setScope(project, scope); } - + if (fBuildConfigComboBox != null) { boolean useActive= fUseActiveBuildButton.getSelection(); ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager(); @@ -597,7 +599,7 @@ public class IndexerBlock extends AbstractCOptionPage { } return IPDOMManager.ID_NO_INDEXER; } - + public IProject getProject() { ICOptionContainer container = getContainer(); if (container != null){ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java index 7b34bbbd8e9..9295a7bb229 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java @@ -46,8 +46,8 @@ public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionC composite.setLayout(new GridLayout()); optionPage.createControl(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INDEXER_PROPERTIES); - + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INDEXER_PROPERTIES); + return composite; } @@ -55,7 +55,7 @@ public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionC protected void performDefaults() { optionPage.performDefaults(); } - + @Override public boolean performOk() { try { @@ -65,7 +65,8 @@ public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionC } return true; } - + + @Override public IProject getProject(){ IProject project= null; IAdaptable elem = getElement(); @@ -77,12 +78,14 @@ public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionC return project; } + @Override public void updateContainer() { } - + /** * @deprecated */ + @Override @Deprecated public org.eclipse.core.runtime.Preferences getPreferences() { throw new UnsupportedOperationException(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java index 142fab98aca..7e7035f0973 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java @@ -65,7 +65,7 @@ public class InputStatusDialog extends StatusDialog { *

* Note that the open method blocks for input dialogs. *

- * + * * @param parentShell * the parent shell, or null to create a top-level * shell @@ -116,7 +116,7 @@ public class InputStatusDialog extends StatusDialog { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ @Override @@ -142,6 +142,7 @@ public class InputStatusDialog extends StatusDialog { text = new Text(composite, getInputTextStyle()); text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); text.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { validateInput(); } @@ -159,7 +160,7 @@ public class InputStatusDialog extends StatusDialog { /** * Returns the text area. - * + * * @return the text area */ protected Text getText() { @@ -168,7 +169,7 @@ public class InputStatusDialog extends StatusDialog { /** * Returns the validator. - * + * * @return the validator */ protected IInputStatusValidator getValidator() { @@ -177,7 +178,7 @@ public class InputStatusDialog extends StatusDialog { /** * Returns the string typed into this input dialog. - * + * * @return the input string */ public String getValue() { @@ -203,9 +204,9 @@ public class InputStatusDialog extends StatusDialog { /** * Returns the style bits that should be used for the input text field. Defaults to a single line entry. * Subclasses may override. - * + * * @return the integer style bits that should be used when creating the input text - * + * */ protected int getInputTextStyle() { return SWT.SINGLE | SWT.BORDER; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java index 31e2dcdcd7b..11991096361 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java @@ -55,7 +55,7 @@ public class MachOBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor) */ @Override @@ -66,7 +66,7 @@ public class MachOBinaryParserPage extends AbstractCOptionPage { String cppfilt = fCPPFiltCommandText.getText().trim(); - monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); + monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); IProject proj = getContainer().getProject(); if (proj != null) { String parserID = ""; //$NON-NLS-1$ @@ -119,7 +119,7 @@ public class MachOBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() */ @Override @@ -139,18 +139,18 @@ public class MachOBinaryParserPage extends AbstractCOptionPage { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ @Override public void createControl(Composite parent) { Group comp = new Group(parent, SWT.SHADOW_ETCHED_IN); - comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); + comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); comp.setLayout(new GridLayout(2, true)); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; - - Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); + + Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); GridData gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); @@ -160,11 +160,12 @@ public class MachOBinaryParserPage extends AbstractCOptionPage { fCPPFiltCommandText.setLayoutData(gd); fCPPFiltCommandText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { //updateLaunchConfigurationDialog(); } }); - Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); + Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); button.addSelectionListener(new SelectionAdapter() { @Override @@ -175,7 +176,7 @@ public class MachOBinaryParserPage extends AbstractCOptionPage { private void handleCPPFiltButtonSelected() { FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); + dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); String command = fCPPFiltCommandText.getText().trim(); int lastSeparatorIndex = command.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { @@ -192,7 +193,7 @@ public class MachOBinaryParserPage extends AbstractCOptionPage { setControl(comp); initialziedValues(); } - + private void initialziedValues() { String cppfilt = null; IProject proj = getContainer().getProject(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java index 3b0cb51e780..62505a1fe5e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java @@ -239,6 +239,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage { link.setText(DialogsMessages.RegexErrorParserOptionPage_LinkToPreferencesMessage); link.addListener(SWT.Selection, new Listener() { + @Override public void handleEvent(Event event) { // Use event.text to tell which link was used PreferencesUtil.createPreferenceDialogOn(parent.getShell(), WORKSPACE_PREFERENCE_PAGE, null, null).open(); @@ -722,7 +723,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage { fTableViewer.insert(item, newPos); fTable.setSelection(newPos); } - + private void applyPatterns() { if (fErrorParser!=null && fEditable) { fErrorParser.clearPatterns(); @@ -768,7 +769,7 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage { public void removeListener(Listener listener){ fListeners.remove(listener); } - + private void fireEvent() { for (Listener listener : fListeners) { listener.handleEvent(new Event()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java index 3d67b9fd06e..6f1b455a008 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java @@ -25,11 +25,12 @@ import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; /** * Input Dialog for validating regular expression syntax. - * + * * @since 5.2 */ public class RegularExpressionStatusDialog extends InputStatusDialog { private static final IInputStatusValidator fValidator = new IInputStatusValidator() { + @Override public IStatus isValid(String newText) { StatusInfo status = new StatusInfo(); if (newText.length() == 0) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java index 219fa1684ee..c5fd8627209 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java @@ -64,15 +64,15 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { // protected boolean showBI = false; // boolean savedShowBI = false; // List incs; - - public static final Image IMG_FS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM); - public static final Image IMG_WS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE); + + public static final Image IMG_FS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM); + public static final Image IMG_WS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE); public static final Image IMG_MK = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO); - private static final String ALL = Messages.AbstractExportTab_0; - private static final String LIST = Messages.AbstractExportTab_1; + private static final String ALL = Messages.AbstractExportTab_0; + private static final String LIST = Messages.AbstractExportTab_1; private static Map names_l = new HashMap(); private static Map names_t = new HashMap(); - private static String[] names_ls; + private static String[] names_ls; private static String[] names_ts; private List namesList; @@ -90,9 +90,9 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { names_t.put(ct.getName(), ct.getId()); names_ts[i] = ct.getName(); } - + } - + @Override public void createControls(Composite parent) { super.createControls(parent); @@ -107,15 +107,18 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { tv = new TableViewer(table); tv.setContentProvider(new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { return (Object[])inputElement; } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); - + tv.setLabelProvider(new RichLabelProvider()); - + table.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -129,22 +132,22 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { }); TableColumn c = new TableColumn(table, SWT.NONE); c.setWidth(hasValues() ? 100 : 200); - c.setText(Messages.EnvDialog_0); + c.setText(Messages.EnvDialog_0); c = new TableColumn(table, SWT.NONE); c.setWidth(hasValues() ? 100 : 0); - c.setText(Messages.EnvDialog_1); + c.setText(Messages.EnvDialog_1); c = new TableColumn(table, SWT.NONE); c.setWidth(100); - c.setText(Messages.LanguagesTab_1); + c.setText(Messages.LanguagesTab_1); c = new TableColumn(table, SWT.NONE); c.setWidth(100); - c.setText(Messages.LanguagesTab_0); - + c.setText(Messages.LanguagesTab_0); + initButtons(new String[] {ADD_STR, EDIT_STR, DEL_STR}); updateData(getResDesc()); } - - + + /** * Updates state of add/edit/delete buttons * Called when table selection changes. @@ -162,15 +165,15 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { buttonSetEnabled(1, x); buttonSetEnabled(2, y); } - + /* - * Methods to be implemented in descendants + * Methods to be implemented in descendants */ public abstract int getKind(); public abstract ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp); public abstract ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp); public abstract boolean hasValues(); - + /** * Called when item added/edited/removed or Tab is changed. * Refreshes whole table contents @@ -178,7 +181,7 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { protected void update() { int x = table.getSelectionIndex(); if (x == -1) x = 0; - + namesList = new ArrayList(); ArrayList lst = new ArrayList(); ICExternalSetting[] vals = cfg.getExternalSettings(); @@ -231,18 +234,18 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { switch (i) { case 0: // add dlg = new ExpDialog(usercomp.getShell(), true, - Messages.AbstractExportTab_2, EMPTY_STR, EMPTY_STR, cfg, - null, null, getKind(), names_ls, names_ts, namesList, false); + Messages.AbstractExportTab_2, EMPTY_STR, EMPTY_STR, cfg, + null, null, getKind(), names_ls, names_ts, namesList, false); if (dlg.open()) { ent[0] = doAdd(dlg.text1.trim(), dlg.text2.trim(), dlg.check2); if (ent[0] != null) if (dlg.check1) { // apply to all ? ICConfigurationDescription[] cfgs = page.getCfgsEditable(); for (ICConfigurationDescription cfg2 : cfgs) - cfg2.createExternalSetting(name2id(dlg.sel_langs, names_l), + cfg2.createExternalSetting(name2id(dlg.sel_langs, names_l), name2id(dlg.sel_types, names_t), null, ent); } else { - cfg.createExternalSetting(name2id(dlg.sel_langs, names_l), + cfg.createExternalSetting(name2id(dlg.sel_langs, names_l), name2id(dlg.sel_types, names_t), null, ent); } update(); @@ -256,19 +259,19 @@ public abstract class AbstractExportTab extends AbstractCPropertyTab { if (getKind() == ICSettingEntry.MACRO) { s1 = old.getName(); s2 = old.getValue(); - } else + } else s1 = s2 = old.getName(); boolean isWsp = (old.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0; dlg = new ExpDialog(usercomp.getShell(), false, - Messages.AbstractExportTab_3, s1, s2, cfg, + Messages.AbstractExportTab_3, s1, s2, cfg, id2name(old.setting.getCompatibleLanguageIds(), names_l), id2name(old.setting.getCompatibleContentTypeIds(), names_t), - getKind(), names_ls, names_ts, null, isWsp); + getKind(), names_ls, names_ts, null, isWsp); if (dlg.open()) { ent[0] = doEdit(dlg.text1.trim(), dlg.text2.trim(), dlg.check2); ICSettingEntry[] ls = old.setting.getEntries(); ICSettingEntry[] ls2 = new ICLanguageSettingEntry[ls.length]; - for (int x=0; x lst = new ArrayList(); -outer: - for (ICSettingEntry se : ls) { +outer: + for (ICSettingEntry se : ls) { for (int y=t; y ... -> Configuration#setSourceEntries(...) -> Configuration#exportArtifactInfo() try { cfg.setSourceEntries(cfg.getSourceEntries()); @@ -372,11 +375,12 @@ outer: public Image getImage(Object element) { return getColumnImage(element, 0); } + @Override public Image getColumnImage(Object element, int columnIndex) { if (columnIndex > 0) return null; ExtData data = (ExtData)element; if (data.entry.getKind() == ICSettingEntry.MACRO) - return IMG_MK; + return IMG_MK; if ((data.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0) return IMG_WS; return IMG_FS; @@ -385,6 +389,7 @@ outer: public String getText(Object element) { return getColumnText(element, 0); } + @Override public String getColumnText(Object element, int columnIndex) { ExtData data = (ExtData)element; switch (columnIndex) { @@ -400,7 +405,8 @@ outer: return EMPTY_STR; } } - + + @Override public Font getFont(Object element) { ExtData data = (ExtData)element; if (data.entry.isBuiltIn()) return null; // built in @@ -412,7 +418,7 @@ outer: @Override public boolean canBeVisible() { - if (! page.isForProject() ) + if (! page.isForProject() ) return false; return true; } @@ -423,20 +429,20 @@ outer: static class ExtData { ICExternalSetting setting; ICSettingEntry entry; - + ExtData(ICExternalSetting _s, ICSettingEntry _e) { setting = _s; entry = _e; } - protected String getName() { - return entry.getName(); + protected String getName() { + return entry.getName(); } protected String getValue() { - if (entry.getKind() == ICSettingEntry.MACRO) + if (entry.getKind() == ICSettingEntry.MACRO) return entry.getValue(); return EMPTY_STR; - } - protected String getLangStr() { + } + protected String getLangStr() { return getLabel(setting.getCompatibleLanguageIds(), names_l); } protected String getTypeStr() { @@ -447,7 +453,7 @@ outer: return getName(); } } - + static protected String getLabel(String[] lst, Map names) { if (lst == null || lst.length == 0) return ALL; if (lst.length > 1) return LIST; @@ -468,6 +474,6 @@ outer: static public Image getWspImage(boolean isWsp) { return isWsp ? AbstractExportTab.IMG_WS : AbstractExportTab.IMG_FS; } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java index 8c3ca850333..3dde6555933 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java @@ -159,6 +159,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { sashForm.setWeights(DEFAULT_SASH_WEIGHTS); sashForm.addListener(SWT.Selection, new Listener() { + @Override public void handleEvent(Event event) { if (event.detail == SWT.DRAG) return; @@ -175,10 +176,13 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { tv = new TableViewer(table); tv.setContentProvider(new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { return (Object[])inputElement; } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); @@ -198,9 +202,11 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { }); table.addControlListener(new ControlListener() { + @Override public void controlMoved(ControlEvent e) { setColumnToFit(); } + @Override public void controlResized(ControlEvent e) { setColumnToFit(); }}); @@ -216,6 +222,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { stringListModeControl = new StringListModeControl(page, usercomp, 1); stringListModeControl.addListener(SWT.Selection, new Listener() { + @Override public void handleEvent(Event event) { update(); } @@ -298,6 +305,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { } }); langTree.addPaintListener(new PaintListener() { + @Override public void paintControl(PaintEvent e) { int x = langTree.getBounds().width - 5; if (langCol.getWidth() != x) @@ -696,6 +704,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { public Image getImage(Object element) { return getColumnImage(element, 0); } + @Override public Image getColumnImage(Object element, int columnIndex) { if (columnIndex > 0) return null; if (! (element instanceof ICLanguageSettingEntry)) return null; @@ -723,6 +732,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { public String getText(Object element) { return getColumnText(element, 0); } + @Override public String getColumnText(Object element, int columnIndex) { if (! (element instanceof ICLanguageSettingEntry)) { return (columnIndex == 0) ? element.toString() : EMPTY_STR; @@ -742,6 +752,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab { return EMPTY_STR; } + @Override public Font getFont(Object element) { if (! (element instanceof ICLanguageSettingEntry)) return null; ICLanguageSettingEntry le = (ICLanguageSettingEntry) element; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index 31afc4191f8..61270ae07d4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -101,27 +101,27 @@ import org.eclipse.cdt.internal.ui.newui.Messages; /** * It is a parent for all standard CDT property pages - * in new CDT model. - * + * in new CDT model. + * * Although it is enough for new page to implement * "IWorkbenchPropertyPage" interface, it would be * better to extend it from "AbstractPage". - * + * * In this case, we'll able to use: * - dynamic tabs support via cPropertyTab extension point * - a lot of utility methods: see ICPropertyProvider interface * - mechanism of messages sent to all pages and all tabs in them - * + * * In fact, descendants of AbstractPage have to implement * the only method: - * protected boolean isSingle(); + * protected boolean isSingle(); * It it returns false, current page can contain multiple tabs * (obtained through "cPropertyTab" extension point). * If it returns true, only one content tab is possible. If * more than 1 tabs refer to this pas as a parent, only 1st - * one would be taken into account, others will be ignored. + * one would be taken into account, others will be ignored. */ -public abstract class AbstractPage extends PropertyPage +public abstract class AbstractPage extends PropertyPage implements IPreferencePageContainer, // dynamic pages ICPropertyProvider // utility methods for tabs @@ -143,13 +143,13 @@ implements private static final Object NOT_NULL = new Object(); public static final String EMPTY_STR = ""; //$NON-NLS-1$ - + private static final int SAVE_MODE_OK = 1; private static final int SAVE_MODE_APPLY = 2; private static final int SAVE_MODE_APPLYOK = 3; - + private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$ - + private Map loadedIcons = new HashMap(); private static Map, Class> recentTabs = new HashMap, Class>(); @@ -174,21 +174,21 @@ implements protected boolean isProject = false; protected boolean isFolder = false; protected boolean isFile = false; - + // tabs protected TabFolder folder; protected ArrayList itabs = new ArrayList(); protected ICPropertyTab currentTab; private static boolean isNewOpening = true; - + protected class InternalTab { Composite comp; String text; String tip; Image image; ICPropertyTab tab; - + InternalTab(Composite _comp, String _text, Image _image, ICPropertyTab _tab, String _tip) { comp = _comp; text = _text; @@ -210,7 +210,7 @@ implements return null; } } - + /** * Default constructor */ @@ -221,7 +221,7 @@ implements multiCfgs = null; } } - + @Override protected Control createContents(Composite parent) { // Create the container we return to the property page editor @@ -235,18 +235,18 @@ implements String s = null; if (!checkElement()) { - s = Messages.AbstractPage_0; + s = Messages.AbstractPage_0; } else if (!isApplicable()) { return null; } else if (!isCDTProject(getProject())) { - s = Messages.AbstractPage_2; + s = Messages.AbstractPage_2; } - + if (s == null) { contentForCDT(composite); return composite; } - + // no contents Label label = new Label(composite, SWT.LEFT); label.setText(s); @@ -255,7 +255,7 @@ implements noDefaultAndApplyButton(); return composite; } - + protected void contentForCDT(Composite composite) { GridData gd; @@ -269,11 +269,12 @@ implements configGroup.setLayout(new GridLayout(3, false)); Label configLabel = new Label(configGroup, SWT.NONE); - configLabel.setText(Messages.AbstractPage_6); + configLabel.setText(Messages.AbstractPage_6); configLabel.setLayoutData(new GridData(GridData.BEGINNING)); configSelector = new Combo(configGroup, SWT.READ_ONLY | SWT.DROP_DOWN); configSelector.addListener(SWT.Selection, new Listener() { + @Override public void handleEvent(Event e) { handleConfigSelection(); } @@ -283,7 +284,7 @@ implements if (!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG)) { manageButton = new Button(configGroup, SWT.PUSH); - manageButton.setText(Messages.AbstractPage_12); + manageButton.setText(Messages.AbstractPage_12); gd = new GridData(GridData.END); gd.minimumWidth = 150; manageButton.setLayoutData(gd); @@ -294,7 +295,7 @@ implements IConfigManager cm = ManageConfigSelector.getManager(obs); if (cm != null && cm.manage(obs, false)) { cfgDescs = null; - populateConfigurations(); + populateConfigurations(); } } }); @@ -322,7 +323,7 @@ implements if (isForFolder() || isForFile()) { excludeFromBuildCheck = new Button(configGroup, SWT.CHECK); - excludeFromBuildCheck.setText(Messages.AbstractPage_7); + excludeFromBuildCheck.setText(Messages.AbstractPage_7); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; excludeFromBuildCheck.setLayoutData(gd); @@ -353,16 +354,16 @@ implements parentComposite = new Composite(c, SWT.NONE); parentComposite.setLayoutData(gd= new GridData(GridData.FILL_BOTH)); gd.widthHint= 800; - itabs.clear(); + itabs.clear(); if (!isSingle()) { parentComposite.setLayout(new FillLayout()); folder = new TabFolder(parentComposite, SWT.NONE); // folder.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY)); } loadExtensionsSynchronized(parentComposite); - + // Set listener after data load, to avoid firing - // selection event on not-initialized tab items + // selection event on not-initialized tab items if (folder != null) { folder.addSelectionListener(new SelectionAdapter() { @Override @@ -390,22 +391,23 @@ implements } } } - + private void updateSelectedTab() { ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData(); if (newTab != null && currentTab != newTab) { recentTabs.put(getClass(), newTab.getClass()); - if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null); + if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null); currentTab = newTab; currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL); } } /** - * + * */ + @Override public IProject getProject() { Object element = getElement(); - if (element != null) { + if (element != null) { if (element instanceof IFile || element instanceof IProject || element instanceof IFolder) @@ -453,7 +455,7 @@ implements } multiCfgs = mcfgs; } - + } lastSelectedCfg = null; @@ -461,7 +463,7 @@ implements return; } multiCfgs = null; - + String id1 = getResDesc() == null ? null : getResDesc().getId(); lastSelectedCfg = cfgDescs[selectionIndex]; String id2 = lastSelectedCfg.getId(); @@ -473,7 +475,7 @@ implements /** * Find index of configuration description in the internal array of * configuration descriptions. - * + * * @param cfgd * @return index of found configuration description or index of active * configuration. @@ -495,13 +497,13 @@ implements /** * Find index of active configuration description in the internal array of * configuration descriptions. - * + * * @return index of active configuration description. */ private static int getActiveCfgIndex() { return getCfgIndex(null); } - + /** * Check if all configuration descriptions are present in the internal array of * configuration descriptions. @@ -510,7 +512,7 @@ implements */ private static boolean areCfgsStillThere(ICConfigurationDescription[] cfgs) { if (cfgs==null || cfgDescs==null) return false; - + for (ICConfigurationDescription multiCfg : cfgs) { boolean foundOne = false; for (ICConfigurationDescription cfgDesc : cfgDescs) { @@ -525,13 +527,13 @@ implements } return true; } - + @Override public boolean performCancel() { if (! noContentOnPage && displayedConfig) forEach(ICPropertyTab.CANCEL); - + CDTPropertyManager.performCancel(this); - + return true; } @Override @@ -540,17 +542,17 @@ implements } @Override public void performApply() { performSave(SAVE_MODE_APPLY); } - + /** * There are 2 ways to perform OK for CDT property pages. - * 1st (default): + * 1st (default): * All pages use the same editable copy of ICProjectDescription. * When OK occurs, this object is simply set. - * - * 2nd: + * + * 2nd: * When OK occurs, each page must copy its data to new instance * of ICProjectDescription, like it occurs during Apply event. - * It allows to avoid collisions with other property pages, + * It allows to avoid collisions with other property pages, * which do not share ICProjectDescription instance. * But some changes may be saved wrong if they are affected * by data from another property pages (Discovery options etc). @@ -558,25 +560,25 @@ implements * To enable 2nd mode, just create the following file: * /.metadata/.plugins/org.eclipse.cdt.ui/apply_mode */ - + @Override public boolean performOk() { File f = CUIPlugin.getDefault().getStateLocation().append("apply_mode").toFile(); //$NON-NLS-1$ - if (f.exists()) + if (f.exists()) return performSave(SAVE_MODE_APPLYOK); - return performSave(SAVE_MODE_OK); - + return performSave(SAVE_MODE_OK); + } /** * Searches in the prj for the config description with the same ID as for given cfg. * If there's no such cfgd, it will be created. - * + * * @param prj - project description where we'll search (or create) config description - * @param cfg - config description belonging to another project description, + * @param cfg - config description belonging to another project description, * it is a sample for search and base for possile creation * of resulting configuration description. - * + * * @return the configuration description (found or created) or null in case of error */ private ICConfigurationDescription findCfg(ICProjectDescription prj, ICConfigurationDescription cfg) { @@ -588,33 +590,33 @@ implements try { c = prj.createConfiguration(id, cfg.getName(), cfg); c.setDescription(cfg.getDescription()); - } catch (CoreException e) { - /* do nothing: c is already null */ + } catch (CoreException e) { + /* do nothing: c is already null */ } } // if creation failed, report an error and return null if (c == null) { MessageBox mb = new MessageBox(getShell()); - mb.setMessage(Messages.AbstractPage_3); + mb.setMessage(Messages.AbstractPage_3); mb.open(); } return c; } - + /** - * The same code used to perform OK and Apply + * The same code used to perform OK and Apply */ private boolean performSave(int mode) { final int finalMode = mode; if (noContentOnPage || !displayedConfig) return true; if ((mode == SAVE_MODE_OK || mode == SAVE_MODE_APPLYOK) && CDTPropertyManager.isSaveDone()) return true; // do not duplicate - + final boolean needs = (mode != SAVE_MODE_OK); final ICProjectDescription local_prjd = needs ? CoreModel.getDefault().getProjectDescription(getProject()) : null; - + ICResourceDescription lc = null; - - if (needs) { + + if (needs) { if (isMultiCfg()) { ICResourceDescription[] rds = (ICResourceDescription[])((ICMultiItemsHolder)resd).getItems(); for (int i=0; i 1) { - configSelector.add(Messages.AbstractPage_4); + configSelector.add(Messages.AbstractPage_4); if (multiCfgs == cfgDescs) { cfgIndex = cfgDescs.length; } } // "Multi cfgs" - shown if at least 3 cfgs available if (cfgDescs.length > 2) { - configSelector.add(Messages.AbstractPage_5); + configSelector.add(Messages.AbstractPage_5); if (multiCfgs != null && multiCfgs != cfgDescs) { cfgIndex = cfgDescs.length + 1; } @@ -800,9 +803,13 @@ implements handleConfigSelection(); } + @Override public void updateButtons() {} + @Override public void updateMessage() { } + @Override public void updateTitle() { } + @Override public void updateContainer() { } @Override @@ -810,7 +817,7 @@ implements updateContainer(); return super.isValid(); } - + @Override public void setVisible(boolean visible) { super.setVisible(visible); @@ -823,7 +830,7 @@ implements } if (itabs.size() < 1) return; - + if (currentTab == null && folder.getItemCount() > 0) { Object ob = folder.getItem(0).getData(); currentTab = (ICPropertyTab)ob; @@ -831,20 +838,20 @@ implements if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, visible ? NOT_NULL : null); } - + protected void handleResize(boolean visible) { if (visible && !isNewOpening) return; // do not duplicate - if (visible) + if (visible) isNewOpening = false; - + int saveMode = CDTPrefUtil.getInt(CDTPrefUtil.KEY_POSSAVE); if (saveMode == CDTPrefUtil.POSITION_SAVE_NONE) return; - - if (internalElement == null && !checkElement()) + + if (internalElement == null && !checkElement()) return; // not initialized. Do not process IProject prj = getProject(); - if (prj == null) - return; // preferences. Do not process. + if (prj == null) + return; // preferences. Do not process. QualifiedName WIDTH = new QualifiedName(prj.getName(),".property.page.width"); //$NON-NLS-1$ QualifiedName HEIGHT = new QualifiedName(prj.getName(),".property.page.height"); //$NON-NLS-1$ QualifiedName XKEY = new QualifiedName(prj.getName(),".property.page.x"); //$NON-NLS-1$ @@ -880,22 +887,25 @@ implements /** * @deprecated, use {@link #getPreferenceStore()}, instead. */ + @Override @Deprecated public org.eclipse.core.runtime.Preferences getPreferences() { return CUIPlugin.getDefault().getPluginPreferences(); } - + + @Override public void enableConfigSelection (boolean enable) { if (configSelector != null) configSelector.setEnabled(enable); if (manageButton != null) manageButton.setEnabled(enable); } - + /** * Returns configuration descriptions for given project */ + @Override public ICConfigurationDescription[] getCfgsReadOnly(IProject p) { - ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); - if (prjd != null) + ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); + if (prjd != null) return prjd.getConfigurations(); return null; } @@ -903,26 +913,29 @@ implements /** * Returns loaded configuration descriptions for current project */ + @Override public ICConfigurationDescription[] getCfgsEditable() { return cfgDescs; } - + /** Checks whether project is new CDT project - * + * * @param p - project to check - * @returns true if it's new-style project. - */ + * @returns true if it's new-style project. + */ public static boolean isCDTPrj(IProject p) { - ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); - if (prjd == null) return false; + ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); + if (prjd == null) return false; ICConfigurationDescription[] cfgs = prjd.getConfigurations(); return (cfgs != null && cfgs.length > 0); } - + + @Override public boolean isCDTProject(IProject p) { return isCDTPrj(p); } - + + @Override public ICResourceDescription getResDesc() { if (resd == null) { if (cfgDescs == null) { @@ -935,17 +948,18 @@ implements return resd; } + @Override public ICResourceDescription getResDesc(ICConfigurationDescription cf) { IAdaptable ad = getElement(); - - if (isForProject()) + + if (isForProject()) return cf.getRootFolderDescription(); ICResourceDescription out = null; - IResource res = (IResource)ad; + IResource res = (IResource)ad; IPath p = res.getProjectRelativePath(); if (isForFolder() || isForFile()) { if (cf instanceof ICMultiItemsHolder) { - out = cf.getResourceDescription(p, isForFolder()); // sic ! + out = cf.getResourceDescription(p, isForFolder()); // sic ! } else { out = cf.getResourceDescription(p, false); if (! p.equals(out.getPath()) ) { @@ -955,7 +969,7 @@ implements else out = cf.createFileDescription(p, out); } catch (CoreException e) { - System.out.println(Messages.AbstractPage_10 + + System.out.println(Messages.AbstractPage_10 + p.toOSString() + "\n" + e.getLocalizedMessage()); //$NON-NLS-1$ } } @@ -963,9 +977,9 @@ implements } return out; } - + protected void cfgChanged(ICConfigurationDescription _cfgd) { - + CConfigurationStatus st = _cfgd.getConfigurationStatus(); if (errPane != null && errMessage != null) { if (st.isOK()) { @@ -977,7 +991,7 @@ implements } resd = getResDesc(_cfgd); - + if (excludeFromBuildCheck != null) { excludeFromBuildCheck.setEnabled(resd.canExclude(!resd.isExcluded())); excludeFromBuildCheck.setSelection(resd.isExcluded()); @@ -1004,7 +1018,7 @@ implements loadedIcons.clear(); if (!isNewOpening) - handleResize(false); // save page size + handleResize(false); // save page size isNewOpening = true; // Remove this page from the property manager CDTPropertyManager.remove(this); @@ -1017,12 +1031,12 @@ implements /** * The only method to be redefined in descendants - * @return + * @return * true if single page is required * false if multiple pages are possible */ - abstract protected boolean isSingle(); - + abstract protected boolean isSingle(); + /** * Defines whether the configurations control is shown or not. * Subclasses may override this. @@ -1041,7 +1055,7 @@ implements if (tab != null) tab.tab.handleTabEvent(m, pars); } } - + // redefine page width /* public Point computeSize() { @@ -1050,12 +1064,12 @@ implements return p; } */ - + public static String getWeight(IConfigurationElement e) { String s = e.getAttribute(WEIGHT_NAME); return (s == null) ? EMPTY_STR : s; } - + private synchronized void loadExtensionsSynchronized(Composite parent) { // Get the extensions IExtensionPoint extensionPoint = Platform.getExtensionRegistry() @@ -1073,44 +1087,44 @@ implements if (element.getName().equals(ELEMENT_NAME)) { if (loadTab(element, parent)) return; } else { - System.out.println(Messages.AbstractPage_13 + element.getName()); + System.out.println(Messages.AbstractPage_13 + element.getName()); } } } /** - * + * * @param element * @param parent * @return true if we should exit (no more loadings) - * false if we should continue extensions scan. + * false if we should continue extensions scan. * @throws BuildException */ private boolean loadTab(IConfigurationElement element, Composite parent) { // MBSCustomPageData currentPageData; // Check whether it's our tab if (!this.getClass().getName().equals(element.getAttribute(PARENT_NAME))) return false; - + ICPropertyTab page = null; try { page = (ICPropertyTab) element.createExecutableExtension(CLASS_NAME); } catch (CoreException e) { - System.out.println(Messages.AbstractPage_14 + + System.out.println(Messages.AbstractPage_14 + e.getLocalizedMessage()); - return false; + return false; } if (page == null) return false; - + String helpId = element.getAttribute(HELPID_NAME); - if (helpId != null && helpId.length() > 0 + if (helpId != null && helpId.length() > 0 // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab && page instanceof AbstractCPropertyTab) { ((AbstractCPropertyTab)page).setHelpContextId(helpId); } - + Image _img = getIcon(element); if (_img != null) page.handleTabEvent(ICPropertyTab.SET_ICON, _img); - + if (isSingle()) { // note that name, image and tooltip // are ignored for single page. @@ -1124,7 +1138,7 @@ implements String _tip = element.getAttribute(TIP_NAME); Composite _comp = new Composite(folder, SWT.NONE); - page.createControls(_comp, this); + page.createControls(_comp, this); InternalTab itab = new InternalTab(_comp, _name, _img, page, _tip); itab.createOn(folder); itabs.add(itab); @@ -1151,6 +1165,7 @@ implements return img; } + @Override public void informAll(int code, Object data) { for (int i=0; i it = fParserPageMap.values().iterator(); - + while (it.hasNext()) { try { ICOptionPage dynamicPage = (it.next()).getPage(); if (dynamicPage.isValid() && dynamicPage.getControl() != null) { - if (apply) + if (apply) dynamicPage.performApply(mon); else dynamicPage.performDefaults(); @@ -368,7 +372,7 @@ public class BinaryParsTab extends AbstractCPropertyTab { } catch (CoreException e) {} } } - + @Override public void buttonPressed(int i) { switch (i) { @@ -386,8 +390,8 @@ public class BinaryParsTab extends AbstractCPropertyTab { // Move item up / down private void moveItem(boolean up) { int n = table.getSelectionIndex(); - if (n < 0 || - (up && n == 0) || + if (n < 0 || + (up && n == 0) || (!up && n+1 == table.getItemCount())) return; Object d = tv.getElementAt(n); @@ -400,7 +404,7 @@ public class BinaryParsTab extends AbstractCPropertyTab { saveChecked(); updateButtons(); } - + private void saveChecked() { Object[] objs = tv.getCheckedElements(); String[] ids = null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java index 2a3deb30261..f1dd427dc44 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java @@ -26,16 +26,16 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.newui.Messages; /** - * This class is intended to handle - * - * When new propertypage is created, it should request - * project description by method + * This class is intended to handle + * + * When new propertypage is created, it should request + * project description by method * getProjectDescription() * This method, in addition, registers page in list. - * + * * While page is active, it can change this description * but should not set it, to avoid inconsistency. - * + * * When page's "performOK" called, it should call * manager's method * performOk() @@ -43,11 +43,11 @@ import org.eclipse.cdt.internal.ui.newui.Messages; * Registered pages can call {@link CDTPropertyManager#remove(Object)} * to explicitly remove themselves from this manager. * - * In addition, there are utility methods for pages: + * In addition, there are utility methods for pages: * getPagesCount() * getPage() * isSaveDone() - * + * * @noextend This class is not intended to be subclassed by clients. */ public class CDTPropertyManager { @@ -57,18 +57,18 @@ public class CDTPropertyManager { private static boolean saveDone = false; private static IProject project = null; private static DListener dListener = new DListener(); - - + + public static ICProjectDescription getProjectDescription(PropertyPage p, IProject prj) { return get(p, prj); - } + } public static ICProjectDescription getProjectDescription(Widget w, IProject prj) { return get(w, prj); - } + } public static ICProjectDescription getProjectDescription(IProject prj) { return get(null, prj); - } - + } + private static ICProjectDescription get(Object p, IProject prj) { // New session - clean static variables if (pages.size() == 0) { @@ -80,13 +80,13 @@ public class CDTPropertyManager { if (p != null && !pages.contains(p)) { pages.add(p); if (p instanceof PropertyPage) { - if (((PropertyPage)p).getControl() != null) + if (((PropertyPage)p).getControl() != null) ((PropertyPage)p).getControl().addDisposeListener(dListener); } else if (p instanceof Widget) { ((Widget)p).addDisposeListener(dListener); } } - // Check that we are working with the same project + // Check that we are working with the same project if (project == null || !project.equals(prj)) { project = prj; prjd = null; @@ -106,17 +106,17 @@ public class CDTPropertyManager { if (saveDone) return; performOkForced(p); - + if (pages.size() == 0) { project = null; prjd = null; saveDone = false; } } - + public static void performCancel(Object p) { saveDone = true; - + if (pages.size() == 0) { project = null; prjd = null; @@ -134,7 +134,7 @@ public class CDTPropertyManager { } /** - * Performs mandatory saving + * Performs mandatory saving * @param p */ public static void performOkForced(Object p) { @@ -142,26 +142,26 @@ public class CDTPropertyManager { try { CoreModel.getDefault().setProjectDescription(project, prjd); } catch (CoreException e) { - CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); + CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); } - + if (pages.size() == 0) { project = null; prjd = null; saveDone = false; } } - + // pages utilities - public static boolean isSaveDone() { return saveDone; } + public static boolean isSaveDone() { return saveDone; } public static int getPagesCount() { return pages.size(); } public static Object getPage(int index) { return pages.get(index); } // Removes disposed items from list static class DListener implements DisposeListener { public static void dispose (Object w) { - if (pages.contains(w)) { // Widget ? - pages.remove(w); + if (pages.contains(w)) { // Widget ? + pages.remove(w); } else { // Property Page ? for (Object ob : pages) { if (ob != null && ob instanceof PropertyPage) { @@ -180,9 +180,10 @@ public class CDTPropertyManager { saveDone = false; } } + @Override public void widgetDisposed(DisposeEvent e) { dispose(e.widget); } } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java index 1809da3bb72..121270da3e1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java @@ -11,11 +11,12 @@ package org.eclipse.cdt.ui.newui; import org.eclipse.core.runtime.IStatus; + import org.eclipse.cdt.ui.CUIPlugin; /** * Simple IStatus implementation to avoid using internal classes. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class CDTStatusInfo implements IStatus { @@ -26,14 +27,23 @@ public class CDTStatusInfo implements IStatus { public CDTStatusInfo(int _code, String _text) { text= _text; code= _code; - } - public IStatus[] getChildren() { return new IStatus[0];} - public int getCode() { return code; } + } + @Override + public IStatus[] getChildren() { return new IStatus[0];} + @Override + public int getCode() { return code; } + @Override public Throwable getException() { return null; } + @Override public String getMessage() { return text; } + @Override public String getPlugin() { return CUIPlugin.PLUGIN_ID; } + @Override public int getSeverity() { return code; } + @Override public boolean isMultiStatus() { return false; } + @Override public boolean isOK() { return (code == OK); } + @Override public boolean matches(int mask) { return (code & mask) != 0; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java index 6ba386703ac..810020d4ba1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java @@ -66,67 +66,67 @@ public abstract class CLocationTab extends AbstractCPropertyTab { private final Image IMG_EN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CFOLDER); private final Image IMG_FI = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB); - + Label label; TreeViewer tree; ArrayList<_Entry> src; ICResourceDescription cfgd; ICProject cprj; - + class _Filter { - _Entry entry; + _Entry entry; _Filter(_Entry _entry) { entry = _entry; } - + public IPath[] getExtPaths() { IPath[] p = null; p = entry.ent.getExclusionPatterns(); return p; } - + public String[] getExts() { IPath[] p = getExtPaths(); - if (p == null || p.length == 0) + if (p == null || p.length == 0) return new String[0]; String[] s = new String[p.length]; - for (int i=0; i 0 && sel[0].getData() instanceof _Entry); } - + @Override public void buttonPressed(int x) { Shell shell = usercomp.getShell(); @@ -202,7 +208,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab { saveData(); } break; - // create / link + // create / link case 1: NewFolderDialog d = new NewFolderDialog(shell, page.getProject()) { @Override @@ -217,14 +223,14 @@ public abstract class CLocationTab extends AbstractCPropertyTab { saveData(); } break; - // edit filter + // edit filter case 2: if (sel.length == 0) return; Object data = sel[0].getData(); _Entry entry = null; - if (data instanceof _Entry) + if (data instanceof _Entry) entry = (_Entry)data; - else if (data instanceof _Filter) + else if (data instanceof _Filter) entry = ((_Filter)data).entry; else return; ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(), entry.getPath(), page.getProject()); @@ -247,7 +253,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab { break; } } - + private void saveData() { ICExclusionPatternPathEntry[] p = new ICExclusionPatternPathEntry[src.size()]; Iterator<_Entry> it = src.iterator(); @@ -261,23 +267,23 @@ public abstract class CLocationTab extends AbstractCPropertyTab { ((AbstractPage)page).cfgChanged(cfgDescription); } } - + @Override public void updateData(ICResourceDescription _cfgd) { if (page.isMultiCfg()) { setAllVisible(false, ""); //$NON-NLS-1$ return; } - + cfgd = _cfgd; IAdaptable ad = page.getElement(); if (ad instanceof ICProject) { cprj = (ICProject)ad; } IResource rc = (IResource)ad; - + setAllVisible(true, null); - + src = new ArrayList<_Entry>(); _Entry selectedSourcePath = null; for (ICExclusionPatternPathEntry e : getEntries(cfgd)) { @@ -292,7 +298,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab { ISelection selection = new StructuredSelection(new Object[] {selectedSourcePath}); tree.setSelection(selection); } - + updateButtons(); } @@ -300,7 +306,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab { protected abstract void setEntries (ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data); protected abstract ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean workspacePath); protected abstract ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean workspacePath); - + @Override protected void performApply(ICResourceDescription src, ICResourceDescription dst) { setEntries(dst, getEntries(src)); @@ -312,24 +318,24 @@ public abstract class CLocationTab extends AbstractCPropertyTab { updateData(cfgd); } - + // This page can be displayed either for project or for folder @Override public boolean canBeVisible() { if (page.getResDesc() instanceof ICMultiItemsHolder) return false; // cannot work with multi cfg - + return page.isForProject() || page.isForFolder(); } - + private String[] getProjectDialog(Shell shell) { Set set = new HashSet(src.size()); for (_Entry e : src) set.add(e.getPath()); - + LocDialog dialog = new LocDialog(shell, set); dialog.setInput(page.getProject()); - + dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE); dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG); if (dialog.open() == Window.OK) { @@ -345,25 +351,26 @@ public abstract class CLocationTab extends AbstractCPropertyTab { } /** - * This class should hold elements for source location tree + * This class should hold elements for source location tree */ class Holder implements IAdaptable { private IFolder f = null; private boolean isRoot = false; private IPath p = null; - + Holder(IProject _p) { f = _p.getFolder(_p.getName()); isRoot = true; p = _p.getFullPath(); } - + Holder(IFolder _f) { f = _f; isRoot = false; p = _f.getFullPath(); } - + + @Override @SuppressWarnings("rawtypes") public Object getAdapter(Class adapter) { return f.getAdapter(adapter); @@ -381,7 +388,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab { private CLocationTab getOuterType() { return CLocationTab.this; } - + @Override public int hashCode() { final int prime = 31; @@ -412,7 +419,7 @@ public abstract class CLocationTab extends AbstractCPropertyTab { return false; return true; } - + /** * For debugging purpose only * @see java.lang.Object#toString() @@ -423,23 +430,23 @@ public abstract class CLocationTab extends AbstractCPropertyTab { return "[Holder] " + p; } } - + class LocDialog extends ElementTreeSelectionDialog { Set existing; - + public LocDialog(Shell parent, Set ex) { super(parent, - + new WorkbenchLabelProvider() { @Override protected String decorateText(String input, Object element) { if (element instanceof Holder && ((Holder)element).isRoot()) - return Messages.CLocationTab_8; + return Messages.CLocationTab_8; return super.decorateText(input, element); } }, - + new WorkbenchContentProvider() { @Override public Object[] getChildren(Object element) { @@ -469,11 +476,11 @@ public abstract class CLocationTab extends AbstractCPropertyTab { ob1 = new Object[cnt]; System.arraycopy(ob2, 0, ob1, 0, cnt); return ob1; - } else + } else return super.getChildren(element); } }); - + addFilter(new ViewerFilter () { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { @@ -484,18 +491,18 @@ public abstract class CLocationTab extends AbstractCPropertyTab { Holder h = (Holder)element; return (! existing.contains(h.getPath())); }}); - + existing = ex; } - + @Override protected TreeViewer createTreeViewer(Composite parent) { TreeViewer treeViewer = super.createTreeViewer(parent); - + // Expand the tree and select current resource if (page.getElement() instanceof IFolder) { IFolder folder = (IFolder)page.getElement(); - + List list = new ArrayList(); list.add(new Holder(folder)); for (IContainer parentFolder = folder.getParent();parentFolder instanceof IFolder;parentFolder=parentFolder.getParent()) { @@ -506,5 +513,5 @@ public abstract class CLocationTab extends AbstractCPropertyTab { } return treeViewer; } - } + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java index 7fcb7994179..de2032d4ca4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java @@ -46,26 +46,26 @@ public class ConfigMultiSelectionDialog extends Dialog { private Button b_ok; private Label message; private static ICConfigurationDescription[] result = null; - + /** * @since 5.2 */ public static ICConfigurationDescription[] select(ICConfigurationDescription[] _cfgds, Shell parentShell) { cfgds = _cfgds; ConfigMultiSelectionDialog d = new ConfigMultiSelectionDialog(parentShell); - if (d.open() == OK) + if (d.open() == OK) return result; return null; } - + public ConfigMultiSelectionDialog(Shell parentShell) { super(parentShell); } @Override protected void configureShell(Shell shell) { super.configureShell(shell); - shell.setText(Messages.ConfigMultiSelectionDialog_0); + shell.setText(Messages.ConfigMultiSelectionDialog_0); } - + /** * Method is overridden to disable "OK" button at start */ @@ -75,7 +75,7 @@ public class ConfigMultiSelectionDialog extends Dialog { b_ok = getButton(IDialogConstants.OK_ID); b_ok.setEnabled(false); return out; - } + } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) @@ -86,34 +86,38 @@ public class ConfigMultiSelectionDialog extends Dialog { composite.setFont(parent.getFont()); composite.setLayout(new GridLayout(1, true)); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - + // Create the current config table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); table.setLayoutData(new GridData(GridData.FILL)); table.setHeaderVisible(true); table.setLinesVisible(true); - + message = new Label(composite, SWT.NONE); message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - message.setText(Messages.ConfigMultiSelectionDialog_1); + message.setText(Messages.ConfigMultiSelectionDialog_1); message.setForeground(composite.getDisplay().getSystemColor(SWT.COLOR_RED)); - + TableColumn col = new TableColumn(table, SWT.NONE); - col.setText(Messages.ManageConfigDialog_1); + col.setText(Messages.ManageConfigDialog_1); col.setWidth(100); col = new TableColumn(table, SWT.NONE); - col.setText(Messages.ManageConfigDialog_2); + col.setText(Messages.ManageConfigDialog_2); col.setWidth(120); - + tv = new CheckboxTableViewer(table); tv.setContentProvider(new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { return cfgds; } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); tv.addCheckStateListener(new ICheckStateListener() { + @Override public void checkStateChanged(CheckStateChangedEvent e) { - boolean enabled = (tv.getCheckedElements().length > 1); + boolean enabled = (tv.getCheckedElements().length > 1); if (b_ok != null) b_ok.setEnabled(enabled); message.setVisible(!enabled); if (enabled) { @@ -124,12 +128,18 @@ public class ConfigMultiSelectionDialog extends Dialog { result = null; }}); tv.setLabelProvider(new ITableLabelProvider() { + @Override public Image getColumnImage(Object element, int columnIndex) { return null; } + @Override public void addListener(ILabelProviderListener listener) {} + @Override public void dispose() {} + @Override public boolean isLabelProperty(Object element, String property) { return false;} + @Override public void removeListener(ILabelProviderListener listener) {} + @Override public String getColumnText(Object element, int index) { ICConfigurationDescription cfg = (ICConfigurationDescription)element; if (index == 0) return cfg.getName(); @@ -143,7 +153,7 @@ public class ConfigMultiSelectionDialog extends Dialog { /** * @deprecated (in org.eclipse.cdt.ui 5.2.0) - * + * * This call is deprecated in plugin org.eclipse.cdt.ui 5.2.0 and intended to be removed * on occasion when the plugin increases major version (Bug 285033). * Use {@link #select(ICConfigurationDescription[], Shell)} to properly set focus. @@ -152,7 +162,7 @@ public class ConfigMultiSelectionDialog extends Dialog { public static ICConfigurationDescription[] select(ICConfigurationDescription[] _cfgds) { cfgds = _cfgds; ConfigMultiSelectionDialog d = new ConfigMultiSelectionDialog(CUIPlugin.getActiveWorkbenchShell()); - if (d.open() == OK) + if (d.open() == OK) return result; return null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java index e9d9c1440e1..c88c48e8b98 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java @@ -47,9 +47,9 @@ public class EnvDialog extends Dialog { public boolean toAll = false; private String title; - public EnvDialog(Shell parent, - IEnvironmentVariable _var, - String _title, + public EnvDialog(Shell parent, + IEnvironmentVariable _var, + String _title, boolean _newAction, boolean _multiCfg, ICConfigurationDescription _cfgd) { @@ -69,44 +69,46 @@ public class EnvDialog extends Dialog { Control out = super.createContents(parent); setButtons(); return out; - } - + } + @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(title); } - + @Override protected Control createDialogArea(Composite c) { c.setLayout(new GridLayout(3, false)); GridData gd; - + Label l1 = new Label(c, SWT.NONE); - l1.setText(Messages.EnvDialog_0); + l1.setText(Messages.EnvDialog_0); l1.setLayoutData(new GridData(GridData.BEGINNING)); - + text1 = new Text(c, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; gd.widthHint = 400; text1.setLayoutData(gd); text1.addModifyListener(new ModifyListener () { + @Override public void modifyText(ModifyEvent e) { setButtons(); }}); - + Label l2 = new Label(c, SWT.NONE); - l2.setText(Messages.EnvDialog_1); + l2.setText(Messages.EnvDialog_1); l2.setLayoutData(new GridData(GridData.BEGINNING)); - + text2 = new Text(c, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 250; text2.setLayoutData(gd); text2.addModifyListener(new ModifyListener () { + @Override public void modifyText(ModifyEvent e) { setButtons(); }}); final Button b = new Button(c, SWT.PUSH); - b.setText(Messages.EnvDialog_2); + b.setText(Messages.EnvDialog_2); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -119,9 +121,9 @@ public class EnvDialog extends Dialog { gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = AbstractCPropertyTab.BUTTON_WIDTH; b.setLayoutData(gd); - + b_add2all = new Button(c, SWT.CHECK); - b_add2all.setText(Messages.EnvDialog_3); + b_add2all.setText(Messages.EnvDialog_3); gd = new GridData(GridData.FILL_HORIZONTAL); if (cfgd == null) b_add2all.setVisible(false); @@ -131,10 +133,10 @@ public class EnvDialog extends Dialog { public void widgetSelected(SelectionEvent e) { toAll = b_add2all.getSelection(); }}); - + if (multiCfg) b_add2all.setVisible(false); - + if (!newAction) { gd.heightHint = 1; b_add2all.setVisible(false); @@ -142,17 +144,17 @@ public class EnvDialog extends Dialog { text1.setText(var.getName()); text1.setEnabled(false); // don't change name String s = var.getValue(); - text2.setText(s == null ? AbstractCPropertyTab.EMPTY_STR : s); + text2.setText(s == null ? AbstractCPropertyTab.EMPTY_STR : s); } - + gd.horizontalSpan = 3; b_add2all.setLayoutData(gd); setButtons(); return c; } - + private void setButtons() { - t1 = text1.getText(); + t1 = text1.getText(); t2 = text2.getText(); Button b = getButton(IDialogConstants.OK_ID); if (b != null) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java index cdc63036d0e..175be00e0b0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java @@ -69,7 +69,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { private static final String LBR = " ["; //$NON-NLS-1$ private static final String RBR = "]"; //$NON-NLS-1$ private static final UserDefinedEnvironmentSupplier fUserSupplier = EnvironmentVariableManager.fUserSupplier; - + private final MultiCfgContributedEnvironment ce = new MultiCfgContributedEnvironment(); private Table table; @@ -86,14 +86,15 @@ public class EnvironmentTab extends AbstractCPropertyTab { TabData(IEnvironmentVariable _var) { var = _var; } + @Override public int compareTo(TabData a) { String s = var.getName(); if (a != null && s != null && a.var != null) - return (s.compareTo(a.var.getName())); + return (s.compareTo(a.var.getName())); return 0; } } - + private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{ public EnvironmentLabelProvider(boolean user){ } @@ -105,9 +106,11 @@ public class EnvironmentTab extends AbstractCPropertyTab { public String getText(Object element) { return getColumnText(element, 0); } + @Override public Image getColumnImage(Object element, int columnIndex) { return null; } + @Override public String getColumnText(Object element, int columnIndex) { TabData td = (TabData)element; switch(columnIndex){ @@ -115,7 +118,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { return td.var.getName(); case 1: if(td.var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE) - return Messages.EnvironmentTab_20; + return Messages.EnvironmentTab_20; return td.var.getValue(); case 2: return ce.getOrigin(td.var); @@ -123,10 +126,12 @@ public class EnvironmentTab extends AbstractCPropertyTab { return EMPTY_STR; } + @Override public Font getFont(Object element) { return getFont(element, 0); } + @Override public Font getFont(Object element, int columnIndex) { TabData td = (TabData)element; switch(columnIndex){ @@ -139,19 +144,21 @@ public class EnvironmentTab extends AbstractCPropertyTab { } return null; } - - public Color getForeground(Object element){ + + @Override + public Color getForeground(Object element){ return null; } - public Color getBackground(Object element){ + @Override + public Color getBackground(Object element){ TabData td = (TabData)element; if (isUsers(td.var)) return BACKGROUND_FOR_USER_VAR; - return null; + return null; } } - + @Override public void createControls(Composite parent) { super.createControls(parent); @@ -165,10 +172,12 @@ public class EnvironmentTab extends AbstractCPropertyTab { table.setHeaderVisible(true); table.setLinesVisible(true); table.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { updateButtons(); } + @Override public void widgetDefaultSelected(SelectionEvent e) { if (buttonIsEnabled(2) && table.getSelectionIndex() != -1) buttonPressed(2); @@ -178,6 +187,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { tv = new TableViewer(table); tv.setContentProvider(new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { if (inputElement != null && inputElement instanceof ArrayList) { @SuppressWarnings("unchecked") @@ -187,9 +197,11 @@ public class EnvironmentTab extends AbstractCPropertyTab { return null; } + @Override public void dispose() { } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); @@ -234,6 +246,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { if (page.isForProject()) { stringListModeControl = new StringListModeControl(page, usercomp, 1); stringListModeControl.addListener(SWT.Selection, new Listener() { + @Override public void handleEvent(Event event) { updateData(); } @@ -262,10 +275,10 @@ public class EnvironmentTab extends AbstractCPropertyTab { Messages.EnvironmentTab_6, Messages.EnvironmentTab_7, Messages.EnvironmentTab_8, - Messages.EnvironmentTab_9 + Messages.EnvironmentTab_9 }); } - + @Override public void buttonPressed(int i) { switch (i) { @@ -287,11 +300,11 @@ public class EnvironmentTab extends AbstractCPropertyTab { } table.setFocus(); } - + @Override protected void updateButtons() { if (table == null || table.isDisposed()) return; - + boolean canEdit = table.getSelectionCount() == 1; boolean canDel = false; boolean canUndef = table.getSelectionCount() >= 1; @@ -312,7 +325,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { @Override protected void updateData(ICResourceDescription _cfgd) { - // null means preference configuration + // null means preference configuration cfgd = (_cfgd != null) ? _cfgd.getConfiguration() : null; if (cfgd == null && vars == null) vars = fUserSupplier.getWorkspaceEnvironmentCopy(); @@ -334,7 +347,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { b2.setSelection(!vars.appendContributedEnvironment()); _vars = vars.getVariables() ; } - + data.clear(); if (_vars != null) { for (IEnvironmentVariable _var : _vars) { @@ -343,7 +356,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { } Collections.sort(data); tv.setInput(data); - + if (stringListModeControl!=null) { stringListModeControl.updateStringListModeControl(); } @@ -354,7 +367,7 @@ public class EnvironmentTab extends AbstractCPropertyTab { protected void performApply(ICResourceDescription _src, ICResourceDescription _dst) { ICConfigurationDescription src = _src.getConfiguration(); ICConfigurationDescription dst = _dst.getConfiguration(); - + ce.setAppendEnvironment(ce.appendEnvironment(src), dst); IEnvironmentVariable[] v = ce.getVariables(dst); for (IEnvironmentVariable element : v) @@ -362,24 +375,24 @@ public class EnvironmentTab extends AbstractCPropertyTab { v = ce.getVariables(src); for (IEnvironmentVariable element : v) { if (ce.isUserVariable(src, element)) - ce.addVariable(element.getName(), element.getValue(), + ce.addVariable(element.getName(), element.getValue(), element.getOperation(), element.getDelimiter(), dst); } } /** - * + * */ private class MyListSelectionDialog extends ListSelectionDialog { public boolean toAll = false; public MyListSelectionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider) { - super(parentShell, input, contentProvider, new LabelProvider() {}, Messages.EnvironmentTab_12); + super(parentShell, input, contentProvider, new LabelProvider() {}, Messages.EnvironmentTab_12); } @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Button b = new Button(composite, SWT.CHECK); - b.setText(Messages.EnvironmentTab_13); + b.setText(Messages.EnvironmentTab_13); b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (cfgd == null) b.setVisible(false); @@ -392,21 +405,21 @@ public class EnvironmentTab extends AbstractCPropertyTab { return composite; } } - + private void handleEnvEditButtonSelected(int n) { if (n == -1) return; IEnvironmentVariable var = ((TabData)tv.getElementAt(n)).var; - EnvDialog dlg = new EnvDialog(usercomp.getShell(), - var, - Messages.EnvironmentTab_11, + EnvDialog dlg = new EnvDialog(usercomp.getShell(), + var, + Messages.EnvironmentTab_11, false, page.isMultiCfg(), cfgd); if (dlg.open() == Window.OK) { if (cfgd != null) - ce.addVariable( var.getName(), dlg.t2.trim(), - IEnvironmentVariable.ENVVAR_REPLACE, + ce.addVariable( var.getName(), dlg.t2.trim(), + IEnvironmentVariable.ENVVAR_REPLACE, var.getDelimiter(), cfgd); else vars.createVariable(dlg.t1.trim(), dlg.t2.trim(), @@ -416,36 +429,36 @@ public class EnvironmentTab extends AbstractCPropertyTab { updateButtons(); } } - + private void handleEnvUndefButtonSelected(int n) { - if (n == -1) + if (n == -1) return; for (int i : table.getSelectionIndices()) { IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var; if (cfgd == null) vars.createVariable( - var.getName(), - null, - IEnvironmentVariable.ENVVAR_REMOVE, + var.getName(), + null, + IEnvironmentVariable.ENVVAR_REMOVE, var.getDelimiter()); - else + else ce.addVariable( - var.getName(), - null, - IEnvironmentVariable.ENVVAR_REMOVE, + var.getName(), + null, + IEnvironmentVariable.ENVVAR_REMOVE, var.getDelimiter(), cfgd); } updateData(); table.setSelection(n); updateButtons(); } - + private void handleEnvDelButtonSelected(int n) { - if (n == -1) + if (n == -1) return; for (int i : table.getSelectionIndices()) { IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var; - if (cfgd == null) + if (cfgd == null) vars.deleteVariable(var.getName()); else ce.removeVariable(var.getName(), cfgd); @@ -457,12 +470,12 @@ public class EnvironmentTab extends AbstractCPropertyTab { updateButtons(); } } - + private void handleEnvAddButtonSelected() { IEnvironmentVariable var = null; - EnvDialog dlg = new EnvDialog(usercomp.getShell(), - var, - Messages.EnvironmentTab_10, + EnvDialog dlg = new EnvDialog(usercomp.getShell(), + var, + Messages.EnvironmentTab_10, true, page.isMultiCfg(), cfgd); @@ -472,15 +485,15 @@ public class EnvironmentTab extends AbstractCPropertyTab { ICConfigurationDescription[] cfgs; if (dlg.toAll) cfgs = page.getCfgsEditable(); - else + else cfgs = new ICConfigurationDescription[] {cfgd}; if (cfgd == null) - vars.createVariable(name, dlg.t2.trim(), + vars.createVariable(name, dlg.t2.trim(), IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR); else - for (ICConfigurationDescription cfg : cfgs) { - ce.addVariable(name, dlg.t2.trim(), - IEnvironmentVariable.ENVVAR_APPEND, + for (ICConfigurationDescription cfg : cfgs) { + ce.addVariable(name, dlg.t2.trim(), + IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR, cfg); } updateData(); @@ -500,21 +513,21 @@ public class EnvironmentTab extends AbstractCPropertyTab { } } } - + private void handleEnvSelectButtonSelected() { // get Environment Variables from the OS Map v = EnvironmentReader.getEnvVars(); MyListSelectionDialog dialog = new MyListSelectionDialog(usercomp.getShell(), v, createSelectionDialogContentProvider()); - - dialog.setTitle(Messages.EnvironmentTab_14); + + dialog.setTitle(Messages.EnvironmentTab_14); if (dialog.open() == Window.OK) { Object[] selected = dialog.getResult(); ICConfigurationDescription[] cfgs; if (dialog.toAll) cfgs = page.getCfgsEditable(); - else + else cfgs = new ICConfigurationDescription[] {cfgd}; - + String name = null; for (Object element : selected) { name = (String)element; @@ -524,14 +537,14 @@ public class EnvironmentTab extends AbstractCPropertyTab { value = name.substring(x + 2, name.length() - 1); name = name.substring(0, x); } - - if (cfgd == null) + + if (cfgd == null) vars.createVariable(name, value); else - for (ICConfigurationDescription cfg : cfgs) { + for (ICConfigurationDescription cfg : cfgs) { ce.addVariable( - name, value, - IEnvironmentVariable.ENVVAR_APPEND, + name, value, + IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR, cfg); } } @@ -539,26 +552,29 @@ public class EnvironmentTab extends AbstractCPropertyTab { setPos(name); } } - + private IStructuredContentProvider createSelectionDialogContentProvider() { return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { String[] els = null; if (inputElement instanceof Map) { @SuppressWarnings("unchecked") Map m = (Map)inputElement; - els = new String[m.size()]; + els = new String[m.size()]; int index = 0; for (Iterator iterator = m.keySet().iterator(); iterator.hasNext(); index++) { String k = iterator.next(); - els[index] = TextProcessor.process(k + LBR + m.get(k) + RBR); + els[index] = TextProcessor.process(k + LBR + m.get(k) + RBR); } } Arrays.sort(els, CDTListComparator.getInstance()); return els; } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }; } @@ -578,22 +594,22 @@ public class EnvironmentTab extends AbstractCPropertyTab { vars = null; super.performOK(); } - + @Override protected void performCancel() { vars = null; super.performCancel(); } - + @Override protected void performDefaults() { ce.restoreDefaults(cfgd); // both for proj & prefs vars = null; updateData(); } - + private boolean isUsers(IEnvironmentVariable var) { - return cfgd == null || + return cfgd == null || (ce.isUserVariable(cfgd, var) && ((EnvVarDescriptor)var).getContextInfo().getContext() != null); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java index 3a71d7747ef..e9fcb0cf1a3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java @@ -145,10 +145,13 @@ public class ErrorParsTab extends AbstractCPropertyTab { }}); fTableViewer = new CheckboxTableViewer(fTable); fTableViewer.setContentProvider(new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { return (Object[])inputElement; } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); fTableViewer.setLabelProvider(new LabelProvider() { @@ -163,11 +166,11 @@ public class ErrorParsTab extends AbstractCPropertyTab { return name; } } - return NLS.bind(Messages.ErrorParsTab_error_NonAccessibleID, id); + return NLS.bind(Messages.ErrorParsTab_error_NonAccessibleID, id); } return OOPS; } - + @Override public Image getImage(Object element) { final String TEST_PLUGIN_ID = "org.eclipse.cdt.core.tests"; //$NON-NLS-1$ @@ -198,6 +201,7 @@ public class ErrorParsTab extends AbstractCPropertyTab { }); fTableViewer.addCheckStateListener(new ICheckStateListener() { + @Override public void checkStateChanged(CheckStateChangedEvent e) { saveChecked(); }}); @@ -277,6 +281,7 @@ public class ErrorParsTab extends AbstractCPropertyTab { // allow to edit only for Build Settings Preference Page (where cfgd==null) RegexErrorParserOptionPage optionsPage = new RegexErrorParserOptionPage((RegexErrorParser) errorParser, isErrorParsersEditable()); optionsPage.addListener(new Listener() { + @Override public void handleEvent(Event event) { fTableViewer.refresh(id); updateButtons(); @@ -358,25 +363,26 @@ public class ErrorParsTab extends AbstractCPropertyTab { private void addErrorParser() { IInputStatusValidator inputValidator = new IInputStatusValidator() { + @Override public IStatus isValid(String newText) { StatusInfo status = new StatusInfo(); if (newText.trim().length() == 0) { - status.setError(Messages.ErrorParsTab_error_NonEmptyName); + status.setError(Messages.ErrorParsTab_error_NonEmptyName); } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER)>=0) { - String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter, + String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter, new Object[] { ErrorParserManager.ERROR_PARSER_DELIMITER }); status.setError(message); } else if (fAvailableErrorParsers.containsKey(makeId(newText))) { - status.setError(Messages.ErrorParsTab_error_NonUniqueID); + status.setError(Messages.ErrorParsTab_error_NonUniqueID); } return status; } }; InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(), - Messages.ErrorParsTab_title_Add, - Messages.ErrorParsTab_label_EnterName, - Messages.ErrorParsTab_label_DefaultRegexErrorParserName, + Messages.ErrorParsTab_title_Add, + Messages.ErrorParsTab_label_EnterName, + Messages.ErrorParsTab_label_DefaultRegexErrorParserName, inputValidator); addDialog.setHelpAvailable(false); @@ -404,12 +410,13 @@ public class ErrorParsTab extends AbstractCPropertyTab { IErrorParserNamed errorParser = fAvailableErrorParsers.get(id); IInputStatusValidator inputValidator = new IInputStatusValidator() { + @Override public IStatus isValid(String newText) { StatusInfo status = new StatusInfo(); if (newText.trim().length() == 0) { - status.setError(Messages.ErrorParsTab_error_NonEmptyName); + status.setError(Messages.ErrorParsTab_error_NonEmptyName); } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER)>=0) { - String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter, + String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter, new Object[] { ErrorParserManager.ERROR_PARSER_DELIMITER }); status.setError(message); } @@ -418,8 +425,8 @@ public class ErrorParsTab extends AbstractCPropertyTab { }; InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(), - Messages.ErrorParsTab_title_Edit, - Messages.ErrorParsTab_label_EnterName, + Messages.ErrorParsTab_title_Edit, + Messages.ErrorParsTab_label_EnterName, errorParser.getName(), inputValidator); addDialog.setHelpAvailable(false); @@ -445,7 +452,7 @@ public class ErrorParsTab extends AbstractCPropertyTab { } else { // Delete fTableViewer.remove(id); - + int last = fTable.getItemCount() - 1; if (n>last) n = last; @@ -502,9 +509,9 @@ public class ErrorParsTab extends AbstractCPropertyTab { boolean isExtensionId = isExtensionId(id); boolean canDelete = !isExtensionId && isErrorParsersEditable(); boolean canReset = isExtensionId && isErrorParsersEditable() && isModified(id); - + buttonSetText(BUTTON_DELETE, isExtensionId ? RESET_STR : DEL_STR); - + buttonSetEnabled(BUTTON_ADD, isErrorParsersEditable()); buttonSetEnabled(BUTTON_EDIT, isErrorParsersEditable() && selected); buttonSetEnabled(BUTTON_DELETE, (canDelete || canReset) && selected); @@ -558,17 +565,17 @@ public class ErrorParsTab extends AbstractCPropertyTab { } } } - + Object[] checkedElements = fTableViewer.getCheckedElements(); String[] checkedErrorParserIds = new String[checkedElements.length]; System.arraycopy(checkedElements, 0, checkedErrorParserIds, 0, checkedElements.length); - + ErrorParserManager.setDefaultErrorParserIds(checkedErrorParserIds); ErrorParserManager.setUserDefinedErrorParsers(errorParsersList.toArray(new IErrorParserNamed[errorParsersList.size()])); } catch (BackingStoreException e) { - CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); + CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); } catch (CoreException e) { - CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); + CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); } } initMapParsers(); @@ -614,16 +621,16 @@ public class ErrorParsTab extends AbstractCPropertyTab { if (isErrorParsersEditable()) { // Must be Build Settings Preference Page if (MessageDialog.openQuestion(usercomp.getShell(), - Messages.ErrorParsTab_title_ConfirmReset, - Messages.ErrorParsTab_message_ConfirmReset)) { + Messages.ErrorParsTab_title_ConfirmReset, + Messages.ErrorParsTab_message_ConfirmReset)) { try { ErrorParserManager.setUserDefinedErrorParsers(null); ErrorParserManager.setDefaultErrorParserIds(null); } catch (BackingStoreException e) { - CUIPlugin.log(Messages.ErrorParsTab_error_OnRestoring, e); + CUIPlugin.log(Messages.ErrorParsTab_error_OnRestoring, e); } catch (CoreException e) { - CUIPlugin.log(Messages.ErrorParsTab_error_OnRestoring, e); + CUIPlugin.log(Messages.ErrorParsTab_error_OnRestoring, e); } } } else { @@ -646,7 +653,7 @@ public class ErrorParsTab extends AbstractCPropertyTab { else dynamicPage.performDefaults(); } catch (CoreException e) { - CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); + CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java index 323eea73807..83d63d9c563 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java @@ -58,32 +58,32 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField; * @noextend This class is not intended to be subclassed by clients. */ public class ExPatternDialog extends StatusDialog { - + private ListDialogField fExclusionPatternList; private IProject fCurrProject; private IPath[] pattern; - private IPath path; + private IPath path; private IContainer fCurrSourceFolder; - + private static final int IDX_ADD= 0; private static final int IDX_ADD_MULTIPLE= 1; private static final int IDX_EDIT= 2; private static final int IDX_REMOVE= 4; - + public ExPatternDialog(Shell parent, IPath[] _data, IPath _path, IProject proj) { super(parent); fCurrProject = proj; pattern = _data; path = _path; - setTitle(CPathEntryMessages.ExclusionPatternDialog_title); + setTitle(CPathEntryMessages.ExclusionPatternDialog_title); String label= NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label, - path.makeRelative().toString()); - + path.makeRelative().toString()); + String[] buttonLabels= new String[] { - CPathEntryMessages.ExclusionPatternDialog_pattern_add, - CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple, - CPathEntryMessages.ExclusionPatternDialog_pattern_edit, + CPathEntryMessages.ExclusionPatternDialog_pattern_add, + CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple, + CPathEntryMessages.ExclusionPatternDialog_pattern_edit, null, CPathEntryMessages.ExclusionPatternDialog_pattern_remove }; @@ -95,15 +95,15 @@ public class ExPatternDialog extends StatusDialog { fExclusionPatternList.setLabelText(label); fExclusionPatternList.setRemoveButtonIndex(IDX_REMOVE); fExclusionPatternList.enableButton(IDX_EDIT, false); - + IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot(); IResource res= root.findMember(path); if (res instanceof IContainer) { fCurrSourceFolder= (IContainer) res; - } - + } + ArrayList elements= new ArrayList(pattern.length); - for (IPath p : pattern) + for (IPath p : pattern) elements.add(p.toString()); fExclusionPatternList.setElements(elements); fExclusionPatternList.selectFirstElement(); @@ -122,14 +122,14 @@ public class ExPatternDialog extends StatusDialog { layout.marginHeight= 0; layout.marginWidth= 0; inner.setLayout(layout); - + fExclusionPatternList.doFillIntoGrid(inner, 3); LayoutUtil.setHorizontalSpan(fExclusionPatternList.getLabelControl(null), 2); - - applyDialogFont(composite); + + applyDialogFont(composite); return composite; } - + protected void doCustomButtonPressed(ListDialogField field, int index) { if (index == IDX_ADD) { addEntry(); @@ -139,22 +139,22 @@ public class ExPatternDialog extends StatusDialog { addMultipleEntries(); } } - + protected void doDoubleClicked(ListDialogField field) { editEntry(); } - + protected void doSelectionChanged(ListDialogField field) { List selected= field.getSelectedElements(); fExclusionPatternList.enableButton(IDX_EDIT, canEdit(selected)); } - + private boolean canEdit(List selected) { return selected.size() == 1; } - + private void editEntry() { - + List selElements= fExclusionPatternList.getSelectedElements(); if (selElements.size() != 1) { return; @@ -166,21 +166,21 @@ public class ExPatternDialog extends StatusDialog { fExclusionPatternList.replaceElement(entry, dialog.getExclusionPattern()); } } - + private void addEntry() { List existing= fExclusionPatternList.getElements(); ExPatternEntryDialog dialog= new ExPatternEntryDialog(getShell(), null, existing, fCurrProject, path); if (dialog.open() == Window.OK) { fExclusionPatternList.addElement(dialog.getExclusionPattern()); } - } - + } + protected void doStatusLineUpdate() { - } - + } + protected void checkIfPatternValid() { } - + public IPath[] getExclusionPattern() { IPath[] res= new IPath[fExclusionPatternList.getSize()]; for (int i= 0; i < res.length; i++) { @@ -189,7 +189,7 @@ public class ExPatternDialog extends StatusDialog { } return res; } - + /* * @see org.eclipse.jface.window.Window#configureShell(Shell) */ @@ -211,13 +211,13 @@ public class ExPatternDialog extends StatusDialog { ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); - - IResource initialElement= null; + + IResource initialElement= null; ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp); - dialog.setTitle(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_title); + dialog.setTitle(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_title); dialog.setValidator(validator); - dialog.setMessage(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_description); + dialog.setMessage(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_description); dialog.addFilter(filter); dialog.setInput(fCurrSourceFolder); dialog.setInitialSelection(initialElement); @@ -226,7 +226,7 @@ public class ExPatternDialog extends StatusDialog { if (dialog.open() == Window.OK) { Object[] objects= dialog.getResult(); int existingSegments= fCurrSourceFolder.getFullPath().segmentCount(); - + for (Object object : objects) { IResource curr= (IResource) object; IPath path= curr.getFullPath().removeFirstSegments(existingSegments).makeRelative(); @@ -239,10 +239,10 @@ public class ExPatternDialog extends StatusDialog { fExclusionPatternList.addElement(res); } } - } - + } + private static class ExPatternLabelProvider extends LabelProvider { - + @Override public Image getImage(Object element) { ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry(); @@ -254,20 +254,24 @@ public class ExPatternDialog extends StatusDialog { return (String) element; } } - + private class ExclusionPatternAdapter implements IListAdapter, IDialogFieldListener { + @Override public void customButtonPressed(ListDialogField field, int index) { doCustomButtonPressed(field, index); } + @Override public void selectionChanged(ListDialogField field) { doSelectionChanged(field); } + @Override public void doubleClicked(ListDialogField field) { doDoubleClicked(field); } + @Override public void dialogFieldChanged(DialogField field) { } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java index 243d4791b95..c628897761d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java @@ -64,9 +64,9 @@ public class ExPatternEntryDialog extends StatusDialog { super(parent); fExistingPatterns = existingPatterns; if (patternToEdit == null) { - setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_add_title); + setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_add_title); } else { - setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_edit_title); + setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_edit_title); fExistingPatterns.remove(patternToEdit); } @@ -78,13 +78,13 @@ public class ExPatternEntryDialog extends StatusDialog { fExclusionPatternStatus = new StatusInfo(); - String label = NLS.bind(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_label, + String label = NLS.bind(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_label, path.makeRelative().toString()); ExPatternAdapter adapter = new ExPatternAdapter(); fExclusionPatternDialog = new StringButtonDialogField(adapter); fExclusionPatternDialog.setLabelText(label); - fExclusionPatternDialog.setButtonLabel(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_button); + fExclusionPatternDialog.setButtonLabel(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_button); fExclusionPatternDialog.setDialogFieldListener(adapter); fExclusionPatternDialog.enableButton(fCurrSourceFolder != null); @@ -111,7 +111,7 @@ public class ExPatternEntryDialog extends StatusDialog { inner.setLayout(layout); Label description = new Label(inner, SWT.WRAP); - description.setText(CPathEntryMessages.ExclusionPatternEntryDialog_description); + description.setText(CPathEntryMessages.ExclusionPatternEntryDialog_description); GridData gd = new GridData(); gd.horizontalSpan = 2; gd.widthHint = convertWidthInCharsToPixels(80); @@ -136,10 +136,12 @@ public class ExPatternEntryDialog extends StatusDialog { // -------- IDialogFieldListener + @Override public void dialogFieldChanged(DialogField field) { doStatusLineUpdate(); } + @Override public void changeControlPressed(DialogField field) { doChangeControlPressed(); } @@ -160,16 +162,16 @@ public class ExPatternEntryDialog extends StatusDialog { protected void checkIfPatternValid() { String pattern = fExclusionPatternDialog.getText().trim(); if (pattern.length() == 0) { - fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_empty); + fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_empty); return; } IPath path = new Path(pattern); if (path.isAbsolute() || path.getDevice() != null) { - fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_notrelative); + fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_notrelative); return; } if (fExistingPatterns.contains(pattern)) { - fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_exists); + fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_exists); return; } @@ -218,9 +220,9 @@ public class ExPatternEntryDialog extends StatusDialog { } ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp); - dialog.setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_title); + dialog.setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_title); dialog.setValidator(validator); - dialog.setMessage(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_description); + dialog.setMessage(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_description); dialog.addFilter(filter); dialog.setInput(fCurrSourceFolder); dialog.setInitialSelection(initialElement); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java index 45d01e9ffe1..22bafd74606 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java @@ -37,13 +37,13 @@ import org.eclipse.cdt.internal.ui.newui.Messages; * @noextend This class is not intended to be subclassed by clients. */ public class ExpDialog extends AbstractPropertyDialog { - - protected static final String TO_ALL = Messages.ExpDialog_5; - protected static final String EMPTY_NAME = Messages.ExpDialog_8; - protected static final String EMPTY_VALUE = Messages.ExpDialog_10; - + + protected static final String TO_ALL = Messages.ExpDialog_5; + protected static final String EMPTY_NAME = Messages.ExpDialog_8; + protected static final String EMPTY_VALUE = Messages.ExpDialog_10; + public String[] sel_types = null; - public String[] sel_langs = null; + public String[] sel_langs = null; private Text txt1; private Text txt2; private List langs; @@ -53,7 +53,7 @@ public class ExpDialog extends AbstractPropertyDialog { private Button c_types; private Button c_all; private Button c_wsp; - + private Button b_vars; private Button b_work; private Button b_file; @@ -69,7 +69,7 @@ public class ExpDialog extends AbstractPropertyDialog { String title, String _data1, String _data2, ICConfigurationDescription _cfgd, String[] _langs, String[] _types, - int _kind, String[] _names_l, String[] _names_t, + int _kind, String[] _names_l, String[] _names_t, java.util.List _existing, boolean _isWsp) { super(parent, title); super.text1 = (_data1 == null) ? EMPTY_STR : _data1; @@ -94,35 +94,37 @@ public class ExpDialog extends AbstractPropertyDialog { c.setLayoutData(gd); } c.setLayout(new GridLayout(4, true)); - + Label l1 = new Label(c, SWT.NONE); - l1.setText(Messages.ExpDialog_6); + l1.setText(Messages.ExpDialog_6); l1.setLayoutData(new GridData(GridData.BEGINNING)); - + txt1 = new Text(c, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; gd.widthHint = 300; txt1.setLayoutData(gd); txt1.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { setButtons(false); }}); - + Label l2 = new Label(c, SWT.NONE); - l2.setText(Messages.ExpDialog_7); + l2.setText(Messages.ExpDialog_7); l2.setLayoutData(new GridData(GridData.BEGINNING)); - + txt2 = new Text(c, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; gd.widthHint = 300; txt2.setLayoutData(gd); txt2.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { setButtons(false); }}); - + if (kind != ICSettingEntry.MACRO) { l1.setVisible(false); txt1.setVisible(false); @@ -132,21 +134,21 @@ public class ExpDialog extends AbstractPropertyDialog { txt2.setText(super.text1); if (!newAction) txt1.setEnabled(false); // macro name } - + b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME); c_all = new Button(c, SWT.CHECK); - c_all.setText(Messages.ExpDialog_0); + c_all.setText(Messages.ExpDialog_0); gd = new GridData(GridData.BEGINNING); gd.horizontalSpan = 2; c_all.setLayoutData(gd); c_all.setVisible(newAction); - + b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME); b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME); c_wsp = new Button(c, SWT.CHECK); - c_wsp.setText(Messages.ExpDialog_4); + c_wsp.setText(Messages.ExpDialog_4); gd = new GridData(GridData.BEGINNING); gd.horizontalSpan = 3; c_wsp.setLayoutData(gd); @@ -158,28 +160,28 @@ public class ExpDialog extends AbstractPropertyDialog { }}); c_wsp.setImage(AbstractExportTab.getWspImage(isWsp)); - + if (kind == ICSettingEntry.MACRO) { b_work.setVisible(false); b_file.setVisible(false); - c_wsp.setVisible(false); + c_wsp.setVisible(false); } - + Group dest = new Group(c, SWT.NONE); - dest.setText(Messages.ExpDialog_1); + dest.setText(Messages.ExpDialog_1); dest.setLayout(new GridLayout(2, true)); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 4; dest.setLayoutData(gd); - + Label l = new Label(dest, SWT.NONE); - l.setText(Messages.ExpDialog_2); + l.setText(Messages.ExpDialog_2); l.setLayoutData(new GridData(GridData.BEGINNING)); l = new Label(dest, SWT.NONE); - l.setText(Messages.ExpDialog_3); + l.setText(Messages.ExpDialog_3); l.setLayoutData(new GridData(GridData.BEGINNING)); - + c_langs = new Button(dest, SWT.CHECK); c_langs.setText(TO_ALL); c_langs.setLayoutData(new GridData(GridData.BEGINNING)); @@ -188,7 +190,7 @@ public class ExpDialog extends AbstractPropertyDialog { public void widgetSelected(SelectionEvent e) { langs.setEnabled(!c_langs.getSelection()); }}); - + c_types = new Button(dest, SWT.CHECK); c_types.setText(TO_ALL); c_types.setLayoutData(new GridData(GridData.BEGINNING)); @@ -197,23 +199,23 @@ public class ExpDialog extends AbstractPropertyDialog { public void widgetSelected(SelectionEvent e) { types.setEnabled(!c_types.getSelection()); }}); - + langs = new List(dest, SWT.BORDER | SWT.MULTI); langs.setLayoutData(new GridData(GridData.FILL_BOTH)); langs.setItems(names_l); setSelections(sel_langs, langs, c_langs); - + types = new List(dest, SWT.BORDER | SWT.MULTI); types.setLayoutData(new GridData(GridData.FILL_BOTH)); types.setItems(names_t); setSelections(sel_types, types, c_types); - + message = new Label(c, SWT.NONE); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 4; message.setLayoutData(gd); message.setForeground(c.getDisplay().getSystemColor(SWT.COLOR_RED)); - + // DUMMY PLACEHOLDER new Label(c, 0).setLayoutData(new GridData(GridData.BEGINNING)); b_ok = setupButton(c, IDialogConstants.OK_LABEL); @@ -223,8 +225,8 @@ public class ExpDialog extends AbstractPropertyDialog { c.pack(); setButtons(true); return c; - } - + } + private void setButtons(boolean anew) { if (b_ok == null) return; // while init only message.setText(EMPTY_STR); @@ -232,28 +234,28 @@ public class ExpDialog extends AbstractPropertyDialog { boolean enabled = true; if (kind == ICSettingEntry.MACRO) name = txt1.getText().trim(); - else + else name = txt2.getText().trim(); if (name.length() == 0) { enabled = false; if (!anew) { - if (kind == ICSettingEntry.MACRO) + if (kind == ICSettingEntry.MACRO) message.setText(EMPTY_NAME); - else + else message.setText(EMPTY_VALUE); } } if (enabled && existing != null && existing.contains(name)) { - message.setText(Messages.ExpDialog_9); + message.setText(Messages.ExpDialog_9); enabled = false; } b_ok.setEnabled(enabled); } - + @Override public void buttonPressed(SelectionEvent e) { String s; - if (e.widget.equals(b_ok)) { + if (e.widget.equals(b_ok)) { if (kind == ICSettingEntry.MACRO) super.text1 = txt1.getText(); super.text2 = txt2.getText(); @@ -262,7 +264,7 @@ public class ExpDialog extends AbstractPropertyDialog { sel_langs = (c_langs.getSelection()) ? null : langs.getSelection(); sel_types = (c_types.getSelection()) ? null : types.getSelection(); result = true; - shell.dispose(); + shell.dispose(); } else if (e.widget.equals(b_ko)) { shell.dispose(); } else if (e.widget.equals(b_vars)) { @@ -272,7 +274,7 @@ public class ExpDialog extends AbstractPropertyDialog { if (kind == ICSettingEntry.INCLUDE_PATH || kind == ICSettingEntry.LIBRARY_PATH) s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, txt2.getText()); - else + else s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, txt2.getText()); if (s != null) { s = strip_wsp(s); @@ -298,7 +300,7 @@ public class ExpDialog extends AbstractPropertyDialog { } } } - + protected void setSelections(String[] sel, List lst, Button check) { if (sel == null) { lst.setEnabled(false); @@ -312,7 +314,7 @@ public class ExpDialog extends AbstractPropertyDialog { int[] indices = new int[items.length]; for (int i=0; i y) { ((GridData)(text.getLayoutData())).widthHint = x; c.pack(); } - + setButtons(); return c; - } - + } + private void setButtons() { b_ok.setEnabled(text.getText().trim().length() > 0); } - + @Override public void buttonPressed(SelectionEvent e) { String s; - if (e.widget.equals(b_ok)) { + if (e.widget.equals(b_ok)) { text1 = text.getText(); check1 = b_add2confs.getSelection(); check2 = c_wsp.getSelection(); check3 = b_add2langs.getSelection(); result = true; - shell.dispose(); + shell.dispose(); } else if (e.widget.equals(b_ko)) { shell.dispose(); } else if (e.widget.equals(b_work)) { if ((mode & DIR_MASK)== DIR_MASK) s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, text.getText()); - else + else s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, text.getText()); if (s != null) { s = strip_wsp(s); @@ -231,10 +232,10 @@ public class IncludeDialog extends AbstractPropertyDialog { if (s != null) text.insert(s); } } - + static private Image getWspImage(boolean isWsp) { - final Image IMG_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE); - final Image IMG_FILESYSTEM = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER); + final Image IMG_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE); + final Image IMG_FILESYSTEM = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER); return isWsp ? IMG_WORKSPACE : IMG_FILESYSTEM; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java index e318962f774..f1b7cbbf7af 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java @@ -40,7 +40,8 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt sashForm.setWeights(PRIVATE_SASH_WEIGHTS); langTree.setVisible(false); } - + + @Override public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) { updateData(getResDesc()); } @@ -49,7 +50,7 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt public ICLanguageSettingEntry doAdd() { IncludeDialog dlg = new IncludeDialog( usercomp.getShell(), IncludeDialog.NEW_DIR, - Messages.LibraryPathTab_1, + Messages.LibraryPathTab_1, EMPTY_STR, getResDesc().getConfiguration(), 0); if (dlg.open() && dlg.text1.trim().length() > 0 ) { toAllCfgs = dlg.check1; @@ -65,7 +66,7 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) { IncludeDialog dlg = new IncludeDialog( usercomp.getShell(), IncludeDialog.OLD_DIR, - Messages.LibraryPathTab_2, + Messages.LibraryPathTab_2, ent.getValue(), getResDesc().getConfiguration(), (ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH)); if (dlg.open() && dlg.text1.trim().length() > 0 ) { @@ -75,12 +76,12 @@ public class LibraryPathTab extends AbstractLangsListTab implements IPathEntrySt } return null; } - + @Override - public int getKind() { - return ICSettingEntry.LIBRARY_PATH; + public int getKind() { + return ICSettingEntry.LIBRARY_PATH; } - + @Override protected boolean isHeaderVisible() { return false; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java index 9292bfed764..21105f5cf76 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java @@ -40,6 +40,7 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL langTree.setVisible(false); } + @Override public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) { updateData(getResDesc()); } @@ -79,12 +80,12 @@ public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreL } return null; } - + @Override - public int getKind() { - return ICSettingEntry.LIBRARY_FILE; + public int getKind() { + return ICSettingEntry.LIBRARY_FILE; } - + @Override protected boolean isHeaderVisible() { return false; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java index 3f546e5ce46..02529b5ad4d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java @@ -32,28 +32,30 @@ import org.eclipse.cdt.internal.ui.newui.Messages; * @noextend This class is not intended to be subclassed by clients. */ public class ManageConfigRunner implements IConfigManager { - private static final String MANAGE_TITLE = Messages.ManageConfigDialog_0; + private static final String MANAGE_TITLE = Messages.ManageConfigDialog_0; protected static ManageConfigRunner instance = null; - + private ICProjectDescription des = null; private IProject prj = null; - + public static ManageConfigRunner getDefault() { if (instance == null) instance = new ManageConfigRunner(); return instance; } - + + @Override public boolean canManage(IProject[] obs) { // Only one project can be accepted return (obs != null && obs.length == 1); } + @Override public boolean manage(IProject[] obs, boolean doOk) { if (!canManage(obs)) return false; - + ManageConfigDialog d = new ManageConfigDialog(Display.getDefault().getActiveShell(), obs[0].getName()+ ": " + MANAGE_TITLE, obs[0]); //$NON-NLS-1$ boolean result = false; @@ -61,7 +63,7 @@ public class ManageConfigRunner implements IConfigManager { if (doOk) { des = d.getProjectDescription(); prj = obs[0]; - if(des != null) + if(des != null) try { PlatformUI.getWorkbench().getProgressService().run(false, false, getRunnable()); } catch (InvocationTargetException e) {} @@ -74,11 +76,13 @@ public class ManageConfigRunner implements IConfigManager { } return result; } - + public IRunnableWithProgress getRunnable() { return new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException { CUIPlugin.getDefault().getShell().getDisplay().syncExec(new Runnable() { + @Override public void run() { try { CoreModel.getDefault().setProjectDescription(prj, des); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java index 36150069d30..c82f82ae9fc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java @@ -23,17 +23,18 @@ import org.eclipse.cdt.core.settings.model.MultiItemsHolder; import org.eclipse.cdt.internal.core.envvar.ContributedEnvironment; /** - * + * * @noextend This class is not intended to be subclassed by clients. */ public class MultiCfgContributedEnvironment implements IContributedEnvironment { private static final IContributedEnvironment ice = CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment(); private boolean isMulti = false; private ICConfigurationDescription[] mono = new ICConfigurationDescription[1]; - private static final EnvCmp comparator = new EnvCmp(); - + private static final EnvCmp comparator = new EnvCmp(); + private static class EnvCmp implements Comparator { - + + @Override public int compare(Object a0, Object a1) { if (a0 == null || a1 == null) return 0; @@ -52,11 +53,12 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment { return 0; } } - + public void setMulti(boolean val) { isMulti = val; } - + + @Override public IEnvironmentVariable addVariable(String name, String value, int op, String delimiter, ICConfigurationDescription des) { IEnvironmentVariable v = null; @@ -67,7 +69,7 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment { } private void doReplace(ICConfigurationDescription des) { - if (isMulti && ! isModifyMode()) { + if (isMulti && ! isModifyMode()) { IEnvironmentVariable[] vars = getVariables(des); for (int i=0; i0) indicating that * the editor should perform validation after every key stroke. @@ -46,7 +46,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { /** * Validation strategy constant (value 1) indicating that - * the editor should perform validation only when the text widget + * the editor should perform validation only when the text widget * loses focus. * * @see #setValidateStrategy @@ -93,19 +93,19 @@ public class MultiLineTextFieldEditor extends FieldEditor { private boolean emptyStringAllowed = true; /** - * The validation strategy; + * The validation strategy; * VALIDATE_ON_KEY_STROKE by default. */ private int validateStrategy = VALIDATE_ON_KEY_STROKE; /** - * Creates a new string field editor + * Creates a new string field editor */ protected MultiLineTextFieldEditor() { } /** * Creates a string field editor. * Use the method setTextLimit to limit the text. - * + * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param width the width of the text input field in characters, @@ -128,11 +128,11 @@ public class MultiLineTextFieldEditor extends FieldEditor { errorMessage = Messages.Multiline_error_message; createControl(parent); } - + /** * Creates a string field editor. * Use the method setTextLimit to limit the text. - * + * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param width the width of the text input field in characters, @@ -146,17 +146,17 @@ public class MultiLineTextFieldEditor extends FieldEditor { /** * Creates a string field editor of unlimited width. * Use the method setTextLimit to limit the text. - * + * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param parent the parent of the field editor's control */ - public MultiLineTextFieldEditor(String name, String labelText, Composite parent) { + public MultiLineTextFieldEditor(String name, String labelText, Composite parent) { this(name, labelText, UNLIMITED, parent); } /** - * Adjusts the horizontal span of this field editor's basic controls + * Adjusts the horizontal span of this field editor's basic controls *

* Subclasses must implement this method to adjust the horizontal span * of controls so they appear correct in the given number of columns. @@ -164,7 +164,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { *

* The number of columns will always be equal to or greater than the * value returned by this editor's getNumberOfControls method. - * + * * @param numColumns the number of columns */ @Override @@ -213,7 +213,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { * Hook for subclasses to do specific state checks. *

* The default implementation of this framework method does - * nothing and returns true. Subclasses should + * nothing and returns true. Subclasses should * override this method to specific state checks. *

* @@ -247,7 +247,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { textField.setLayoutData(gd); } - + /** * Initializes this field editor with the preference value from * the preference store. @@ -264,7 +264,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { oldValue = value; } } - + /** * Initializes this field editor with the default preference value from * the preference store. @@ -290,9 +290,9 @@ public class MultiLineTextFieldEditor extends FieldEditor { protected void doStore() { getPreferenceStore().setValue(getPreferenceName(), textField.getText()); } - + /** - * Returns the error message that will be displayed when and if + * Returns the error message that will be displayed when and if * an error occurs. * * @return the error message, or null if none @@ -319,7 +319,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { return textField.getText(); return getPreferenceStore().getString(getPreferenceName()); } - + /** * Returns this field editor's text control. * @return the text control, or null if no @@ -328,7 +328,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { protected Text getTextControl() { return textField; } - + /** * Returns this field editor's text control. *

@@ -387,6 +387,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { default : } textField.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent event) { textField = null; } @@ -399,7 +400,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { } return textField; } - + /** * Returns whether an empty string is a valid value. * @@ -410,7 +411,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { public boolean isEmptyStringAllowed() { return emptyStringAllowed; } - + /** * Returns whether this field editor contains a valid value. *

@@ -419,7 +420,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { * validation should override both this method and * refreshValidState. *

- * + * * @return true if the field value is valid, * and false if invalid * @see #refreshValidState @@ -428,7 +429,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { public boolean isValid() { return isValid; } - + /** * Refreshes this field editor's valid state after a value change * and fires an IS_VALID property change event if @@ -443,7 +444,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { protected void refreshValidState() { isValid = checkState(); } - + /** * Sets whether the empty string is a valid value or not. * @@ -453,9 +454,9 @@ public class MultiLineTextFieldEditor extends FieldEditor { public void setEmptyStringAllowed(boolean b) { emptyStringAllowed = b; } - + /** - * Sets the error message that will be displayed when and if + * Sets the error message that will be displayed when and if * an error occurs. * * @param message the error message @@ -463,7 +464,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { public void setErrorMessage(String message) { errorMessage = message; } - + /** * Sets the focus to this field editor. *

@@ -477,7 +478,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { textField.setFocus(); } } - + /** * Sets this field editor's value. * @@ -494,7 +495,7 @@ public class MultiLineTextFieldEditor extends FieldEditor { } } } - + /** * Sets this text field's text limit. * @@ -506,13 +507,13 @@ public class MultiLineTextFieldEditor extends FieldEditor { if (textField != null) textField.setTextLimit(limit); } - + /** * Sets the strategy for validating the text. *

* Calling this method has no effect after createPartControl * is called. Thus this method is really only useful for subclasses to call - * in their constructor. However, it has public visibility for backward + * in their constructor. However, it has public visibility for backward * compatibility. *

* @@ -525,20 +526,20 @@ public class MultiLineTextFieldEditor extends FieldEditor { value == VALIDATE_ON_FOCUS_LOST || value == VALIDATE_ON_KEY_STROKE); validateStrategy = value; } - + /** * Shows the error message set via setErrorMessage. */ public void showErrorMessage() { showErrorMessage(errorMessage); } - + /** * Informs this field editor's listener, if it has one, about a change * to the value (VALUE property) provided that the old and * new values are different. *

- * This hook is not called when the text is initialized + * This hook is not called when the text is initialized * (or reset to the default value) from the preference store. *

*/ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java index 2dbe75a3046..1a6a6aa844e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java @@ -51,12 +51,12 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { /** Default configurations defined in the toolchain description */ private ICProjectDescription des; private ICConfigurationDescription[] cfgds; - private ICConfigurationDescription parentConfig; + private ICConfigurationDescription parentConfig; private String newName; private String newDescription; private String title; - + /** */ protected NewConfigurationDialog(Shell parentShell) { @@ -65,19 +65,21 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { newName = new String(); newDescription = new String(); } - + + @Override public void setProject(ICProjectDescription prj) { des = prj; cfgds = des.getConfigurations(); } + @Override public void setTitle(String _title) { title = _title; } - + /* (non-Javadoc) * Method declared on Dialog. Cache the name and base config selections. - * We don't have to worry that the index or name is wrong because we + * We don't have to worry that the index or name is wrong because we * enable the OK button IFF those conditions are met. */ @Override @@ -86,14 +88,14 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { String description = new String(); String nameAndDescription = new String(); String baseConfigNameAndDescription = new String(); - + newName = configName.getText().trim(); newDescription = configDescription.getText().trim(); - - baseConfigNameAndDescription = cloneConfigSelector.getItem(cloneConfigSelector.getSelectionIndex()); + + baseConfigNameAndDescription = cloneConfigSelector.getItem(cloneConfigSelector.getSelectionIndex()); for (int i = 0; i < cfgds.length; i++) { description = cfgds[i].getDescription(); - + if( (description == null) || (description.equals("")) ){ //$NON-NLS-1$ nameAndDescription = cfgds[i].getName(); } else { @@ -101,7 +103,7 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { } if (nameAndDescription.equals(baseConfigNameAndDescription)) { parentConfig = cfgds[i]; - break; + break; } } newConfiguration(); @@ -157,16 +159,16 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { // as a directory name in the filesystem. Label warningLabel = new Label(group1, SWT.BEGINNING | SWT.WRAP); warningLabel.setFont(parent.getFont()); - warningLabel.setText(Messages.NewConfiguration_label_warning); + warningLabel.setText(Messages.NewConfiguration_label_warning); gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1); gd.widthHint = 300; warningLabel.setLayoutData(gd); - + // Add a label and a text widget for Configuration's name final Label nameLabel = new Label(group1, SWT.LEFT); nameLabel.setFont(parent.getFont()); nameLabel.setText(Messages.NewConfiguration_label_name); - + gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; gd.grabExcessHorizontalSpace = false; @@ -181,11 +183,12 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; configName.setLayoutData(gd); configName.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { validateState(); } }); - + // Add a label and a text widget for Configuration's description final Label descriptionLabel = new Label(group1, SWT.LEFT); descriptionLabel.setFont(parent.getFont()); @@ -199,12 +202,12 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { configDescription.setFont(group1.getFont()); configDescription.setText(getNewDescription()); configDescription.setFocus(); - + gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 2; gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; configDescription.setLayoutData(gd); - + final Group group = new Group(composite, SWT.NONE); group.setFont(composite.getFont()); group.setText(Messages.NewConfiguration_label_group); @@ -224,9 +227,9 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { cloneConfigSelector.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - validateState(); + validateState(); } - }); + }); statusLabel = new Label(composite, SWT.CENTER); gd = new GridData(GridData.FILL_HORIZONTAL); @@ -241,7 +244,7 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { /* * Returns the array of configuration names defined for this managed project. - * This list will be used to populate the list of configurations to + * This list will be used to populate the list of configurations to * clone. */ private String [] getDefinedConfigNamesAndDescriptions() { @@ -252,7 +255,7 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { else namesAndDescriptions[i] = cfgds[i].getName() + "( " + cfgds[i].getDescription() +" )"; //$NON-NLS-1$ //$NON-NLS-2$ } - return namesAndDescriptions; + return namesAndDescriptions; } /** @@ -262,10 +265,10 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { public String getNewName() { return newName; } - + protected boolean isDuplicateName(String newName) { for (int i = 0; i < cfgds.length; i++) { - if (cfgds[i].getName().equals(newName)) + if (cfgds[i].getName().equals(newName)) return true; } return false; @@ -280,7 +283,7 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { } /* (non-Javadoc) - * Checks the argument for leading whitespaces and invalid directory name characters. + * Checks the argument for leading whitespaces and invalid directory name characters. * @param name * @return true is the name is a valid directory name with no whitespaces */ @@ -288,7 +291,7 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { // Names must be at least one character in length if (name.trim().length() == 0) return false; - + // Iterate over the name checking for bad characters char[] chars = name.toCharArray(); // No whitespaces at the start of a name @@ -318,11 +321,11 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { /* (non-Javadoc) * Update the status message and button state based on the input selected * by the user - * + * */ private void validateState() { String s = null; - String currentName = configName.getText(); + String currentName = configName.getText(); // Trim trailing whitespace while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) { currentName = currentName.substring(0, currentName.length()-1); @@ -341,7 +344,7 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { } else if (!validateName(currentName)) { // TODO Create a decent I18N string to describe this problem s = NLS.bind(Messages.NewConfiguration_error_invalidName, currentName); - } + } if (statusLabel == null) return; Button b = getButton(IDialogConstants.OK_ID); if (s != null) { @@ -359,11 +362,11 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { } /** - * Create a new configuration, using the values currently set in + * Create a new configuration, using the values currently set in * the dialog. */ private void newConfiguration() { - String id = CDataUtil.genId(parentConfig.getId()); + String id = CDataUtil.genId(parentConfig.getId()); try { ICConfigurationDescription newcfg = des.createConfiguration(id, newName, parentConfig); newcfg.setDescription(newDescription); @@ -371,7 +374,8 @@ public class NewConfigurationDialog extends Dialog implements INewCfgDialog { System.out.println("Cannot create config\n"+ e.getLocalizedMessage()); //$NON-NLS-1$ } } - + // useless in our case + @Override public void setShell(Shell shell) {} } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java index 183a343f31b..4318a4c3c64 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java @@ -30,7 +30,7 @@ import org.eclipse.cdt.ui.dialogs.ICOptionContainer; public class Page_head_general extends PropertyPage implements ICOptionContainer { private DocCommentOwnerBlock fDocBlock; private boolean isProjectLevel; - + @Override protected Control createContents(Composite parent) { isProjectLevel= getProject() != null; @@ -42,7 +42,7 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer noDefaultAndApplyButton(); return parent; } - + @Override protected void performDefaults() { if(isProjectLevel) { @@ -50,7 +50,7 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer } super.performDefaults(); } - + @Override public boolean performOk() { if(isProjectLevel) { @@ -63,6 +63,7 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer return true; } + @Override public IProject getProject(){ IProject project= null; IAdaptable elem = getElement(); @@ -74,10 +75,12 @@ public class Page_head_general extends PropertyPage implements ICOptionContainer return project; } + @Override public Preferences getPreferences() { throw new UnsupportedOperationException(); } + @Override public void updateContainer() { } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java index 44152480538..a56d7995f80 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Intel corporation - cloned to CDT UI, to avoid discouraged access + * Intel corporation - cloned to CDT UI, to avoid discouraged access *******************************************************************************/ package org.eclipse.cdt.ui.newui; @@ -41,14 +41,14 @@ import org.eclipse.cdt.internal.ui.newui.Messages; * @noextend This class is not intended to be subclassed by clients. */ public class ProjectContentsArea { - private static final String ERROR_INVALID_PATH = Messages.ProjectContentsArea_3; - private static final String ERROR_PATH_EMPTY = Messages.ProjectContentsArea_4; - private static final String ERROR_NOT_ABSOLUTE = Messages.ProjectContentsArea_6; - private static final String ERROR_NOT_VALID = Messages.ProjectContentsArea_7; - private static final String ERROR_CANNOT_CREATE = Messages.ProjectContentsArea_8; - private static final String ERROR_FILE_EXISTS = Messages.ProjectContentsArea_9; - - private static final String BROWSE_LABEL = Messages.ProjectContentsArea_0; + private static final String ERROR_INVALID_PATH = Messages.ProjectContentsArea_3; + private static final String ERROR_PATH_EMPTY = Messages.ProjectContentsArea_4; + private static final String ERROR_NOT_ABSOLUTE = Messages.ProjectContentsArea_6; + private static final String ERROR_NOT_VALID = Messages.ProjectContentsArea_7; + private static final String ERROR_CANNOT_CREATE = Messages.ProjectContentsArea_8; + private static final String ERROR_FILE_EXISTS = Messages.ProjectContentsArea_9; + + private static final String BROWSE_LABEL = Messages.ProjectContentsArea_0; private static final int SIZING_TEXT_FIELD_WIDTH = 250; private static final String FILE_SCHEME = "file"; //$NON-NLS-1$ private Label locationLabel; @@ -62,7 +62,7 @@ public class ProjectContentsArea { /** * Create a new instance of a ProjectContentsLocationArea. - * + * * @param composite */ public ProjectContentsArea(IErrorMessageReporter er, Composite composite) { @@ -72,7 +72,7 @@ public class ProjectContentsArea { /** * Create the contents of the receiver. - * + * * @param composite * @param defaultEnabled */ @@ -85,7 +85,7 @@ public class ProjectContentsArea { projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); useDefaultsButton = new Button(projectGroup, SWT.CHECK | SWT.RIGHT); - useDefaultsButton.setText(Messages.ProjectContentsArea_1); + useDefaultsButton.setText(Messages.ProjectContentsArea_1); useDefaultsButton.setSelection(defaultEnabled); GridData buttonData = new GridData(); buttonData.horizontalSpan = 4; @@ -114,7 +114,7 @@ public class ProjectContentsArea { /** * Return whether or not we are currently showing the default location for * the project. - * + * * @return boolean */ public boolean isDefault() { @@ -123,14 +123,14 @@ public class ProjectContentsArea { /** * Create the area for user entry. - * + * * @param composite * @param defaultEnabled */ private void createUserEntryArea(Composite composite, boolean defaultEnabled) { // location label locationLabel = new Label(composite, SWT.NONE); - locationLabel.setText(Messages.ProjectContentsArea_2); + locationLabel.setText(Messages.ProjectContentsArea_2); // project location entry field locationPathField = new Text(composite, SWT.BORDER); @@ -162,6 +162,7 @@ public class ProjectContentsArea { } locationPathField.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { errorReporter.reportError(checkValidLocation()); } @@ -171,7 +172,7 @@ public class ProjectContentsArea { /** * Return the path we are going to display. If it is a file URI then remove * the file prefix. - * + * * @return String */ private String getDefaultPathDisplayString() { @@ -191,7 +192,7 @@ public class ProjectContentsArea { /** * Set the enablement state of the receiver. - * + * * @param enabled */ private void setUserAreaEnabled(boolean enabled) { @@ -203,7 +204,7 @@ public class ProjectContentsArea { /** * Return the browse button. Usually referenced in order to set the layout * data for a dialog. - * + * * @return Button */ public Button getBrowseButton() { @@ -224,7 +225,7 @@ public class ProjectContentsArea { } DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell()); - dialog.setMessage(Messages.ProjectContentsArea_5); + dialog.setMessage(Messages.ProjectContentsArea_5); dialog.setFilterPath(dirName); selectedDirectory = dialog.open(); @@ -234,7 +235,7 @@ public class ProjectContentsArea { /** * Update the location field based on the selected path. - * + * * @param selectedPath */ private void updateLocationField(String selectedPath) { @@ -243,7 +244,7 @@ public class ProjectContentsArea { /** * Return the path on the location field. - * + * * @return String */ private String getPathFromLocationField() { @@ -259,18 +260,18 @@ public class ProjectContentsArea { /** * Check if the entry in the widget location is valid. If it is valid return * null. Otherwise return a string that indicates the problem. - * + * * @return String */ private String checkValidLocation() { - + if (isDefault()) return null; - + String locationFieldContents = locationPathField.getText(); - + if (locationFieldContents.length() == 0) return ERROR_PATH_EMPTY; - + URI newPath = getProjectLocationURI(); if (newPath == null) @@ -280,10 +281,10 @@ public class ProjectContentsArea { return ERROR_NOT_VALID; Path p = new Path(locationFieldContents); - + if (!p.isAbsolute()) return ERROR_NOT_ABSOLUTE; - + // try to create dummy file File f = p.toFile(); if (!f.exists()) { @@ -291,24 +292,24 @@ public class ProjectContentsArea { try { result = f.createNewFile(); } catch (IOException e) {} - + if (result) f.delete(); else return ERROR_CANNOT_CREATE; } else { - if (f.isFile()) + if (f.isFile()) return ERROR_FILE_EXISTS; } - + //create a dummy project for the purpose of validation if necessary IProject project = existingProject; if (project == null) { String name = new Path(locationFieldContents).lastSegment(); if (name != null && Path.EMPTY.isValidSegment(name)) project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); - else - return ERROR_INVALID_PATH; + else + return ERROR_INVALID_PATH; } IStatus locationStatus = project.getWorkspace().validateProjectLocationURI(project, newPath); @@ -328,7 +329,7 @@ public class ProjectContentsArea { * Get the URI for the location field if possible. * @return URI or null if it is not valid. */ - public URI getProjectLocationURI() { + public URI getProjectLocationURI() { return URIUtil.toURI(locationPathField.getText()); } @@ -347,12 +348,12 @@ public class ProjectContentsArea { /** * Return the location for the project. If we are using defaults then return * the workspace root so that core creates it with default values. - * + * * @return String */ public String getProjectLocation() { - return isDefault() ? - Platform.getLocation().toString(): + return isDefault() ? + Platform.getLocation().toString(): locationPathField.getText(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java index a140e8634aa..120caaebc72 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java @@ -24,7 +24,8 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester private static final String KEY_PAGE = "pageEnabled"; //$NON-NLS-1$ private static final String VAL_EXP = "export"; //$NON-NLS-1$ private static final String VAL_TOOL = "toolEdit"; //$NON-NLS-1$ - + + @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (KEY_SRC.equals(property)) { @@ -35,7 +36,7 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester IFile file = (IFile)receiver; return CoreModel.isValidSourceUnitName(file.getProject(), file.getName()); } - } else if (KEY_PAGE.equals(property) + } else if (KEY_PAGE.equals(property) && expectedValue instanceof String) { String s = (String) expectedValue; if (VAL_EXP.equalsIgnoreCase(s)) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java index 4558fe5b29f..df8c516ea44 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java @@ -134,9 +134,11 @@ public class RefsTab extends AbstractCPropertyTab { }); tree.addTreeListener(new TreeListener() { + @Override public void treeCollapsed(TreeEvent e) { updateExpandButtons(e, false, true); } + @Override public void treeExpanded(TreeEvent e) { updateExpandButtons(e, true, false); }}); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java index 0b59899f563..bd0b1f312f3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java @@ -11,10 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.ui.newui; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; - -import org.eclipse.cdt.internal.ui.newui.Messages; - import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.JFacePreferences; @@ -33,26 +29,30 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; + +import org.eclipse.cdt.internal.ui.newui.Messages; + /** * @noextend This class is not intended to be subclassed by clients. */ public class RenameConfigurationDialog extends Dialog { // Widgets - + private Text configName; private Text configDescription; - + private ICConfigurationDescription[] cfgds; private ICConfigurationDescription renameConfig; private String newName; private String newDescription; private Label statusLabel; - + private String originalName; final private String title; /** */ - protected RenameConfigurationDialog(Shell parentShell, + protected RenameConfigurationDialog(Shell parentShell, ICConfigurationDescription _renameConfig, ICConfigurationDescription[] _cfgds, String _title) { @@ -60,17 +60,17 @@ public class RenameConfigurationDialog extends Dialog { title = _title; renameConfig = _renameConfig; cfgds = _cfgds; - + setShellStyle(getShellStyle()|SWT.RESIZE); newName = renameConfig.getName(); newDescription = renameConfig.getDescription(); if(newDescription == null) newDescription = new String(); originalName = renameConfig.getName(); } - + /* (non-Javadoc) * Method declared on Dialog. Cache the name and base config selections. - * We don't have to worry that the index or name is wrong because we + * We don't have to worry that the index or name is wrong because we * enable the OK button IFF those conditions are met. */ @Override @@ -78,7 +78,7 @@ public class RenameConfigurationDialog extends Dialog { if (buttonId == IDialogConstants.OK_ID) { newName = configName.getText().trim(); newDescription = configDescription.getText().trim(); - } + } super.buttonPressed(buttonId); } @@ -106,12 +106,12 @@ public class RenameConfigurationDialog extends Dialog { @Override protected Control createDialogArea(Composite parent) { - + Composite composite = new Composite(parent, SWT.NULL); composite.setFont(parent.getFont()); composite.setLayout(new GridLayout(3, false)); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - + // Create a group for the name & description final Group group1 = new Group(composite, SWT.NONE); @@ -126,7 +126,7 @@ public class RenameConfigurationDialog extends Dialog { // as a directory name in the filesystem. Label warningLabel = new Label(group1, SWT.BEGINNING | SWT.WRAP); warningLabel.setFont(parent.getFont()); - warningLabel.setText(Messages.RenameConfiguration_label_warning); + warningLabel.setText(Messages.RenameConfiguration_label_warning); gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1); gd.widthHint = 300; warningLabel.setLayoutData(gd); @@ -135,7 +135,7 @@ public class RenameConfigurationDialog extends Dialog { final Label nameLabel = new Label(group1, SWT.LEFT); nameLabel.setFont(parent.getFont()); nameLabel.setText(Messages.RenameConfiguration_label_name); - + gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 1; gd.grabExcessHorizontalSpace = false; @@ -150,11 +150,12 @@ public class RenameConfigurationDialog extends Dialog { gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; configName.setLayoutData(gd); configName.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { validateState(); } }); - + // Add a label and a text widget for Configuration's description final Label descriptionLabel = new Label(group1, SWT.LEFT); descriptionLabel.setFont(parent.getFont()); @@ -168,12 +169,12 @@ public class RenameConfigurationDialog extends Dialog { configDescription.setFont(group1.getFont()); configDescription.setText(getNewDescription()); configDescription.setFocus(); - + gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 2; gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; configDescription.setLayoutData(gd); - + statusLabel = new Label(parent, SWT.CENTER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; @@ -191,7 +192,7 @@ public class RenameConfigurationDialog extends Dialog { } return false; } - + protected boolean isSimilarName(String newName) { if(newName.equalsIgnoreCase(originalName)) return false; // Return true if there is already a config of that name defined on the target @@ -202,7 +203,7 @@ public class RenameConfigurationDialog extends Dialog { } /* (non-Javadoc) - * Checks the argument for leading whitespaces and invalid directory name characters. + * Checks the argument for leading whitespaces and invalid directory name characters. * @param name * @return true is the name is a valid directory name with no whitespaces */ @@ -236,7 +237,7 @@ public class RenameConfigurationDialog extends Dialog { /* (non-Javadoc) * Update the status message and button state based on the input selected * by the user - * + * */ private void validateState() { String s = null; @@ -250,7 +251,7 @@ public class RenameConfigurationDialog extends Dialog { } else if (isSimilarName(currentName)) { s = NLS.bind(Messages.RenameConfiguration_error_caseName, currentName); } else if (!validateName(currentName)) { - s = NLS.bind(Messages.RenameConfiguration_error_invalidName, currentName); + s = NLS.bind(Messages.RenameConfiguration_error_invalidName, currentName); } Button b = getButton(IDialogConstants.OK_ID); if (s != null) { @@ -263,7 +264,7 @@ public class RenameConfigurationDialog extends Dialog { } return; } - + public String getNewName() { return newName; } public String getNewDescription() { return newDescription; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java index 3b65521812f..43e45eb22d0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java @@ -51,6 +51,7 @@ public class StringListModeControl { linkStringListMode.setToolTipText(Messages.AbstractLangsListTab_MultiConfigStringListModeLinkHint); linkStringListMode.addListener(SWT.Selection, new Listener() { + @Override public void handleEvent(Event event) { // Use event.text to tell which link was used int result = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), STRING_LIST_MODE_PREFERENCE_PAGE, null, null).open(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java index 21f9c9197a0..4cefeecc69b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java @@ -68,18 +68,18 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.newui.Messages; /** - * This tab is intended to browse - * contents of whole class such as ResourceDescription, + * This tab is intended to browse + * contents of whole class such as ResourceDescription, * ConfigurationDescription or ProjectDescription - * + * * Notes: - * + * * 1. Many strings in the file remain unlocalized * since they represent method names. - * 2. It is experimental functionality. Work is in progress. + * 2. It is experimental functionality. Work is in progress. * 3. Tree depth is limited by 16. Deeper branches are truncated. * But it seems to be very rare situation. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class StructureTreeTab extends AbstractCPropertyTab { @@ -94,7 +94,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { c.setLayoutData(new GridData(GridData.FILL_BOTH)); c.setLayout(new GridLayout(2, false)); Label l = new Label(c, 0); - l.setText(Messages.StructureTreeTab_0); + l.setText(Messages.StructureTreeTab_0); c.setLayoutData(new GridData(GridData.BEGINNING)); Spinner sp = new Spinner(c, SWT.BORDER); sp.setMaximum(NESTING_MAX); @@ -135,17 +135,17 @@ public class StructureTreeTab extends AbstractCPropertyTab { ti = ti.getParentItem(); if (ti == null) return true; } - tiSaved.setText(2, Messages.StructureTreeTab_1); + tiSaved.setText(2, Messages.StructureTreeTab_1); tiSaved.setImage(IMG); return false; } - + private TreeItem create(TreeItem ti0, String text, boolean val) { TreeItem t = create(ti0, text, String.valueOf(val)); t.setText(2, EMPTY_STR); return t; } - + private TreeItem create(TreeItem ti0, String text, int val) { TreeItem t = create(ti0, text, String.valueOf(val)); t.setText(2, EMPTY_STR); @@ -153,7 +153,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { } private TreeItem create(TreeItem ti0, String text, long val) { TreeItem t = create(ti0, text, String.valueOf(val)); - t.setText(2, Messages.StructureTreeTab_2); + t.setText(2, Messages.StructureTreeTab_2); return t; } @@ -161,25 +161,25 @@ public class StructureTreeTab extends AbstractCPropertyTab { TreeItem ti = ti0 == null ? new TreeItem(tree, 0) : new TreeItem(ti0, 0); ti.setText(0, text == null ? NULL : text); ti.setText(1, val == null ? NULL : val ); - ti.setText(2, Messages.StructureTreeTab_3); + ti.setText(2, Messages.StructureTreeTab_3); return ti; } - + @Override public void createControls(Composite parent) { super.createControls(parent); usercomp.setLayout(new GridLayout(5, false)); - + Label lb = new Label(usercomp, 0); - lb.setText(Messages.StructureTreeTab_4); + lb.setText(Messages.StructureTreeTab_4); lb.setLayoutData(new GridData(GridData.BEGINNING)); - + combo = new Combo(usercomp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER); combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - combo.add(Messages.ConfigDescriptionTab_0); - combo.add(Messages.ConfigDescriptionTab_1); + combo.add(Messages.ConfigDescriptionTab_0); + combo.add(Messages.ConfigDescriptionTab_1); if (page.isForFolder() || page.isForFile()) { - combo.add(Messages.ConfigDescriptionTab_2); + combo.add(Messages.ConfigDescriptionTab_2); combo.select(2); // ResourceDescription } else combo.select(1); // ConfigurationDescription @@ -193,7 +193,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { GridData gd = new GridData(GridData.END); gd.minimumWidth = BUTTON_WIDTH; b1.setLayoutData(gd); - b1.setText(Messages.StructureTreeTab_5); + b1.setText(Messages.StructureTreeTab_5); b1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -206,7 +206,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { gd = new GridData(GridData.END); gd.minimumWidth = BUTTON_WIDTH; b2.setLayoutData(gd); - b2.setText(Messages.StructureTreeTab_6); + b2.setText(Messages.StructureTreeTab_6); b2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -216,46 +216,48 @@ public class StructureTreeTab extends AbstractCPropertyTab { expandAll(tree.getItem(0), true, 0); tree.setRedraw(true); } - }}); + }}); Button b3 = new Button(usercomp, SWT.PUSH); gd = new GridData(GridData.END); gd.minimumWidth = BUTTON_WIDTH; b3.setLayoutData(gd); - b3.setText(Messages.StructureTreeTab_7); + b3.setText(Messages.StructureTreeTab_7); b3.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { tree.setRedraw(false); expandAll(tree.getItem(0), false, -1); tree.setRedraw(true); - }}); + }}); tree = new Tree(usercomp, SWT.BORDER); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 5; tree.setLayoutData(gd); - + TreeColumn tc = new TreeColumn(tree, 0); - tc.setText(Messages.StructureTreeTab_8); + tc.setText(Messages.StructureTreeTab_8); tc.setWidth(300); tc = new TreeColumn(tree, 0); - tc.setText(Messages.StructureTreeTab_9); + tc.setText(Messages.StructureTreeTab_9); tc.setWidth(100); tc = new TreeColumn(tree, 0); - tc.setText(Messages.StructureTreeTab_10); + tc.setText(Messages.StructureTreeTab_10); tc.setWidth(200); - + tree.setHeaderVisible(true); tree.setLinesVisible(true); - + tree.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { } + @Override public void widgetSelected(SelectionEvent e) { }}); } - + private TreeItem createObj(TreeItem ti0, String text, String name, Object obj) { TreeItem t = create(ti0, text, BL+name+BR); if (obj != null) t.setText(2, obj.getClass().getName()); @@ -263,11 +265,11 @@ public class StructureTreeTab extends AbstractCPropertyTab { } /** - * Adds conents of array to tree. + * Adds conents of array to tree. */ private void expand(TreeItem ti0, String text, Object[] obs) { TreeItem ti = create(ti0, text, obs == null ? 0 : obs.length); - if (obs == null || !check(ti, obs)) + if (obs == null || !check(ti, obs)) return; for (int i=0; i NESTING_CFG) return ti; - + update(ti, "getBuildSetting()", cfg.getBuildSetting()); //$NON-NLS-1$ create(ti, "getBuildSystemId()", cfg.getBuildSystemId()); //$NON-NLS-1$ createObj(ti, "getBuildVariablesContributor()", EMPTY_STR, cfg.getBuildVariablesContributor()); //$NON-NLS-1$ @@ -469,7 +471,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { if (!check(ti, s)) return ti; char[][] chrs = s.fullExclusionPatternChars(); TreeItem ti1 = create(ti, "fullExclusionPatternChars()", chrs.length); //$NON-NLS-1$ - for (int j=0; j NESTING_CFG) + if (getDepth(ti) > NESTING_CFG) create(ti, "getNestedResourceDescriptions()", rds.length); //$NON-NLS-1$ else expand(ti, "getNestedResourceDescriptions()", rds); //$NON-NLS-1$ @@ -520,7 +522,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { create(ti,"isRoot()",((ICFolderDescription)rcfg).isRoot()); //$NON-NLS-1$ create(ti,"isValid()",rcfg.isValid()); //$NON-NLS-1$ return ti; - } + } private TreeItem update(TreeItem ti0, String text, ICLanguageSetting ls) { TreeItem ti = createObj(ti0, text, ls == null ? NULL : ls.getName(), ls); if (ls == null || !check(ti, ls)) return ti; @@ -564,8 +566,8 @@ public class StructureTreeTab extends AbstractCPropertyTab { if (getDepth(ti) > NESTING_CFG) return ti; expand(ti, "getChildSettings()", c.getChildSettings()); //$NON-NLS-1$ return ti; - } - + } + private TreeItem update(TreeItem ti0, String text, ICSettingObject obj) { TreeItem ti = createObj(ti0, text, obj == null ? NULL : obj.getName(), obj); if (obj == null || !check(ti, obj)) return ti; @@ -597,7 +599,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { private TreeItem update(TreeItem ti0, String text, IPath p) { TreeItem ti = createObj(ti0, text, p == null ? NULL : p.toString(), p); if (p == null || !check(ti, p)) return ti; - create(ti, "getDevice()", p.getDevice()); //$NON-NLS-1$ + create(ti, "getDevice()", p.getDevice()); //$NON-NLS-1$ create(ti, "getFileExtension()", p.getFileExtension()); //$NON-NLS-1$ create(ti, "hasTrailingSeparator()", p.hasTrailingSeparator()); //$NON-NLS-1$ create(ti, "isAbsolute()", p.isAbsolute()); //$NON-NLS-1$ @@ -605,8 +607,8 @@ public class StructureTreeTab extends AbstractCPropertyTab { create(ti, "isRoot()", p.isRoot()); //$NON-NLS-1$ create(ti, "isUNC()", p.isUNC()); //$NON-NLS-1$ TreeItem ti1 = create(ti, "segmentCount()", p.segmentCount()); //$NON-NLS-1$ - for (int i=0; i NESTING_CFG) return ti; - + if (c instanceof IContainer) try { create(ti, "getDefaultCharset()", ((IContainer)c).getDefaultCharset()); //$NON-NLS-1$ } catch (CoreException e) {} create(ti, "getFileExtension()", c.getFileExtension()); //$NON-NLS-1$ update(ti, "getFullPath()", c.getFullPath()); //$NON-NLS-1$ -// TODO: +// TODO: // c.getLocalTimeStamp()); update(ti, "getLocation()", c.getLocation()); //$NON-NLS-1$ update(ti, "getLocationURI()", c.getLocationURI()); //$NON-NLS-1$ @@ -723,7 +725,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { check(ti, ob); return ti; } - + private TreeItem update(TreeItem ti0, String text, Map m) { String s = (m == null) ? NULL : String.valueOf(m.size()); TreeItem ti = createObj(ti0, text, s, m); @@ -735,7 +737,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { } return ti; } - + private TreeItem update(TreeItem ti0, String text, ResourceAttributes ra) { TreeItem ti = createObj(ti0, text, EMPTY_STR, ra); if (!check(ti, ra)) return ti; @@ -760,16 +762,17 @@ public class StructureTreeTab extends AbstractCPropertyTab { create(ti, "toASCIIString()", uri.toASCIIString()); //$NON-NLS-1$ return ti; } - + @Override public void updateData(ICResourceDescription rcfg) { cfg = rcfg; tree.getDisplay().asyncExec(new Runnable() { + @Override public void run() { try { tree.removeAll(); TreeItem ti = new TreeItem(tree, 0); - ti.setText(0, Messages.StructureTreeTab_11); + ti.setText(0, Messages.StructureTreeTab_11); tree.update(); tree.setRedraw(false); tree.removeAll(); @@ -777,10 +780,10 @@ public class StructureTreeTab extends AbstractCPropertyTab { case 0: update(cfg.getConfiguration().getProjectDescription()); break; - case 1: + case 1: update(null, "ICConfigurationDescription", cfg.getConfiguration()); //$NON-NLS-1$ break; - case 2: + case 2: update(null, "ICResourceDescription", cfg); //$NON-NLS-1$ break; } @@ -790,7 +793,7 @@ public class StructureTreeTab extends AbstractCPropertyTab { } }); } - + // This page can be displayed if it's permitted in prefs @Override public boolean canBeVisible() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java index e7d4c9ffcfb..78c0e335ef9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java @@ -59,39 +59,41 @@ public class SymbolDialog extends AbstractPropertyDialog { protected Control createDialogArea(Composite c) { c.setLayout(new GridLayout(4, true)); GridData gd; - + Label l1 = new Label(c, SWT.NONE); - l1.setText(Messages.SymbolDialog_0); + l1.setText(Messages.SymbolDialog_0); l1.setLayoutData(new GridData(GridData.BEGINNING)); - + txt1 = new Text(c, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; gd.widthHint = 300; txt1.setLayoutData(gd); txt1.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { setButtons(); - }}); - + }}); + Label l2 = new Label(c, SWT.NONE); - l2.setText(Messages.SymbolDialog_1); + l2.setText(Messages.SymbolDialog_1); l2.setLayoutData(new GridData(GridData.BEGINNING)); - + txt2 = new Text(c, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; gd.widthHint = 200; txt2.setLayoutData(gd); txt2.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { setButtons(); - }}); + }}); b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME); - + b_add2conf = new Button(c, SWT.CHECK); - b_add2conf.setText(Messages.IncludeDialog_2); + b_add2conf.setText(Messages.IncludeDialog_2); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 4; b_add2conf.setLayoutData(gd); @@ -101,7 +103,7 @@ public class SymbolDialog extends AbstractPropertyDialog { } b_add2lang = new Button(c, SWT.CHECK); - b_add2lang.setText(Messages.IncludeDialog_3); + b_add2lang.setText(Messages.IncludeDialog_3); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 4; b_add2lang.setLayoutData(gd); @@ -109,37 +111,37 @@ public class SymbolDialog extends AbstractPropertyDialog { b_add2lang.setVisible(false); txt1.setEnabled(false); // don't change name } - + // add 2 placeholders new Label(c, 0).setLayoutData(new GridData()); new Label(c, 0).setLayoutData(new GridData()); b_ok = setupButton(c, IDialogConstants.OK_LABEL); b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL); - + c.getShell().setDefaultButton(b_ok); c.pack(); // moved here to avoid accessing b_ok before it created. txt1.setText(data1); - txt2.setText(data2); - + txt2.setText(data2); + setButtons(); return c; - } - + } + private void setButtons() { b_ok.setEnabled(txt1.getText().trim().length() > 0); } - + @Override public void buttonPressed(SelectionEvent e) { - if (e.widget.equals(b_ok)) { + if (e.widget.equals(b_ok)) { super.text1 = txt1.getText(); super.text2 = txt2.getText(); - check1 = b_add2conf.getSelection(); - check3 = b_add2lang.getSelection(); + check1 = b_add2conf.getSelection(); + check3 = b_add2lang.getSelection(); result = true; - shell.dispose(); + shell.dispose(); } else if (e.widget.equals(b_ko)) { shell.dispose(); } else if (e.widget.equals(b_vars)) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java index e2bf380dd61..8901d6cab13 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java @@ -54,29 +54,29 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard; -public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard +public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard { private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$ private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$ private static final String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$ private static final String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$ - private static final String[] EMPTY_ARR = new String[0]; - + private static final String[] EMPTY_ARR = new String[0]; + protected IConfigurationElement fConfigElement; protected CDTMainWizardPage fMainPage; - + protected IProject newProject; private String wz_title; private String wz_desc; - + private boolean existingPath = false; private String lastProjectName = null; private URI lastProjectLocation = null; private CWizardHandler savedHandler = null; public CDTCommonProjectWizard() { - this(Messages.NewModelProjectWizard_0,Messages.NewModelProjectWizard_1); + this(Messages.NewModelProjectWizard_0,Messages.NewModelProjectWizard_1); } public CDTCommonProjectWizard(String title, String desc) { @@ -88,7 +88,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard wz_title = title; wz_desc = desc; } - + @Override public void addPages() { fMainPage= new CDTMainWizardPage(CUIPlugin.getResourceString(PREFIX)); @@ -106,30 +106,32 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard if (!fMainPage.getProjectName().equals(lastProjectName)) return true; - + URI projectLocation = fMainPage.getProjectLocation(); if (projectLocation == null) { if (lastProjectLocation != null) return true; } else if (!projectLocation.equals(lastProjectLocation)) return true; - - return savedHandler.isChanged(); + + return savedHandler.isChanged(); } + @Override public IProject getProject(boolean defaults) { return getProject(defaults, true); } + @Override public IProject getProject(boolean defaults, boolean onFinish) { - if (newProject != null && isChanged()) - clearProject(); + if (newProject != null && isChanged()) + clearProject(); if (newProject == null) { existingPath = false; try { IFileStore fs; URI p = fMainPage.getProjectLocation(); - if (p == null) { + if (p == null) { fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI()); fs = fs.getChild(fMainPage.getProjectName()); } else @@ -150,14 +152,14 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard lastProjectName = fMainPage.getProjectName(); lastProjectLocation = fMainPage.getProjectLocation(); // start creation process - invokeRunnable(getRunnable(defaults, onFinish)); - } + invokeRunnable(getRunnable(defaults, onFinish)); + } return newProject; } /** * Remove created project either after error - * or if user returned back from config page. + * or if user returned back from config page. */ private void clearProject() { if (lastProjectName == null) return; @@ -168,7 +170,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard lastProjectName = null; lastProjectLocation = null; } - + private boolean invokeRunnable(IRunnableWithProgress runnable) { IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable); try { @@ -188,7 +190,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard public boolean performFinish() { boolean needsPost = (newProject != null && !isChanged()); // create project if it is not created yet - if (getProject(fMainPage.isCurrent(), true) == null) + if (getProject(fMainPage.isCurrent(), true) == null) return false; fMainPage.h_selected.postProcess(newProject, needsPost); try { @@ -201,16 +203,16 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard selectAndReveal(newProject); return true; } - + protected boolean setCreated() throws CoreException { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - + ICProjectDescription des = mngr.getProjectDescription(newProject, false); - + if(des == null ) { return false; } - + if(des.isCdtProjectCreating()){ des = mngr.getProjectDescription(newProject, true); des.setCdtProjectCreated(); @@ -219,13 +221,14 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard } return false; } - + @Override public boolean performCancel() { clearProject(); return true; } + @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { fConfigElement= config; } @@ -233,11 +236,14 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard private IRunnableWithProgress getRunnable(boolean _defaults, final boolean onFinish) { final boolean defaults = _defaults; return new IRunnableWithProgress() { + @Override public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException { final Exception except[] = new Exception[1]; getShell().getDisplay().syncExec(new Runnable() { + @Override public void run() { IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { final IProgressMonitor fMonitor; if (monitor == null) { @@ -247,9 +253,9 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard } fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$ fMonitor.worked(10); - try { + try { newProject = createIProject(lastProjectName, lastProjectLocation, new SubProgressMonitor(fMonitor, 40)); - if (newProject != null) + if (newProject != null) fMainPage.h_selected.createProject(newProject, defaults, onFinish, new SubProgressMonitor(fMonitor, 40)); fMonitor.worked(10); } catch (CoreException e) { CUIPlugin.log(e); } @@ -275,35 +281,37 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard throw (InterruptedException)except[0]; } throw new InvocationTargetException(except[0]); - } + } } }; } - + + @Override public IProject createIProject(final String name, final URI location) throws CoreException{ return createIProject(name, location, new NullProgressMonitor()); } - + /** * @since 5.1 */ protected IProgressMonitor continueCreationMonitor; /** - * @param monitor + * @param monitor * @since 5.1 - * - */ + * + */ + @Override public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException{ - - monitor.beginTask(Messages.CDTCommonProjectWizard_creatingProject, 100); - + + monitor.beginTask(Messages.CDTCommonProjectWizard_creatingProject, 100); + if (newProject != null) return newProject; - + IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); final IProject newProjectHandle = root.getProject(name); - + if (!newProjectHandle.exists()) { // IWorkspaceDescription workspaceDesc = workspace.getDescription(); // workspaceDesc.setAutoBuilding(false); @@ -314,6 +322,7 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new SubProgressMonitor(monitor,25)); } else { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); } @@ -321,28 +330,29 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor,25)); newProject = newProjectHandle; } - + // Open the project if we have to if (!newProject.isOpen()) { newProject.open(new SubProgressMonitor(monitor,25)); } - + continueCreationMonitor = new SubProgressMonitor(monitor,25); IProject proj = continueCreation(newProject); - + monitor.done(); - - return proj; + + return proj; } - - protected abstract IProject continueCreation(IProject prj); + + protected abstract IProject continueCreation(IProject prj); + @Override public abstract String[] getNatures(); - + @Override public void dispose() { fMainPage.dispose(); } - + @Override public boolean canFinish() { if (fMainPage.h_selected != null) { @@ -356,19 +366,23 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard /** * Returns last project name used for creation */ + @Override public String getLastProjectName() { return lastProjectName; } + @Override public URI getLastProjectLocation() { return lastProjectLocation; } + @Override public IProject getLastProject() { return newProject; } // Methods below should provide data for language check + @Override public String[] getLanguageIDs (){ String[] contentTypeIds = getContentTypeIDs(); if(contentTypeIds.length > 0) { @@ -387,9 +401,11 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard } return EMPTY_ARR; } + @Override public String[] getContentTypeIDs (){ return EMPTY_ARR; } + @Override public String[] getExtensions (){ String[] contentTypeIds = getContentTypeIDs(); if(contentTypeIds.length > 0) { @@ -406,5 +422,5 @@ implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard } return EMPTY_ARR; } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java index f214a9fd72b..bcdd3864dbf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java @@ -61,14 +61,14 @@ import org.eclipse.cdt.internal.ui.newui.Messages; private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CDTWizard"; //$NON-NLS-1$ private static final String ELEMENT_NAME = "wizard"; //$NON-NLS-1$ private static final String CLASS_NAME = "class"; //$NON-NLS-1$ - public static final String DESC = "EntryDescriptor"; //$NON-NLS-1$ + public static final String DESC = "EntryDescriptor"; //$NON-NLS-1$ // widgets private Tree tree; private Composite right; private Button show_sup; private Label right_label; - + public CWizardHandler h_selected = null; private Label categorySelectedLabel; @@ -88,8 +88,8 @@ import org.eclipse.cdt.internal.ui.newui.Messages; @Override public void createControl(Composite parent) { super.createControl(parent); - - createDynamicGroup((Composite)getControl()); + + createDynamicGroup((Composite)getControl()); switchTo(updateData(tree, right, show_sup, CDTMainWizardPage.this, getWizard()), getDescriptor(tree)); @@ -97,21 +97,21 @@ import org.eclipse.cdt.internal.ui.newui.Messages; setErrorMessage(null); setMessage(null); } - + private void createDynamicGroup(Composite parent) { Composite c = new Composite(parent, SWT.NONE); c.setLayoutData(new GridData(GridData.FILL_BOTH)); c.setLayout(new GridLayout(2, true)); - + Label l1 = new Label(c, SWT.NONE); - l1.setText(Messages.CMainWizardPage_0); + l1.setText(Messages.CMainWizardPage_0); l1.setFont(parent.getFont()); l1.setLayoutData(new GridData(GridData.BEGINNING)); - + right_label = new Label(c, SWT.NONE); right_label.setFont(parent.getFont()); right_label.setLayoutData(new GridData(GridData.BEGINNING)); - + tree = new Tree(c, SWT.SINGLE | SWT.BORDER); tree.setLayoutData(new GridData(GridData.FILL_BOTH)); tree.addSelectionListener(new SelectionAdapter() { @@ -123,14 +123,14 @@ import org.eclipse.cdt.internal.ui.newui.Messages; setPageComplete(validatePage()); }}); tree.getAccessible().addAccessibleListener( - new AccessibleAdapter() { + new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { for (int i = 0; i < tree.getItemCount(); i++) { if (tree.getItem(i).getText().equals(e.result)) return; } - e.result = Messages.CMainWizardPage_0; + e.result = Messages.CMainWizardPage_0; } } ); @@ -139,7 +139,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages; right.setLayout(new PageLayout()); show_sup = new Button(c, SWT.CHECK); - show_sup.setText(Messages.CMainWizardPage_1); + show_sup.setText(Messages.CMainWizardPage_1); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; show_sup.setLayoutData(gd); @@ -155,18 +155,18 @@ import org.eclipse.cdt.internal.ui.newui.Messages; // restore settings from preferences show_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP)); } - + @Override public IWizardPage getNextPage() { return (h_selected == null) ? null : h_selected.getSpecificPage(); - } + } public URI getProjectLocation() { return useDefaults() ? null : getLocationURI(); } /** - * Returns whether this page's controls currently all contain valid + * Returns whether this page's controls currently all contain valid * values. * * @return true if all controls are valid, and @@ -179,12 +179,12 @@ import org.eclipse.cdt.internal.ui.newui.Messages; return false; if (getProjectName().indexOf('#') >= 0) { - setErrorMessage(Messages.CDTMainWizardPage_0); + setErrorMessage(Messages.CDTMainWizardPage_0); return false; } - + boolean bad = true; // should we treat existing project as error - + IProject handle = getProjectHandle(); if (handle.exists()) { if (getWizard() instanceof IWizardWithMemory) { @@ -192,13 +192,13 @@ import org.eclipse.cdt.internal.ui.newui.Messages; if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName())) bad = false; } - if (bad) { - setErrorMessage(Messages.CMainWizardPage_10); + if (bad) { + setErrorMessage(Messages.CMainWizardPage_10); return false; } } - if (bad) { // skip this check if project already created + if (bad) { // skip this check if project already created try { IFileStore fs; URI p = getProjectLocation(); @@ -210,9 +210,9 @@ import org.eclipse.cdt.internal.ui.newui.Messages; IFileInfo f = fs.fetchInfo(); if (f.exists()) { if (f.isDirectory()) { - setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING); + setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING); } else { - setErrorMessage(Messages.CMainWizardPage_6); + setErrorMessage(Messages.CMainWizardPage_6); return false; } } @@ -220,7 +220,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages; CUIPlugin.log(e.getStatus()); } } - + if (!useDefaults()) { IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle, getLocationURI()); @@ -231,28 +231,28 @@ import org.eclipse.cdt.internal.ui.newui.Messages; } if (tree.getItemCount() == 0) { - setErrorMessage(Messages.CMainWizardPage_3); + setErrorMessage(Messages.CMainWizardPage_3); return false; } - + // it is not an error, but we cannot continue if (h_selected == null) { setErrorMessage(null); - return false; + return false; } - String s = h_selected.getErrorMessage(); + String s = h_selected.getErrorMessage(); if (s != null) { setErrorMessage(s); return false; } - + setErrorMessage(null); return true; } /** - * + * * @param tree * @param right * @param show_sup @@ -263,17 +263,17 @@ import org.eclipse.cdt.internal.ui.newui.Messages; public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls, IWizard wizard) { // remember selected item TreeItem[] selection = tree.getSelection(); - TreeItem selectedItem = selection.length>0 ? selection[0] : null; + TreeItem selectedItem = selection.length>0 ? selection[0] : null; String savedLabel = selectedItem!=null ? selectedItem.getText() : null; String savedParentLabel = getParentText(selectedItem); - + tree.removeAll(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID); if (extensionPoint == null) return null; IExtension[] extensions = extensionPoint.getExtensions(); if (extensions == null) return null; - + List items = new ArrayList(); for (int i = 0; i < extensions.length; ++i) { IConfigurationElement[] elements = extensions[i].getConfigurationElements(); @@ -283,17 +283,17 @@ import org.eclipse.cdt.internal.ui.newui.Messages; try { w = (CNewWizard) element.createExecutableExtension(CLASS_NAME); } catch (CoreException e) { - System.out.println(Messages.CMainWizardPage_5 + e.getLocalizedMessage()); - return null; + System.out.println(Messages.CMainWizardPage_5 + e.getLocalizedMessage()); + return null; } if (w == null) return null; w.setDependentControl(right, ls); - for (EntryDescriptor ed : w.createItems(show_sup.getSelection(), wizard)) + for (EntryDescriptor ed : w.createItems(show_sup.getSelection(), wizard)) items.add(ed); } } } - // If there is a EntryDescriptor which is default for category, make sure it + // If there is a EntryDescriptor which is default for category, make sure it // is in the front of the list. for (int i = 0; i < items.size(); ++i) { @@ -303,14 +303,14 @@ import org.eclipse.cdt.internal.ui.newui.Messages; items.remove(i); items.add(0, ed); break; - } + } } - + // bug # 211935 : allow items filtering. if (ls != null) // NULL means call from prefs items = ls.filterItems(items); addItemsToTree(tree, items); - + if (tree.getItemCount() > 0) { TreeItem target = null; // try to search item which was selected before @@ -346,7 +346,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages; private static TreeItem findTreeItem(TreeItem item, String label, String parentLabel) { if (item.getText().equals(label) && getParentText(item).equals(parentLabel)) return item; - + for (TreeItem child : item.getItems()) { TreeItem foundItem = findTreeItem(child, label, parentLabel); if (foundItem!=null) @@ -356,9 +356,9 @@ import org.eclipse.cdt.internal.ui.newui.Messages; } private static void addItemsToTree(Tree tree, List items) { - // Sorting is disabled because of users requests + // Sorting is disabled because of users requests // Collections.sort(items, CDTListComparator.getInstance()); - + ArrayList placedTreeItemsList = new ArrayList(items.size()); ArrayList placedEntryDescriptorsList = new ArrayList(items.size()); for (EntryDescriptor wd : items) { @@ -401,7 +401,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages; if (!h.isApplicable(wd1)) break; } - + TreeItem p = placedTreeItemsList.get(i); TreeItem ti = new TreeItem(p, SWT.NONE); ti.setText(wd1.getName()); @@ -421,17 +421,17 @@ import org.eclipse.cdt.internal.ui.newui.Messages; } private void switchTo(CWizardHandler h, EntryDescriptor ed) { - if (h == null) + if (h == null) h = ed.getHandler(); if (ed.isCategory()) h = null; try { - if (h != null) + if (h != null) h.initialize(ed); - } catch (CoreException e) { + } catch (CoreException e) { h = null; } - if (h_selected != null) + if (h_selected != null) h_selected.handleUnSelection(); h_selected = h; if (h == null) { @@ -439,7 +439,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages; if (categorySelectedLabel == null) { categorySelectedLabel = new Label(right, SWT.WRAP); categorySelectedLabel.setText( - Messages.CDTMainWizardPage_1); + Messages.CDTMainWizardPage_1); right.layout(); } categorySelectedLabel.setVisible(true); @@ -456,24 +456,27 @@ import org.eclipse.cdt.internal.ui.newui.Messages; public static EntryDescriptor getDescriptor(Tree _tree) { TreeItem[] sel = _tree.getSelection(); - if (sel == null || sel.length == 0) + if (sel == null || sel.length == 0) return null; return (EntryDescriptor)sel[0].getData(DESC); } - + + @Override public void toolChainListChanged(int count) { setPageComplete(validatePage()); getWizard().getContainer().updateButtons(); } + @Override public boolean isCurrent() { return isCurrentPage(); } - + private static Image calcImage(EntryDescriptor ed) { if (ed.getImage() != null) return ed.getImage(); if (ed.isCategory()) return IMG_CATEGORY; return IMG_ITEM; } + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public List filterItems(List items) { return items; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java index 5c66f80c321..afc9c3cedf4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java @@ -63,18 +63,18 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement private static final String WZ_DESC= "CProjectWizard.description"; //$NON-NLS-1$ private static final String WINDOW_TITLE = "CProjectWizard.windowTitle"; //$NON-NLS-1$ - + private String wz_title; private String wz_desc; // private String op_error; protected IConfigurationElement fConfigElement; - protected NewCProjectWizardPage fMainPage; + protected NewCProjectWizardPage fMainPage; protected IProject newProject; public NewCProjectWizard() { - this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC), + this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC), CUIPlugin.getResourceString(OP_ERROR)); } @@ -93,7 +93,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizard#addPages() - */ + */ @Override public void addPages() { fMainPage= new NewCProjectWizardPage(CUIPlugin.getResourceString(PREFIX)); @@ -145,7 +145,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement * in the main page. * * @returns the C project - */ + */ public IProject getNewProject() { return newProject; } @@ -156,7 +156,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ + */ @Override public boolean performFinish() { if (!invokeRunnable(getRunnable())) { @@ -189,10 +189,11 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement * * @see IExecutableExtension#setInitializationData */ + @Override public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) { fConfigElement= cfig; } - + /* * Reimplemented method from superclass */ @@ -212,12 +213,15 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement public IRunnableWithProgress getRunnable() { return new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException { final Exception except[] = new Exception[1]; // ugly, need to make the wizard page run in a non ui thread so that this can go away!!! getShell().getDisplay().syncExec(new Runnable() { + @Override public void run() { IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { final IProgressMonitor fMonitor; if (monitor == null) { @@ -270,7 +274,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement Shell shell= getShell(); String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$ String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$ - + Throwable th= e.getTargetException(); CUIPlugin.errorDialog(shell, title, message, th, false); try { @@ -287,7 +291,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement protected void doRun(IProgressMonitor monitor) throws CoreException { createNewProject(monitor); - } + } /** * Creates a new project resource with the selected name. @@ -331,7 +335,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, getBuildSystemId(), monitor); else newProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, monitor, getProjectID()); - + return newProject; } @@ -341,7 +345,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement * @return String */ public abstract String getProjectID(); - + public String getBuildSystemId(){ return null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java index 7da60da7ef2..ff3a5b238ec 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java @@ -40,6 +40,7 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements protected abstract TabFolderOptionBlock createOptionBlock(); + @Override public void createControl(Composite parent) { fOptionBlock = createOptionBlock(); setControl(fOptionBlock.createContents(parent)); @@ -52,6 +53,7 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements updateContainer(); } + @Override public void updateContainer() { fOptionBlock.update(); setPageComplete(fOptionBlock.isValid()); @@ -65,11 +67,13 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements /* (non-Javadoc) * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferenceStore() */ + @Override public abstract Preferences getPreferences(); /* (non-Javadoc) * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject() */ + @Override public IProject getProject() { return ((NewCProjectWizard)getWizard()).getNewProject(); } @@ -77,6 +81,7 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements /* (non-Javadoc) * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject() */ + @Override public IProject getProjectHandle() { return ((NewCProjectWizard)getWizard()).getProjectHandle(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java index fa9f75cf41b..4ce3ebc734d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java @@ -21,7 +21,6 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -88,12 +87,12 @@ import org.eclipse.cdt.internal.ui.wizards.classwizard.IMethodStub; import org.eclipse.cdt.internal.ui.wizards.classwizard.MethodStubsListDialogField; import org.eclipse.cdt.internal.ui.wizards.classwizard.NamespaceSelectionDialog; import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog; +import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog.ITypeSelectionListener; import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator; import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardMessages; import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardPrefs; import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardUtil; import org.eclipse.cdt.internal.ui.wizards.classwizard.SourceFileSelectionDialog; -import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog.ITypeSelectionListener; import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter; @@ -117,7 +116,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { private static final String KEY_STUB_SELECTED = "stubSelected"; //$NON-NLS-1$ private static final String KEY_STUB_VIRTUAL = "stubVirtual"; //$NON-NLS-1$ private static final String KEY_STUB_INLINE = "stubInline"; //$NON-NLS-1$ - + // Field IDs protected static final int SOURCE_FOLDER_ID = 1; protected static final int NAMESPACE_ID = 2; @@ -168,15 +167,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** @since 5.3 */ protected IFile fCreatedTestFile; protected ICElement fCreatedClass; - + /** * This flag isFirstTime is used to keep a note - * that the class creation wizard has just been + * that the class creation wizard has just been * created. */ private boolean isFirstTime = false; - - + + /** * Constructor for NewClassCreationWizardPage */ @@ -184,7 +183,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { super(PAGE_NAME); setTitle(NewClassWizardMessages.NewClassCreationWizardPage_title); setDescription(NewClassWizardMessages.NewClassCreationWizardPage_description); - + SourceFolderFieldAdapter sourceFolderAdapter = new SourceFolderFieldAdapter(); fSourceFolderDialogField = new StringButtonDialogField(sourceFolderAdapter); fSourceFolderDialogField.setDialogFieldListener(sourceFolderAdapter); @@ -204,13 +203,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { fClassNameDialogField = new StringDialogField(); fClassNameDialogField.setDialogFieldListener(classAdapter); fClassNameDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_className_label); - + BaseClassesFieldAdapter baseClassesAdapter = new BaseClassesFieldAdapter(); fBaseClassesDialogField = new BaseClassesListDialogField(NewClassWizardMessages.NewClassCreationWizardPage_baseClasses_label, baseClassesAdapter); - + MethodStubsFieldAdapter methodStubsAdapter = new MethodStubsFieldAdapter(); fMethodStubsDialogField = new MethodStubsListDialogField(NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label, methodStubsAdapter); - + FileGroupFieldAdapter fileGroupAdapter = new FileGroupFieldAdapter(); fHeaderFileDialogField = new StringButtonDialogField(fileGroupAdapter); fHeaderFileDialogField.setDialogFieldListener(fileGroupAdapter); @@ -240,55 +239,56 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { fSourceFileStatus = STATUS_OK; fTestFileStatus = STATUS_OK; fLastFocusedField = 0; - + isFirstTime = true; } - + // -------- UI Creation --------- /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ - public void createControl(Composite parent) { + @Override + public void createControl(Composite parent) { initializeDialogUnits(parent); - + Composite composite = new Composite(parent, SWT.NONE); int nColumns = 4; - + GridLayout layout = new GridLayout(); layout.numColumns = nColumns; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); - + createSourceFolderControls(composite, nColumns); createNamespaceControls(composite, nColumns); - + createSeparator(composite, nColumns); - + createClassNameControls(composite, nColumns); createBaseClassesControls(composite, nColumns); createMethodStubsControls(composite, nColumns); - + createSeparator(composite, nColumns); - + createFileControls(composite, nColumns); - - composite.layout(); + + composite.layout(); setErrorMessage(null); setMessage(null); setControl(composite); } - + /** * Creates a separator line. Expects a GridLayout with at least 1 column. - * + * * @param composite the parent composite * @param nColumns number of columns to span */ protected void createSeparator(Composite composite, int nColumns) { - (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, convertHeightInCharsToPixels(1)); + (new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, convertHeightInCharsToPixels(1)); } /** @@ -296,7 +296,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { * the source folder location. The method expects that the parent composite * uses a GridLayout as its layout manager and that the * grid layout has at least 3 columns. - * + * * @param parent the parent composite * @param nColumns the number of columns to span. This number must be * greater or equal three @@ -307,14 +307,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { LayoutUtil.setWidthHint(textControl, getMaxFieldWidth()); textControl.addFocusListener(new StatusFocusListener(SOURCE_FOLDER_ID)); } - + /** - * Creates the controls for the namespace field. Expects a GridLayout with at + * Creates the controls for the namespace field. Expects a GridLayout with at * least 4 columns. - * + * * @param composite the parent composite * @param nColumns number of columns to span - */ + */ protected void createNamespaceControls(Composite composite, int nColumns) { Composite tabGroup= new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(); @@ -330,20 +330,20 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { gd.horizontalSpan= 2; textControl.setLayoutData(gd); textControl.addFocusListener(new StatusFocusListener(NAMESPACE_ID)); - + Button button= fNamespaceDialogField.getChangeControl(composite); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.widthHint = SWTUtil.getButtonWidthHint(button); button.setLayoutData(gd); - } + } /** - * Creates the controls for the class name field. Expects a GridLayout with at + * Creates the controls for the class name field. Expects a GridLayout with at * least 2 columns. - * + * * @param composite the parent composite * @param nColumns number of columns to span - */ + */ protected void createClassNameControls(Composite composite, int nColumns) { fClassNameDialogField.doFillIntoGrid(composite, nColumns - 1); DialogField.createEmptySpace(composite); @@ -353,26 +353,26 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } /** - * Creates the controls for the base classes field. Expects a GridLayout with + * Creates the controls for the base classes field. Expects a GridLayout with * at least 3 columns. - * + * * @param composite the parent composite * @param nColumns number of columns to span - */ + */ protected void createBaseClassesControls(Composite composite, int nColumns) { fBaseClassesDialogField.doFillIntoGrid(composite, nColumns); Control listControl = fBaseClassesDialogField.getListControl(null); LayoutUtil.setVerticalGrabbing(listControl, false); listControl.addFocusListener(new StatusFocusListener(BASE_CLASSES_ID)); } - + /** - * Creates the controls for the method stubs field. Expects a GridLayout with + * Creates the controls for the method stubs field. Expects a GridLayout with * at least 4 columns. - * + * * @param composite the parent composite * @param nColumns number of columns to span - */ + */ protected void createMethodStubsControls(Composite composite, int nColumns) { fMethodStubsDialogField.doFillIntoGrid(composite, nColumns); Control listControl = fMethodStubsDialogField.getListControl(null); @@ -381,25 +381,25 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { LayoutUtil.setVerticalGrabbing(listControl, false); listControl.addFocusListener(new StatusFocusListener(METHOD_STUBS_ID)); } - + /** - * Creates the controls for the file name fields. Expects a GridLayout with + * Creates the controls for the file name fields. Expects a GridLayout with * at least 4 columns. - * + * * @param composite the parent composite * @param nColumns number of columns to span - */ + */ protected void createFileControls(Composite composite, int nColumns) { fHeaderFileDialogField.doFillIntoGrid(composite, nColumns); Text textControl = fHeaderFileDialogField.getTextControl(null); LayoutUtil.setWidthHint(textControl, getMaxFieldWidth()); textControl.addFocusListener(new StatusFocusListener(HEADER_FILE_ID)); - + fSourceFileDialogField.doFillIntoGrid(composite, nColumns); textControl = fSourceFileDialogField.getTextControl(null); LayoutUtil.setWidthHint(textControl, getMaxFieldWidth()); textControl.addFocusListener(new StatusFocusListener(SOURCE_FILE_ID)); - + Composite tabGroup = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0; @@ -407,25 +407,25 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { tabGroup.setLayout(layout); fTestFileSelection.doFillIntoGrid(tabGroup, 1); - + textControl = fTestFileDialogField.getTextControl(composite); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = getMaxFieldWidth(); gd.horizontalSpan = 2; textControl.setLayoutData(gd); textControl.addFocusListener(new StatusFocusListener(TEST_FILE_ID)); - + Button button = fTestFileDialogField.getChangeControl(composite); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.widthHint = SWTUtil.getButtonWidthHint(button); button.setLayoutData(gd); - } - + } + /** * The wizard owning this page is responsible for calling this method with the - * current selection. The selection is used to initialize the fields of the wizard + * current selection. The selection is used to initialize the fields of the wizard * page. - * + * * @param selection used to initialize the fields */ public void init(IStructuredSelection selection) { @@ -437,7 +437,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } ICElement celem = getInitialCElement(selection); - + String namespace = null; if (celem != null) { ICElement ns = NewClassWizardUtil.getNamespace(celem); @@ -455,7 +455,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { setNamespaceText(namespace, false); setNamespaceSelection(namespace != null || fDialogSettings.getBoolean(KEY_NAMESPACE_SELECTED), true); - + IPath folderPath = null; if (celem != null) { ICContainer folder = NewClassWizardUtil.getSourceFolder(celem); @@ -470,7 +470,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } } setSourceFolderFullPath(folderPath, false); - + String className = null; ITextSelection textSel = getEditorTextSelection(); if (textSel != null) { @@ -480,7 +480,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } } setClassName(className, false); - + IMethodStub[] stubs = getDefaultMethodStubs(); for (int i = 0; i < stubs.length; ++i) { IMethodStub stub = stubs[i]; @@ -492,7 +492,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } addMethodStub(stub, getBooleanSettingWithDefault(KEY_STUB_SELECTED + i, true)); } - + setTestFileSelection(fDialogSettings.getBoolean(KEY_TEST_FILE_SELECTED), true); handleFieldChanged(ALL_FIELDS); } @@ -507,7 +507,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Attempts to extract a C Element from the initial selection. - * + * * @param selection the initial selection * @return a C Element, or null if not available */ @@ -528,13 +528,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } return celem; } - + /** * Returns the recommended maximum width for text fields (in pixels). This * method requires that createContent has been called before this method is - * call. Subclasses may override to change the maximum width for text + * call. Subclasses may override to change the maximum width for text * fields. - * + * * @return the recommended maximum width for text fields. */ protected int getMaxFieldWidth() { @@ -563,10 +563,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } return null; } - + /** * Returns the method stubs to display in the wizard. - * + * * @return array of method stubs */ protected IMethodStub[] getDefaultMethodStubs() { @@ -575,32 +575,32 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { new DestructorMethodStub() }; } - + /** * Returns the text entered into the source folder input field. - * + * * @return the source folder */ public String getSourceFolderText() { return fSourceFolderDialogField.getText().trim(); } - + /** * Sets the text of the source folder input field. - * + * * @param folder the folder name * @param update true if the dialog should be updated - */ + */ public void setSourceFolderText(String folder, boolean update) { fSourceFolderDialogField.setTextWithoutUpdate(folder != null ? folder : ""); //$NON-NLS-1$ if (update) { fSourceFolderDialogField.dialogFieldChanged(); } } - + /** * Returns the current source folder as a path. - * + * * @return the source folder path */ protected IPath getSourceFolderFullPath() { @@ -609,10 +609,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { return new Path(text).makeAbsolute(); return null; } - + /** * Sets the source folder from the given path. - * + * * @param folderPath the source folder path * @param update true if the dialog should be updated */ @@ -620,10 +620,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { String str = (folderPath != null) ? folderPath.makeRelative().toString() : ""; //.makeRelative().toString(); //$NON-NLS-1$ setSourceFolderText(str, update); } - + /** * Returns the current project, based on the current source folder. - * + * * @return the current project */ protected ICProject getCurrentProject() { @@ -642,7 +642,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Returns the text entered into the namespace input field. - * + * * @return the namespace */ public String getNamespaceText() { @@ -651,29 +651,29 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets the text of the namespace input field. - * + * * @param namespace the namespace name * @param update true if the dialog should be updated - */ + */ public void setNamespaceText(String namespace, boolean update) { fNamespaceDialogField.setTextWithoutUpdate(namespace != null ? namespace : ""); //$NON-NLS-1$ if (update) { fNamespaceDialogField.dialogFieldChanged(); } } - + /** * Returns the selection state of the namespace checkbox. - * + * * @return the selection state of the namespace checkbox */ public boolean isNamespaceSelected() { return fNamespaceSelection.isSelected(); } - + /** * Sets the namespace checkbox's selection state. - * + * * @param isSelected the checkbox's selection state * @param canBeModified if true the checkbox is * modifiable; otherwise it is read-only. @@ -683,17 +683,17 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { fNamespaceSelection.setEnabled(canBeModified); updateNamespaceEnableState(); } - + /** * Updates the enable state of the namespace button. */ private void updateNamespaceEnableState() { fNamespaceDialogField.setEnabled(isNamespaceSelected()); } - + /** * Returns the class name entered into the class input field. - * + * * @return the class name */ public String getClassName() { @@ -702,20 +702,20 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets the text of the class name input field. - * + * * @param name the new class name * @param update true if the dialog should be updated - */ + */ public void setClassName(String name, boolean update) { fClassNameDialogField.setTextWithoutUpdate(name != null ? name : ""); //$NON-NLS-1$ if (update) { fClassNameDialogField.dialogFieldChanged(); } } - + /** * Returns the currently selected (checked) method stubs. - * + * * @return array of IMethodStub or empty array if none selected. */ protected IMethodStub[] getSelectedMethodStubs() { @@ -733,14 +733,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Returns the contents of the base classes field. - * + * * @return array of IBaseClassInfo */ protected IBaseClassInfo[] getBaseClasses() { List classesList = fBaseClassesDialogField.getElements(); return classesList.toArray(new IBaseClassInfo[classesList.size()]); } - + /** * Adds a base class to the base classes field. * @param newBaseClass the new base class @@ -769,7 +769,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets the use test file creation checkbox's selection state. - * + * * @param isSelected the checkbox's selection state * @param canBeModified if true the checkbox is * modifiable; otherwise it is read-only. @@ -787,38 +787,38 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { private void updateTestFileEnableState() { fTestFileDialogField.setEnabled(fTestFileSelection.isSelected()); } - + /** * Returns the text entered into the header file input field. - * + * * @return the header file */ public String getHeaderFileText() { return fHeaderFileDialogField.getText().trim(); } - + /** * Sets the text of the header file input field. - * + * * @param header the header file name * @param update true if the dialog should be updated - */ + */ public void setHeaderFileText(String header, boolean update) { setFileText(fHeaderFileDialogField, header, update); } /** * Returns the current header file as a path. - * + * * @return the header file path */ protected IPath getHeaderFileFullPath() { return getFilePath(getHeaderFileText()); } - + /** * Sets the header file from the given path. - * + * * @param path the header file path * @param update true if the dialog should be updated */ @@ -828,35 +828,35 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Returns the text entered into the source file input field. - * + * * @return the source file */ public String getSourceFileText() { return fSourceFileDialogField.getText().trim(); } - + /** * Sets the text of the source file input field. - * + * * @param source the source file name * @param update true if the dialog should be updated - */ + */ public void setSourceFileText(String source, boolean update) { setFileText(fSourceFileDialogField, source, update); } - + /** * Returns the current source file as a path. - * + * * @return the source file path */ protected IPath getSourceFileFullPath() { return getFilePath(getSourceFileText()); } - + /** * Sets the source file from the given path. - * + * * @param path the source file path * @param update true if the dialog should be updated */ @@ -866,7 +866,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Returns the text entered into the source file input field. - * + * * @return the source file * @since 5.3 */ @@ -876,11 +876,11 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets the text of the test file input field. - * + * * @param testFile the test file name * @param update true if the dialog should be updated * @since 5.3 - */ + */ public void setTestFileText(String testFile, boolean update) { setFileText(fTestFileDialogField, testFile, update); } @@ -888,7 +888,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Returns the current test file as a path. Returns {@code null} if creation of test file * is disabled. - * + * * @return the test file path, or {@code null} if creation of test file is disabled. * @since 5.3 */ @@ -916,7 +916,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets a file name field to a given value. - * + * * @param field the field to set * @param filename the new value of the field * @param update true if the dialog should be updated @@ -930,7 +930,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets a file name field from the given path. - * + * * @param path the file path * @param update true if the dialog should be updated */ @@ -950,7 +950,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets the test file from the given path. - * + * * @param path the test file path * @param update true if the dialog should be updated * @since 5.3 @@ -972,13 +972,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Sets the focus on the class name input field. - */ + */ protected void setFocus() { fClassNameDialogField.setFocus(); } - + // ----------- UI Validation ---------- - + /** * Causes doStatusUpdate() to be called whenever the focus changes. * Remembers the last focused field. @@ -990,7 +990,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { this.fieldID = fieldID; } - public void focusGained(FocusEvent e) { + @Override + public void focusGained(FocusEvent e) { if (fLastFocusedField != this.fieldID) { fLastFocusedField = this.fieldID; if (isFirstTime) { @@ -1001,7 +1002,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } } - public void focusLost(FocusEvent e) { + @Override + public void focusLost(FocusEvent e) { if (fLastFocusedField != 0) { fLastFocusedField = 0; doStatusUpdate(); @@ -1013,6 +1015,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { * Handles changes to the source folder field */ private final class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener { + @Override public void changeControlPressed(DialogField field) { IPath oldFolderPath = getSourceFolderFullPath(); IPath newFolderPath = chooseSourceFolder(oldFolderPath); @@ -1021,12 +1024,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS); } } - + + @Override public void dialogFieldChanged(DialogField field) { handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS); } } - + private IPath chooseSourceFolder(IPath initialPath) { ICElement initElement = NewClassWizardUtil.getSourceFolder(initialPath); if (initElement instanceof ISourceRoot) { @@ -1035,11 +1039,11 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { if (projRoot != null && projRoot.equals(initElement)) initElement = cProject; } - + SourceFolderSelectionDialog dialog = new SourceFolderSelectionDialog(getShell()); dialog.setInput(CoreModel.create(NewClassWizardUtil.getWorkspaceRoot())); dialog.setInitialSelection(initElement); - + if (dialog.open() == Window.OK) { Object result = dialog.getFirstResult(); if (result instanceof ICElement) { @@ -1054,12 +1058,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } } return null; - } - + } + /** * handles changes to the namespace field */ private final class NamespaceFieldAdapter implements IStringButtonAdapter, IDialogFieldListener { + @Override public void changeControlPressed(DialogField field) { ITypeInfo ns = chooseNamespace(); if (ns != null) { @@ -1083,13 +1088,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { handleFieldChanged(changedFields); } } - + + @Override public void dialogFieldChanged(DialogField field) { updateNamespaceEnableState(); handleFieldChanged(NAMESPACE_ID|CLASS_NAME_ID); } } - + private IPath updateSourceFolderFromPath(IPath filePath) { ICElement folder = NewClassWizardUtil.getSourceFolder(filePath); if (folder instanceof ISourceRoot) { @@ -1103,10 +1109,10 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } IProject proj = PathUtil.getEnclosingProject(filePath); if (proj != null) - return proj.getFullPath(); + return proj.getFullPath(); return null; } - + private ITypeInfo chooseNamespace() { ITypeSearchScope scope; ICProject project = getCurrentProject(); @@ -1123,21 +1129,22 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { MessageDialog.openInformation(getShell(), title, message); return null; } - + NamespaceSelectionDialog dialog = new NamespaceSelectionDialog(getShell()); dialog.setElements(elements); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { return (ITypeInfo) dialog.getFirstResult(); } - + return null; } - + /** * Handles changes to the class name field */ private final class ClassNameFieldAdapter implements IDialogFieldListener { + @Override public void dialogFieldChanged(DialogField field) { int changedFields = CLASS_NAME_ID; updateFilesFromClassName(fClassNameDialogField.getText().trim()); @@ -1145,30 +1152,34 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { handleFieldChanged(changedFields); } } - + /** * Handles changes to the base classes field */ private final class BaseClassesFieldAdapter implements IListAdapter { - public void customButtonPressed(ListDialogField field, int index) { + @Override + public void customButtonPressed(ListDialogField field, int index) { if (index == 0) { chooseBaseClasses(); } handleFieldChanged(BASE_CLASSES_ID); } - public void selectionChanged(ListDialogField field) { + @Override + public void selectionChanged(ListDialogField field) { } - public void doubleClicked(ListDialogField field) { + @Override + public void doubleClicked(ListDialogField field) { } } - + private void chooseBaseClasses() { List oldContents = fBaseClassesDialogField.getElements(); NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell()); dialog.addListener(new ITypeSelectionListener() { - public void typeAdded(ITypeInfo newBaseClass) { + @Override + public void typeAdded(ITypeInfo newBaseClass) { addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false); } }); @@ -1178,19 +1189,22 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { fBaseClassesDialogField.setElements(oldContents); } } - + /** * Handles changes to the method stubs field */ private final class MethodStubsFieldAdapter implements IListAdapter { - public void customButtonPressed(ListDialogField field, int index) { + @Override + public void customButtonPressed(ListDialogField field, int index) { } - public void selectionChanged(ListDialogField field) { + @Override + public void selectionChanged(ListDialogField field) { } - public void doubleClicked(ListDialogField field) { + @Override + public void doubleClicked(ListDialogField field) { } } @@ -1198,6 +1212,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { * handles changes to the file name fields */ private final class FileGroupFieldAdapter implements IStringButtonAdapter, IDialogFieldListener { + @Override public void changeControlPressed(DialogField field) { IPath filePath = null; IPath headerPath = getHeaderFileFullPath(); @@ -1260,7 +1275,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { handleFieldChanged(changedFields); } } - + + @Override public void dialogFieldChanged(DialogField field) { int changedFields = 0; if (field == fTestFileSelection) { @@ -1289,7 +1305,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { handleFieldChanged(changedFields); } } - + private IPath chooseFile(String title, IPath initialPath) { SourceFileSelectionDialog dialog = new SourceFileSelectionDialog(getShell()); dialog.setTitle(title); @@ -1310,12 +1326,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { dialog.setInitialSelection(filePath.toString(), null); } } - + if (dialog.open() == Window.OK) { return dialog.getFilePath(); } return null; - } + } /** * update header and source file fields from the class name @@ -1340,7 +1356,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { if (fTestFileDerivedFromClassName && fTestFileDialogField.isEnabled()) fTestFileDialogField.setTextWithoutUpdate(testName); } - + private static final int MAX_UNIQUE_CLASSNAME = 99; private IDialogSettings fDialogSettings; @@ -1348,7 +1364,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { * Returns the names of the header file and source file which will be * used when this class is created, e.g. "MyClass" -> ["MyClass.h","MyClass.cpp"] * Note: the file names should be unique to avoid overwriting existing files. - * + * * @param className the class name * @param folder the folder where the files are to be created, or null * @return an array of 2 Strings, containing the header file name and @@ -1358,7 +1374,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { String headerName = null; String sourceName = null; String testName = null; - + if (folder == null) { headerName = NewSourceFileGenerator.generateHeaderFileNameFromClass(className); sourceName = NewSourceFileGenerator.generateSourceFileNameFromClass(className); @@ -1389,16 +1405,16 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } } ++count; - currName = className + separator + count; + currName = className + separator + count; } } - + return new String[] { headerName, sourceName, testName }; } - + /** * Hook method that gets called when a field on this page has changed. - * + * * @param fields Bitwise-OR'd ids of the fields that changed. */ protected void handleFieldChanged(int fields) { @@ -1439,7 +1455,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Updates the status line and the ok button according to the status of the fields * on the page. The most severe error is taken, with the last-focused field being - * evaluated first. + * evaluated first. */ protected void doStatusUpdate() { // do the last focused field first @@ -1456,7 +1472,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { (fHeaderFileStatus != lastStatus && isClassNameWarning) ? fHeaderFileStatus : STATUS_OK, (fSourceFileStatus != lastStatus && isClassNameWarning) ? fSourceFileStatus : STATUS_OK, (fTestFileStatus != lastStatus && isClassNameWarning) ? fTestFileStatus : STATUS_OK, - + (fClassNameStatus != lastStatus) ? fClassNameStatus : STATUS_OK, (fBaseClassesStatus != lastStatus) ? fBaseClassesStatus : STATUS_OK, (fMethodStubsStatus != lastStatus) ? fMethodStubsStatus : STATUS_OK, @@ -1464,14 +1480,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { (fSourceFileStatus != lastStatus) ? fSourceFileStatus : STATUS_OK, (fTestFileStatus != lastStatus) ? fTestFileStatus : STATUS_OK, }; - + // the mode severe status will be displayed and the ok button enabled/disabled. updateStatus(status); } /** * Returns the status of the last field which had focus. - * + * * @return status of the last field which had focus */ protected IStatus getLastFocusedStatus() { @@ -1496,16 +1512,16 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { return STATUS_OK; } } - + /** - * Hook method that gets called when the source folder has changed. The method validates the + * Hook method that gets called when the source folder has changed. The method validates the * source folder and returns the status of the validation. - * + * * @return the status of the validation */ protected IStatus sourceFolderChanged() { StatusInfo status = new StatusInfo(); - + IPath folderPath = getSourceFolderFullPath(); if (folderPath == null) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterSourceFolderName); @@ -1543,11 +1559,11 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { return status; } - + /** - * Hook method that gets called when the namespace has changed. The method validates the + * Hook method that gets called when the namespace has changed. The method validates the * namespace and returns the status of the validation. - * + * * @return the status of the validation */ protected IStatus namespaceChanged() { @@ -1588,7 +1604,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { switch(searchResult) { case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT: status.setOK(); - return status; + return status; case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE: status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExists); return status; @@ -1611,16 +1627,16 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } return status; } - + /** - * Hook method that gets called when the class name has changed. The method validates the + * Hook method that gets called when the class name has changed. The method validates the * class name and returns the status of the validation. - * + * * @return the status of the validation */ protected IStatus classNameChanged() { StatusInfo status = new StatusInfo(); - + String className = getClassName(); // must not be empty if (className == null || className.length() == 0) { @@ -1633,7 +1649,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_QualifiedClassName); return status; } - + IStatus val = CConventions.validateClassName(className); if (val.getSeverity() == IStatus.ERROR) { status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidClassName, val.getMessage())); @@ -1642,7 +1658,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_ClassNameDiscouraged, val.getMessage())); // continue checking } - + ICProject project = getCurrentProject(); if (project != null) { IQualifiedTypeName fullyQualifiedName = typeName; @@ -1656,7 +1672,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { switch(searchResult) { case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT: status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_ClassNameExists); - return status; + return status; case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE: status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingClassExists); return status; @@ -1668,15 +1684,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { return status; case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND: break; - } + } } return status; } - + /** - * Hook method that gets called when the list of base classes has changed. The method + * Hook method that gets called when the list of base classes has changed. The method * validates the base classes and returns the status of the validation. - * + * * @return the status of the validation */ protected IStatus baseClassesChanged() { @@ -1698,15 +1714,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } return Status.OK_STATUS; } - + /** * This method validates the base classes by searching through the project's * include paths and checking if each base class is reachable. - * + * * @param project the current project * @param sourceFolder the current source folder * @param baseClasses an array of base classes - * + * * @return the status of the validation */ protected IStatus baseClassesChanged(ICProject project, IPath sourceFolder, IBaseClassInfo[] baseClasses) { @@ -1734,17 +1750,17 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { /** * Checks if the base classes need to be verified (ie they must exist in the project) - * + * * @return true if the base classes should be verified */ public boolean verifyBaseClasses() { return NewClassWizardPrefs.verifyBaseClasses(); } - + /** - * Hook method that gets called when the list of method stubs has changed. The method + * Hook method that gets called when the list of method stubs has changed. The method * validates the method stubs and returns the status of the validation. - * + * * @return the status of the validation */ protected IStatus methodStubsChanged() { @@ -1753,32 +1769,32 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } /** - * Hook method that gets called when the header file has changed. The method + * Hook method that gets called when the header file has changed. The method * validates the header file and returns the status of the validation. - * + * * @return the status of the validation */ protected IStatus headerFileChanged() { StatusInfo status = new StatusInfo(); - + IPath path = getHeaderFileFullPath(); if (path == null) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterHeaderFileName); return status; } - + IPath sourceFolderPath = getSourceFolderFullPath(); if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_HeaderFileNotInSourceFolder); return status; } - + // Make sure the file location is under a source root if (!NewClassWizardUtil.isOnSourceRoot(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_HeaderFileNotInSourceFolder); return status; } - + boolean fileExists = false; // Check if the file already exists IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path); @@ -1795,7 +1811,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } else { fileExists = true; } - + IProject proj = file.getProject(); if (!proj.isOpen()) { status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile, path)); @@ -1811,7 +1827,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile); return status; } - + // Check if folder exists IPath folderPath = path.removeLastSegments(1).makeRelative(); IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath); @@ -1833,32 +1849,32 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } /** - * Hook method that gets called when the source file has changed. The method + * Hook method that gets called when the source file has changed. The method * validates the source file and returns the status of the validation. - * + * * @return the status of the validation */ protected IStatus sourceFileChanged() { StatusInfo status = new StatusInfo(); - + IPath path = getSourceFileFullPath(); if (path == null) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterSourceFileName); return status; } - + IPath sourceFolderPath = getSourceFolderFullPath(); if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_SourceFileNotInSourceFolder); return status; } - + // Make sure the file location is under a source root if (!NewClassWizardUtil.isOnSourceRoot(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_SourceFileNotInSourceFolder); return status; } - + boolean fileExists = false; // Check if file already exists IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path); @@ -1875,7 +1891,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } else { fileExists = true; } - + IProject proj = file.getProject(); if (!proj.isOpen()) { status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile, path)); @@ -1891,7 +1907,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile); return status; } - + // Check if folder exists IPath folderPath = path.removeLastSegments(1).makeRelative(); IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath); @@ -1911,11 +1927,11 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } return status; } - + /** - * Hook method that gets called when the test file has changed. The method + * Hook method that gets called when the test file has changed. The method * validates the test file and returns the status of the validation. - * + * * @return the status of the validation * @since 5.3 */ @@ -1936,13 +1952,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_TestFileNotInSourceFolder); return status; } - + // Make sure the file location is under a source root if (!NewClassWizardUtil.isOnSourceRoot(path)) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_TestFileNotInSourceFolder); return status; } - + boolean fileExists = false; // Check if file already exists IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path); @@ -1959,7 +1975,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } else { fileExists = true; } - + IProject proj = file.getProject(); if (!proj.isOpen()) { status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile, path)); @@ -1975,7 +1991,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile); return status; } - + // Check if folder exists IPath folderPath = path.removeLastSegments(1).makeRelative(); IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath); @@ -1995,12 +2011,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } return status; } - + // -------- Code Generation --------- - + /** * Creates the new class using the entered field values. - * + * * @param monitor a progress monitor to report progress. * @throws CoreException Thrown when the creation failed. * @throws InterruptedException Thrown when the operation was cancelled. @@ -2034,21 +2050,21 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { createClass(headerPath, sourcePath, testPath, getClassName(), namespace, getBaseClasses(), getSelectedMethodStubs(), monitor); } - + /** * Returns whether the generated header and source files should be * opened in editors after the finish button is pressed. - * + * * @return true if the header and source file should be * displayed */ public boolean openClassInEditor() { return NewClassWizardPrefs.openClassInEditor(); } - + /** * Creates a new class. - * + * * @param headerPath the header file path * @param sourcePath the source file path * @param testPath the test file path, can be {@code null}. @@ -2074,13 +2090,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { methodStubs); generator.setForceSourceFileCreation(true); generator.createClass(monitor); - + fCreatedClass = generator.getCreatedClass(); fCreatedHeaderFile = generator.getCreatedHeaderFile(); fCreatedSourceFile = generator.getCreatedSourceFile(); fCreatedTestFile = generator.getCreatedTestFile(); } - + protected void createClass(IPath headerPath, IPath sourcePath, String className, String namespace, IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor) throws CoreException, InterruptedException { @@ -2089,46 +2105,46 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } /** - * Returns the created class. The method only returns a valid class + * Returns the created class. The method only returns a valid class * after createClass has been called. - * + * * @return the created class * @see #createClass(IProgressMonitor) - */ + */ public ICElement getCreatedClass() { return fCreatedClass; } - + /** - * Returns the created header file. The method only returns a valid file + * Returns the created header file. The method only returns a valid file * after createClass has been called. * * @return the created header file * @see #createClass(IProgressMonitor) - */ + */ public IFile getCreatedHeaderFile() { return fCreatedHeaderFile; } /** - * Returns the created source file. The method only returns a valid file + * Returns the created source file. The method only returns a valid file * after createClass has been called. - * + * * @return the created source file * @see #createClass(IProgressMonitor) - */ + */ public IFile getCreatedSourceFile() { return fCreatedSourceFile; } /** - * Returns the created test file. The method only returns a valid file + * Returns the created test file. The method only returns a valid file * after createClass has been called. - * + * * @return the created test file * @see #createClass(IProgressMonitor) * @since 5.3 - */ + */ public IFile getCreatedTestFile() { return fCreatedTestFile; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java index 2637231d966..5550878e1cc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java @@ -71,10 +71,10 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil; * defined by all subclasses.
Subclasses provide the methods that * determine what files are displayed and what action is performed on them as * well as the labels for the Wizard.

- * + * * Note: Only Projects that are open will be considered for conversion. - * - * + * + * * @author Judy N. Green * @since Aug 6, 2002

*/ @@ -89,19 +89,19 @@ public abstract class ConvertProjectWizardPage protected boolean convertToCC = true; protected Button cRadioButton; protected Button ccRadioButton; - + // The Main widget containing the table and its list of candidate open projects protected CheckboxTableViewer tableViewer; - + protected Button selectAllButton; protected Button deselectAllButton; - + // We only need to calculate this once per instantiation of this wizard protected Object[] listItems = null; /** * Constructor for ConvertProjectWizardPage. - * + * * @param pageName */ public ConvertProjectWizardPage(String pageName) { @@ -117,7 +117,7 @@ public abstract class ConvertProjectWizardPage /** * Returns the elements that the user has checked - * + * * @return Object[] */ protected Object[] getCheckedElements() { @@ -127,65 +127,67 @@ public abstract class ConvertProjectWizardPage /** * Creates the main wizard page. - * + * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite) */ - public void createControl(Composite parent) { + @Override + public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); - + GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; container.setLayout(layout); - setControl(createAvailableProjectsGroup(container)); - addToMainPage(container); + setControl(createAvailableProjectsGroup(container)); + addToMainPage(container); // will default to false until a selection is made setPageComplete(validatePage()); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CONVERT_TO_CCPP_WIZARD_PAGE); } - + /** - * Method addToMainPage allows subclasses to add - * elements to the main page. - * + * Method addToMainPage allows subclasses to add + * elements to the main page. + * */ protected void addToMainPage(Composite container){ - + // Add convert to C or C/C++ buttons - Composite area = ControlFactory.createGroup(container, CUIMessages.ConvertProjectWizardPage_convertTo, 2); - + Composite area = ControlFactory.createGroup(container, CUIMessages.ConvertProjectWizardPage_convertTo, 2); + SelectionListener cListener = new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) { + public void widgetSelected(SelectionEvent event) { convertToC = cRadioButton.getSelection(); - convertToCC = ccRadioButton.getSelection(); + convertToCC = ccRadioButton.getSelection(); validatePage(); } }; - cRadioButton = ControlFactory.createRadioButton(area, - CUIMessages.ConvertProjectWizardPage_CProject, + cRadioButton = ControlFactory.createRadioButton(area, + CUIMessages.ConvertProjectWizardPage_CProject, "C ", //$NON-NLS-1$ cListener); - cRadioButton.setSelection(convertToC); - ccRadioButton = ControlFactory.createRadioButton(area, - CUIMessages.ConvertProjectWizardPage_CppProject, + cRadioButton.setSelection(convertToC); + ccRadioButton = ControlFactory.createRadioButton(area, + CUIMessages.ConvertProjectWizardPage_CppProject, "C++", //$NON-NLS-1$ - cListener); - ccRadioButton.setSelection(convertToCC); - + cListener); + ccRadioButton.setSelection(convertToCC); + area.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent event) { cRadioButton = null; ccRadioButton = null; } - }); + }); } /** * Creates a list of projects that can be selected by the user. - * + * * @param parent the parent composite * @return Composite */ @@ -194,7 +196,7 @@ public abstract class ConvertProjectWizardPage // Add a label Label label = new Label(parent, SWT.LEFT); label.setText(CUIPlugin.getResourceString(PROJECT_LIST)); - + Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 5; @@ -203,25 +205,25 @@ public abstract class ConvertProjectWizardPage container.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); container.setLayoutData(data); - + // create the table - Table table = new Table(container, - SWT.CHECK | SWT.BORDER | SWT.MULTI | - SWT.SINGLE | SWT.H_SCROLL | + Table table = new Table(container, + SWT.CHECK | SWT.BORDER | SWT.MULTI | + SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); data = new GridData(GridData.FILL_BOTH); table.setLayoutData(data); table.setHeaderVisible(true); table.setLinesVisible(false); table.getAccessible().addAccessibleListener( - new AccessibleAdapter() { + new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = CUIPlugin.getResourceString(PROJECT_LIST); } } ); - + TableLayout tableLayout = new TableLayout(); table.setHeaderVisible(false); table.setLayout(tableLayout); @@ -257,18 +259,19 @@ public abstract class ConvertProjectWizardPage return true; } }); - tableViewer.setAllChecked(false); + tableViewer.setAllChecked(false); tableViewer.refresh(); - + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { + @Override + public void selectionChanged(SelectionChangedEvent e) { // will default to false until a selection is made setPageComplete(validatePage()); updateSelectionButtons(); } }); // Add button panel - + Composite buttons= new Composite(container, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout= new GridLayout(); @@ -276,74 +279,76 @@ public abstract class ConvertProjectWizardPage layout.marginWidth= 0; layout.verticalSpacing = 8; buttons.setLayout(layout); - - + + selectAllButton= new Button(buttons, SWT.PUSH); - selectAllButton.setText(CUIMessages.ConvertProjectWizardPage_SelectAll); + selectAllButton.setText(CUIMessages.ConvertProjectWizardPage_SelectAll); selectAllButton.setLayoutData(getButtonGridData(selectAllButton)); selectAllButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { + @Override + public void handleEvent(Event e) { ConvertProjectWizardPage.this.tableViewer.setAllChecked(true); // update the pageComplete status setPageComplete(true); - updateSelectionButtons(); + updateSelectionButtons(); } }); deselectAllButton= new Button(buttons, SWT.PUSH); - deselectAllButton.setText(CUIMessages.ConvertProjectWizardPage_DeselectAll); + deselectAllButton.setText(CUIMessages.ConvertProjectWizardPage_DeselectAll); deselectAllButton.setLayoutData(getButtonGridData(deselectAllButton)); deselectAllButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { + @Override + public void handleEvent(Event e) { ConvertProjectWizardPage.this.tableViewer.setAllChecked(false); // update the pageComplete status setPageComplete(false); updateSelectionButtons(); } }); - + // enable or disable selection buttons Object[] elements = getElements(); boolean enableSelectionButtons = (elements != null) && (elements.length > 0); - + selectAllButton.setEnabled(enableSelectionButtons); // we've called setAllChecked(false) earlier - deselectAllButton.setEnabled(false); + deselectAllButton.setEnabled(false); return parent; } - + /* * Method updateSelectionButtons, enables/disables buttons * dependent on what is selected */ - - protected void updateSelectionButtons() { - - // update select and deselect buttons as required - Object[] checkedObjects = getCheckedElements(); + + protected void updateSelectionButtons() { + + // update select and deselect buttons as required + Object[] checkedObjects = getCheckedElements(); int totalItems = tableViewer.getTable().getItemCount(); boolean allSelected = checkedObjects.length == totalItems; - boolean noneSelected = checkedObjects.length == 0; + boolean noneSelected = checkedObjects.length == 0; selectAllButton.setEnabled(!allSelected); deselectAllButton.setEnabled(!noneSelected); } /* - * Method getButtonGridData creates + * Method getButtonGridData creates * and returns a GridData for the given button - * + * * @GridData */ private static GridData getButtonGridData(Button button) { GridData data= new GridData(GridData.FILL_HORIZONTAL); data.widthHint= SWTUtil.getButtonWidthHint(button); - + return data; } /** * Returns whether this page's controls currently all contain valid values. - * + * * @return true if the user has selected at least one * candidate project. */ @@ -360,13 +365,16 @@ public abstract class ConvertProjectWizardPage */ public class ProjectContentProvider implements IStructuredContentProvider { - public Object[] getElements(Object parent) { - return listItems; + @Override + public Object[] getElements(Object parent) { + return listItems; } - public void dispose() {} + @Override + public void dispose() {} - public void inputChanged(Viewer viewer, Object oldInput, + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} } @@ -377,7 +385,8 @@ public abstract class ConvertProjectWizardPage public class ProjectLabelProvider extends LabelProvider implements ITableLabelProvider { - public String getColumnText(Object obj, int index) { + @Override + public String getColumnText(Object obj, int index) { if (index == 0) { @@ -387,7 +396,8 @@ public abstract class ConvertProjectWizardPage return ""; //$NON-NLS-1$ } - public Image getColumnImage(Object obj, int index) { + @Override + public Image getColumnImage(Object obj, int index) { return PlatformUI.getWorkbench().getSharedImages().getImage( IDE.SharedImages.IMG_OBJ_PROJECT); @@ -397,9 +407,9 @@ public abstract class ConvertProjectWizardPage /** * Returns a list of open projects that are determined to be candidates * through the method isCandidate().
- * + * * Note: Only Projects that are open will be considered for conversion. - * + * * @return Object[] which may be null */ protected Object[] getElements() { @@ -413,8 +423,8 @@ public abstract class ConvertProjectWizardPage for (IProject project : projects) { next = project; - if ((next != null) - && next.isOpen() + if ((next != null) + && next.isOpen() && isCandidate(next)) { candidates.addElement(next); } @@ -429,10 +439,10 @@ public abstract class ConvertProjectWizardPage candidateArray = new Object[candidates.size()]; candidates.copyInto(candidateArray); } - // update the global variable that will + // update the global variable that will // be returned by the ProjectContentProvider listItems = candidateArray; - + return candidateArray; } @@ -440,7 +450,7 @@ public abstract class ConvertProjectWizardPage * doRun can be overwritten in subclasses to change behaviour, but this is * generally not required. It is called from the corresponding Conversion * Wizard - * + * * @param monitor * @param projectID * @exception CoreException @@ -458,7 +468,7 @@ public abstract class ConvertProjectWizardPage convertProjects(selection, monitor, projectID); } } - + public void doRun(IProgressMonitor monitor, String projectID, String bsId) throws CoreException { if(bsId == null) doRun(monitor, projectID); @@ -481,7 +491,7 @@ public abstract class ConvertProjectWizardPage /** * convertProjects calls the convertProject() method on each project * passed to it. - * + * * @param selected * @param monitor * @param projectID @@ -489,7 +499,7 @@ public abstract class ConvertProjectWizardPage */ private void convertProjects(Object[] selected, IProgressMonitor monitor, String projectID) throws CoreException { - monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), + monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), selected.length); try { for (Object element : selected) { @@ -503,7 +513,7 @@ public abstract class ConvertProjectWizardPage private void convertProjects(Object[] selected, String bsId, IProgressMonitor monitor) throws CoreException { - monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), + monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), selected.length); try { for (Object element : selected) { @@ -516,7 +526,7 @@ public abstract class ConvertProjectWizardPage } /** * Method finish we always finish successfully :) - * + * * @return boolean */ public boolean finish() { @@ -527,7 +537,7 @@ public abstract class ConvertProjectWizardPage /** * Must be overwritten in subclasses to change behaviour Determines which * projects will be displayed in the list - * + * * @param project * @return boolean */ @@ -535,31 +545,31 @@ public abstract class ConvertProjectWizardPage /** * convertProject must be overwritten in subclasses to change behaviour - * + * * @param project * @param monitor * @param projectID * @throws CoreException */ - public void convertProject(IProject project, - IProgressMonitor monitor, + public void convertProject(IProject project, + IProgressMonitor monitor, String projectID) throws CoreException{ // Add the correct nature if (convertToC) { if (!project.hasNature(CProjectNature.C_NATURE_ID)){ - addCNature(project, monitor, true); + addCNature(project, monitor, true); } else { if (project.hasNature(CCProjectNature.CC_NATURE_ID)){ // remove the C++ nature CCProjectNature.removeCCNature(project, monitor); - } + } } } else { if (convertToCC && !project.hasNature(CCProjectNature.CC_NATURE_ID)) { - addCCNature(project, monitor, true); - } - } + addCCNature(project, monitor, true); + } + } } public void convertProject(IProject project, @@ -569,18 +579,18 @@ public abstract class ConvertProjectWizardPage // Add the correct nature if (convertToC) { if (!project.hasNature(CProjectNature.C_NATURE_ID)){ - addCNature(project, monitor, true); + addCNature(project, monitor, true); } else { if (project.hasNature(CCProjectNature.CC_NATURE_ID)){ // remove the C++ nature CCProjectNature.removeCCNature(project, monitor); - } + } } } else { if (convertToCC && !project.hasNature(CCProjectNature.CC_NATURE_ID)) { - addCCNature(project, monitor, true); - } - } + addCCNature(project, monitor, true); + } + } } protected void addCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder) throws CoreException{ @@ -592,10 +602,10 @@ public abstract class ConvertProjectWizardPage CCorePlugin.getDefault().convertProjectToC(project, monitor, cw.getProjectID()); } } - + protected void addCCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder) throws CoreException{ if ( getWizard() instanceof ConversionWizard) { - if (project.hasNature(CProjectNature.C_NATURE_ID)) { + if (project.hasNature(CProjectNature.C_NATURE_ID)) { CCorePlugin.getDefault().convertProjectFromCtoCC(project, monitor); } else { ConversionWizard cw = (ConversionWizard)getWizard(); @@ -606,5 +616,5 @@ public abstract class ConvertProjectWizardPage } } } - + } diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java index a3ce92d992c..25640e59412 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java @@ -20,7 +20,7 @@ import org.eclipse.jface.wizard.WizardPage; */ public abstract class AbstractWizardDataPage extends WizardPage implements IWizardDataPage { protected IWizardPage next; - + /** * Creates a new wizard page with the given name, and * with no title or image. @@ -30,7 +30,7 @@ public abstract class AbstractWizardDataPage extends WizardPage implements IWiza public AbstractWizardDataPage(String pageName) { super(pageName); } - + /** * Creates a new wizard page with the given name, title, and image. * @@ -43,15 +43,16 @@ public abstract class AbstractWizardDataPage extends WizardPage implements IWiza public AbstractWizardDataPage(String pageName, String title, ImageDescriptor imageDescriptor) { super(pageName, title, imageDescriptor); } - + /* * (non-Javadoc) * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage) */ + @Override public void setNextPage(IWizardPage next) { this.next= next; } - + /* * (non-Javadoc) * @see org.eclipse.jface.wizard.WizardPage#getNextPage() diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/FormBrowser.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/FormBrowser.java index f9415e0049a..7e5bf040007 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/FormBrowser.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/FormBrowser.java @@ -21,7 +21,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledFormText; /** - * FormBrowser. + * FormBrowser. */ class FormBrowser { private FormToolkit toolkit; @@ -52,6 +52,7 @@ class FormBrowser { ftext.marginHeight = 2; ftext.setHyperlinkSettings(toolkit.getHyperlinkGroup()); formText.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent e) { if (toolkit != null) { toolkit.dispose(); diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java index a35c3825158..0c98782ba3c 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java @@ -55,7 +55,7 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.ICHelpContextIds; public class ProjectSelectionPage extends WizardPage implements IWizardDataPage { - + private static final String PAGE_NAME= "NewProjectSelectionWizardPage"; //$NON-NLS-1$ private static final String PAGE_TITLE = Messages.getString("ProjectSelectionPage.0"); //$NON-NLS-1$ private static final String PAGE_DESCRIPTION = Messages.getString("ProjectSelectionPage.1"); //$NON-NLS-1$ @@ -68,42 +68,42 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage private IWorkspaceRoot workspaceRoot; private ICProject currentCProject; private IWizardPage next; - + public ProjectSelectionPage() { super(PAGE_NAME); setTitle(PAGE_TITLE); setDescription(PAGE_DESCRIPTION); - + workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - + setPageComplete(false); } - + public void init(IStructuredSelection selection) { if (selection == null || selection.isEmpty()) { setDefaultAttributes(); return; } - + Object selectedElement= selection.getFirstElement(); if (selectedElement == null) { selectedElement= getActiveEditorCInput(); - } - + } + String projPath= null; - + if (selectedElement instanceof IResource) { IProject project= ((IResource)selectedElement).getProject(); if (project != null) { projPath= project.getFullPath().makeRelative().toString(); - } + } } else if (selectedElement instanceof ICElement) { ICProject cProject= ((ICElement)selectedElement).getCProject(); if (cProject != null) { projPath= cProject.getProject().getFullPath().makeRelative().toString(); } - } - + } + if (projPath != null) { projectName = projPath; } else { @@ -126,11 +126,11 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage } } } - return null; + return null; } - + private void setDefaultAttributes() { - + try { // find the first C project IProject[] projects= workspaceRoot.getProjects(); @@ -140,14 +140,15 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage projectName = project.getFullPath().makeRelative().toString(); break; } - } + } } catch (CoreException e) { // ignore here } } - + private Map data = new HashMap(2); - + + @Override public Map getPageData() { String cPojectName = currentCProject.getResource().getName().trim(); data.put("projectName", cPojectName); //$NON-NLS-1$ @@ -167,37 +168,38 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage } return baseName; } - + + @Override public void createControl(Composite parent) { initializeDialogUnits(parent); - + Composite composite= new Composite(parent, SWT.NONE); - + GridLayout layout= new GridLayout(); layout.marginWidth= 0; - layout.marginHeight= 0; + layout.marginHeight= 0; layout.numColumns= 3; composite.setLayout(layout); - + createProjectFiled(composite); - + setControl(composite); Dialog.applyDialogFont(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.NEW_SRCFLDER_WIZARD_PAGE); - + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.NEW_SRCFLDER_WIZARD_PAGE); + projectNameText.setFocus(); projectNameText.setSelection(0, projectNameText.getText().length()); - + setPageComplete(validatePage()); } - + private void createProjectFiled(Composite parent) { getLabelControl(parent); GridData gdLabel = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gdLabel.horizontalSpan= 1; projectNameLabel.setLayoutData(gdLabel); - - + + getTextControl(parent); GridData gdText = new GridData(); gdText.horizontalAlignment= GridData.FILL; @@ -205,7 +207,7 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage gdText.horizontalSpan= 1; gdText.widthHint = convertWidthInCharsToPixels(40); projectNameText.setLayoutData(gdText); - + getButtonControl(parent); GridData gdButton = new GridData(); gdButton.horizontalAlignment= GridData.FILL; @@ -217,24 +219,25 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage /** * Creates or returns the created Label control. * @param parent The parent composite - */ + */ private void getLabelControl(Composite parent) { projectNameLabel = new Label(parent, SWT.LEFT | SWT.WRAP); projectNameLabel.setText(Messages.getString("ProjectSelectionPage.4")); //$NON-NLS-1$ projectNameLabel.setFont(parent.getFont()); - projectNameLabel.setEnabled(true); + projectNameLabel.setEnabled(true); } /** * Creates or returns the created text control. * @param parent The parent composite - */ + */ private void getTextControl(Composite parent) { projectNameText = new Text(parent, SWT.SINGLE | SWT.BORDER); projectNameText.setText(projectName); projectNameText.setFont(parent.getFont()); projectNameText.setEnabled(true); projectNameText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { setPageComplete(validatePage()); } @@ -244,27 +247,29 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage /** * Creates or returns the created buttom widget. * @param parent The parent composite - */ + */ private void getButtonControl(Composite parent) { projectBrowseButton = new Button(parent, SWT.PUSH); projectBrowseButton.setText(Messages.getString("ProjectSelectionPage.5")); //$NON-NLS-1$ projectBrowseButton.setFont(parent.getFont()); projectBrowseButton.setEnabled(true); projectBrowseButton.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { packRootChangeControlPressed(); } + @Override public void widgetSelected(SelectionEvent e) { packRootChangeControlPressed(); } - }); + }); } - + @Override public void setVisible(boolean visible) { super.setVisible(visible); - } - + } + protected void packRootChangeControlPressed() { ICProject cProject= chooseProject(); if (cProject != null) { @@ -272,29 +277,29 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage projectName = path.toOSString(); projectNameText.setText(projectName); } - } - + } + private boolean validatePage() { currentCProject= null; - + String projectName = projectNameText.getText(); if (projectName.length() == 0) { setErrorMessage(Messages.getString("ProjectSelectionPage.6")); //$NON-NLS-1$ return false; } - + IPath path= new Path(projectName); if (path.segmentCount() != 1) { setErrorMessage(Messages.getString("ProjectSelectionPage.7")); //$NON-NLS-1$ return false; } - + IProject project= workspaceRoot.getProject(path.toString()); if (!project.exists()) { setErrorMessage(Messages.getString("ProjectSelectionPage.8")); //$NON-NLS-1$ return false; } - + try { if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) { currentCProject= CoreModel.getDefault().create(project); @@ -305,11 +310,11 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage CUIPlugin.log(e); currentCProject= null; } - + setErrorMessage(Messages.getString("ProjectSelectionPage.9")); //$NON-NLS-1$ return false; } - + private ICProject chooseProject() { ICProject[] projects; try { @@ -318,27 +323,28 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage CUIPlugin.log(e); projects= new ICProject[0]; } - + ILabelProvider labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT); ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider); dialog.setTitle(Messages.getString("ProjectSelectionPage.10")); //$NON-NLS-1$ dialog.setMessage(Messages.getString("ProjectSelectionPage.11")); //$NON-NLS-1$ dialog.setElements(projects); dialog.setInitialSelections(new Object[] { currentCProject }); - if (dialog.open() == Window.OK) { + if (dialog.open() == Window.OK) { return (ICProject) dialog.getFirstResult(); - } - return null; + } + return null; } - + /* * (non-Javadoc) * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage) */ + @Override public void setNextPage(IWizardPage next) { this.next= next; } - + /* * (non-Javadoc) * @see org.eclipse.jface.wizard.WizardPage#getNextPage() diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateClassWizard.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateClassWizard.java index a014299c46d..9a3b566f873 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateClassWizard.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateClassWizard.java @@ -80,12 +80,14 @@ public class TemplateClassWizard extends TemplatesChoiceWizard implements INewWi return pagesAfterTemplatePages; } + @Override public Template[] getTemplates() { SortedSet templateList = new TreeSet(Template.TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR); templateList.addAll(Arrays.asList(TemplateEngineUI.getDefault().getTemplates())); return templateList.toArray(new Template[templateList.size()]); } + @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { configElement = config; } @@ -105,6 +107,7 @@ public class TemplateClassWizard extends TemplatesChoiceWizard implements INewWi return pagesAfterTemplateSelection; } + @Override public String getDescription(Object object) { if (object instanceof Template) { @@ -113,26 +116,32 @@ public class TemplateClassWizard extends TemplatesChoiceWizard implements INewWi return ""; //$NON-NLS-1$ } + @Override public boolean showTemplatesInTreeView() { return false; } + @Override public Object[] getChildren(Object parentElement) { return null; } + @Override public Object getParent(Object element) { return null; } + @Override public boolean hasChildren(Object element) { return false; } + @Override public Object[] getElements(Object inputElement) { return getTemplates(); } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.java index 5d700b104e2..27e37494f61 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.java @@ -32,20 +32,20 @@ import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage; /** * Any wizard intending to use template (@see org.eclipse.cdt.core.templateenginee.Template) based pages - * can extend this wizard and use it. Alternatively, a wizard intending to show a choice of templates + * can extend this wizard and use it. Alternatively, a wizard intending to show a choice of templates * should use TemplatesChoiceWizard (@see org.eclipse.cdt.core.templateenginee.ui.TemplatesChoiceWizard) - * + * */ public abstract class TemplateDrivenWizard extends Wizard { protected List pagesBeforeTemplatePages = new ArrayList(); protected List pagesAfterTemplatePages = new ArrayList(); - + protected Template template; protected int pageIndex; protected Map templatePages; protected Composite pageContainer; protected List templatePagesOrderVector; - + @Override public final void addPage(IWizardPage page) { page.setWizard(this); @@ -57,7 +57,7 @@ public abstract class TemplateDrivenWizard extends Wizard { for (IWizardPage page : pages) { addPageBeforeTemplatePages(page); } - + pages = getPagesAfterTemplatePages(); for (IWizardPage page : pages) { addPageAfterTemplatePages(page); @@ -77,7 +77,7 @@ public abstract class TemplateDrivenWizard extends Wizard { protected abstract IWizardPage[] getPagesBeforeTemplatePages(); protected abstract IWizardPage[] getPagesAfterTemplatePages(); - + /** * @return the template */ @@ -156,6 +156,7 @@ public abstract class TemplateDrivenWizard extends Wizard { @Override public boolean performFinish() { IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { finishPage(monitor); } @@ -181,7 +182,7 @@ public abstract class TemplateDrivenWizard extends Wizard { TemplateEngineUIUtil.showStatusDialog(msg, new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, statuses, msg, null)); return true; } - + @Override public final void createPageControls(Composite pageContainer) { super.createPageControls(pageContainer); diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.java index 7cc7c990375..0044107c4fe 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.java @@ -37,7 +37,7 @@ import org.eclipse.swt.widgets.Label; /** - * TemplateListSelectionPage + * TemplateListSelectionPage */ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectionChangedListener { @@ -70,11 +70,11 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio public String getLabel() { return labelText; } - + public void setDescriptionText(String text) { descriptionBrowser.setText(text); } - + public void setDescriptionEnabled(boolean enabled) { Control control = descriptionBrowser.getControl(); if (control != null) { @@ -86,24 +86,25 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio getContainer().showPage(getNextPage()); } + @Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.verticalSpacing = 10; container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); - + Label label = new Label(container, SWT.NONE); label.setText(getLabel()); GridData gd = new GridData(); label.setLayoutData(gd); - + SashForm sashForm = new SashForm(container, SWT.VERTICAL); gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 300; gd.minimumHeight = 230; sashForm.setLayoutData(gd); - + boolean useTree = parentWizard.showTemplatesInTreeView(); if (useTree) @@ -111,6 +112,7 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio wizardSelectionTreeViewer = new TreeViewer(sashForm, SWT.BORDER); wizardSelectionTreeViewer.setContentProvider(parentWizard); wizardSelectionTreeViewer.addDoubleClickListener(new IDoubleClickListener() { + @Override public void doubleClick(DoubleClickEvent event) { selectionChanged(new SelectionChangedEvent(wizardSelectionTreeViewer, wizardSelectionTreeViewer.getSelection())); moveToNextPage(); @@ -120,13 +122,14 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio wizardSelectionTreeViewer.addSelectionChangedListener(this); wizardSelectionTreeViewer.getTree().setData("name", "templates"); //$NON-NLS-1$ //$NON-NLS-2$ wizardSelectionViewer = wizardSelectionTreeViewer; - + } else { wizardSelectionTableViewer = new TableViewer(sashForm, SWT.BORDER); wizardSelectionTableViewer.setContentProvider(parentWizard); wizardSelectionTableViewer.addDoubleClickListener(new IDoubleClickListener() { + @Override public void doubleClick(DoubleClickEvent event) { selectionChanged(new SelectionChangedEvent(wizardSelectionTableViewer, wizardSelectionTableViewer.getSelection())); moveToNextPage(); @@ -136,7 +139,7 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio wizardSelectionTableViewer.addSelectionChangedListener(this); wizardSelectionTableViewer.getTable().setData("name", "templates"); //$NON-NLS-1$ //$NON-NLS-2$ wizardSelectionViewer = wizardSelectionTableViewer; - + } wizardSelectionViewer.getControl().setData(".uid", "wizardSelectionViewer"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -146,7 +149,8 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio Dialog.applyDialogFont(container); setControl(container); } - + + @Override public void selectionChanged(SelectionChangedEvent event) { setErrorMessage(null); IStructuredSelection selection = (IStructuredSelection) event.getSelection(); @@ -168,7 +172,7 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio setDescriptionText(parentWizard.getDescription(finalSelection)); getContainer().updateButtons(); } - + public Template getTemplate() { IWizardNode selectedNode = getSelectedNode(); if (selectedNode != null) { @@ -176,7 +180,7 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio } return null; } - + public IWizardPage getNextPage(boolean shouldCreate) { if (!shouldCreate) { return super.getNextPage(); @@ -191,10 +195,10 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio if (shouldCreate) { wizard.addPages(); } - + return wizard.getStartingPage(); } - + @Override public boolean canFlipToNextPage() { IStructuredSelection ssel = (IStructuredSelection)wizardSelectionViewer.getSelection(); @@ -212,7 +216,7 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio if (wizardSelectionTreeViewer != null) { wizardSelectionTreeViewer.expandAll(); } - + // select the first element by default if (wizardSelectionTableViewer != null) { wizardSelectionTableViewer.setSelection(new StructuredSelection(wizardSelectionTableViewer.getElementAt(0)), true); @@ -226,13 +230,13 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio if (visible) { if (wizardSelectionTreeViewer != null) { wizardSelectionTreeViewer.getTree().setFocus(); - } + } if (wizardSelectionTableViewer != null) { wizardSelectionTableViewer.getTable().setFocus(); } } } - + private boolean templatesHaveChanged(Template[] newTemplates) { // doing this rather than an array compare because even when // the templates are the same the objects are not. we really @@ -248,7 +252,7 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio } else { changed = true; } - + return changed; } @@ -260,14 +264,14 @@ class TemplateListSelectionPage extends WizardSelectionPage implements ISelectio { return parentWizard.getPagesAfterTemplatePages(); } - + public IWizardDataPage[] getPagesAfterTemplateSelection() throws InstantiationException, IllegalAccessException, ClassNotFoundException { - return parentWizard.getPagesAfterTemplateSelectionWithExtraPages(getTemplate()); + return parentWizard.getPagesAfterTemplateSelectionWithExtraPages(getTemplate()); } public void adjustTemplateValues(Template template) { - parentWizard.adjustTemplateValues(template); + parentWizard.adjustTemplateValues(template); } } diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java index e384f458eb7..f5075e132ac 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java @@ -34,11 +34,11 @@ import org.eclipse.cdt.ui.CUIPlugin; /** - * A wizard intending to show a choice of templates (@see org.eclipse.cdt.core.templateenginee.Template) + * A wizard intending to show a choice of templates (@see org.eclipse.cdt.core.templateenginee.Template) * before switching to the pages driven by the chosen template should extend from TemplatesChoiceWizard. * Alternatively, when a choice of templates needn't be shown, TemplateDrivenWizard is a better fit. * (@see org.eclipse.cdt.ui.templateengine.TemplateDrivenWizard) - * + * */ public abstract class TemplatesChoiceWizard extends Wizard implements ITemplatesListProvider, IWorkbenchWizard { private static final boolean DEBUG = false; @@ -47,7 +47,7 @@ public abstract class TemplatesChoiceWizard extends Wizard implements ITemplates protected IStructuredSelection selection; @Override - public final void addPages() { + public final void addPages() { IWizardPage[] pages = getPagesBeforeTemplatePages(); for (IWizardPage page : pages) { addPage(page); @@ -93,7 +93,7 @@ public abstract class TemplatesChoiceWizard extends Wizard implements ITemplates pageList.addAll(Arrays.asList(extraPages)); pages = pageList.toArray(new IWizardDataPage[pageList.size()]); } - return pages; + return pages; } IWizardDataPage[] getExtraCreatedPages(Template template) throws InstantiationException, IllegalAccessException, ClassNotFoundException { @@ -105,12 +105,13 @@ public abstract class TemplatesChoiceWizard extends Wizard implements ITemplates pageList.addAll(Arrays.asList(extraPages)); return pageList.toArray(new IWizardDataPage[pageList.size()]); } - return new IWizardDataPage[0]; + return new IWizardDataPage[0]; } @Override public boolean performFinish() { IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { finishPage(monitor); } @@ -177,6 +178,7 @@ public abstract class TemplatesChoiceWizard extends Wizard implements ITemplates /** * initializes the workbench */ + @Override public void init(IWorkbench workbench, IStructuredSelection currentSelection) { this.workbench = workbench; this.selection = currentSelection; diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/WizardNode.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/WizardNode.java index 8c0b696dccc..adee66f2240 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/WizardNode.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/WizardNode.java @@ -24,7 +24,7 @@ import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage; /** - * Wizard Node + * Wizard Node */ class WizardNode implements IWizardNode { private IWizard wizard; @@ -40,14 +40,15 @@ class WizardNode implements IWizardNode { this.parentPage = parentPage; this.template = template; } - + + @Override public void dispose() { if (wizard != null) { wizard.dispose(); wizard = null; } } - + /** * Returns the Template */ @@ -55,13 +56,15 @@ class WizardNode implements IWizardNode { return template; } + @Override public Point getExtent() { return new Point(-1, -1); } - + /** * Returns the Wizard. */ + @Override public IWizard getWizard() { if (wizard != null) { return wizard; @@ -70,9 +73,9 @@ class WizardNode implements IWizardNode { { setWindowTitle(template.getLabel()); } - + private boolean finishPressed; - + @Override public void addPages() { IWizardPage[] wpages = null; @@ -83,7 +86,7 @@ class WizardNode implements IWizardNode { } } catch (Exception e) { } - + Map pages = template.getUIPages(); for (Object element : template.getPagesOrderVector()) { String id = (String) element; @@ -95,7 +98,7 @@ class WizardNode implements IWizardNode { addPage(wpage); } } - + @Override public boolean performFinish() { Map valueStore = template.getValueStore(); @@ -109,7 +112,7 @@ class WizardNode implements IWizardNode { template.getValueStore().putAll(parentPage.getDataInPreviousPages()); return true; } - + @Override public boolean canFinish(){ return !finishPressed && super.canFinish(); @@ -134,6 +137,7 @@ class WizardNode implements IWizardNode { return wizard; } + @Override public boolean isContentCreated() { return wizard != null; } diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java index 7c5f74e4b20..6a300937fe4 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java @@ -25,20 +25,21 @@ import org.eclipse.cdt.ui.templateengine.IWizardDataPage; * The first page in a NewProjectWizard. This is the wizard page that * asks the user for the name and location of the new project. */ -public class NewProjectCreationPage extends WizardNewProjectCreationPage implements IWizardDataPage { +public class NewProjectCreationPage extends WizardNewProjectCreationPage implements IWizardDataPage { private static final String ERROR_SUFFIX = Messages.getString("NewProjectCreationPage.0"); //$NON-NLS-1$ private static final String ERROR_SUFFIX_TOO_LONG = Messages.getString("NewProjectCreationPage.1"); //$NON-NLS-1$ private static final Status OK_STATUS = new Status(IStatus.OK, CUIPlugin.getPluginId(), 0, "", null); //$NON-NLS-1$ private Map data; private IWizardPage next; - + public NewProjectCreationPage(String name) { super(name); data= new HashMap(); this.setDescription(Messages.getString("NewProjectCreationPage.3")); //$NON-NLS-1$ } + @Override public Map getPageData() { String projName = super.getProjectName().trim(); data.put("projectName", projName); //$NON-NLS-1$ @@ -61,7 +62,7 @@ public class NewProjectCreationPage extends WizardNewProjectCreationPage impleme } return baseName; } - + @Override protected boolean validatePage() { if (super.validatePage() == true) { @@ -74,38 +75,38 @@ public class NewProjectCreationPage extends WizardNewProjectCreationPage impleme } return false; } - + /** - * Projects names should only be alphanumeric and can contain ' ' and '_' chars. + * Projects names should only be alphanumeric and can contain ' ' and '_' chars. * Names are limited to 31 chars. Names cannot end in a '.' char. Note that '.' * characters currently not allowed as many of the command line generators get * the name wrong for generated files. e.g. my.foo project name results in * foo.rsc, foo.rsg, etc.. rather than the expected my.foo.rsc. - * @param projectName - The unmodified project name from the project wizard. + * @param projectName - The unmodified project name from the project wizard. * @return an IStatus message on error. - * + * * Note: Platform may have a different project name constraints. Please subclass this * to add your own versions of validnames for template projects. */ private IStatus isValidName(String projectName) { //String baseName = getBaseName(projectName); String baseName = projectName; - + if (!Character.isLetter(baseName.charAt(0))) { return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, projectName + ERROR_SUFFIX, null); } - + if (baseName.length() > 31) { return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, projectName + ERROR_SUFFIX_TOO_LONG, null); } - + for (int i = 1, l = baseName.length(); i < l; i++) { char c = baseName.charAt(i); if (!Character.isLetterOrDigit(c) && c != '_' && c != ' ') { return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, projectName + ERROR_SUFFIX, null); } } - + return OK_STATUS; } @@ -113,10 +114,11 @@ public class NewProjectCreationPage extends WizardNewProjectCreationPage impleme * (non-Javadoc) * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage) */ + @Override public void setNextPage(IWizardPage next) { this.next= next; } - + /* * (non-Javadoc) * @see org.eclipse.jface.wizard.WizardPage#getNextPage() diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.java index d7d442a9213..42882200ed1 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.java @@ -90,7 +90,7 @@ public class TemplateInputDialog extends Dialog { /** * JFace Dialog Constructor, constructs controls of the super class - * + * * @param parentShell */ @@ -101,7 +101,7 @@ public class TemplateInputDialog extends Dialog { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ @@ -114,7 +114,7 @@ public class TemplateInputDialog extends Dialog { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @@ -131,7 +131,7 @@ public class TemplateInputDialog extends Dialog { /** * Opens the Dialog to accept user input for shared values. - * + * * @param myDialog * @param dataOption */ @@ -155,7 +155,7 @@ public class TemplateInputDialog extends Dialog { /** * Creates control under the parent composite - * + * * @param composite */ @@ -209,12 +209,13 @@ public class TemplateInputDialog extends Dialog { /** * Adds Modify listeners to the Text fields - * + * * @param aText */ public void addTextListener(final Text aText) { ModifyListener mListener = new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { String nameField = aText.getText(); textChanged(nameField); @@ -226,7 +227,7 @@ public class TemplateInputDialog extends Dialog { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#okPressed() This method is * overridden to perform custom events on OK button. */ @@ -267,7 +268,7 @@ public class TemplateInputDialog extends Dialog { /** * Pops up Message dialog if duplicate entry is found and returns * confirmation. - * + * * @return result */ @@ -283,7 +284,7 @@ public class TemplateInputDialog extends Dialog { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() */ @Override @@ -293,9 +294,9 @@ public class TemplateInputDialog extends Dialog { } /** - * + * * Implements the modify listener for the text field Name and Value fields. - * + * * @param textField */ diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.java index 2ee976e088c..d392b99e229 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.java @@ -149,7 +149,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Sets the values of the Message Dialog - * + * * @param aName * @param aValue */ @@ -176,7 +176,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Creates controls on the Preference Page Adds the created Table and Button * composite to the parent composite. - * + * * @param parent * @return subComposite */ @@ -212,7 +212,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Adds table into the first composite present under parent Updates the * Table with backend persistence data. - * + * * @param parent */ @@ -224,7 +224,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Creates second composite for buttons present under the parent - * + * * @param parent */ @@ -235,7 +235,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Creates default composite area for the Buttons - * + * * @param parent * @return composite */ @@ -259,7 +259,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Creates Table with XML properties as its settings - * + * * @param composite */ @@ -350,7 +350,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench * Creates button controls on the first composite present under parent * composite. Its aligned at rightmost end of Table and top of the second * composite. - * + * * @param composite */ @@ -372,7 +372,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Constructs button listeners to trigger specific functionality - * + * * @param button */ public void addButtonListener(final Button button) { @@ -444,7 +444,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Gets the size of the Attributes of an Element of XML file - * + * * @param sharedElementList * @return attrListSize */ @@ -481,6 +481,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench } } + @Override public void init(IWorkbench workbench) { } @@ -504,7 +505,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Gives the item for the selected row in the table - * + * * @return selectedItemName */ @@ -542,7 +543,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench if (result == SWT.OK) { int itemSelected[] = table.getSelectionIndices(); table.remove(itemSelected); - + if (delItemNames != null) { sharedDefaults.deleteBackEndStorage(delItemNames); } @@ -554,7 +555,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench /** * Sets confirmation for the data deletion at the fronend and backend - * + * * @param selectedItems * @return result */ diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.java index d2bb071ff22..629f9d7b2c7 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.java @@ -38,7 +38,7 @@ import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite; public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEventListener { /** - * This map will contain reference to the source widgets, which has generated the + * This map will contain reference to the source widgets, which has generated the * SWT events. If this map contains an event source, the error message will not be cleared. */ HashMap validInvalid; @@ -64,10 +64,10 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven private IWizardPage previousPage = null; private IWizardPage nextPage = null; - + /** * Title of the page, Page Name and UIElement group are the parameters. - * + * * @param title * Title of this page * @param pageName @@ -84,9 +84,10 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * returns true if the page is complete, and there is a next page to flip. - * + * * @return boolean. true if can flip to next page, otherwise false. */ + @Override public boolean canFlipToNextPage() { boolean retVal = false; @@ -110,7 +111,7 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * Returns the dialog setting for this wizard page. null, if none exists. - * + * * @return IDialogSettings, if Wizard is not set null. */ @@ -124,7 +125,7 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * Overloaded from DialogPage get the Image from the super class, * DialogPage. if not defined, then the default page Image is returned. - * + * * @return Image. */ @@ -141,25 +142,28 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * @return String, page Name. */ + @Override public String getName() { return name; } /** * gets the Nextpage to be displayed, if set. - * + * * @return IWizardPage. */ + @Override public IWizardPage getNextPage() { if (nextPage != null) return nextPage; - + if (wizard == null) return null; return wizard.getNextPage(this); } - + + @Override public void setNextPage(IWizardPage page) { nextPage = page; } @@ -168,9 +172,10 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven * returns the PreviousPage, if Previous page is not initialized. Wizard is * checked for previous page. if wizard for this page is not set null is * returned. - * + * * @return IWizardPage */ + @Override public IWizardPage getPreviousPage() { if (previousPage != null) return previousPage; @@ -197,16 +202,17 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * returns the Wizard instance to which this page is added. - * + * * @return IWizard. */ + @Override public IWizard getWizard() { return wizard; } /** * is this is the current page being displayed. - * + * * @return boolean, true if this is the current page. otherwise false. */ protected boolean isCurrentPage() { @@ -220,6 +226,7 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * @return boolean, true if this page is complete, otherwise false. */ + @Override public boolean isPageComplete() { return isPageComplete; } @@ -237,8 +244,9 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * Method from IWizardPage - * + * */ + @Override public void setPreviousPage(IWizardPage page) { previousPage = page; } @@ -246,8 +254,9 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * set the Wizard for this page, the wizard will contain this page. In the * list of pages which will be displayed as part of this Wizard. - * + * */ + @Override public void setWizard(IWizard newWizard) { wizard = newWizard; } @@ -263,22 +272,23 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven /** * Creates the top level control for this dialog page under the given parent * composite. - * + * * @param parent * the parent composite */ + @Override public void createControl(Composite parent) { initializeDialogUnits(parent); uiComposite = new UIComposite(parent, uiElement, valueStore); uiComposite.addPatternListener(this); uiElement.createWidgets(uiComposite); - + // set the focus so that InfoPop is displayed when F1 is Pressed. uiComposite.setFocus(); - + setControl(uiComposite); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), pageId); - + setPageComplete(uiComposite.isValid()); } @@ -289,17 +299,18 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven * the Container. Which has to reflect the same as an ErrorMeesage. Get the * source of the PatternEvent, and the error String causing the * PatternEvent. Store this pair in validInvalid HashMap. - * + * */ + @Override public void patternPerformed(PatternEvent patternEvent) { if (!patternEvent.getValid()) { - + validInvalid.put(patternEvent.getSource(), patternEvent.toString()); setErrorMessage(getErrorString()); setPageComplete(validInvalid.isEmpty() && uiComposite.isValid()); } else { - + validInvalid.remove(patternEvent.getSource()); setPageComplete(validInvalid.isEmpty() && uiComposite.isValid()); if (validInvalid.isEmpty()) { @@ -316,13 +327,13 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven * Iterate through the validInvalid HashMap, formulate the error string * return the same. This will ensure that the proper error string is * updated. - * + * * @return */ private String getErrorString() { Iterator iterator = validInvalid.keySet().iterator(); String message = ""; //$NON-NLS-1$ - + // only display one error message at a time if (iterator.hasNext()) { message = validInvalid.get(iterator.next()); diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHelper.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHelper.java index b36915b2abf..7cff3ab3b7b 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHelper.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHelper.java @@ -50,7 +50,7 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { /** * Constructor, takes an TemplateDescriptor instance as parameter. - * + * * @param templateDescriptor */ public UIElementTreeBuilderHelper(TemplateDescriptor templateDescriptor, TemplateInfo templateInfo) { @@ -59,7 +59,7 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { } /** - * + * * @return List of child Elements for the given */ public List getPropertyGroupList() { @@ -71,10 +71,11 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { * same is returned. The Type attribute is verified, based on Type * appropriate UIWidget is instantiated. This class the getUIWidget private * method. - * + * * @param element * @return UIElement. */ + @Override public UIElement getUIElement(Element element) { UIAttributes uiAttributes = new UIAttributes(templateInfo); @@ -83,7 +84,7 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { Node attribute = list.item(i); uiAttributes.put(attribute.getNodeName(), attribute.getNodeValue()); } - + return getUIWidget(element, uiAttributes); } @@ -91,7 +92,7 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { * Given an XML Element, representing a PropertyElement. A UIElement for the * same is returned. The Type attribute is verified, based on Type * appropriate UIWidget is instantiated. - * + * * @param uiAttributes * @return UIElement. */ @@ -99,22 +100,22 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { UIElement widgetElement= null; String id= uiAttributes.get(UIElement.ID); String type= uiAttributes.get(UIElement.TYPE); - + if (type == null || type.length()==0 ) { return null; } - + if (new Boolean(uiAttributes.get(InputUIElement.HIDDEN)).booleanValue()) { - return null; + return null; } - + if (type.equalsIgnoreCase(InputUIElement.INPUTTYPE)) { widgetElement = new UITextWidget(uiAttributes); } else if (type.equalsIgnoreCase(InputUIElement.MULTILINETYPE)) { widgetElement = new UITextWidget(uiAttributes); } else if (type.equalsIgnoreCase(InputUIElement.SELECTTYPE)) { String defaultValue= element.getAttribute(InputUIElement.DEFAULT); - + Map value2name= new LinkedHashMap(); for(Element item : TemplateEngine.getChildrenOfElement(element)) { String label= item.getAttribute(InputUIElement.COMBOITEM_LABEL); // item displayed in Combo @@ -134,7 +135,7 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { } } } - + widgetElement = new UISelectWidget(uiAttributes, value2name, defaultValue); } else if (type.equalsIgnoreCase(InputUIElement.BOOLEANTYPE)) { String defaultValue= element.getAttribute(InputUIElement.DEFAULT); @@ -152,7 +153,7 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper { widgetElement = new SimpleUIElementGroup(uiAttributes); } else if (type.equalsIgnoreCase(UIGroupTypeEnum.PAGES_TAB.getId())) { // Note: This is not implemented now as we haven't found a use case - // for generating UI pages as TABS in a single page. + // for generating UI pages as TABS in a single page. } else { String msg= MessageFormat.format(Messages.getString("UIElementTreeBuilderHelper.UnknownWidgetType0"), new Object[] {type}); //$NON-NLS-1$ CUIPlugin.log(TEMPLATE_ENGINE_ERROR, new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, msg))); diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderManager.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderManager.java index 37796d450a9..b02c340bd12 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderManager.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderManager.java @@ -20,29 +20,29 @@ import org.eclipse.cdt.ui.templateengine.SimpleElementException; /** - * + * * call setgetUIElementTreeRootNull(), before createUIElementTree(...). * UIElementTreeBuilderManager builds a UIElementTree. - * + * * --------------UITree creation algorithm---------------------------- * createUIElementTree(UITreeRoot, RootPropertyGroupElement) UITreeRoot is * initially null. createUIElementTree(UIElement parent, XML_Element element) * Step 1. if( parent == null ) parent = * UIElementTreeBuilderHelper.getUIElement(element). - * Step 2. else { + * Step 2. else { * Step 3. List - * childList = getChildList(element); + * childList = getChildList(element); * Step 4. Iterator I = - * getIterator(childList); + * getIterator(childList); * Step 5. for every element belonging to childList - * { + * { * Step 6. uiElement = getUIElement (element from childList); advance I to next * Element. uiElement .setParent(parent); parent.put(uiElement ); - * createUIElementTree(uiElement, element from childList); + * createUIElementTree(uiElement, element from childList); * } * } * --------------------------------------------------------------------- - * + * */ public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager { @@ -57,7 +57,7 @@ public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager private UIElement uiTreeRoot = null; /** - * + * * @param uiElementTreeBuilderHelper */ public UIElementTreeBuilderManager(UIElementTreeBuilderHelper uiElementTreeBuilderHelper) { @@ -68,6 +68,7 @@ public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager * This method create the UIElementTree, by following the algorithm given * above. */ + @Override public void createUIElementTree(UIElement uiParent, Element element) { if (uiParent == null) { uiTreeRoot = uiElementTreeBuilderHelper.getUIElement(element); @@ -94,7 +95,7 @@ public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager } /** - * + * * @return UIElement, root UIElement. */ public UIElement getUIElementTreeRoot() { diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialListWidget.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialListWidget.java index a2b6ffd0dea..4b7843ed980 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialListWidget.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialListWidget.java @@ -27,12 +27,12 @@ import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener; /** * This gives a Label and UISpecialList Widget. - * + * */ public class UISpecialListWidget extends UIStringListWidget { /** * Constructor. - * + * * @param attribute * attribute associated with this widget. */ @@ -44,7 +44,7 @@ public class UISpecialListWidget extends UIStringListWidget { * create a Label and Text widget, add it to UIComposite. set Layout for the * widgets to be added to UIComposite. set required parameters to the * Widgets. - * + * * @param uiComposite */ @Override @@ -73,6 +73,7 @@ public class UISpecialListWidget extends UIStringListWidget { fileListControl.setList(itemsList.toArray(new String[itemsList.size()])); fileListControl.setSelection(0); fileListControl.addChangeListener(new IFileListChangeListener(){ + @Override public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) { itemsList.clear(); itemsList.addAll(Arrays.asList(newValue)); diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListWidget.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListWidget.java index e4f623b2dcd..1424c3b2136 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListWidget.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListWidget.java @@ -37,7 +37,7 @@ import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener; /** * This gives a Label and StringList Widget. - * + * */ public class UIStringListWidget extends InputUIElement { /** @@ -54,7 +54,7 @@ public class UIStringListWidget extends InputUIElement { /** * Constructor. - * + * * @param attribute * attribute associated with this widget. */ @@ -80,7 +80,7 @@ public class UIStringListWidget extends InputUIElement { /** * Set the Text widget with new value. - * + * * @param valueMap */ @Override @@ -100,7 +100,7 @@ public class UIStringListWidget extends InputUIElement { * create a Label and StringList widget, add it to UIComposite. set Layout * for the widgets to be added to UIComposite. set required parameters to * the Widgets. - * + * * @param uiComposite */ @Override @@ -129,16 +129,17 @@ public class UIStringListWidget extends InputUIElement { fileListControl.setList(itemsList.toArray(new String[itemsList.size()])); fileListControl.setSelection(0); fileListControl.addChangeListener(new IFileListChangeListener(){ + @Override public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) { itemsList.clear(); itemsList.addAll(Arrays.asList(newValue)); uiComposite.firePatternEvent(createPatternEvent()); } }); - + uiComposite.firePatternEvent(createPatternEvent()); } - + protected PatternEvent createPatternEvent() { String msg= MessageFormat.format("Please add an item to {0}", new String[] {label.getText()}); //$NON-NLS-1$ return new PatternEvent(this, msg, isValid()); @@ -149,7 +150,7 @@ public class UIStringListWidget extends InputUIElement { * will be used by the UIPage to update its(UIPage) state. Return value * depends on the value contained in String List Widget. If value contained * is null and Mandatory value from attributes. - * + * * @return boolean. */ @Override diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.java index 23ac1c7fd0e..a49dbb4380a 100644 --- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.java +++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.java @@ -39,7 +39,7 @@ import org.eclipse.cdt.ui.templateengine.uitree.UIElement; * entered by the user is verified against an expected pattern. If the user * entered data doesn't confirms to the expected pattern, a PatternEvent is * fired to UIComposite. - * + * * The UI***Widget classes which needs to handle patterns, can inherit the same * from this class. The inheriting class need not cache UIComposite instance * but should set the same for UITextWidget(super). @@ -61,12 +61,12 @@ public class UITextWidget extends InputUIElement implements ModifyListener { * Composite to which this widget control is added. Classes extending this class, should make sure that they initialize this from the respective class createWidgets method. */ protected UIComposite uiComposite; - + protected String textValue; /** * Constructor. - * + * * @param uiAttribute * attribute associated with this widget. */ @@ -88,7 +88,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener { /** * Set the Text widget with new value. - * + * * @param valueMap */ @Override @@ -114,7 +114,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener { * create a Label and Text widget, add it to UIComposite. set Layout for the * widgets to be added to UIComposite. set required parameters to the * Widgets. - * + * * @param uiComposite */ @Override @@ -161,7 +161,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener { * the value entered in this widget is treated as project name. The same is * verified if there is a directory by the same name in workspace, * PatternEvent is thrown to Container. - * + * * @param pattern */ public void evaluatePattern(String labelText, String userInputText, String pattern) { @@ -195,6 +195,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener { * Method from ModifyListener. Extracts the Text from the widget. calls * evaluatePattern. */ + @Override public void modifyText(ModifyEvent e) { String patternName = uiAttributes.get(InputUIElement.INPUTPATTERN); @@ -216,9 +217,9 @@ public class UITextWidget extends InputUIElement implements ModifyListener { // evaluatePattern and isValid. textValue = text.getText(); - if ((patternValue == null) || (textValue == null)) + if ((patternValue == null) || (textValue == null)) return; - + String mandatory = uiAttributes.get(InputUIElement.MANDATORY); if ((mandatory == null || !mandatory.equalsIgnoreCase("true")) && textValue.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ return; @@ -254,7 +255,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener { * will be used by the UIPage to update its(UIPage) state. Return value * depends on the value contained in TextWidget. If value contained is null, "" * and Mandatory value from attributes. - * + * * @return boolean. */ @Override @@ -274,7 +275,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener { /** * Based on Input Type Text widget is created. The Text widget created can * be of Type SINGLE or MULTI. - * + * * @param type * of Text widget required. * @return Text. diff --git a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java index 7c6771c9d87..24941702d91 100644 --- a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java +++ b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java @@ -59,7 +59,7 @@ public class ControlFactory { control.setForeground(parent.getForeground()); return control; } - + /** * Creates composite control and sets the default layout data. * @@ -82,7 +82,7 @@ public class ControlFactory { public static Composite createCompositeEx(Composite parent, int numColumns, int layoutMode) { Composite composite = new Composite(parent, SWT.NULL); composite.setFont(parent.getFont()); - + composite.setLayout(new GridLayout(numColumns, true)); composite.setLayoutData(new GridData(layoutMode)); return composite; @@ -107,7 +107,7 @@ public class ControlFactory { /** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. - * + * * @param font the font to use * @param composite the parent composite * @param title the title of the note @@ -129,12 +129,13 @@ public class ControlFactory { final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold( - JFaceResources.DEFAULT_FONT)); + JFaceResources.DEFAULT_FONT)); noteLabel .setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { + @Override + public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources .getFont(JFaceResources.BANNER_FONT)); @@ -143,7 +144,8 @@ public class ControlFactory { }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent event) { + @Override + public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); @@ -172,7 +174,7 @@ public class ControlFactory { /** * Creates a spacer control. * @param parent The parent composite - */ + */ public static Control createEmptySpace(Composite parent) { return createEmptySpace(parent, 1); } @@ -182,7 +184,7 @@ public class ControlFactory { * The composite is assumed to have MGridLayout as * layout. * @param parent The parent composite - */ + */ public static Control createEmptySpace(Composite parent, int span) { Label label= new Label(parent, SWT.LEFT); GridData gd= new GridData(); @@ -205,10 +207,10 @@ public class ControlFactory { * @param heightHint - recommended widget height * @param style - control style * @return the new label - */ + */ public static Label createLabel(Composite parent, String text, int widthHint, int heightHint, int style) { - Label label = new Label(parent, style); + Label label = new Label(parent, style); label.setFont(parent.getFont()); label.setText(text); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -233,7 +235,7 @@ public class ControlFactory { /** * Utility method that creates a label instance - * and sets the default layout data and sets the + * and sets the default layout data and sets the * font attributes to be SWT.BOLD. * * @param parent the parent for the new label @@ -250,15 +252,15 @@ public class ControlFactory { } /** - * Creates an new Wrapped label - * + * Creates an new Wrapped label + * * * @param parent parent object * @param text the label text * @param widthHint - recommended widget width * @param heightHint - recommended widget height * @return the new label - */ + */ public static Label createWrappedLabel(Composite parent, String text, int widthHint, int heightHint) { return createLabel(parent, text, widthHint, heightHint, SWT.LEFT | SWT.WRAP); } @@ -270,7 +272,7 @@ public class ControlFactory { * @param group the composite in which to create the checkbox * @param label the string to set into the checkbox * @return the new checkbox - */ + */ public static Button createCheckBox(Composite group, String label) { Button button = new Button(group, SWT.CHECK | SWT.LEFT); button.setFont(group.getFont()); @@ -289,7 +291,7 @@ public class ControlFactory { * @param group the composite in which to create the checkbox * @param label the string to set into the checkbox * @return the new checkbox - */ + */ public static Button createCheckBoxEx(Composite group, String label, int style) { Button button = new Button(group, SWT.CHECK | style); button.setFont(group.getFont()); @@ -309,7 +311,7 @@ public class ControlFactory { * @param label the string to set into the radiobutton * @param value the string to identify radiobutton * @return the new checkbox - */ + */ public static Button createRadioButton(Composite group, String label, String value, SelectionListener listener) { Button button = new Button(group, SWT.RADIO | SWT.LEFT); @@ -324,7 +326,7 @@ public class ControlFactory { button.addSelectionListener(listener); return button; } - + /** * Utility method that creates a push button instance * and sets the default layout data. @@ -343,7 +345,7 @@ public class ControlFactory { button.setLayoutData(data); return button; } - + /** * Create a text field specific for this application * @@ -353,7 +355,7 @@ public class ControlFactory { public static Text createTextField(Composite parent) { return createTextField(parent, SWT.SINGLE | SWT.BORDER); } - + public static Text createTextField(Composite parent, int style) { Text text = new Text(parent, style); GridData data = new GridData(); @@ -362,10 +364,10 @@ public class ControlFactory { data.verticalAlignment = GridData.CENTER; data.grabExcessVerticalSpace = false; text.setLayoutData(data); - + return text; } - + /** * Create a group box * @@ -382,8 +384,8 @@ public class ControlFactory { layout.numColumns = nColumns; group.setLayout(layout); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - return group; + + return group; } /** @@ -417,11 +419,11 @@ public class ControlFactory { n_sel = 0; list.select(n_sel); } - + /** * Create this group's list viewer. */ - public static TableViewer createTableViewer(Composite parent, String[] opt_list, + public static TableViewer createTableViewer(Composite parent, String[] opt_list, int width, int height, int style) { TableViewer listViewer = new TableViewer(parent, SWT.BORDER | style); GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); @@ -430,37 +432,37 @@ public class ControlFactory { listViewer.getTable().setLayoutData(data); if (null != opt_list) listViewer.add(opt_list); - return listViewer; + return listViewer; } /** * Create this group's list viewer. */ - public static TableViewer createTableViewer(Composite parent, + public static TableViewer createTableViewer(Composite parent, int width, int height, int style, String[] columns, int[] colWidths) { TableViewer listViewer = createTableViewer(parent, null, width, height, style); Table table= listViewer.getTable(); - + table.setHeaderVisible(true); table.setLinesVisible(true); - + TableLayout tableLayout= new TableLayout(); /* TableColumn column= table.getColumn(0); - column.setText(columns[0]); + column.setText(columns[0]); tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false)); -*/ +*/ TableColumn column; for (int i = 0; i < columns.length; ++i) { column= new TableColumn(table, SWT.NULL); - column.setText(columns[i]); + column.setText(columns[i]); tableLayout.addColumnData(new ColumnWeightData(colWidths[i], true)); } table.setLayout(tableLayout); - - return listViewer; + + return listViewer; } public static void deactivateCellEditor(TableViewer viewer) { @@ -488,9 +490,9 @@ public class ControlFactory { /** * Create this group's list viewer. */ - public static CheckboxTableViewer createListViewer(Composite parent, String[] opt_list, + public static CheckboxTableViewer createListViewer(Composite parent, String[] opt_list, int width, int height, int style) { - + Table table = new Table(parent, SWT.BORDER | SWT.CHECK); table.setFont(parent.getFont()); CheckboxTableViewer listViewer = new CheckboxTableViewer(table); @@ -502,37 +504,37 @@ public class ControlFactory { listViewer.add(opt_list); // listViewer.setLabelProvider(listLabelProvider); // listViewer.addCheckStateListener(this); - return listViewer; + return listViewer; } - public static CheckboxTableViewer createListViewer(Composite parent, + public static CheckboxTableViewer createListViewer(Composite parent, int width, int height, int style, String[] columns, int[] colWidths) { - CheckboxTableViewer listViewer = createListViewer(parent, null, + CheckboxTableViewer listViewer = createListViewer(parent, null, width, height, style); - + Table table= listViewer.getTable(); table.setFont(parent.getFont()); - + table.setHeaderVisible(true); table.setLinesVisible(true); - + TableLayout tableLayout= new TableLayout(); table.setLayout(tableLayout); TableColumn column= table.getColumn(0); - column.setText(columns[0]); + column.setText(columns[0]); tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false)); - + for (int i = 1; i < columns.length; ++i) { column= new TableColumn(table, SWT.NULL); - column.setText(columns[i]); + column.setText(columns[i]); tableLayout.addColumnData(new ColumnWeightData(colWidths[i], false)); - + } - - return listViewer; + + return listViewer; } - + /** * Create a selection combo * @@ -542,10 +544,10 @@ public class ControlFactory { * @return the new combo */ public static CCombo createSelectCCombo(Composite parent, String strdata, String selData) { - return createSelectCCombo(parent, strdata, selData, + return createSelectCCombo(parent, strdata, selData, SWT.READ_ONLY | SWT.BORDER); } - + public static CCombo createSelectCCombo(Composite parent, String strdata, String selData, int style) { CCombo combo = new CCombo(parent, style); combo.setFont(parent.getFont()); @@ -567,14 +569,14 @@ public class ControlFactory { * Create a selection combo * * @param parent the parent of the new text field - * @param strdata array of elements + * @param strdata array of elements * @param selData selected element * @return the new combo */ public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData) { return createSelectCCombo(parent, strdata, selData, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); } - + public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData, int style) { CCombo combo = new CCombo(parent, style); @@ -587,7 +589,7 @@ public class ControlFactory { if (selData == null) combo.select(0); else - selectCCombo(combo, selData); + selectCCombo(combo, selData); return combo; } @@ -596,7 +598,7 @@ public class ControlFactory { if (0 > n_sel) n_sel = 0; combo.select(n_sel); - } + } /** * Create a selection combo @@ -607,10 +609,10 @@ public class ControlFactory { * @return the new combo */ public static Combo createSelectCombo(Composite parent, String strdata, String selData) { - return createSelectCombo(parent, strdata, selData, + return createSelectCombo(parent, strdata, selData, SWT.READ_ONLY | SWT.BORDER); } - + public static Combo createSelectCombo(Composite parent, String strdata, String selData, int style) { Combo combo = new Combo(parent, style); combo.setFont(parent.getFont()); @@ -632,14 +634,14 @@ public class ControlFactory { * Create a selection combo * * @param parent the parent of the new text field - * @param strdata array of elements + * @param strdata array of elements * @param selData selected element * @return the new combo */ public static Combo createSelectCombo(Composite parent, String[] strdata, String selData) { return createSelectCombo(parent, strdata, selData, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); } - + public static Combo createSelectCombo(Composite parent, String[] strdata, String selData, int style) { Combo combo = new Combo(parent, style); combo.setFont(parent.getFont()); @@ -651,7 +653,7 @@ public class ControlFactory { if (selData == null) combo.select(0); else - selectCombo(combo, selData); + selectCombo(combo, selData); return combo; } @@ -665,7 +667,7 @@ public class ControlFactory { n_sel = 0; } combo.select(n_sel); - } + } /** * Create a dialog shell, child to the top level workbench shell. diff --git a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java index 1f9ae4c0d08..6af9d0ec1eb 100644 --- a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java +++ b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java @@ -94,7 +94,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages; /** * Instances of this class allow the user to add, remove, delete, moveup and movedown * the items in the list control. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class FileListControl { @@ -103,7 +103,7 @@ public class FileListControl { * Constant copied from ManagedBuild IOption indicating that the entries in this * FileListControl are neither files nor directories -- they're treated as a plain * String list. - * + * * #see org.eclipse.cdt.managedbuilder.core.IOption#BROWSE_NONE * @since 5.2 */ @@ -111,7 +111,7 @@ public class FileListControl { /** * Constant copied from ManagedBuild IOption indicating that the entries in this * FileListControl are Files. - * + * * #see org.eclipse.cdt.managedbuilder.core.IOption#BROWSE_FILE * @since 5.2 */ @@ -119,7 +119,7 @@ public class FileListControl { /** * Constant copied from ManagedBuild IOption indicating that the entries in this * FileListControl are Directories. - * + * * #see org.eclipse.cdt.managedbuilder.core.IOption#BROWSE_DIR * @since 5.2 */ @@ -247,7 +247,8 @@ public class FileListControl { } else { dialog.setInitialSelection(resource); dialog.setValidator(new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { + @Override + public IStatus validate(Object[] selection) { if (selection != null) for (Object sel : selection) if (!(sel instanceof IFile)) @@ -259,7 +260,7 @@ public class FileListControl { dialog.setMessage(WORKSPACE_FILE_DIALOG_MSG); } - /* Open dialog and process result. + /* Open dialog and process result. * If a resource has been selected we create a workspace relative path for it. * Use ${ProjName} if the full path is relative to the context's location */ if (dialog.open() == Window.OK) { @@ -400,7 +401,7 @@ public class FileListControl { } catch (ExecutionException e) { CUIPlugin.log(e); } - } + } private Clipboard getClipboard() { if (clipboard == null) clipboard = new Clipboard(Display.getDefault()); @@ -432,27 +433,27 @@ public class FileListControl { private static final IPath PROJECTNAME_PATH = new Path(VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression(PROJECTNAME_VAR, null)); /* Names, messages and titles */ - private static final String WORKSPACEBUTTON_NAME = Messages.FileListControl_button_workspace; - private static final String FILESYSTEMBUTTON_NAME = Messages.FileListControl_button_fs; + private static final String WORKSPACEBUTTON_NAME = Messages.FileListControl_button_workspace; + private static final String FILESYSTEMBUTTON_NAME = Messages.FileListControl_button_fs; - private static final String ADD_STR = Messages.FileListControl_add; - private static final String DEL_STR = Messages.FileListControl_delete; - private static final String EDIT_STR = Messages.FileListControl_edit; - private static final String MOVEUP_STR = Messages.FileListControl_moveup; - private static final String MOVEDOWN_STR = Messages.FileListControl_movedown; - private static final String FILE_TITLE_ADD = Messages.BrowseEntryDialog_file_title_add; - private static final String DIR_TITLE_ADD = Messages.BrowseEntryDialog_dir_title_add; - private static final String FILE_TITLE_EDIT = Messages.BrowseEntryDialog_file_title_edit; - private static final String DIR_TITLE_EDIT = Messages.BrowseEntryDialog_dir_title_edit; - private static final String WORKSPACE_DIR_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_dir_dlg_title; - private static final String WORKSPACE_FILE_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_file_dlg_title; - private static final String WORKSPACE_DIR_DIALOG_MSG = Messages.FileListControl_BrowseEntryDialog_wsp_dir_dlg_msg; - private static final String WORKSPACE_FILE_DIALOG_MSG = Messages.FileListControl_BrowseEntryDialog_wsp_file_dlg_msg; - private static final String WORKSPACE_FILE_DIALOG_ERR = Messages.FileListControl_BrowseEntryDialog_wsp_file_dlg_err; - private static final String FILESYSTEM_DIR_DIALOG_MSG = Messages.BrowseEntryDialog_fs_dir_dlg_msg; - private static final String FILE_MSG = Messages.BrowseEntryDialog_message_file; - private static final String DIR_MSG = Messages.BrowseEntryDialog_message_directory; - private static final String TITLE = Messages.BuildPropertyCommon_label_title; + private static final String ADD_STR = Messages.FileListControl_add; + private static final String DEL_STR = Messages.FileListControl_delete; + private static final String EDIT_STR = Messages.FileListControl_edit; + private static final String MOVEUP_STR = Messages.FileListControl_moveup; + private static final String MOVEDOWN_STR = Messages.FileListControl_movedown; + private static final String FILE_TITLE_ADD = Messages.BrowseEntryDialog_file_title_add; + private static final String DIR_TITLE_ADD = Messages.BrowseEntryDialog_dir_title_add; + private static final String FILE_TITLE_EDIT = Messages.BrowseEntryDialog_file_title_edit; + private static final String DIR_TITLE_EDIT = Messages.BrowseEntryDialog_dir_title_edit; + private static final String WORKSPACE_DIR_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_dir_dlg_title; + private static final String WORKSPACE_FILE_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_file_dlg_title; + private static final String WORKSPACE_DIR_DIALOG_MSG = Messages.FileListControl_BrowseEntryDialog_wsp_dir_dlg_msg; + private static final String WORKSPACE_FILE_DIALOG_MSG = Messages.FileListControl_BrowseEntryDialog_wsp_file_dlg_msg; + private static final String WORKSPACE_FILE_DIALOG_ERR = Messages.FileListControl_BrowseEntryDialog_wsp_file_dlg_err; + private static final String FILESYSTEM_DIR_DIALOG_MSG = Messages.BrowseEntryDialog_fs_dir_dlg_msg; + private static final String FILE_MSG = Messages.BrowseEntryDialog_message_file; + private static final String DIR_MSG = Messages.BrowseEntryDialog_message_directory; + private static final String TITLE = Messages.BuildPropertyCommon_label_title; /** flag which prevents us from resetting the prompt for delete flag */ private boolean neverPromptForDelete; @@ -484,7 +485,7 @@ public class FileListControl { /** Undo support */ IUndoContext undoContext; IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory(); - + private java.util.List listeners = new ArrayList(); private String[] oldValue; @@ -647,7 +648,7 @@ public class FileListControl { selectionChanged(); } - + /** * Set list values * @@ -685,7 +686,7 @@ public class FileListControl { if(oldValue != null) { if (Arrays.equals(oldValue, items)) return; - + // Add some context to the undo history IUndoableOperation op = new AbstractOperation("") { //$NON-NLS-1$ final String[] previousValue = oldValue; @@ -700,7 +701,7 @@ public class FileListControl { @Override public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { list.setItems(newValue); - notifyListeners(previousValue, newValue); + notifyListeners(previousValue, newValue); oldValue = newValue; return Status.OK_STATUS; } @@ -819,8 +820,8 @@ public class FileListControl { return; boolean delDir = true; if (promptForDelete) { - String quest = Messages.FileListControl_deletedialog_message; - String title = Messages.FileListControl_deletedialog_title; + String quest = Messages.FileListControl_deletedialog_message; + String title = Messages.FileListControl_deletedialog_title; delDir = MessageDialog.openQuestion(list.getShell(), title, quest); } if (delDir){ @@ -883,7 +884,7 @@ public class FileListControl { } dialog = new SelectPathInputDialog(getListControl().getShell(), title, message, selItem, null, browseType); } else { - String title = Messages.FileListControl_editdialog_title; + String title = Messages.FileListControl_editdialog_title; dialog = new InputDialog(null, title, compTitle, selItem, null); } @@ -963,23 +964,23 @@ public class FileListControl { /** * Sets the default filter-path for the underlying Browse dialog. Only applies when browseType is 'file' or 'dir'. * @param filterPath - * + * * @since 5.2 */ public void setFilterPath(String filterPath) { this.filterPath = filterPath; } - + /** * Sets the filter-extensions for the underlying Browse dialog. Only applies when browseType is 'file'. * @param filterExtensions - * + * * @since 5.2 */ public void setFilterExtensions(String[] filterExtensions) { this.filterExtensions = filterExtensions; } - + /** * Enable/Disable workspace support. If enabled, the workspace browse button * will be visible in the SelectPathInputDialog. diff --git a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.java b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.java index ab4ee87ba07..2f720ddf1ee 100644 --- a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.java +++ b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.java @@ -30,7 +30,7 @@ import org.eclipse.swt.widgets.Composite; /** * A field editor for an enumeration type preference. * The choices are presented as a list of radio buttons. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class RadioButtonsArea extends Composite { @@ -54,12 +54,12 @@ public class RadioButtonsArea extends Composite { * The current value, or null if none. */ protected String value = null; - + private SelectionListener listener; - + private List externalListeners = new ArrayList(); - private Composite area = null; + private Composite area = null; /** * The radio buttons, or null if none * (before creation and after disposal). @@ -74,16 +74,16 @@ public class RadioButtonsArea extends Composite { this.numColumns = numColumns; createControl(parent, labelText); } - + @Override public void setEnabled(boolean enabled) { for (Button radioButton : radioButtons) { radioButton.setEnabled(enabled); } } - + /** - * Checks whether given String[][] is of "type" + * Checks whether given String[][] is of "type" * String[][2]. * * @return true if it is ok, and false otherwise @@ -103,7 +103,7 @@ public class RadioButtonsArea extends Composite { s.widgetSelected(event); } } - + /** * Create control area */ @@ -113,7 +113,7 @@ public class RadioButtonsArea extends Composite { gl.marginWidth = 0; gl.horizontalSpacing = 0; this.setLayout(gl); - + if(null != labelText) { // Create group box area = ControlFactory.createGroup(this, labelText, numColumns); } else { @@ -128,22 +128,23 @@ public class RadioButtonsArea extends Composite { fireSelectionEvent(event); // Infor any external listener } }; - + for (int i = 0; i < labelsAndValues.length; i++) { - radioButtons[i] = ControlFactory.createRadioButton(area, + radioButtons[i] = ControlFactory.createRadioButton(area, labelsAndValues[i][0], labelsAndValues[i][1], listener); } - + area.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent event) { radioButtons = null; } }); } - + /** * Sets the indent used for the first column of the radion button matrix. * @@ -168,7 +169,7 @@ public class RadioButtonsArea extends Composite { this.value = selectedValue; if (radioButtons == null) return; - + if (this.value != null) { boolean found = false; for (Button radio : radioButtons) { @@ -182,7 +183,7 @@ public class RadioButtonsArea extends Composite { if (found) return; } - + // We weren't able to find the value. So we select the first // radio button as a default. if (radioButtons.length > 0) { @@ -194,10 +195,10 @@ public class RadioButtonsArea extends Composite { public void setSelectedButton(int index) { Button b; - + if((index < 0) || (index >= radioButtons.length)) return; - + for(int i = 0; i < radioButtons.length; ++i) { b = radioButtons[i]; boolean selected = b.getSelection(); @@ -214,25 +215,25 @@ public class RadioButtonsArea extends Composite { this.value = (String)b.getData(); b.setSelection(true); } - + public String getSelectedValue() { return value; } - + public int getSeletedIndex() { if (radioButtons == null) return -1; - + if (value != null) { for (int i = 0; i < radioButtons.length; i++) { - if (radioButtons[i].getData().equals(this.value)) + if (radioButtons[i].getData().equals(this.value)) return i; } } - + return -1; } - + public void addSelectionListener(SelectionListener s) { if(externalListeners.contains(s)) return;