diff options
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core')
17 files changed, 667 insertions, 667 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java index e8c63f69c..bbc9a275c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java @@ -46,145 +46,145 @@ import org.eclipse.core.resources.IStorage; */ public interface IFileContentManager { - /** - * Get the content type for a given instance of <code>IStorage</code>. User-defined mappings - * take precedence over plugin-contributed mappings; further, mappings for the entire file name - * take precedence over mappings for the file extension only. - * - * @param storage the instance of <code>IStorage</code>. - * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. - * - * @since 3.1 - */ - int getType(IStorage storage); - - /** - * Check whether the given file name is assigned to a specific type in the content type registry. - * @param filename the file name to check for - * @return True if the file name is registered in the system and assigned to a content type, false - * if the file name is unknown. - * - * @since 3.1 - */ - boolean isKnownFilename(String filename); - - /** - * Check whether the given file extension is assigned to a specific type in the content type registry. - * @param extension the extension to check for - * @return True if the extension is registered in the system and assigned to a content type, false - * if the extension is unknown. - * - * @since 3.1 - */ - boolean isKnownExtension(String extension); - - /** - * Get the content type for a given file name. - * @param filename The file name - * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. - * - * @since 3.1 - */ - int getTypeForName(String filename); - - /** - * Get the content type for a given file extension. - * @param extension The extension - * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. - * - * @since 3.1 - */ - int getTypeForExtension(String extension); - - /** - * Map a set of file names to a set of content types and save the mappings in - * the preferences. Already existing mappings for these file names are updated - * with the new ones, other mappings will be preserved. - * - * @param names The file names - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void addNameMappings(String[] names, int[] types); - - /** - * Map a set of file extensions to a set of content types and save the mapping in - * the preferences. Already existing mappings for these extensions are updated - * with the new ones, other mappings will be preserved. - * - * @param extensions The extensions - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void addExtensionMappings(String[] extensions, int[] types); - - /** - * Map a set of file names to a set of content types and save the mappings in - * the preferences. All existing user-defined mappings for <b>any - * </b> file names are deleted and replaced by the new ones. - * - * @param names The file names - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void setNameMappings(String[] names, int[] types); - - /** - * Map a set of file extensions to a set of content types and save the - * mapping in the preferences. All existing user-defined mappings for <b>any - * </b> file extensions are deleted and replaced by the new ones. - * - * @param extensions The extensions - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void setExtensionMappings(String[] extensions, int[] types); - - /** - * Get all the currently defined mappings from file names to content types. - * - * @return the mappings - * - * @since 3.1 - */ - IStringMapping [] getNameMappings(); - - /** - * Get all the currently defined mappings from file names to content types. - * - * @return the mappings - * - * @since 3.1 - */ - IStringMapping [] getExtensionMappings(); - - /** - * Get all the plugin-contributed mappings from file names to content types. - * - * @return the mappings - * - * @since 3.1 - */ - IStringMapping [] getDefaultNameMappings(); - - /** - * Get all the plugin-contributed mappings from file extensions to content types. - * - * @return the mappings - - * @since 3.1 - */ - IStringMapping [] getDefaultExtensionMappings(); + /** + * Get the content type for a given instance of <code>IStorage</code>. User-defined mappings + * take precedence over plugin-contributed mappings; further, mappings for the entire file name + * take precedence over mappings for the file extension only. + * + * @param storage the instance of <code>IStorage</code>. + * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. + * + * @since 3.1 + */ + int getType(IStorage storage); + + /** + * Check whether the given file name is assigned to a specific type in the content type registry. + * @param filename the file name to check for + * @return True if the file name is registered in the system and assigned to a content type, false + * if the file name is unknown. + * + * @since 3.1 + */ + boolean isKnownFilename(String filename); + + /** + * Check whether the given file extension is assigned to a specific type in the content type registry. + * @param extension the extension to check for + * @return True if the extension is registered in the system and assigned to a content type, false + * if the extension is unknown. + * + * @since 3.1 + */ + boolean isKnownExtension(String extension); + + /** + * Get the content type for a given file name. + * @param filename The file name + * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. + * + * @since 3.1 + */ + int getTypeForName(String filename); + + /** + * Get the content type for a given file extension. + * @param extension The extension + * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. + * + * @since 3.1 + */ + int getTypeForExtension(String extension); + + /** + * Map a set of file names to a set of content types and save the mappings in + * the preferences. Already existing mappings for these file names are updated + * with the new ones, other mappings will be preserved. + * + * @param names The file names + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void addNameMappings(String[] names, int[] types); + + /** + * Map a set of file extensions to a set of content types and save the mapping in + * the preferences. Already existing mappings for these extensions are updated + * with the new ones, other mappings will be preserved. + * + * @param extensions The extensions + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void addExtensionMappings(String[] extensions, int[] types); + + /** + * Map a set of file names to a set of content types and save the mappings in + * the preferences. All existing user-defined mappings for <b>any + * </b> file names are deleted and replaced by the new ones. + * + * @param names The file names + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void setNameMappings(String[] names, int[] types); + + /** + * Map a set of file extensions to a set of content types and save the + * mapping in the preferences. All existing user-defined mappings for <b>any + * </b> file extensions are deleted and replaced by the new ones. + * + * @param extensions The extensions + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void setExtensionMappings(String[] extensions, int[] types); + + /** + * Get all the currently defined mappings from file names to content types. + * + * @return the mappings + * + * @since 3.1 + */ + IStringMapping [] getNameMappings(); + + /** + * Get all the currently defined mappings from file names to content types. + * + * @return the mappings + * + * @since 3.1 + */ + IStringMapping [] getExtensionMappings(); + + /** + * Get all the plugin-contributed mappings from file names to content types. + * + * @return the mappings + * + * @since 3.1 + */ + IStringMapping [] getDefaultNameMappings(); + + /** + * Get all the plugin-contributed mappings from file extensions to content types. + * + * @return the mappings + + * @since 3.1 + */ + IStringMapping [] getDefaultExtensionMappings(); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java index f62bbe399..ac54d1ddd 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java @@ -24,21 +24,21 @@ package org.eclipse.team.core; */ public interface IStringMapping { - /** - * The string part of the mapping - * - * @return the string - * - * @since 3.1 - */ - String getString(); + /** + * The string part of the mapping + * + * @return the string + * + * @since 3.1 + */ + String getString(); - /** - * The content type associated with the string - * - * @return the content type - * - * @since 3.1 - */ - int getType(); + /** + * The content type associated with the string + * + * @return the content type + * + * @since 3.1 + */ + int getType(); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java index e2a5c5e19..b6473385a 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java @@ -244,9 +244,9 @@ public abstract class ProjectSetCapability { IProject eachProj = projects[i]; if (eachProj.exists()) { existingProjects.add(eachProj); - } else if (new File(eachProj.getParent().getLocation().toFile(), eachProj.getName()).exists()) { - existingProjects.add(eachProj); - } + } else if (new File(eachProj.getParent().getLocation().toFile(), eachProj.getName()).exists()) { + existingProjects.add(eachProj); + } } if (existingProjects.size() == 0) return projects; diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java index d2f4c70f9..8e4ba1259 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java @@ -100,8 +100,8 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { // lock to ensure that map/unmap and getProvider support concurrency private static final ILock mappingLock = Job.getJobManager().newLock(); - // Session property used to identify projects that are not mapped - private static final Object NOT_MAPPED = new Object(); + // Session property used to identify projects that are not mapped + private static final Object NOT_MAPPED = new Object(); /** * Instantiate a new RepositoryProvider with concrete class by given providerID @@ -330,10 +330,10 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { */ private static RepositoryProvider lookupProviderProp(IProject project) throws CoreException { Object provider = project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY); - if (provider instanceof RepositoryProvider) { - return (RepositoryProvider) provider; - } - return null; + if (provider instanceof RepositoryProvider) { + return (RepositoryProvider) provider; + } + return null; } @@ -394,12 +394,12 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { /** * Returns an <code>IFileModificationValidator</code> for pre-checking operations - * that modify the contents of files. - * Returns <code>null</code> if the provider does not wish to participate in - * file modification validation. + * that modify the contents of files. + * Returns <code>null</code> if the provider does not wish to participate in + * file modification validation. * @return an <code>IFileModificationValidator</code> for pre-checking operations - * that modify the contents of files - * + * that modify the contents of files + * * @see org.eclipse.core.resources.IFileModificationValidator * @deprecated use {@link #getFileModificationValidator2()} */ @@ -460,7 +460,7 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { * @since 3.2 */ public IFileHistoryProvider getFileHistoryProvider(){ - return null; + return null; } /** @@ -532,10 +532,10 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { RepositoryProvider provider = lookupProviderProp(project); if(provider != null) return provider; - // Do a quick check to see it the project is known to be unshared. - // This is done to avoid accessing the persistent property store - if (isMarkedAsUnshared(project)) - return null; + // Do a quick check to see it the project is known to be unshared. + // This is done to avoid accessing the persistent property store + if (isMarkedAsUnshared(project)) + return null; // ----------------------------- //Next, check if it has the ID as a persistent property, if yes then instantiate provider @@ -603,10 +603,10 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { return null; } } - // Do a quick check to see it the project is known to be unshared. - // This is done to avoid accessing the persistent property store - if (isMarkedAsUnshared(project)) - return null; + // Do a quick check to see it the project is known to be unshared. + // This is done to avoid accessing the persistent property store + if (isMarkedAsUnshared(project)) + return null; // There isn't one so check the persistent property String existingID = project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY); @@ -666,14 +666,14 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { if (!project.isAccessible()) return false; try { if (lookupProviderProp(project) != null) return true; - // Do a quick check to see it the project is known to be unshared. - // This is done to avoid accessing the persistent property store - if (isMarkedAsUnshared(project)) - return false; + // Do a quick check to see it the project is known to be unshared. + // This is done to avoid accessing the persistent property store + if (isMarkedAsUnshared(project)) + return false; boolean shared = project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY) != null; - if (!shared) - markAsUnshared(project); - return shared; + if (!shared) + markAsUnshared(project); + return shared; } catch (CoreException e) { TeamPlugin.log(e); return false; @@ -681,20 +681,20 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { } private static boolean isMarkedAsUnshared(IProject project) { - try { - return project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY) == NOT_MAPPED; - } catch (CoreException e) { - return false; - } - } - - private static void markAsUnshared(IProject project) { - try { - project.setSessionProperty(TeamPlugin.PROVIDER_PROP_KEY, NOT_MAPPED); - } catch (CoreException e) { - // Just ignore the error as this is just an optimization - } - } + try { + return project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY) == NOT_MAPPED; + } catch (CoreException e) { + return false; + } + } + + private static void markAsUnshared(IProject project) { + try { + project.setSessionProperty(TeamPlugin.PROVIDER_PROP_KEY, NOT_MAPPED); + } catch (CoreException e) { + // Just ignore the error as this is just an optimization + } + } @Override public IProject getProject() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java index 219100a99..62ca83791 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java @@ -233,9 +233,9 @@ public abstract class RepositoryProviderType extends PlatformObject { * or in any way modify workspace resources (including auto-sharing the project). However, * auto-sharing (or other modification) could be performed by a background job scheduled from * this callback. - * - * @since 3.1 - * + * + * @since 3.1 + * * @param project the project that contains the detected meta-files. * @param containers the folders (possibly including the project folder) in which meta-files were found */ diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java index 480c90177..d65e49f24 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java @@ -65,25 +65,25 @@ import org.eclipse.team.internal.core.importing.BundleImporterExtension; */ public final class Team { - private static class StringMappingWrapper implements IFileTypeInfo { + private static class StringMappingWrapper implements IFileTypeInfo { - private final IStringMapping fMapping; + private final IStringMapping fMapping; - public StringMappingWrapper(IStringMapping mapping) { - fMapping= mapping; - } + public StringMappingWrapper(IStringMapping mapping) { + fMapping= mapping; + } - @Override + @Override public String getExtension() { - return fMapping.getString(); - } + return fMapping.getString(); + } - @Override + @Override public int getType() { - return fMapping.getType(); - } + return fMapping.getType(); + } - } + } private static final String PREF_TEAM_IGNORES = "ignore_files"; //$NON-NLS-1$ private static final String PREF_TEAM_SEPARATOR = "\n"; //$NON-NLS-1$ @@ -99,19 +99,19 @@ public final class Team { protected static SortedMap<String, Boolean> globalIgnore, pluginIgnore; private static StringMatcher[] ignoreMatchers; - private final static FileContentManager fFileContentManager; + private final static FileContentManager fFileContentManager; private static List<IBundleImporter> fBundleImporters; - static { - fFileContentManager= new FileContentManager(); - } + static { + fFileContentManager= new FileContentManager(); + } /** - * Return the type of the given IStorage. First, we check whether a mapping has - * been defined for the name of the IStorage. If this is not the case, we check for - * a mapping with the extension. If no mapping is defined, UNKNOWN is returned. + * Return the type of the given IStorage. First, we check whether a mapping has + * been defined for the name of the IStorage. If this is not the case, we check for + * a mapping with the extension. If no mapping is defined, UNKNOWN is returned. * * Valid return values are: * Team.TEXT @@ -120,12 +120,12 @@ public final class Team { * * @param storage the IStorage * @return whether the given IStorage is TEXT, BINARY, or UNKNOWN - * - * @deprecated Use <code>getFileContentManager().getType(IStorage storage)</code> instead. + * + * @deprecated Use <code>getFileContentManager().getType(IStorage storage)</code> instead. */ @Deprecated public static int getType(IStorage storage) { - return fFileContentManager.getType(storage); + return fFileContentManager.getType(storage); } /** @@ -179,19 +179,19 @@ public final class Team { /** - * Return all known file types. + * Return all known file types. * * @return all known file types - * @deprecated Use <code>getFileContentManager().getExtensionMappings()</code> instead. + * @deprecated Use <code>getFileContentManager().getExtensionMappings()</code> instead. */ @Deprecated public static IFileTypeInfo[] getAllTypes() { - final IStringMapping [] mappings= fFileContentManager.getExtensionMappings(); - final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; - for (int i = 0; i < infos.length; i++) { - infos[i]= new StringMappingWrapper(mappings[i]); - } - return infos; + final IStringMapping [] mappings= fFileContentManager.getExtensionMappings(); + final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; + for (int i = 0; i < infos.length; i++) { + infos[i]= new StringMappingWrapper(mappings[i]); + } + return infos; } /** @@ -262,8 +262,8 @@ public final class Team { /** - * Set the file type for the give extensions. This - * will replace the existing file types with this new list. + * Set the file type for the give extensions. This + * will replace the existing file types with this new list. * * Valid types are: * Team.TEXT @@ -272,12 +272,12 @@ public final class Team { * * @param extensions the file extensions * @param types the file types - * - * @deprecated Use <code>getFileContentManager().setExtensionMappings()</code> instead. + * + * @deprecated Use <code>getFileContentManager().setExtensionMappings()</code> instead. */ @Deprecated public static void setAllTypes(String[] extensions, int[] types) { - fFileContentManager.addExtensionMappings(extensions, types); + fFileContentManager.addExtensionMappings(extensions, types); } /** @@ -529,40 +529,40 @@ public final class Team { } /** - * TODO: change to file content manager + * TODO: change to file content manager * Return the default file type bindings * (i.e. those that are specified in * plugin manifests). * @return the default file type bindings * @since 3.0 - * @deprecated Use Team.getFileContentManager().getDefaultExtensionMappings() instead. + * @deprecated Use Team.getFileContentManager().getDefaultExtensionMappings() instead. */ @Deprecated public static IFileTypeInfo[] getDefaultTypes() { - return asFileTypeInfo(getFileContentManager().getDefaultExtensionMappings()); + return asFileTypeInfo(getFileContentManager().getDefaultExtensionMappings()); } - private static IFileTypeInfo [] asFileTypeInfo(IStringMapping [] mappings) { - final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; - for (int i = 0; i < infos.length; i++) { - infos[i]= new StringMappingWrapper(mappings[i]); - } - return infos; - } - - /** - * Get the file content manager which implements the API for manipulating the mappings between - * file names, file extensions and content types. - * - * @return an instance of IFileContentManager - * - * @see IFileContentManager - * - * @since 3.1 - */ - public static IFileContentManager getFileContentManager() { - return fFileContentManager; - } + private static IFileTypeInfo [] asFileTypeInfo(IStringMapping [] mappings) { + final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; + for (int i = 0; i < infos.length; i++) { + infos[i]= new StringMappingWrapper(mappings[i]); + } + return infos; + } + + /** + * Get the file content manager which implements the API for manipulating the mappings between + * file names, file extensions and content types. + * + * @return an instance of IFileContentManager + * + * @see IFileContentManager + * + * @since 3.1 + */ + public static IFileContentManager getFileContentManager() { + return fFileContentManager; + } /** * Creates a storage merger for the given content type. @@ -574,9 +574,9 @@ public final class Team { * * @since 3.4 */ - public static IStorageMerger createMerger(IContentType type) { - return StorageMergerRegistry.getInstance().createStreamMerger(type); - } + public static IStorageMerger createMerger(IContentType type) { + return StorageMergerRegistry.getInstance().createStreamMerger(type); + } /** * Creates a storage merger for the given file extension. @@ -588,9 +588,9 @@ public final class Team { * * @since 3.4 */ - public static IStorageMerger createMerger(String extension) { - return StorageMergerRegistry.getInstance().createStreamMerger(extension); - } + public static IStorageMerger createMerger(String extension) { + return StorageMergerRegistry.getInstance().createStreamMerger(extension); + } /** * Creates a storage merger for the given content type. @@ -602,10 +602,10 @@ public final class Team { * @deprecated Use {@link #createMerger(IContentType)} instead. * @since 3.2 */ - @Deprecated + @Deprecated public IStorageMerger createStorageMerger(IContentType type) { - return createMerger(type); - } + return createMerger(type); + } /** * Creates a storage merger for the given file extension. @@ -617,10 +617,10 @@ public final class Team { * @deprecated Use {@link #createMerger(String)} instead. * @since 3.2 */ - @Deprecated + @Deprecated public IStorageMerger createStorageMerger(String extension) { - return createMerger(extension); - } + return createMerger(extension); + } /** * Returns the available bundle importers. diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java index 1a9cb6870..d97a47cb6 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java @@ -32,10 +32,10 @@ import org.eclipse.team.internal.core.TeamPlugin; */ public class TeamException extends CoreException { - // Field required to avoid compiler warning + // Field required to avoid compiler warning private static final long serialVersionUID = 1L; - // The operation completed successfully. + // The operation completed successfully. public static final int OK = 0; // The operation failed because the resource is not checked-in. diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java index a4bdf84c3..80fcc52ea 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java @@ -102,8 +102,8 @@ public interface IFileRevision { * Returns the branches names of file revision. * * @return an array of ITag's if branch names exist for this revision - * or an empty ITag array if no names exist - * @since 3.6 + * or an empty ITag array if no names exist + * @since 3.6 */ public ITag[] getBranches(); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java index 36a95954f..1180d7bdf 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java @@ -49,7 +49,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule; */ public interface IResourceMappingMerger { - /** + /** * Attempt to automatically merge the mappings of the merge context(<code>MergeContext#getMappings()</code>). * The merge context provides access to the out-of-sync resources (<code>MergeContext#getSyncInfoTree()</code>) * associated with the mappings to be merged. The set of provided mappings @@ -86,48 +86,48 @@ public interface IResourceMappingMerger { * <code>MergeStatus#getConflictingMappings()</code> * @throws CoreException if errors occurred */ - public IStatus merge(IMergeContext mergeContext, - IProgressMonitor monitor) throws CoreException; + public IStatus merge(IMergeContext mergeContext, + IProgressMonitor monitor) throws CoreException; - /** - * Return the scheduling rule that is required to merge - * all the changes that apply to this merger in the given - * context. When calling {@link #merge(IMergeContext, IProgressMonitor)}, - * clients must ensure that they either have obtained - * a rule that covers the rule returned by this method or - * they must not hold any rule. - * @param context the context that contains the changes to be merged - * @return the scheduling rule required by this merger to merge all - * the changes in the given context belonging to the merger's - * model provider. - */ - public ISchedulingRule getMergeRule(IMergeContext context); + /** + * Return the scheduling rule that is required to merge + * all the changes that apply to this merger in the given + * context. When calling {@link #merge(IMergeContext, IProgressMonitor)}, + * clients must ensure that they either have obtained + * a rule that covers the rule returned by this method or + * they must not hold any rule. + * @param context the context that contains the changes to be merged + * @return the scheduling rule required by this merger to merge all + * the changes in the given context belonging to the merger's + * model provider. + */ + public ISchedulingRule getMergeRule(IMergeContext context); - /** - * Validate an auto-merge for the given context. This - * method must be invoked for all mergers involved - * in the merge before the auto-merge is attempted. - * The purpose of the validation is to indicate whether there - * are conditions in the merge context that make an auto-merge - * undesirable. The purpose is not to indicate that conflicts - * exist (this is done by the <code>merge</code> method) but instead - * to indicate that the nature of one of more incoming changes - * is such that performing an auto-merge may be undesirable. - * <p> - * Clients should validate before performing the merge and, if - * any of the returned status are not OK, should prompt the - * user to make them aware of the potential side effects. - * The user may still decide to attempt an auto-merge, in which case - * the client may still invoke the <code>merge</code> method. - * + /** + * Validate an auto-merge for the given context. This + * method must be invoked for all mergers involved + * in the merge before the auto-merge is attempted. + * The purpose of the validation is to indicate whether there + * are conditions in the merge context that make an auto-merge + * undesirable. The purpose is not to indicate that conflicts + * exist (this is done by the <code>merge</code> method) but instead + * to indicate that the nature of one of more incoming changes + * is such that performing an auto-merge may be undesirable. + * <p> + * Clients should validate before performing the merge and, if + * any of the returned status are not OK, should prompt the + * user to make them aware of the potential side effects. + * The user may still decide to attempt an auto-merge, in which case + * the client may still invoke the <code>merge</code> method. + * * @param mergeContext a context that provides access to the resources * involved in the merge. The context must not be * <code>null</code>. * @param monitor a progress monitor - * @return a status indicating any potential side effects of - * performing an auto-merge. - */ - public IStatus validateMerge(IMergeContext mergeContext, - IProgressMonitor monitor); + * @return a status indicating any potential side effects of + * performing an auto-merge. + */ + public IStatus validateMerge(IMergeContext mergeContext, + IProgressMonitor monitor); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java index 5fcbdd1c0..53d3327ab 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java @@ -33,46 +33,46 @@ import org.eclipse.core.runtime.IStatus; */ public interface IStorageMerger { - /** - * Indicates the successful completion of the merge operation (value <code>IStatus.OK</code>) - */ - public static final int OK= IStatus.OK; + /** + * Indicates the successful completion of the merge operation (value <code>IStatus.OK</code>) + */ + public static final int OK= IStatus.OK; - /** - * Indicates that a change conflict prevented the merge from successful completion (value <code>1</code>) - */ - public static final int CONFLICT= 1; + /** + * Indicates that a change conflict prevented the merge from successful completion (value <code>1</code>) + */ + public static final int CONFLICT= 1; - /** - * Status code describing an internal error (value <code>2</code>) - */ - public static final int INTERNAL_ERROR= 2; + /** + * Status code describing an internal error (value <code>2</code>) + */ + public static final int INTERNAL_ERROR= 2; - /** - * Indicates that at least one of the encodings associated with the input was unsupported (value <code>3</code>) - */ - public static final int UNSUPPORTED_ENCODING= 3; + /** + * Indicates that at least one of the encodings associated with the input was unsupported (value <code>3</code>) + */ + public static final int UNSUPPORTED_ENCODING= 3; - /** - * Performs a merge operation on the given storage instances and writes the merge result to the output stream. - * On success a status <code>IStatus.OK</code> is returned, on error a status <code>IStatus.ERROR</code>. - * If the merge operation cannot deal with conflicts, the code of the error status has the value <code>IStreamMerger.CONFLICT</code>. - * For text oriented mergers the encoding for the input and output is honored if they implement - * {@link IEncodedStorage}. - * It is the responsibility of callers to close the output stream. - * <p> - * The provided ancestor may be <code>null</code> if this merger - * returns <code>true</code> from {@link #canMergeWithoutAncestor()}. - * - * @param output the byte stream to which the merge result is written; the merger will not close the stream - * @param outputEncoding the encoding to use when writing to the output stream - * @param ancestor the storage from which the common ancestor is read - * @param target the storage containing the target of the merge - * @param other the storage containing the target of the merge - * @param monitor reports progress of the merge operation - * @return returns the completion status of the operation - * @throws CoreException if an error occurs - */ + /** + * Performs a merge operation on the given storage instances and writes the merge result to the output stream. + * On success a status <code>IStatus.OK</code> is returned, on error a status <code>IStatus.ERROR</code>. + * If the merge operation cannot deal with conflicts, the code of the error status has the value <code>IStreamMerger.CONFLICT</code>. + * For text oriented mergers the encoding for the input and output is honored if they implement + * {@link IEncodedStorage}. + * It is the responsibility of callers to close the output stream. + * <p> + * The provided ancestor may be <code>null</code> if this merger + * returns <code>true</code> from {@link #canMergeWithoutAncestor()}. + * + * @param output the byte stream to which the merge result is written; the merger will not close the stream + * @param outputEncoding the encoding to use when writing to the output stream + * @param ancestor the storage from which the common ancestor is read + * @param target the storage containing the target of the merge + * @param other the storage containing the target of the merge + * @param monitor reports progress of the merge operation + * @return returns the completion status of the operation + * @throws CoreException if an error occurs + */ IStatus merge(OutputStream output, String outputEncoding, IStorage ancestor, IStorage target, IStorage other, IProgressMonitor monitor) throws CoreException; diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java index 37ef3cbcd..b3c994661 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java @@ -61,10 +61,10 @@ public abstract class ResourceMappingMerger implements IResourceMappingMerger { * changes in the context for the model provider of this merger. * By default, return a rule that covers all the projects for the mappings * that belong to the model provider of this merger. - * @param context the context that contains the changes to be merged - * @return the scheduling rule required by this merger to merge all - * the changes in the given context belonging to the merger's - * model provider. + * @param context the context that contains the changes to be merged + * @return the scheduling rule required by this merger to merge all + * the changes in the given context belonging to the merger's + * model provider. * @see org.eclipse.team.core.mapping.IResourceMappingMerger#getMergeRule(org.eclipse.team.core.mapping.IMergeContext) */ @Override diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java index f30286846..5a29fe4ea 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java @@ -79,11 +79,11 @@ public abstract class MergeContext extends SynchronizationContext implements IMe * @param type the type of synchronization (ONE_WAY or TWO_WAY) * @param deltaTree the sync info tree that contains all out-of-sync resources */ - protected MergeContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree deltaTree) { - super(manager, type, deltaTree); - } + protected MergeContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree deltaTree) { + super(manager, type, deltaTree); + } - @Override + @Override public void reject(final IDiff[] diffs, IProgressMonitor monitor) throws CoreException { run(monitor1 -> { for (int i = 0; i < diffs.length; i++) { @@ -91,9 +91,9 @@ public abstract class MergeContext extends SynchronizationContext implements IMe reject(node, monitor1); } }, getMergeRule(diffs), IResource.NONE, monitor); - } + } - @Override + @Override public void markAsMerged(final IDiff[] nodes, final boolean inSyncHint, IProgressMonitor monitor) throws CoreException { run(monitor1 -> { for (int i = 0; i < nodes.length; i++) { @@ -101,9 +101,9 @@ public abstract class MergeContext extends SynchronizationContext implements IMe markAsMerged(node, inSyncHint, monitor1); } }, getMergeRule(nodes), IResource.NONE, monitor); - } + } - @Override + @Override public IStatus merge(final IDiff[] deltas, final boolean force, IProgressMonitor monitor) throws CoreException { final List<IFile> failedFiles = new ArrayList<>(); run(monitor1 -> { @@ -129,7 +129,7 @@ public abstract class MergeContext extends SynchronizationContext implements IMe } else { return new MergeStatus(TeamPlugin.ID, Messages.MergeContext_0, failedFiles.toArray(new IFile[failedFiles.size()])); } - } + } @Override public IStatus merge(IDiff diff, boolean ignoreLocalChanges, IProgressMonitor monitor) throws CoreException { @@ -156,30 +156,30 @@ public abstract class MergeContext extends SynchronizationContext implements IMe } return Status.OK_STATUS; } - if (diff instanceof IThreeWayDiff && !ignoreLocalChanges && getMergeType() == THREE_WAY) { + if (diff instanceof IThreeWayDiff && !ignoreLocalChanges && getMergeType() == THREE_WAY) { IThreeWayDiff twDelta = (IThreeWayDiff) diff; - int direction = twDelta.getDirection(); - if (direction == IThreeWayDiff.OUTGOING) { - // There's nothing to do so return OK - return Status.OK_STATUS; - } - if (direction == IThreeWayDiff.INCOMING) { - // Just copy the stream since there are no conflicts - performReplace(diff, monitor); - return Status.OK_STATUS; - } + int direction = twDelta.getDirection(); + if (direction == IThreeWayDiff.OUTGOING) { + // There's nothing to do so return OK + return Status.OK_STATUS; + } + if (direction == IThreeWayDiff.INCOMING) { + // Just copy the stream since there are no conflicts + performReplace(diff, monitor); + return Status.OK_STATUS; + } // direction == SyncInfo.CONFLICTING - int type = twDelta.getKind(); - if (type == IDiff.REMOVE) { - makeInSync(diff, monitor); - return Status.OK_STATUS; - } + int type = twDelta.getKind(); + if (type == IDiff.REMOVE) { + makeInSync(diff, monitor); + return Status.OK_STATUS; + } // type == SyncInfo.CHANGE IResourceDiff remoteChange = (IResourceDiff)twDelta.getRemoteChange(); IFileRevision remote = null; - if (remoteChange != null) { - remote = remoteChange.getAfterState(); - } + if (remoteChange != null) { + remote = remoteChange.getAfterState(); + } if (remote == null || !getLocalFile(diff).exists()) { // Nothing we can do so return a conflict status // TODO: Should we handle the case where the local and remote have the same contents for a conflicting addition? @@ -187,11 +187,11 @@ public abstract class MergeContext extends SynchronizationContext implements IMe } // We have a conflict, a local, base and remote so we can do // a three-way merge - return performThreeWayMerge(twDelta, monitor); - } else { - performReplace(diff, monitor); - return Status.OK_STATUS; - } + return performThreeWayMerge(twDelta, monitor); + } else { + performReplace(diff, monitor); + return Status.OK_STATUS; + } } @@ -236,70 +236,70 @@ public abstract class MergeContext extends SynchronizationContext implements IMe status = new MergeStatus(status.getPlugin(), status.getMessage(), new IFile[]{file}); } result[0] = status; - } finally { - disposeTempOutputStream(file, os); - } - monitor1.done(); + } finally { + disposeTempOutputStream(file, os); + } + monitor1.done(); }, getMergeRule(diff), IWorkspace.AVOID_UPDATE, monitor); return result[0]; } - private void disposeTempOutputStream(IFile file, OutputStream output) { - if (output instanceof ByteArrayOutputStream) - return; - // We created a temporary file so we need to clean it up - try { - // First make sure the output stream is closed - // so that file deletion will not fail because of that. - if (output != null) - output.close(); - } catch (IOException e) { - // Ignore - } - File tmpFile = getTempFile(file); - if (tmpFile.exists()) - tmpFile.delete(); - } + private void disposeTempOutputStream(IFile file, OutputStream output) { + if (output instanceof ByteArrayOutputStream) + return; + // We created a temporary file so we need to clean it up + try { + // First make sure the output stream is closed + // so that file deletion will not fail because of that. + if (output != null) + output.close(); + } catch (IOException e) { + // Ignore + } + File tmpFile = getTempFile(file); + if (tmpFile.exists()) + tmpFile.delete(); + } - private OutputStream getTempOutputStream(IFile file) throws CoreException { - File tmpFile = getTempFile(file); - if (tmpFile.exists()) - tmpFile.delete(); - File parent = tmpFile.getParentFile(); - if (!parent.exists()) - parent.mkdirs(); - try { - return new BufferedOutputStream(new FileOutputStream(tmpFile)); - } catch (FileNotFoundException e) { - TeamPlugin.log(IStatus.ERROR, NLS.bind("Could not open temporary file {0} for writing: {1}", new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e); //$NON-NLS-1$ - return new ByteArrayOutputStream(); - } - } + private OutputStream getTempOutputStream(IFile file) throws CoreException { + File tmpFile = getTempFile(file); + if (tmpFile.exists()) + tmpFile.delete(); + File parent = tmpFile.getParentFile(); + if (!parent.exists()) + parent.mkdirs(); + try { + return new BufferedOutputStream(new FileOutputStream(tmpFile)); + } catch (FileNotFoundException e) { + TeamPlugin.log(IStatus.ERROR, NLS.bind("Could not open temporary file {0} for writing: {1}", new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e); //$NON-NLS-1$ + return new ByteArrayOutputStream(); + } + } - private InputStream getTempInputStream(IFile file, OutputStream output) throws CoreException { - if (output instanceof ByteArrayOutputStream) { - ByteArrayOutputStream baos = (ByteArrayOutputStream) output; - return new ByteArrayInputStream(baos.toByteArray()); - } - // We created a temporary file so we need to open an input stream on it - try { - // First make sure the output stream is closed - if (output != null) - output.close(); - } catch (IOException e) { - // Ignore - } - File tmpFile = getTempFile(file); - try { - return new BufferedInputStream(new FileInputStream(tmpFile)); - } catch (FileNotFoundException e) { - throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IMergeStatus.INTERNAL_ERROR, NLS.bind(Messages.MergeContext_4, new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e)); - } - } + private InputStream getTempInputStream(IFile file, OutputStream output) throws CoreException { + if (output instanceof ByteArrayOutputStream) { + ByteArrayOutputStream baos = (ByteArrayOutputStream) output; + return new ByteArrayInputStream(baos.toByteArray()); + } + // We created a temporary file so we need to open an input stream on it + try { + // First make sure the output stream is closed + if (output != null) + output.close(); + } catch (IOException e) { + // Ignore + } + File tmpFile = getTempFile(file); + try { + return new BufferedInputStream(new FileInputStream(tmpFile)); + } catch (FileNotFoundException e) { + throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IMergeStatus.INTERNAL_ERROR, NLS.bind(Messages.MergeContext_4, new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e)); + } + } - private File getTempFile(IFile file) { - return TeamPlugin.getPlugin().getStateLocation().append(".tmp").append(file.getName() + ".tmp").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ - } + private File getTempFile(IFile file) { + return TeamPlugin.getPlugin().getStateLocation().append(".tmp").append(file.getName() + ".tmp").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ + } private IFile getLocalFile(IDiff delta) { return ResourcesPlugin.getWorkspace().getRoot().getFile(delta.getPath()); @@ -321,31 +321,31 @@ public abstract class MergeContext extends SynchronizationContext implements IMe * a progress monitor * @throws CoreException */ - protected void performReplace(final IDiff diff, IProgressMonitor monitor) throws CoreException { - IResourceDiff d; - IFile file = getLocalFile(diff); - IFileRevision remote = null; - if (diff instanceof IResourceDiff) { - d = (IResourceDiff) diff; - remote = d.getAfterState(); - } else { - d = (IResourceDiff)((IThreeWayDiff)diff).getRemoteChange(); - if (d != null) - remote = d.getAfterState(); - } - if (d == null) { - d = (IResourceDiff)((IThreeWayDiff)diff).getLocalChange(); - if (d != null) - remote = d.getBeforeState(); - } + protected void performReplace(final IDiff diff, IProgressMonitor monitor) throws CoreException { + IResourceDiff d; + IFile file = getLocalFile(diff); + IFileRevision remote = null; + if (diff instanceof IResourceDiff) { + d = (IResourceDiff) diff; + remote = d.getAfterState(); + } else { + d = (IResourceDiff)((IThreeWayDiff)diff).getRemoteChange(); + if (d != null) + remote = d.getAfterState(); + } + if (d == null) { + d = (IResourceDiff)((IThreeWayDiff)diff).getLocalChange(); + if (d != null) + remote = d.getBeforeState(); + } - // Only perform the replace if a local or remote change was found - if (d != null) { - performReplace(diff, file, remote, monitor); - } + // Only perform the replace if a local or remote change was found + if (d != null) { + performReplace(diff, file, remote, monitor); + } } - /** + /** * Method that is invoked from * {@link #performReplace(IDiff, IProgressMonitor)} after the local has been * changed to match the remote. Subclasses may override @@ -361,7 +361,7 @@ public abstract class MergeContext extends SynchronizationContext implements IMe * a progress monitor * @throws CoreException */ - protected abstract void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException; + protected abstract void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException; private void performReplace(final IDiff diff, final IFile file, final IFileRevision remote, IProgressMonitor monitor) throws CoreException { run(monitor1 -> { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java index cf272544a..675fbd21c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java @@ -34,40 +34,40 @@ import org.eclipse.team.core.mapping.IMergeStatus; */ public class MergeStatus extends Status implements IMergeStatus { - private ResourceMapping[] conflictingMappings; + private ResourceMapping[] conflictingMappings; private IFile[] conflictingFiles; - /** - * Create a merge status for reporting that some of the resource mappings - * for which a merge was attempted were not auto-mergable. - * @param pluginId the plugin id - * @param message the message for the status - * @param conflictingMappings the mappings which were not auto-mergable - */ - public MergeStatus(String pluginId, String message, ResourceMapping[] conflictingMappings) { - super(IStatus.ERROR, pluginId, CONFLICTS, message, null); - this.conflictingMappings = conflictingMappings; - } + /** + * Create a merge status for reporting that some of the resource mappings + * for which a merge was attempted were not auto-mergable. + * @param pluginId the plugin id + * @param message the message for the status + * @param conflictingMappings the mappings which were not auto-mergable + */ + public MergeStatus(String pluginId, String message, ResourceMapping[] conflictingMappings) { + super(IStatus.ERROR, pluginId, CONFLICTS, message, null); + this.conflictingMappings = conflictingMappings; + } - /** - * Create a merge status for reporting that some of the files - * for which a merge was attempted were not auto-mergable. - * @param pluginId the plugin id - * @param message the message for the status - * @param files the files which were not auto-mergable - */ - public MergeStatus(String pluginId, String message, IFile[] files) { - super(IStatus.ERROR, pluginId, CONFLICTS, message, null); - this.conflictingFiles = files; + /** + * Create a merge status for reporting that some of the files + * for which a merge was attempted were not auto-mergable. + * @param pluginId the plugin id + * @param message the message for the status + * @param files the files which were not auto-mergable + */ + public MergeStatus(String pluginId, String message, IFile[] files) { + super(IStatus.ERROR, pluginId, CONFLICTS, message, null); + this.conflictingFiles = files; } - @Override + @Override public ResourceMapping[] getConflictingMappings() { - return conflictingMappings; - } + return conflictingMappings; + } - @Override + @Override public IFile[] getConflictingFiles() { - return conflictingFiles; - } + return conflictingFiles; + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java index 75708813d..89349c548 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java @@ -36,22 +36,22 @@ import org.eclipse.team.internal.core.Policy; */ public abstract class SynchronizationContext extends PlatformObject implements ISynchronizationContext { - private final int type; - private final IResourceDiffTree diffTree; - private Cache cache; + private final int type; + private final IResourceDiffTree diffTree; + private Cache cache; private final ISynchronizationScopeManager manager; - /** - * Create a synchronization context. - * @param manager the manager that defines the scope of the synchronization - * @param type the type of synchronization (ONE_WAY or TWO_WAY) - * @param diffTree the sync info tree that contains all out-of-sync resources - */ - protected SynchronizationContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree diffTree) { - this.manager = manager; + /** + * Create a synchronization context. + * @param manager the manager that defines the scope of the synchronization + * @param type the type of synchronization (ONE_WAY or TWO_WAY) + * @param diffTree the sync info tree that contains all out-of-sync resources + */ + protected SynchronizationContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree diffTree) { + this.manager = manager; this.type = type; this.diffTree = diffTree; - } + } @Override public ISynchronizationScope getScope() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java index 3df0805ad..b1f3d8817 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java @@ -45,126 +45,126 @@ import org.eclipse.team.internal.core.TeamPlugin; */ public class SubscriberResourceMappingContext extends RemoteResourceMappingContext { - private final Subscriber subscriber; + private final Subscriber subscriber; - // Lists used to keep track of resources that have been refreshed - private Set<IResource> shallowRefresh = new HashSet<>(); - private Set<IResource> deepRefresh = new HashSet<>(); - private boolean autoRefresh; + // Lists used to keep track of resources that have been refreshed + private Set<IResource> shallowRefresh = new HashSet<>(); + private Set<IResource> deepRefresh = new HashSet<>(); + private boolean autoRefresh; - /** - * Return a resource mapping context suitable for comparison operations. - * Comparisons require that any out-of-sync resources have contents - * that differ. - * @param subscriber the subscriber - * @return a resource mapping context suitable for compare operations - */ - public static RemoteResourceMappingContext createContext(Subscriber subscriber) { - return new SubscriberResourceMappingContext(subscriber, true); - } + /** + * Return a resource mapping context suitable for comparison operations. + * Comparisons require that any out-of-sync resources have contents + * that differ. + * @param subscriber the subscriber + * @return a resource mapping context suitable for compare operations + */ + public static RemoteResourceMappingContext createContext(Subscriber subscriber) { + return new SubscriberResourceMappingContext(subscriber, true); + } - /** - * Create a resource mapping context for the given subscriber - * @param subscriber the subscriber - * from the local contents - * @param autoRefresh whether the context should auto-refresh when queried - */ - public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh) { - this.subscriber = subscriber; - this.autoRefresh = autoRefresh; - } + /** + * Create a resource mapping context for the given subscriber + * @param subscriber the subscriber + * from the local contents + * @param autoRefresh whether the context should auto-refresh when queried + */ + public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh) { + this.subscriber = subscriber; + this.autoRefresh = autoRefresh; + } - @Override + @Override public final boolean hasRemoteChange(IResource resource, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); ensureRefreshed(resource, IResource.DEPTH_ONE, NONE, monitor); SyncInfo syncInfo = subscriber.getSyncInfo(resource); validateRemote(resource, syncInfo); - if (syncInfo == null) return false; - int direction = SyncInfo.getDirection(syncInfo.getKind()); + if (syncInfo == null) return false; + int direction = SyncInfo.getDirection(syncInfo.getKind()); return direction == SyncInfo.INCOMING || direction == SyncInfo.CONFLICTING; } finally { monitor.done(); } - } + } - @Override + @Override public boolean hasLocalChange(IResource resource, IProgressMonitor monitor) throws CoreException { - SyncInfo syncInfo = subscriber.getSyncInfo(resource); - if (syncInfo == null) return false; - int direction = SyncInfo.getDirection(syncInfo.getKind()); + SyncInfo syncInfo = subscriber.getSyncInfo(resource); + if (syncInfo == null) return false; + int direction = SyncInfo.getDirection(syncInfo.getKind()); return direction == SyncInfo.OUTGOING || direction == SyncInfo.CONFLICTING; - } + } - @Override + @Override public final IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); - ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); - SyncInfo syncInfo = subscriber.getSyncInfo(file); - IResourceVariant remote = validateRemote(file, syncInfo); - if (remote == null) { - return null; - } - return remote.getStorage(Policy.subMonitorFor(monitor, 90)); + ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); + SyncInfo syncInfo = subscriber.getSyncInfo(file); + IResourceVariant remote = validateRemote(file, syncInfo); + if (remote == null) { + return null; + } + return remote.getStorage(Policy.subMonitorFor(monitor, 90)); } finally { monitor.done(); } - } + } - @Override + @Override public final IStorage fetchBaseContents(IFile file, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); - ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); - SyncInfo syncInfo = subscriber.getSyncInfo(file); - IResourceVariant base = validateBase(file, syncInfo); - if (base == null) { - return null; - } - return base.getStorage(Policy.subMonitorFor(monitor, 90)); + ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); + SyncInfo syncInfo = subscriber.getSyncInfo(file); + IResourceVariant base = validateBase(file, syncInfo); + if (base == null) { + return null; + } + return base.getStorage(Policy.subMonitorFor(monitor, 90)); } finally { monitor.done(); } - } + } - @Override + @Override public final IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); - ensureRefreshed(container, IResource.DEPTH_ONE, NONE, Policy.subMonitorFor(monitor, 100)); - SyncInfo syncInfo = subscriber.getSyncInfo(container); - if (validateRemote(container, syncInfo) == null) { - // There is no remote so return an empty array - return new IResource[0]; - } - return subscriber.members(container); + ensureRefreshed(container, IResource.DEPTH_ONE, NONE, Policy.subMonitorFor(monitor, 100)); + SyncInfo syncInfo = subscriber.getSyncInfo(container); + if (validateRemote(container, syncInfo) == null) { + // There is no remote so return an empty array + return new IResource[0]; + } + return subscriber.members(container); } finally { monitor.done(); } - } + } - @Override + @Override public final void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException { - subscriber.refresh(traversals, monitor); - for (int i = 0; i < traversals.length; i++) { + subscriber.refresh(traversals, monitor); + for (int i = 0; i < traversals.length; i++) { ResourceTraversal traversal = traversals[i]; refreshed(traversal.getResources(), traversal.getDepth()); } - } + } - /** - * Refresh the subscriber and cache the fact that the resources were refreshed by - * calling the <code>refreshed</code> method. The default implementation only refreshes - * the state and does not fetch contents in the <code>FILE_CONTENTS_REQUIRED</code> - * flag is passed. It is up to subclass to handle this. - * @param resources the resources to be refreshed - * @param depth the depth of the refresh - * @param flags the flags that indicate extra state that should be fetched - * @param monitor a progress monitor - * @throws TeamException - */ + /** + * Refresh the subscriber and cache the fact that the resources were refreshed by + * calling the <code>refreshed</code> method. The default implementation only refreshes + * the state and does not fetch contents in the <code>FILE_CONTENTS_REQUIRED</code> + * flag is passed. It is up to subclass to handle this. + * @param resources the resources to be refreshed + * @param depth the depth of the refresh + * @param flags the flags that indicate extra state that should be fetched + * @param monitor a progress monitor + * @throws TeamException + */ protected void refresh(IResource[] resources, int depth, int flags, IProgressMonitor monitor) throws TeamException { subscriber.refresh(resources, depth, monitor); refreshed(resources, depth); @@ -189,32 +189,32 @@ public class SubscriberResourceMappingContext extends RemoteResourceMappingConte } } - /* - * Ensure that the given resource has been refreshed to the specified depth - * since the context has been created. - */ - private void ensureRefreshed(IResource resource, int depth, int flags, IProgressMonitor monitor) throws TeamException { - if (autoRefresh) { - if (depth == IResource.DEPTH_INFINITE) { - // If the resource or a parent was refreshed deeply, no need to do it again - if (wasRefreshedDeeply(resource)) - return; - // if the resource is a file, a shallow refresh is enough - if (resource.getType() == IResource.FILE && wasRefreshedShallow(resource)) - return; - } else { - if (wasRefreshedShallow(resource)) - return; - } - refresh(new IResource[] { resource }, depth, flags, monitor); - } + /* + * Ensure that the given resource has been refreshed to the specified depth + * since the context has been created. + */ + private void ensureRefreshed(IResource resource, int depth, int flags, IProgressMonitor monitor) throws TeamException { + if (autoRefresh) { + if (depth == IResource.DEPTH_INFINITE) { + // If the resource or a parent was refreshed deeply, no need to do it again + if (wasRefreshedDeeply(resource)) + return; + // if the resource is a file, a shallow refresh is enough + if (resource.getType() == IResource.FILE && wasRefreshedShallow(resource)) + return; + } else { + if (wasRefreshedShallow(resource)) + return; + } + refresh(new IResource[] { resource }, depth, flags, monitor); + } } - /* - * Look for a shallow refresh of the resource. If not there, - * look fir a deep refresh of a parent or a shallow refresh of the - * direct parent if the resource is a file. - */ + /* + * Look for a shallow refresh of the resource. If not there, + * look fir a deep refresh of a parent or a shallow refresh of the + * direct parent if the resource is a file. + */ private boolean wasRefreshedShallow(IResource resource) { if (shallowRefresh.contains(resource)) return true; @@ -240,45 +240,45 @@ public class SubscriberResourceMappingContext extends RemoteResourceMappingConte * Validate that the remote resource is of the proper type and return the * remote resource if it is OK. A return of null indicates that there is no remote. */ - private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo) throws CoreException { - if (syncInfo == null) return null; - IResourceVariant remote = syncInfo.getRemote(); - if (remote == null) return null; - return validateRemote(resource, remote); - } + private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo) throws CoreException { + if (syncInfo == null) return null; + IResourceVariant remote = syncInfo.getRemote(); + if (remote == null) return null; + return validateRemote(resource, remote); + } private IResourceVariant validateRemote(IResource resource, IResourceVariant remote) throws CoreException { boolean containerExpected = resource.getType() != IResource.FILE; - if (remote.isContainer() && !containerExpected) { - throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_0 + resource.getFullPath().toString(), null)); - } else if (!remote.isContainer() && containerExpected) { - throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_1 + resource.getFullPath().toString(), null)); - } - return remote; + if (remote.isContainer() && !containerExpected) { + throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_0 + resource.getFullPath().toString(), null)); + } else if (!remote.isContainer() && containerExpected) { + throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_1 + resource.getFullPath().toString(), null)); + } + return remote; } /* * Validate that the base resource is of the proper type and return the * base resource if it is OK. A return of null indicates that there is no base. */ - private IResourceVariant validateBase(IResource resource, SyncInfo syncInfo) throws CoreException { - if (syncInfo == null) return null; - IResourceVariant base = syncInfo.getBase(); - if (base == null) return null; - return validateRemote(resource, base); - } + private IResourceVariant validateBase(IResource resource, SyncInfo syncInfo) throws CoreException { + if (syncInfo == null) return null; + IResourceVariant base = syncInfo.getBase(); + if (base == null) return null; + return validateRemote(resource, base); + } - /** - * Set whether the context should refresh the state of resources - * when their state is requested. The context keeps track of what - * resources were refreshed and only auto-refreshes a resource - * once. - * @param autoRefresh whether the context should refresh the state of resources - * when their state is requested - */ - public void setAutoRefresh(boolean autoRefresh) { - this.autoRefresh = autoRefresh; - } + /** + * Set whether the context should refresh the state of resources + * when their state is requested. The context keeps track of what + * resources were refreshed and only auto-refreshes a resource + * once. + * @param autoRefresh whether the context should refresh the state of resources + * when their state is requested + */ + public void setAutoRefresh(boolean autoRefresh) { + this.autoRefresh = autoRefresh; + } @Override public boolean isThreeWay() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java index 91103b8c6..5e5ae3c40 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java @@ -148,20 +148,20 @@ public class SyncInfo implements IAdaptable { /*==================================================================== * Members: *====================================================================*/ - private IResource local; - private IResourceVariant base; - private IResourceVariant remote; - private IResourceVariantComparator comparator; - - private int syncKind; - - /** - * Construct a sync info object. - * @param local the local resource. Must be non-null but may not exist. - * @param base the base resource variant or <code>null</code> - * @param remote the remote resource variant or <code>null</code> - * @param comparator the comparator used to determine if resources differ - */ + private IResource local; + private IResourceVariant base; + private IResourceVariant remote; + private IResourceVariantComparator comparator; + + private int syncKind; + + /** + * Construct a sync info object. + * @param local the local resource. Must be non-null but may not exist. + * @param base the base resource variant or <code>null</code> + * @param remote the remote resource variant or <code>null</code> + * @param comparator the comparator used to determine if resources differ + */ public SyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator) { Assert.isNotNull(local); Assert.isNotNull(comparator); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java index cd6b35f63..beb723704 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java @@ -667,14 +667,14 @@ public class SyncInfoSet { return errors.values().toArray(new ITeamStatus[errors.size()]); } - /** - * Return an iterator over all <code>SyncInfo</code> - * contained in this set. - * @return an iterator over all <code>SyncInfo</code> - * contained in this set. - * @since 3.1 - */ - public Iterator iterator() { - return resources.values().iterator(); - } + /** + * Return an iterator over all <code>SyncInfo</code> + * contained in this set. + * @return an iterator over all <code>SyncInfo</code> + * contained in this set. + * @since 3.1 + */ + public Iterator iterator() { + return resources.values().iterator(); + } } |