ICElement
the methods of this class returns a
- * list of the lightweight objects TypeInfo
.
- * - * AllTypesCache runs asynchronously using a background job to rebuild the cache - * as needed. If the cache becomes dirty again while the background job is - * running, the job is restarted. - *
- * If getTypes
is called in response to a user action, a progress
- * dialog is shown. If called before the background job has finished, getTypes
- * waits for the completion of the background job.
- */
-public class AllTypesCache {
-
- private static final int INITIAL_DELAY = 5000;
- private static IWorkingCopyProvider fgWorkingCopyProvider;
- private static TypeHierarchyBuilder fgTypeHierarchyBuilder;
- private static IElementChangedListener fgElementChangedListener;
- private static IPropertyChangeListener fgPropertyChangeListener;
- static boolean fgEnableIndexing = true;
-
- /** Preference key for enabling background cache */
- public final static String ENABLE_BACKGROUND_TYPE_CACHE = "enableBackgroundTypeCache"; //$NON-NLS-1$
-
- /**
- * Initializes the AllTypesCache service.
- *
- * @param provider A working copy provider.
- */
- public static void initialize(IWorkingCopyProvider workingCopyProvider) {
- fgWorkingCopyProvider = workingCopyProvider;
- TypeCacheManager.getInstance().setWorkingCopyProvider(fgWorkingCopyProvider);
- fgTypeHierarchyBuilder = new TypeHierarchyBuilder();
-
- // load prefs
-// Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
-// if (prefs.contains(ENABLE_BACKGROUND_TYPE_CACHE)) {
-// fgEnableIndexing = prefs.getBoolean(ENABLE_BACKGROUND_TYPE_CACHE);
-// } else {
-// prefs.setDefault(ENABLE_BACKGROUND_TYPE_CACHE, false);
-// prefs.setValue(ENABLE_BACKGROUND_TYPE_CACHE, false);
-// CCorePlugin.getDefault().savePluginPreferences();
-// fgEnableIndexing = true;
-// }
- fgEnableIndexing = false;
-
- // start jobs in background after INITIAL_DELAY
- TypeCacheManager.getInstance().reconcile(fgEnableIndexing, Job.BUILD, INITIAL_DELAY);
-
- // add delta listener
- fgElementChangedListener = new IElementChangedListener() {
- public void elementChanged(ElementChangedEvent event) {
- TypeCacheManager.getInstance().processElementChanged(event, fgEnableIndexing);
- }
- };
- CoreModel.getDefault().addElementChangedListener(fgElementChangedListener);
-
-// // add property change listener
-// fgPropertyChangeListener = new IPropertyChangeListener() {
-// public void propertyChange(PropertyChangeEvent event) {
-// String property = event.getProperty();
-// if (property.equals(ENABLE_BACKGROUND_TYPE_CACHE)) {
-// String value = (String) event.getNewValue();
-// fgEnableIndexing = Boolean.valueOf(value).booleanValue();
-// if (!fgEnableIndexing) {
-// TypeCacheManager.getInstance().cancelJobs();
-// } else {
-// TypeCacheManager.getInstance().reconcile(fgEnableIndexing, Job.BUILD, 0);
-// }
-// }
-// }
-// };
-// prefs.addPropertyChangeListener(fgPropertyChangeListener);
- }
-
- /**
- * Terminates the service provided by AllTypesCache.
- */
- public static void terminate() {
- // remove delta listener
- if (fgElementChangedListener != null)
- CoreModel.getDefault().removeElementChangedListener(fgElementChangedListener);
-
- // remove property change listener
- if (fgPropertyChangeListener != null)
- CCorePlugin.getDefault().getPluginPreferences().removePropertyChangeListener(fgPropertyChangeListener);
-
- // terminate all running jobs
- if (TypeCacheManager.getInstance() != null) {
- TypeCacheManager.getInstance().cancelJobs();
- }
- }
-
- /**
- * Returns all types in the workspace.
- */
- public static ITypeInfo[] getAllTypes() {
- final Collection fAllTypes = new ArrayList();
- TypeSearchScope workspaceScope = new TypeSearchScope(true);
- IProject[] projects = workspaceScope.getEnclosingProjects();
- ITypeInfoVisitor visitor = new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo info) {
- fAllTypes.add(info);
- return true;
- }
- public boolean shouldContinue() { return true; }
- };
- for (int i = 0; i < projects.length; ++i) {
- TypeCacheManager.getInstance().getCache(projects[i]).accept(visitor);
- }
- return (ITypeInfo[]) fAllTypes.toArray(new ITypeInfo[fAllTypes.size()]);
- }
-
- /**
- * Returns all types in the given scope.
- *
- * @param scope The search scope
- * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS,
- * C_UNION, C_ENUMERATION, C_TYPEDEF
- */
- public static ITypeInfo[] getTypes(ITypeSearchScope scope, int[] kinds) {
- final Collection fTypesFound = new ArrayList();
- final ITypeSearchScope fScope = scope;
- final int[] fKinds = kinds;
- IProject[] projects = scope.getEnclosingProjects();
- ITypeInfoVisitor visitor = new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo info) {
- if (ArrayUtil.contains(fKinds, info.getCElementType())
- && (fScope != null && info.isEnclosed(fScope))) {
- fTypesFound.add(info);
- }
- return true;
- }
- public boolean shouldContinue() { return true; }
- };
- for (int i = 0; i < projects.length; ++i) {
- TypeCacheManager.getInstance().getCache(projects[i]).accept(visitor);
- }
- return (ITypeInfo[]) fTypesFound.toArray(new ITypeInfo[fTypesFound.size()]);
- }
-
- /**
- * Returns all types matching name in the given scope.
- *
- * @param scope The search scope
- * @param qualifiedName The qualified type name
- * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS,
- * C_UNION, C_ENUMERATION, C_TYPEDEF
- * @param matchEnclosed true
if enclosed types count as matches (foo::bar == bar)
- */
- public static ITypeInfo[] getTypes(ITypeSearchScope scope, IQualifiedTypeName qualifiedName, int[] kinds, boolean matchEnclosed) {
- final Collection fTypesFound = new ArrayList();
- final ITypeSearchScope fScope = scope;
- final int[] fKinds = kinds;
- final IQualifiedTypeName fQualifiedName = qualifiedName;
- final boolean fMatchEnclosed = matchEnclosed;
- IProject[] projects = scope.getEnclosingProjects();
- ITypeInfoVisitor visitor = new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo info) {
- if (ArrayUtil.contains(fKinds, info.getCElementType())
- && (fScope != null && info.isEnclosed(fScope))) {
- IQualifiedTypeName currName = info.getQualifiedTypeName();
- if (fMatchEnclosed && currName.segmentCount() > fQualifiedName.segmentCount()
- && currName.lastSegment().equals(fQualifiedName.lastSegment())) {
- currName = currName.removeFirstSegments(currName.segmentCount() - fQualifiedName.segmentCount());
- }
- if (currName.equals(fQualifiedName)) {
- fTypesFound.add(info);
- }
- }
- return true;
- }
- public boolean shouldContinue() { return true; }
- };
- for (int i = 0; i < projects.length; ++i) {
- TypeCacheManager.getInstance().getCache(projects[i]).accept(visitor);
- }
- return (ITypeInfo[]) fTypesFound.toArray(new ITypeInfo[fTypesFound.size()]);
- }
-
- /**
- * Returns all namespaces in the given scope.
- *
- * @param scope The search scope
- * @param includeGlobalNamespace true
if the global (default) namespace should be returned
- */
- public static ITypeInfo[] getNamespaces(ITypeSearchScope scope, boolean includeGlobalNamespace) {
- final Collection fTypesFound = new ArrayList();
- final ITypeSearchScope fScope = scope;
- IProject[] projects = scope.getEnclosingProjects();
- ITypeInfoVisitor visitor = new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo info) {
- if (info.getCElementType() == ICElement.C_NAMESPACE
- && (fScope != null && info.isEnclosed(fScope))) {
- fTypesFound.add(info);
- }
- return true;
- }
- public boolean shouldContinue() { return true; }
- };
- for (int i = 0; i < projects.length; ++i) {
- ITypeCache cache = TypeCacheManager.getInstance().getCache(projects[i]);
- cache.accept(visitor);
- if (includeGlobalNamespace) {
- fTypesFound.add(cache.getGlobalNamespace());
- }
- }
- return (ITypeInfo[]) fTypesFound.toArray(new ITypeInfo[fTypesFound.size()]);
- }
-
- /**
- * Returns the global (default) namespace for the given project.
- *
- * @param project the project
- */
- public static ITypeInfo getGlobalNamespace(IProject project) {
- ITypeCache cache = TypeCacheManager.getInstance().getCache(project);
- return cache.getGlobalNamespace();
- }
-
- /**
- * Returns true if the type cache is up to date.
- */
- public static boolean isCacheUpToDate(ITypeSearchScope scope) {
- forceDeltaComplete();
-
- IProject[] projects = scope.getEnclosingProjects();
- for (int i = 0; i < projects.length; ++i) {
- IProject project = projects[i];
- if (project.exists() && project.isOpen()) {
- if (!TypeCacheManager.getInstance().getCache(project).isUpToDate())
- return false;
- }
- }
- return true;
- }
-
- private static void forceDeltaComplete() {
- if (fgWorkingCopyProvider != null) {
- IWorkingCopy[] workingCopies = fgWorkingCopyProvider.getWorkingCopies();
- for (int i = 0; i < workingCopies.length; ++i) {
- IWorkingCopy wc = workingCopies[i];
- try {
- synchronized (wc) {
- wc.reconcile();
- }
- } catch (CModelException ex) {
- }
- }
- }
- }
-
- /**
- * Updates the type cache.
- *
- * @param monitor the progress monitor
- */
- public static void updateCache(ITypeSearchScope scope, IProgressMonitor monitor) {
- TypeCacheManager.getInstance().updateCache(scope, monitor);
- }
-
- /**
- * Resolves a type location.
- *
- * @param info the type to search for
- * @param monitor the progress monitor
- */
- public static ITypeReference resolveTypeLocation(ITypeInfo info, IProgressMonitor monitor) {
- return TypeCacheManager.getInstance().resolveTypeLocation(info, monitor, fgEnableIndexing);
- }
-
- /** Returns first type in the cache which matches the given
- * type and name. If no type is found, null
- * is returned.
- *
- * @param project the enclosing project
- * @param type the ICElement type
- * @param qualifiedName the qualified type name to match
- * @return the matching type
- */
- public static ITypeInfo getType(IProject project, int type, IQualifiedTypeName qualifiedName) {
- ITypeCache cache = TypeCacheManager.getInstance().getCache(project);
- return cache.getType(type, qualifiedName);
- }
-
- /**
- * Returns all types matching name in the given project.
- *
- * @param project the enclosing project
- * @param qualifiedName The qualified type name
- * @param matchEnclosed true
if enclosed types count as matches (foo::bar == bar)
- * @param ignoreCase true
if case-insensitive
- * @return Array of types
- */
- public static ITypeInfo[] getTypes(IProject project, IQualifiedTypeName qualifiedName, boolean matchEnclosed, boolean ignoreCase) {
- ITypeCache cache = TypeCacheManager.getInstance().getCache(project);
- return cache.getTypes(qualifiedName, matchEnclosed, ignoreCase);
- }
-
- /**
- * Creates and returns a type hierarchy for this type containing
- * this type and all of its supertypes and subtypes in the workspace.
- *
- * @param info the given type
- * @param monitor the given progress monitor
- * @return a type hierarchy for the given type
- */
- public static ITypeHierarchy createTypeHierarchy(ICElement type, IProgressMonitor monitor) throws CModelException {
- ITypeInfo info = TypeCacheManager.getInstance().getTypeForElement(type, true, true, fgEnableIndexing, monitor);
- if (info != null)
- return fgTypeHierarchyBuilder.createTypeHierarchy(info, fgEnableIndexing, monitor);
- return null;
- }
-
- public static void addTypeCacheChangedListener(ITypeCacheChangedListener listener) {
- TypeCacheManager.getInstance().addTypeCacheChangedListener(listener);
- }
-
- public static void removeTypeCacheChangedListener(ITypeCacheChangedListener listener) {
- TypeCacheManager.getInstance().removeTypeCacheChangedListener(listener);
- }
-
- public static ITypeInfo getTypeForElement(ICElement element, boolean forceUpdate, boolean forceResolve, IProgressMonitor monitor) {
- return TypeCacheManager.getInstance().getTypeForElement(element, forceUpdate, forceResolve, fgEnableIndexing, monitor);
- }
-
- public static ICElement getElementForType(ITypeInfo type, boolean forceUpdate, boolean forceResolve, IProgressMonitor monitor) {
- return TypeCacheManager.getInstance().getElementForType(type, forceUpdate, forceResolve, fgEnableIndexing, monitor);
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeCacheChangedListener.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeCacheChangedListener.java
deleted file mode 100644
index a7e7bce5d19..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeCacheChangedListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-import org.eclipse.core.resources.IProject;
-
-
-/**
- * A listener which gets notified when the type cache changes.
- *
- * This interface may be implemented by clients. - *
- */ -public interface ITypeCacheChangedListener { - - /** - * Notifies that the type cache for the given project has changed in some way - * and should be refreshed at some point to make it consistent with the current - * state of the C model. - * - * @param project the given project - */ - void typeCacheChanged(IProject project); -} diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeInfo.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeInfo.java deleted file mode 100644 index b985dbf27f6..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeInfo.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.browser; - -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; -import org.eclipse.cdt.internal.core.browser.cache.ITypeCache; -import org.eclipse.core.resources.IProject; - -/** - * Type information. - */ -public interface ITypeInfo extends Comparable { - - public static final int KNOWN_TYPES[] = { - ICElement.C_NAMESPACE, - ICElement.C_CLASS, - ICElement.C_STRUCT, - ICElement.C_UNION, - ICElement.C_ENUMERATION, - ICElement.C_TYPEDEF - }; - - /** - * Gets the CElement type. - * @return ICElement.C_NAMESPACE, C_CLASS, C_STRUCT, C_UNION, C_ENUMERATION, or C_TYPEDEF, - * or zero if unknown type. - */ - public int getCElementType(); - - /** - * Sets the CElement type. - */ - public void setCElementType(int type); - - /** - * Gets the type name. - */ - public String getName(); - - /** - * Gets the qualified type name. - */ - public IQualifiedTypeName getQualifiedTypeName(); - - /** - * Returns true if the type exists. - */ - public boolean exists(); - - /** - * Returns true if the element type is unknown. - */ - public boolean isUndefinedType(); - - /** - * Returns true if this type is enclosed by other types, - * i.e. declared an inside another namespace or class. - */ - public boolean isEnclosedType(); - - /** Gets the enclosing type, i.e. the outer class or namespace which contains this type. - * @return the enclosing type, ornull
if not found.
- */
- public ITypeInfo getEnclosingType();
-
- /** Gets the enclosing namespace for this type.
- * @return the enclosing namespace, or null
if none exists.
- */
- public ITypeInfo getEnclosingNamespace(boolean includeGlobalNamespace);
-
- /** Gets the first enclosing type which matches one of the given kinds.
- * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS, C_STRUCT
- * @return the enclosing type, or null
if not found.
- */
- public ITypeInfo getEnclosingType(int[] kinds);
-
- /** Gets the root namespace, i.e. the outermost namespace
- * which contains this type.
- * @param includeGlobalNamespace true
if the global (default) namespace should be returned
- * @return the namespace, or null
if not found.
- */
- public ITypeInfo getRootNamespace(boolean includeGlobalNamespace);
-
- /**
- * Returns true if this type is capable of enclosing other types,
- * i.e. it is a namespace, class, or struct.
- */
- public boolean isEnclosingType();
-
- /**
- * Returns true if this type encloses other types, i.e. contains
- * inner classes or namespaces.
- */
- public boolean hasEnclosedTypes();
-
- /**
- * Returns true if this type encloses the given type.
- */
- public boolean encloses(ITypeInfo info);
-
- /**
- * Returns true if this type is enclosed by the given type.
- */
- public boolean isEnclosed(ITypeInfo info);
-
- /** Gets the enclosed types, i.e. inner classes or classes inside this namespace.
- * @return array of inner types, or empty array if not found.
- */
- public ITypeInfo[] getEnclosedTypes();
-
- /** Gets the enclosed types, i.e. inner classes or classes inside this namespace.
- * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS, C_STRUCT,
- * C_UNION, C_ENUMERATION, C_TYPEDEF
- * @return array of inner types, or empty array if not found.
- */
- public ITypeInfo[] getEnclosedTypes(int kinds[]);
-
- /**
- * Gets the enclosing project.
- */
- public IProject getEnclosingProject();
-
- /**
- * Returns true if type is enclosed in the given scope.
- */
- public boolean isEnclosed(ITypeSearchScope scope);
-
- /**
- * Adds a source reference.
- */
- public void addReference(ITypeReference location);
-
- /** Gets the originating locations where this type was declared.
- * @return all known source references, or an empty
- * array if none found.
- */
- public ITypeReference[] getReferences();
-
- /** Gets the real location where type was declared.
- * @return the parsed source reference (with offset and length),
- * or null
if not found.
- */
- public ITypeReference getResolvedReference();
-
- /**
- * Returns true if the type can be substituted.
- */
- public boolean canSubstituteFor(ITypeInfo info);
-
- public ITypeCache getCache();
- public void setCache(ITypeCache typeCache);
-
- /**
- * Returns true if other types extend this type.
- */
- public boolean hasSubTypes();
-
- /** Gets all types which extend this type.
- * @return array of types, or null
if none found.
- */
- public ITypeInfo[] getSubTypes();
-
- /**
- * Returns true if this type has base classes.
- */
- public boolean hasSuperTypes();
-
- /** Gets the base classes.
- * @return array of types, or null
if none found.
- */
- public ITypeInfo[] getSuperTypes();
-
- /**
- * Gets the base class access visibility (PRIVATE, PROTECTED, PUBLIC)
- */
- public ASTAccessVisibility getSuperTypeAccess(ITypeInfo subType);
-
- /**
- * Adds a derived class reference, i.e. this type is used as
- * a base class at the given location.
- */
- public void addDerivedReference(ITypeReference location);
-
- /** Gets the originating locations where this type was
- * used as a base class.
- * @return all known source references, or an empty
- * array if none found.
- */
- public ITypeReference[] getDerivedReferences();
-
- /**
- * Returns true if the type is a class or struct.
- */
- public boolean isClass();
-
- /**
- * Returns true if type is referenced in the given scope.
- */
- public boolean isReferenced(ITypeSearchScope scope);
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeInfoVisitor.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeInfoVisitor.java
deleted file mode 100644
index 38dcbe93abe..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeInfoVisitor.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-public interface ITypeInfoVisitor {
-
- public boolean visit(ITypeInfo info);
-
- public boolean shouldContinue();
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java
deleted file mode 100644
index 90d29c4283f..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-
-public interface ITypeReference {
-
- /**
- * Returns the full, absolute path of this reference
- * relative to the workspace, or null if no path can be
- * determined.
- */
- public IPath getPath();
-
- /**
- * Returns the absolute path in the local file system
- * to this reference, or null if no path can be
- * determined.
- */
- public IPath getLocation();
-
- /**
- * Returns the resource.
- */
- public IResource getResource();
-
- /**
- * Returns the working copy.
- */
- public IWorkingCopy getWorkingCopy();
-
- /**
- * Returns the project.
- */
- public IProject getProject();
-
- /**
- * Returns the offset.
- */
- public int getOffset();
-
- /**
- * Returns the length.
- */
- public int getLength();
-
- /**
- * Returns the CElements located at the stored offset and length,
- * or null
if not found.
- */
- public ICElement[] getCElements();
-
- /**
- * Returns a translation unit for this location.
- */
- public ITranslationUnit getTranslationUnit();
-
- /** Gets the path for this location, relative to one of
- * the given project's include paths.
- *
- * @param project the project to use as a reference.
- * @return The path to this location, relative to the longest
- * matching include path in the given project.
- */
- public IPath getRelativeIncludePath(IProject project);
-
- /** Gets the path for this location, relative to the
- * given path.
- *
- * @param relativeToPath the path to use as a reference.
- * @return The path to this location, relative to the
- * given path.
- */
- public IPath getRelativePath(IPath relativeToPath);
-
- boolean isLineNumber();
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeSearchScope.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeSearchScope.java
deleted file mode 100644
index 269d3c9a8f5..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeSearchScope.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-import java.util.Collection;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-public interface ITypeSearchScope {
-
- public boolean isPathScope();
- public boolean isProjectScope();
- public boolean isWorkspaceScope();
- public boolean isEmpty();
-
- public boolean encloses(ITypeSearchScope scope);
- public boolean encloses(IProject project);
- public boolean encloses(IPath path);
- public boolean encloses(String path);
- public boolean encloses(ICElement element);
- public boolean encloses(IWorkingCopy workingCopy);
-
- public void add(IWorkingCopy workingCopy);
- public void add(IPath path, boolean addSubfolders, IProject enclosingProject);
- public void add(IProject project);
- public void add(ICElement elem);
- public void add(ITypeSearchScope scope);
- public void addWorkspace();
- public void clear();
- public IProject[] getEnclosingProjects();
-
- public Collection pathSet();
- public Collection containerSet();
- public Collection projectSet();
- public Collection enclosingProjectSet();
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeInfo.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeInfo.java
deleted file mode 100644
index 9a10b78da9d..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeInfo.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.internal.core.browser.cache.ITypeCache;
-import org.eclipse.cdt.internal.core.browser.util.ArrayUtil;
-import org.eclipse.core.resources.IProject;
-
-public class TypeInfo implements ITypeInfo
-{
- protected ITypeCache fTypeCache;
- protected int fElementType;
- protected IQualifiedTypeName fQualifiedName;
- protected ITypeReference[] fSourceRefs = null;
- protected int fSourceRefsCount = 0;
- protected ITypeReference[] fDerivedSourceRefs = null;
- protected int fDerivedSourceRefsCount = 0;
-
- protected final static int INITIAL_REFS_SIZE = 1;
- protected final static int REFS_GROW_BY = 2;
- protected final static ITypeInfo[] EMPTY_TYPES = new ITypeInfo[0];
-
- public TypeInfo(int elementType, IQualifiedTypeName typeName) {
- fElementType = elementType;
- fQualifiedName = typeName;
- }
-
- public void addReference(ITypeReference location) {
- if (fSourceRefs == null) {
- fSourceRefs = new ITypeReference[INITIAL_REFS_SIZE];
- fSourceRefsCount = 0;
- } else if (fSourceRefsCount == fSourceRefs.length) {
- ITypeReference[] refs = new ITypeReference[fSourceRefs.length + REFS_GROW_BY];
- System.arraycopy(fSourceRefs, 0, refs, 0, fSourceRefsCount);
- fSourceRefs = refs;
- }
- fSourceRefs[fSourceRefsCount] = location;
- ++fSourceRefsCount;
- }
-
- public ITypeReference[] getReferences() {
- if (fSourceRefs != null) {
- ITypeReference[] refs = new ITypeReference[fSourceRefsCount];
- System.arraycopy(fSourceRefs, 0, refs, 0, fSourceRefsCount);
- return refs;
- }
- return null;
- }
-
- public ITypeReference getResolvedReference() {
- for (int i = 0; i < fSourceRefsCount; ++i) {
- ITypeReference location = fSourceRefs[i];
- if (location.isLineNumber() )
- return location;
- if( location.getLength() != 0) {
- return location;
- }
- }
- return null;
- }
-
- public boolean isReferenced() {
- return (fSourceRefs != null || fDerivedSourceRefs != null);
- }
-
- public boolean isReferenced(ITypeSearchScope scope) {
- if (scope == null || scope.isWorkspaceScope())
- return true;
-
- // check if path is in scope
- for (int i = 0; i < fSourceRefsCount; ++i) {
- ITypeReference location = fSourceRefs[i];
- if (scope.encloses(location.getPath()))
- return true;
- }
- for (int i = 0; i < fDerivedSourceRefsCount; ++i) {
- ITypeReference location = fDerivedSourceRefs[i];
- if (scope.encloses(location.getPath()))
- return true;
- }
-
- return false;
- }
-
- public boolean isUndefinedType() {
- return fElementType == 0;
- }
-
- public boolean canSubstituteFor(ITypeInfo info) {
- return isExactMatch(info);
- }
-
- protected boolean isExactMatch(ITypeInfo info) {
- if (hashCode() != info.hashCode())
- return false;
- if (fElementType == info.getCElementType()
- && fQualifiedName.equals(info.getQualifiedTypeName())) {
- IProject project1 = getEnclosingProject();
- IProject project2 = info.getEnclosingProject();
- if (project1 == null && project2 == null)
- return true;
- if (project1 == null || project2 == null)
- return false;
- return project1.equals(project2);
- }
- return false;
- }
-
- public boolean exists() {
- return fTypeCache != null;
- }
-
- public int getCElementType() {
- return fElementType;
- }
-
- public void setCElementType(int type) {
- fElementType = type;
- }
-
- public IQualifiedTypeName getQualifiedTypeName() {
- return fQualifiedName;
- }
-
- public String getName() {
- return fQualifiedName.getName();
- }
-
- public boolean isEnclosedType() {
- return (fQualifiedName.isQualified());
- }
-
- public ITypeInfo getEnclosingType(int kinds[]) {
- if (fTypeCache != null) {
- return fTypeCache.getEnclosingType(this, kinds);
- }
- return null;
- }
-
- public ITypeInfo getEnclosingType() {
- return getEnclosingType(KNOWN_TYPES);
- }
-
- public ITypeInfo getEnclosingNamespace(boolean includeGlobalNamespace) {
- if (fTypeCache != null) {
- return fTypeCache.getEnclosingNamespace(this, includeGlobalNamespace);
- }
- return null;
- }
-
- public ITypeInfo getRootNamespace(boolean includeGlobalNamespace) {
- if (fTypeCache != null) {
- return fTypeCache.getRootNamespace(this, includeGlobalNamespace);
- }
- return null;
- }
-
- public boolean isEnclosingType() {
- return (fElementType == ICElement.C_NAMESPACE
- || fElementType == ICElement.C_CLASS
- || fElementType == ICElement.C_STRUCT);
- }
-
- public boolean encloses(ITypeInfo info) {
- if (isEnclosingType() && fTypeCache == info.getCache()) {
- return fQualifiedName.isPrefixOf(info.getQualifiedTypeName());
- }
- return false;
- }
-
- public boolean isEnclosed(ITypeInfo info) {
- return info.encloses(this);
- }
-
- public boolean hasEnclosedTypes() {
- if (isEnclosingType() && fTypeCache != null) {
- return fTypeCache.hasEnclosedTypes(this);
- }
- return false;
- }
-
- public ITypeInfo[] getEnclosedTypes() {
- return getEnclosedTypes(KNOWN_TYPES);
- }
-
- public ITypeInfo[] getEnclosedTypes(int kinds[]) {
- if (fTypeCache != null) {
- return fTypeCache.getEnclosedTypes(this, kinds);
- }
- return EMPTY_TYPES;
- }
-
- public IProject getEnclosingProject() {
- if (fTypeCache != null) {
- return fTypeCache.getProject();
- }
- return null;
- }
-
- public String toString() {
- return fQualifiedName.toString();
- }
-
- public boolean isEnclosed(ITypeSearchScope scope) {
- if (scope == null || scope.isWorkspaceScope())
- return true;
-
- // check if path is in scope
- for (int i = 0; i < fSourceRefsCount; ++i) {
- ITypeReference location = fSourceRefs[i];
- if (scope.encloses(location.getPath()))
- return true;
- }
-
- return false;
- }
-
- public int hashCode() {
- int hashCode = fQualifiedName.hashCode() + fElementType;
- IProject project = getEnclosingProject();
- if (project != null)
- hashCode += project.hashCode();
- return hashCode;
- }
-
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof TypeInfo)) {
- return false;
- }
- return isExactMatch((TypeInfo)obj);
- }
-
- public int compareTo(Object obj) {
- if (obj == this) {
- return 0;
- }
- if( !(obj instanceof TypeInfo)) {
- throw new ClassCastException();
- }
- TypeInfo info= (TypeInfo)obj;
- if (fElementType != info.fElementType)
- return (fElementType < info.fElementType) ? -1 : 1;
- return fQualifiedName.compareTo(info.getQualifiedTypeName());
- }
-
- public static boolean isValidType(int type) {
- return ArrayUtil.contains(KNOWN_TYPES, type);
- }
-
- public ITypeCache getCache() {
- return fTypeCache;
- }
-
- public void setCache(ITypeCache typeCache) {
- fTypeCache = typeCache;
- }
-
- public void addDerivedReference(ITypeReference location) {
- if (fDerivedSourceRefs == null) {
- fDerivedSourceRefs = new ITypeReference[INITIAL_REFS_SIZE];
- fDerivedSourceRefsCount = 0;
- } else if (fDerivedSourceRefsCount == fDerivedSourceRefs.length) {
- ITypeReference[] refs = new ITypeReference[fDerivedSourceRefs.length + REFS_GROW_BY];
- System.arraycopy(fDerivedSourceRefs, 0, refs, 0, fDerivedSourceRefsCount);
- fDerivedSourceRefs = refs;
- }
- fDerivedSourceRefs[fDerivedSourceRefsCount] = location;
- ++fDerivedSourceRefsCount;
- }
-
- public ITypeReference[] getDerivedReferences() {
- if (fDerivedSourceRefs != null) {
- ITypeReference[] refs = new ITypeReference[fDerivedSourceRefsCount];
- System.arraycopy(fDerivedSourceRefs, 0, refs, 0, fDerivedSourceRefsCount);
- return refs;
- }
- return null;
- }
-
- public boolean hasSubTypes() {
- return (fDerivedSourceRefs != null);
- }
-
- public ITypeInfo[] getSubTypes() {
- if (fTypeCache != null) {
- return fTypeCache.getSubtypes(this);
- }
- return null;
- }
-
- public boolean hasSuperTypes() {
- if (fTypeCache != null) {
- return (fTypeCache.getSupertypes(this) != null);
- }
- return false;
-// return true; //TODO can't know this until we parse
- }
-
- public ITypeInfo[] getSuperTypes() {
- if (fTypeCache != null) {
- return fTypeCache.getSupertypes(this);
- }
- return null;
- }
-
- public ASTAccessVisibility getSuperTypeAccess(ITypeInfo superType) {
- if (fTypeCache != null) {
- return fTypeCache.getSupertypeAccess(this, superType);
- }
- return null;
- }
-
- public boolean isClass() {
- return (fElementType == ICElement.C_CLASS
- || fElementType == ICElement.C_STRUCT);
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeReference.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeReference.java
deleted file mode 100644
index cb91663e812..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeReference.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-
-
-public class TypeReference implements ITypeReference {
- private IPath fPath;
- private IProject fProject;
- private IResource fResource;
- private IWorkingCopy fWorkingCopy;
- private int fOffset;
- private int fLength;
- public boolean offsetIsLineNumber = false;
-
- public TypeReference(IPath path, IProject project, int offset, int length) {
- fPath = path;
- fProject = project;
- fWorkingCopy = null;
- fResource = null;
- fOffset = offset;
- fLength = length;
- }
-
- public TypeReference(IResource resource, IProject project, int offset, int length) {
- fPath = null;
- fProject = project;
- fWorkingCopy = null;
- fResource = resource;
- fOffset = offset;
- fLength = length;
- }
-
- public TypeReference(IWorkingCopy workingCopy, IProject project, int offset, int length) {
- fPath = null;
- fProject = project;
- fWorkingCopy = workingCopy;
- fResource = null;
- fOffset = offset;
- fLength = length;
- }
-
- public TypeReference(IPath path, IProject project) {
- this(path, project, 0, 0);
- }
-
- public TypeReference(IResource resource, IProject project) {
- this(resource, project, 0, 0);
- }
-
- public TypeReference(IWorkingCopy workingCopy, IProject project) {
- this(workingCopy, project, 0, 0);
- }
-
- public IPath getPath() {
- if (fWorkingCopy != null) {
- return fWorkingCopy.getPath();
- } else if (fResource != null) {
- return fResource.getFullPath();
- } else {
- return fPath;
- }
- }
-
- public IPath getLocation() {
- if (fWorkingCopy != null) {
- IResource resource = fWorkingCopy.getUnderlyingResource();
- if (resource != null) {
- return resource.getLocation();
- }
- return null;
- } else if (fResource != null) {
- return fResource.getLocation();
- } else if (fPath != null) {
- return fPath;
- } else if (fProject != null) {
- return fProject.getLocation();
- } else {
- return null;
- }
- }
-
- public IResource getResource() {
- return fResource;
- }
-
- public IWorkingCopy getWorkingCopy() {
- return fWorkingCopy;
- }
-
- public IProject getProject() {
- if (fProject != null) {
- return fProject;
- }
- if (fWorkingCopy != null) {
- ICProject cProject = fWorkingCopy.getCProject();
- if (cProject != null) {
- return cProject.getProject();
- }
- return null;
- } else if (fResource != null) {
- return fResource.getProject();
- } else {
- return null;
- }
- }
-
- public ITranslationUnit getTranslationUnit() {
- ITranslationUnit unit = null;
- if (fWorkingCopy != null) {
- unit = fWorkingCopy.getTranslationUnit();
- } else if (fResource != null) {
- ICElement elem = CoreModel.getDefault().create(fResource);
- if (elem instanceof ITranslationUnit)
- unit = (ITranslationUnit) elem;
- } else {
- IPath path = getLocation();
- ICElement elem = CoreModel.getDefault().create(path);
- if (elem instanceof ITranslationUnit)
- unit = (ITranslationUnit) elem;
- }
-
- if (unit == null) {
- IProject project = getProject();
- if (project != null) {
- ICProject cProject = findCProject(project);
- if (cProject != null) {
- IPath path = getLocation();
- ICElement elem = CoreModel.getDefault().createTranslationUnitFrom(cProject, path);
- if (elem instanceof ITranslationUnit)
- unit = (ITranslationUnit) elem;
- }
- }
- }
- return unit;
- }
-
- private ICProject findCProject(IProject project) {
- try {
- ICProject[] cProjects = CoreModel.getDefault().getCModel().getCProjects();
- if (cProjects != null) {
- for (int i = 0; i < cProjects.length; ++i) {
- ICProject cProject = cProjects[i];
- if (project.equals(cProjects[i].getProject()))
- return cProject;
- }
- }
- } catch (CModelException e) {
- }
- return null;
- }
-
- public ICElement[] getCElements() {
- ITranslationUnit unit = getTranslationUnit();
- if (unit != null) {
- try {
- if( offsetIsLineNumber )
- {
- ICElement [] result = new ICElement[1];
- result[0] = unit.getElementAtLine(fOffset);
- return result;
- }
- return unit.getElementsAtOffset(fOffset);
- } catch (CModelException e) {
- }
- }
- return null;
- }
-
- public int getOffset() {
- return fOffset;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public IPath getRelativeIncludePath(IProject project) {
- IPath path = getLocation();
- if (path != null) {
- IPath relativePath = PathUtil.makeRelativePathToProjectIncludes(path, project);
- if (relativePath != null)
- return relativePath;
- }
- return path;
- }
-
- public IPath getRelativePath(IPath relativeToPath) {
- IPath path = getPath();
- if (path != null) {
- IPath relativePath = PathUtil.makeRelativePath(path, relativeToPath);
- if (relativePath != null)
- return relativePath;
- }
- return path;
- }
-
- public String toString() {
- IPath path = getLocation();
- if (path != null) {
- if (fLength == 0 && fOffset == 0) {
- return path.toString();
- }
- return path.toString() + ":" + fOffset + "-" + (fOffset + fLength); //$NON-NLS-1$//$NON-NLS-2$
- }
- return ""; //$NON-NLS-1$
- }
-
- public int hashCode() {
- return toString().hashCode();
- }
-
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof ITypeReference)) {
- return false;
- }
- ITypeReference ref = (ITypeReference)obj;
- return toString().equals(ref.toString());
- }
-
- public boolean isLineNumber() {
- return offsetIsLineNumber;
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeSearchScope.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeSearchScope.java
deleted file mode 100644
index c29ea790f9a..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeSearchScope.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-public class TypeSearchScope implements ITypeSearchScope {
-
- private Set fPathSet = new HashSet();
- private Set fContainerSet = new HashSet();
- private Set fProjectSet = new HashSet();
- private Set fEnclosingProjectSet = new HashSet();
- private boolean fWorkspaceScope = false;
-
- // cached arrays
- private IProject[] fAllProjects = null;
- private IProject[] fProjects = null;
- private IPath[] fContainerPaths = null;
-
- public TypeSearchScope() {
- }
-
- public TypeSearchScope(boolean workspaceScope) {
- fWorkspaceScope = workspaceScope;
- }
-
- public TypeSearchScope(ITypeSearchScope scope) {
- add(scope);
- }
-
- public TypeSearchScope(IProject project) {
- add(project);
- }
-
- public Collection pathSet() {
- return fPathSet;
- }
- public Collection containerSet() {
- return fContainerSet;
- }
- public Collection projectSet() {
- return fProjectSet;
- }
- public Collection enclosingProjectSet() {
- return fEnclosingProjectSet;
- }
-
- public boolean encloses(ITypeSearchScope scope) {
- if (isWorkspaceScope())
- return true;
-
- if (!scope.pathSet().isEmpty()) {
- // check if this scope encloses the other scope's paths
- for (Iterator i = scope.pathSet().iterator(); i.hasNext(); ) {
- IPath path = (IPath) i.next();
- if (!encloses(path))
- return false;
- }
- }
-
- if (!scope.containerSet().isEmpty()) {
- // check if this scope encloses the other scope's containers
- for (Iterator i = scope.containerSet().iterator(); i.hasNext(); ) {
- IPath path = (IPath) i.next();
- if (!encloses(path))
- return false;
- }
- }
-
- if (!scope.projectSet().isEmpty()) {
- // check if this scope encloses the other scope's projects
- for (Iterator i = scope.projectSet().iterator(); i.hasNext(); ) {
- IProject project = (IProject) i.next();
- if (!encloses(project))
- return false;
- }
- }
-
- return true;
- }
-
- public boolean encloses(IProject project) {
- if (isWorkspaceScope())
- return true;
-
- // check projects that were explicity added to scope
- if (fProjectSet.contains(project))
- return true;
-
- return false;
- }
-
- public boolean encloses(IPath path) {
- if (isWorkspaceScope())
- return true;
-
- // check files that were explicity added to scope
- if (fPathSet.contains(path))
- return true;
-
- // check containers that were explicity added to scope
- // including subdirs
- if (fContainerSet.contains(path))
- return true;
- if (fContainerPaths == null) {
- fContainerPaths = (IPath[]) fContainerSet.toArray(new IPath[fContainerSet.size()]);
-// java.util.Arrays.sort(fContainerPaths);
- }
- for (int i = 0; i < fContainerPaths.length; ++i) {
- if (fContainerPaths[i].isPrefixOf(path)) {
- return true;
- }
- }
-
- // check projects that were explicity added to scope
- if (fProjectSet.contains(path))
- return true;
-
- // check projects that were explicity added to scope
- if (fProjects == null) {
- fProjects = (IProject[]) fProjectSet.toArray(new IProject[fProjectSet.size()]);
- }
- // check if one of the projects contains path
- for (int i = 0; i < fProjects.length; ++i) {
- if (projectContainsPath(fProjects[i], path, false)) {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean encloses(String path) {
- return encloses(new Path(path));
- }
-
- public boolean encloses(ICElement element) {
- return encloses(element.getPath());
- }
-
- public boolean encloses(IWorkingCopy workingCopy) {
- return encloses(workingCopy.getOriginalElement().getPath());
- }
-
- public IProject[] getEnclosingProjects() {
- if (isWorkspaceScope()) {
- return getAllProjects();
- }
- return (IProject[]) fEnclosingProjectSet.toArray(new IProject[fEnclosingProjectSet.size()]);
- }
-
- private static boolean projectContainsPath(IProject project, IPath path, boolean checkIncludePaths) {
- IPath projectPath = project.getFullPath();
- if (projectPath.isPrefixOf(path)) {
-// ISourceRoot[] sourceRoots = null;
-// try {
-// sourceRoots = cProject.getSourceRoots();
-// } catch (CModelException ex) {
-// }
-// if (sourceRoots != null) {
-// for (int j = 0; j < sourceRoots.length; ++j) {
-// ISourceRoot root = sourceRoots[j];
-// if (root.isOnSourceEntry(path))
-// return true;
-// }
-// }
- return true;
- }
-
- if (checkIncludePaths) {
- //TODO this appears to be very slow -- cache this?
- IPath[] includePaths = getIncludePaths(project);
- if (includePaths != null) {
- for (int i = 0; i < includePaths.length; ++i) {
- IPath include = includePaths[i];
- if (include.isPrefixOf(path) || include.equals(path))
- return true;
- }
- }
- }
-
- return false;
- }
-
- private static IPath[] getIncludePaths(IProject project) {
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- if (provider != null) {
- IScannerInfo info = provider.getScannerInformation(project);
- if (info != null) {
- String[] includes = info.getIncludePaths();
- if (includes != null && includes.length > 0) {
- IPath[] includePaths = new IPath[includes.length];
- for (int i = 0; i < includes.length; ++i) {
- includePaths[i] = new Path(includes[i]);
- }
-// java.util.Arrays.sort(includePaths);
- return includePaths;
- }
- }
- }
- return null;
- }
-
- private static IProject[] getAllProjects() {
- IProject[] projects = getCProjects();
- if (projects == null)
- projects = new IProject[0];
- return projects;
- }
-
- private static IProject[] getCProjects() {
- IProject[] allProjects = CCorePlugin.getWorkspace().getRoot().getProjects();
- if (allProjects != null) {
- IProject[] cProjects = new IProject[allProjects.length];
- int count = 0;
- for (int i = 0; i < allProjects.length; ++i) {
- IProject project = allProjects[i];
- if (isCProject(project)) {
- cProjects[count++] = project;
- }
- }
- if (count > 0) {
- if (count == allProjects.length) {
- return cProjects;
- }
- IProject[] newProjects = new IProject[count];
- System.arraycopy(cProjects, 0, newProjects, 0, count);
- return newProjects;
- }
- }
- return null;
- }
-
- private static boolean isCProject(IProject project) {
- IProjectDescription projDesc = null;
- try {
- projDesc = project.getDescription();
- if (projDesc == null)
- return false;
- } catch (CoreException e) {
- return false;
- }
- String[] natures = projDesc.getNatureIds();
- if (natures != null) {
- for (int i = 0; i < natures.length; ++i) {
- if (natures[i].equals(CProjectNature.C_NATURE_ID)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public boolean isPathScope() {
- return !fPathSet.isEmpty();
- }
-
- public boolean isProjectScope() {
- return !fProjectSet.isEmpty();
- }
-
- public boolean isWorkspaceScope() {
- return fWorkspaceScope;
- }
-
- public boolean isEmpty() {
- return (!isWorkspaceScope() && fPathSet.isEmpty() && fContainerSet.isEmpty() && fProjectSet.isEmpty());
- }
-
- public void add(IWorkingCopy workingCopy) {
- IPath path = workingCopy.getOriginalElement().getPath();
- IProject enclosingProject = null;
- ICProject cProject = workingCopy.getCProject();
- if (cProject != null)
- enclosingProject = cProject.getProject();
- fPathSet.add(path);
- if (enclosingProject != null)
- addEnclosingProject(enclosingProject);
- }
-
- public void add(IPath path, boolean addSubfolders, IProject enclosingProject) {
- if (addSubfolders) {
- fContainerSet.add(path);
- fContainerPaths = null;
- } else {
- fPathSet.add(path);
- }
- if (enclosingProject != null) {
- addEnclosingProject(enclosingProject);
- } else {
- // check all projects in workspace
- if (fAllProjects == null) {
- fAllProjects = getAllProjects();
- }
- // check if one of the projects contains path
- for (int i = 0; i < fAllProjects.length; ++i) {
- if (projectContainsPath(fAllProjects[i], path, false)) {
- addEnclosingProject(fAllProjects[i]);
- break;
- }
- }
- }
- }
-
- public void add(IProject project) {
- fProjectSet.add(project);
- fProjects = null;
- fAllProjects = null;
- addEnclosingProject(project);
- }
-
- private void addEnclosingProject(IProject project) {
- fEnclosingProjectSet.add(project);
- }
-
- public void addWorkspace() {
- fWorkspaceScope = true;
- fProjects = null;
- fAllProjects = null;
- }
-
- public void add(ICElement elem) {
- if (elem == null)
- return;
-
- switch (elem.getElementType()) {
- case ICElement.C_MODEL: {
- addWorkspace();
- break;
- }
-
- case ICElement.C_PROJECT: {
- IProject project = ((ICProject)elem).getProject();
- add(project);
- break;
- }
-
- case ICElement.C_CCONTAINER: {
- IProject project = null;
- ICProject cProject = elem.getCProject();
- if (cProject != null)
- project = cProject.getProject();
- add(elem.getPath(), true, project);
- break;
- }
-
- case ICElement.C_UNIT: {
- IProject project = null;
- ICProject cProject = elem.getCProject();
- if (cProject != null)
- project = cProject.getProject();
- add(elem.getPath(), false, project);
- break;
- }
-
- case ICElement.C_INCLUDE:
- case ICElement.C_NAMESPACE:
- case ICElement.C_TEMPLATE_CLASS:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF: {
- IProject project = null;
- ICProject cProject = elem.getCProject();
- if (cProject != null)
- project = cProject.getProject();
- add(elem.getPath(), false, project);
- break;
- }
- }
- }
-
- public void add(ITypeSearchScope scope) {
- fPathSet.addAll(scope.pathSet());
- fContainerSet.addAll(scope.containerSet());
- fProjectSet.addAll(scope.projectSet());
- fEnclosingProjectSet.addAll(scope.enclosingProjectSet());
- fProjects = null;
- fAllProjects = null;
- fContainerPaths = null;
- fWorkspaceScope |= scope.isWorkspaceScope();
- }
-
- public void clear() {
- fPathSet.clear();
- fContainerSet.clear();
- fProjectSet.clear();
- fEnclosingProjectSet.clear();
- fWorkspaceScope = false;
- fProjects = null;
- fAllProjects = null;
- fContainerPaths = null;
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/UnknownTypeInfo.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/UnknownTypeInfo.java
deleted file mode 100644
index c31921f596c..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/UnknownTypeInfo.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.browser;
-
-import org.eclipse.core.runtime.IPath;
-
-public class UnknownTypeInfo extends TypeInfo {
-
- public UnknownTypeInfo(String name, IPath path) {
- this(new QualifiedTypeName(name));
- if (path != null) {
- addReference(new TypeReference(path, null));
- }
- }
-
- public UnknownTypeInfo(IQualifiedTypeName typeName) {
- super(0, typeName);
- }
-
- public boolean isUndefinedType() {
- return true;
- }
-
- public boolean canSubstituteFor(ITypeInfo info) {
- if (fTypeCache == info.getCache()) {
- int compareType = info.getCElementType();
- if (fElementType == 0 || compareType == 0 || fElementType == compareType) {
- return fQualifiedName.equals(info.getQualifiedTypeName());
- }
- }
- return false;
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/ChangeCollector.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/ChangeCollector.java
deleted file mode 100644
index 71f9fe0f775..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/ChangeCollector.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.core.browser.typehierarchy;
-
-import java.util.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.core.model.CElement;
-
-/*
- * Collects changes (reported through fine-grained deltas) that can affect a type hierarchy.
- */
-public class ChangeCollector {
-
- /*
- * A table from ICElements to TypeDeltas
- */
- HashMap changes = new HashMap();
-
- TypeHierarchy hierarchy;
-
- public ChangeCollector(TypeHierarchy hierarchy) {
- this.hierarchy = hierarchy;
- }
-
- /*
- * Adds the children of the given delta to the list of changes.
- */
- private void addAffectedChildren(ICElementDelta delta) throws CModelException {
-// ICElementDelta[] children = delta.getAffectedChildren();
-// for (int i = 0, length = children.length; i < length; i++) {
-// ICElementDelta child = children[i];
-// ICElement childElement = child.getElement();
-// switch (childElement.getElementType()) {
-// case ICElement.IMPORT_CONTAINER:
-// addChange((IImportContainer)childElement, child);
-// break;
-// case ICElement.IMPORT_DECLARATION:
-// addChange((IImportDeclaration)childElement, child);
-// break;
-// case ICElement.TYPE:
-// addChange((ICElement)childElement, child);
-// break;
-// case ICElement.INITIALIZER:
-// case ICElement.FIELD:
-// case ICElement.METHOD:
-// addChange((IMember)childElement, child);
-// break;
-// }
-// }
- }
-
- /*
- * Adds the given delta on a compilation unit to the list of changes.
- */
- public void addChange(ITranslationUnit cu, ICElementDelta newDelta) throws CModelException {
-// int newKind = newDelta.getKind();
-// switch (newKind) {
-// case ICElementDelta.ADDED:
-// ArrayList allTypes = new ArrayList();
-// getAllTypesFromElement(cu, allTypes);
-// for (int i = 0, length = allTypes.size(); i < length; i++) {
-// ICElement type = (ICElement)allTypes.get(i);
-// addTypeAddition(type, (SimpleDelta)this.changes.get(type));
-// }
-// break;
-// case ICElementDelta.REMOVED:
-// allTypes = new ArrayList();
-// getAllTypesFromHierarchy((JavaElement)cu, allTypes);
-// for (int i = 0, length = allTypes.size(); i < length; i++) {
-// ICElement type = (ICElement)allTypes.get(i);
-// addTypeRemoval(type, (SimpleDelta)this.changes.get(type));
-// }
-// break;
-// case ICElementDelta.CHANGED:
-// addAffectedChildren(newDelta);
-// break;
-// }
- }
-
-/* private void addChange(IImportContainer importContainer, ICElementDelta newDelta) throws CModelException {
- int newKind = newDelta.getKind();
- if (newKind == ICElementDelta.CHANGED) {
- addAffectedChildren(newDelta);
- return;
- }
- SimpleDelta existingDelta = (SimpleDelta)this.changes.get(importContainer);
- if (existingDelta != null) {
- switch (newKind) {
- case ICElementDelta.ADDED:
- if (existingDelta.getKind() == ICElementDelta.REMOVED) {
- // REMOVED then ADDED
- this.changes.remove(importContainer);
- }
- break;
- case ICElementDelta.REMOVED:
- if (existingDelta.getKind() == ICElementDelta.ADDED) {
- // ADDED then REMOVED
- this.changes.remove(importContainer);
- }
- break;
- // CHANGED handled above
- }
- } else {
- SimpleDelta delta = new SimpleDelta();
- switch (newKind) {
- case ICElementDelta.ADDED:
- delta.added();
- break;
- case ICElementDelta.REMOVED:
- delta.removed();
- break;
- }
- this.changes.put(importContainer, delta);
- }
- }
-
- private void addChange(IImportDeclaration importDecl, ICElementDelta newDelta) {
- SimpleDelta existingDelta = (SimpleDelta)this.changes.get(importDecl);
- int newKind = newDelta.getKind();
- if (existingDelta != null) {
- switch (newKind) {
- case ICElementDelta.ADDED:
- if (existingDelta.getKind() == ICElementDelta.REMOVED) {
- // REMOVED then ADDED
- this.changes.remove(importDecl);
- }
- break;
- case ICElementDelta.REMOVED:
- if (existingDelta.getKind() == ICElementDelta.ADDED) {
- // ADDED then REMOVED
- this.changes.remove(importDecl);
- }
- break;
- // CHANGED cannot happen for import declaration
- }
- } else {
- SimpleDelta delta = new SimpleDelta();
- switch (newKind) {
- case ICElementDelta.ADDED:
- delta.added();
- break;
- case ICElementDelta.REMOVED:
- delta.removed();
- break;
- }
- this.changes.put(importDecl, delta);
- }
- }
-*/
-
- /*
- * Adds a change for the given member (a method, a field or an initializer) and the types it defines.
- */
- private void addChange(IMember member, ICElementDelta newDelta) throws CModelException {
-// int newKind = newDelta.getKind();
-// switch (newKind) {
-// case ICElementDelta.ADDED:
-// ArrayList allTypes = new ArrayList();
-// getAllTypesFromElement(member, allTypes);
-// for (int i = 0, length = allTypes.size(); i < length; i++) {
-// ICElement innerType = (ICElement)allTypes.get(i);
-// addTypeAddition(innerType, (SimpleDelta)this.changes.get(innerType));
-// }
-// break;
-// case ICElementDelta.REMOVED:
-// allTypes = new ArrayList();
-// getAllTypesFromHierarchy((JavaElement)member, allTypes);
-// for (int i = 0, length = allTypes.size(); i < length; i++) {
-// ICElement type = (ICElement)allTypes.get(i);
-// addTypeRemoval(type, (SimpleDelta)this.changes.get(type));
-// }
-// break;
-// case ICElementDelta.CHANGED:
-// addAffectedChildren(newDelta);
-// break;
-// }
- }
-
- /*
- * Adds a change for the given type and the types it defines.
- */
- private void addChange(ICElement type, ICElementDelta newDelta) throws CModelException {
-// int newKind = newDelta.getKind();
-// SimpleDelta existingDelta = (SimpleDelta)this.changes.get(type);
-// switch (newKind) {
-// case ICElementDelta.ADDED:
-// addTypeAddition(type, existingDelta);
-// ArrayList allTypes = new ArrayList();
-// getAllTypesFromElement(type, allTypes);
-// for (int i = 0, length = allTypes.size(); i < length; i++) {
-// ICElement innerType = (ICElement)allTypes.get(i);
-// addTypeAddition(innerType, (SimpleDelta)this.changes.get(innerType));
-// }
-// break;
-// case ICElementDelta.REMOVED:
-// addTypeRemoval(type, existingDelta);
-// allTypes = new ArrayList();
-// getAllTypesFromHierarchy((JavaElement)type, allTypes);
-// for (int i = 0, length = allTypes.size(); i < length; i++) {
-// ICElement innerType = (ICElement)allTypes.get(i);
-// addTypeRemoval(innerType, (SimpleDelta)this.changes.get(innerType));
-// }
-// break;
-// case ICElementDelta.CHANGED:
-// addTypeChange(type, newDelta.getFlags(), existingDelta);
-// addAffectedChildren(newDelta);
-// break;
-// }
- }
-
-/* private void addTypeAddition(ICElement type, SimpleDelta existingDelta) throws CModelException {
- if (existingDelta != null) {
- switch (existingDelta.getKind()) {
- case ICElementDelta.REMOVED:
- // REMOVED then ADDED
- boolean hasChange = false;
- if (hasSuperTypeChange(type)) {
- existingDelta.superTypes();
- hasChange = true;
- }
- if (hasVisibilityChange(type)) {
- existingDelta.modifiers();
- hasChange = true;
- }
- if (!hasChange) {
- this.changes.remove(type);
- }
- break;
- // CHANGED then ADDED
- // or ADDED then ADDED: should not happen
- }
- } else {
- // check whether the type addition affects the hierarchy
- String typeName = type.getElementName();
- if (this.hierarchy.hasSupertype(typeName)
- || this.hierarchy.subtypesIncludeSupertypeOf(type)
- || this.hierarchy.missingTypes.contains(typeName)) {
- SimpleDelta delta = new SimpleDelta();
- delta.added();
- this.changes.put(type, delta);
- }
- }
- }
-*/
-/* private void addTypeChange(ICElement type, int newFlags, SimpleDelta existingDelta) throws CModelException {
- if (existingDelta != null) {
- switch (existingDelta.getKind()) {
- case ICElementDelta.CHANGED:
- // CHANGED then CHANGED
- int existingFlags = existingDelta.getFlags();
- boolean hasChange = false;
- if ((existingFlags & ICElementDelta.F_SUPER_TYPES) != 0
- && hasSuperTypeChange(type)) {
- existingDelta.superTypes();
- hasChange = true;
- }
- if ((existingFlags & ICElementDelta.F_MODIFIERS) != 0
- && hasVisibilityChange(type)) {
- existingDelta.modifiers();
- hasChange = true;
- }
- if (!hasChange) {
- // super types and visibility are back to the ones in the existing hierarchy
- this.changes.remove(type);
- }
- break;
- // ADDED then CHANGED: leave it as ADDED
- // REMOVED then CHANGED: should not happen
- }
- } else {
- // check whether the type change affects the hierarchy
- SimpleDelta typeDelta = null;
- if ((newFlags & ICElementDelta.F_SUPER_TYPES) != 0
- && this.hierarchy.includesTypeOrSupertype(type)) {
- typeDelta = new SimpleDelta();
- typeDelta.superTypes();
- }
- if ((newFlags & ICElementDelta.F_MODIFIERS) != 0
- && this.hierarchy.hasSupertype(type.getElementName())) {
- if (typeDelta == null) {
- typeDelta = new SimpleDelta();
- }
- typeDelta.modifiers();
- }
- if (typeDelta != null) {
- this.changes.put(type, typeDelta);
- }
- }
- }
-*/
-/* private void addTypeRemoval(ICElement type, SimpleDelta existingDelta) {
- if (existingDelta != null) {
- switch (existingDelta.getKind()) {
- case ICElementDelta.ADDED:
- // ADDED then REMOVED
- this.changes.remove(type);
- break;
- case ICElementDelta.CHANGED:
- // CHANGED then REMOVED
- existingDelta.removed();
- break;
- // REMOVED then REMOVED: should not happen
- }
- } else {
- // check whether the type removal affects the hierarchy
- if (this.hierarchy.contains(type)) {
- SimpleDelta typeDelta = new SimpleDelta();
- typeDelta.removed();
- this.changes.put(type, typeDelta);
- }
- }
- }
-*/
- /*
- * Returns all types defined in the given element excluding the given element.
- */
- private void getAllTypesFromElement(ICElement element, ArrayList allTypes) throws CModelException {
- switch (element.getElementType()) {
- case ICElement.C_UNIT:
- ICElement[] types = TypeUtil.getTypes((ITranslationUnit)element);
- for (int i = 0, length = types.length; i < length; i++) {
- ICElement type = types[i];
- allTypes.add(type);
- getAllTypesFromElement(type, allTypes);
- }
- break;
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
-// types = ((ICElement)element).getTypes();
- types = TypeUtil.getTypes(element);
- for (int i = 0, length = types.length; i < length; i++) {
- ICElement type = types[i];
- allTypes.add(type);
- getAllTypesFromElement(type, allTypes);
- }
- break;
-// case ICElement.INITIALIZER:
-// case ICElement.FIELD:
- case ICElement.C_METHOD:
- if (element instanceof IParent) {
- ICElement[] children = ((IParent)element).getChildren();
- for (int i = 0, length = children.length; i < length; i++) {
- ICElement type = (ICElement)children[i];
- allTypes.add(type);
- getAllTypesFromElement(type, allTypes);
- }
- }
- break;
- }
- }
-
- /*
- * Returns all types in the existing hierarchy that have the given element as a parent.
- */
- private void getAllTypesFromHierarchy(CElement element, ArrayList allTypes) {
- switch (element.getElementType()) {
- case ICElement.C_UNIT:
- ArrayList types = (ArrayList)this.hierarchy.files.get(element);
- if (types != null) {
- allTypes.addAll(types);
- }
- break;
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
-// case ICElement.INITIALIZER:
-// case ICElement.FIELD:
- case ICElement.C_METHOD:
- types = (ArrayList)this.hierarchy.files.get(((IMember)element).getTranslationUnit());
- if (types != null) {
- for (int i = 0, length = types.size(); i < length; i++) {
- ICElement type = (ICElement)types.get(i);
- if (element.isAncestorOf(type)) {
- allTypes.add(type);
- }
- }
- }
- break;
- }
- }
-
- private boolean hasSuperTypeChange(ICElement type) throws CModelException {
-// // check super class
-// ICElement superclass = this.hierarchy.getSuperclass(type);
-// String existingSuperclassName = superclass == null ? null : superclass.getElementName();
-// String newSuperclassName = type.getSuperclassName();
-// if (existingSuperclassName != null && !existingSuperclassName.equals(newSuperclassName)) {
-// return true;
-// }
-//
-// // check super interfaces
-// ICElement[] existingSuperInterfaces = this.hierarchy.getSuperInterfaces(type);
-// String[] newSuperInterfaces = type.getSuperInterfaceNames();
-// if (existingSuperInterfaces.length != newSuperInterfaces.length) {
-// return true;
-// }
-// for (int i = 0, length = newSuperInterfaces.length; i < length; i++) {
-// String superInterfaceName = newSuperInterfaces[i];
-// if (!superInterfaceName.equals(newSuperInterfaces[i])) {
-// return true;
-// }
-// }
-
- return false;
- }
-
- private boolean hasVisibilityChange(ICElement type) throws CModelException {
-// int existingFlags = this.hierarchy.getCachedFlags(type);
-// int newFlags = type.getFlags();
-// return existingFlags != newFlags;
- return false;
- }
-
- /*
- * Whether the hierarchy needs refresh according to the changes collected so far.
- */
- public boolean needsRefresh() {
- return changes.size() != 0;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- Iterator iterator = this.changes.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry)iterator.next();
- buffer.append(((CElement)entry.getKey()).toDebugString());
- buffer.append(entry.getValue());
- if (iterator.hasNext()) {
- buffer.append('\n');
- }
- }
- return buffer.toString();
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/ITypeHierarchy.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/ITypeHierarchy.java
deleted file mode 100644
index befed906b67..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/ITypeHierarchy.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.core.browser.typehierarchy;
-
-import java.io.OutputStream;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * A type hierarchy provides navigations between a type and its resolved
- * supertypes and subtypes for a specific type or for all types within a region.
- * Supertypes may extend outside of the type hierarchy's region in which it was
- * created such that the root of the hierarchy is always included. For example, if a type
- * hierarchy is created for a java.io.File
, and the region the hierarchy was
- * created in is the package fragment java.io
, the supertype
- * java.lang.Object
will still be included.
- *
- * A type hierarchy is static and can become stale. Although consistent when
- * created, it does not automatically track changes in the model.
- * As changes in the model potentially invalidate the hierarchy, change notifications
- * are sent to registered ICElementHierarchyChangedListener
s. Listeners should
- * use the exists
method to determine if the hierarchy has become completely
- * invalid (for example, when the type or project the hierarchy was created on
- * has been removed). To refresh a hierarchy, use the refresh
method.
- *
- * The type hierarchy may contain cycles due to malformed supertype declarations.
- * Most type hierarchy queries are oblivious to cycles; the getAll*
- * methods are implemented such that they are unaffected by cycles.
- *
- * This interface is not intended to be implemented by clients. - *
- */ -public interface ITypeHierarchy { -/** - * Adds the given listener for changes to this type hierarchy. Listeners are - * notified when this type hierarchy changes and needs to be refreshed. - * Has no effect if an identical listener is already registered. - * - * @param listener the listener - */ -void addTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener); -/** - * Returns whether the given type is part of this hierarchy. - * - * @param type the given type - * @return true if the given type is part of this hierarchy, false otherwise - */ -boolean contains(ICElement type); -/** - * Returns whether the type and project this hierarchy was created on exist. - * @return true if the type and project this hierarchy was created on exist, false otherwise - */ -boolean exists(); - -/** - * Returns all resolved subtypes (direct and indirect) of the - * given type, in no particular order, limited to the - * types in this type hierarchy's graph. An empty array - * is returned if there are no resolved subtypes for the - * given type. - * - * @param type the given type - * @return all resolved subtypes (direct and indirect) of the given type - */ -ICElement[] getAllSubtypes(ICElement type); -/** - * Returns all resolved superclasses of the - * given class, in bottom-up order. An empty array - * is returned if there are no resolved superclasses for the - * given class. - * - *NOTE: once a type hierarchy has been created, it is more efficient to
- * query the hierarchy for superclasses than to query a class recursively up
- * the superclass chain. Querying an element performs a dynamic resolution,
- * whereas the hierarchy returns a pre-computed result.
- *
- * @param type the given type
- * @return all resolved superclasses of the given class, in bottom-up order, an empty
- * array if none.
- */
-ICElement[] getAllSupertypes(ICElement type);
-
-/**
- * Returns all classes in the graph which have no resolved superclass,
- * in no particular order.
- *
- * @return all classes in the graph which have no resolved superclass
- */
-ICElement[] getRootClasses();
-
-/**
- * Returns the direct resolved subtypes of the given type,
- * in no particular order, limited to the types in this
- * type hierarchy's graph.
- * If the type is a class, this returns the resolved subclasses.
- * If the type is an interface, this returns both the classes which implement
- * the interface and the interfaces which extend it.
- *
- * @param type the given type
- * @return the direct resolved subtypes of the given type limited to the types in this
- * type hierarchy's graph
- */
-ICElement[] getSubtypes(ICElement type);
-
-/**
- * Returns the resolved supertypes of the given type,
- * in no particular order, limited to the types in this
- * type hierarchy's graph.
- * For classes, this returns its superclass and the interfaces that the class implements.
- * For interfaces, this returns the interfaces that the interface extends. As a consequence
- * java.lang.Object
is NOT considered to be a supertype of any interface
- * type.
- *
- * @param type the given type
- * @return the resolved supertypes of the given type limited to the types in this
- * type hierarchy's graph
- */
-ICElement[] getSupertypes(ICElement type);
-/**
- * Returns the type this hierarchy was computed for.
- * Returns null
if this hierarchy was computed for a region.
- *
- * @return the type this hierarchy was computed for
- */
-ICElement getType();
-/**
- * Re-computes the type hierarchy reporting progress.
- *
- * @param monitor the given progress monitor
- * @exception JavaModelException if unable to refresh the hierarchy
- */
-void refresh(IProgressMonitor monitor) throws CModelException;
-/**
- * Removes the given listener from this type hierarchy.
- * Has no affect if an identical listener is not registered.
- *
- * @param listener the listener
- */
-void removeTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener);
-/**
- * Stores the type hierarchy in an output stream. This stored hierarchy can be load by
- * ICElement#loadTypeHierachy(IJavaProject, InputStream, IProgressMonitor).
- * Listeners of this hierarchy are not stored.
- *
- * Only hierarchies created by the following methods can be store:
- *
- * This interface may be implemented by clients. - *
- */ -public interface ITypeHierarchyChangedListener { - /** - * Notifies that the given type hierarchy has changed in some way and should - * be refreshed at some point to make it consistent with the current state of - * the Java model. - * - * @param typeHierarchy the given type hierarchy - */ - void typeHierarchyChanged(ITypeHierarchy typeHierarchy); -} diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchy.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchy.java deleted file mode 100644 index 5288ff7e649..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchy.java +++ /dev/null @@ -1,582 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.browser.typehierarchy; - -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.cdt.core.ICLogConstants; -import org.eclipse.cdt.core.browser.AllTypesCache; -import org.eclipse.cdt.core.browser.ITypeInfo; -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ElementChangedEvent; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICElementDelta; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.IElementChangedListener; -import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; -import org.eclipse.cdt.core.search.ICSearchScope; -import org.eclipse.cdt.internal.core.model.Util; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.Platform; - -public class TypeHierarchy implements ITypeHierarchy, IElementChangedListener { - - public static boolean DEBUG = false; - - private static final class TypeEntry { - ITypeInfo type; - ASTAccessVisibility access; - TypeEntry(ITypeInfo type, ASTAccessVisibility access) { - this.type = type; - this.access = access; - } - } - private static final int INITIAL_SUPER_TYPES = 1; - private static final int INITIAL_SUB_TYPES = 1; - private static final ITypeInfo[] NO_TYPES = new ITypeInfo[0]; - private ArrayList fRootTypes = new ArrayList(); - private Map fTypeToSuperTypes = new HashMap(); - private Map fTypeToSubTypes = new HashMap(); - - private ITypeInfo fFocusType; - - /** - * The progress monitor to report work completed too. - */ - protected IProgressMonitor fProgressMonitor = null; - /** - * Change listeners - null if no one is listening. - */ - protected ArrayList fChangeListeners = null; - - /* - * A map from Openables to ArrayLists of ITypes - */ - public Map files = null; - - /** - * Whether this hierarchy should contains subtypes. - */ - protected boolean fComputeSubtypes; - - /** - * The scope this hierarchy should restrain itsef in. - */ - ICSearchScope fScope; - - /* - * Whether this hierarchy needs refresh - */ - public boolean fNeedsRefresh = true; -// /* -// * Collects changes to types -// */ -// protected ChangeCollector fChangeCollector; - - - - /** - * Creates a TypeHierarchy on the given type. - */ - public TypeHierarchy(ITypeInfo type) { - fFocusType = type; - } - - /** - * Adds the type to the collection of root classes - * if the classes is not already present in the collection. - */ - public void addRootType(ITypeInfo type) { - if (!fRootTypes.contains(type)) { - fRootTypes.add(type); - } - } - - /** - * Adds the given supertype to the type. - */ - public void addSuperType(ITypeInfo type, ITypeInfo superType, ASTAccessVisibility access) { - Collection superEntries = (Collection) fTypeToSuperTypes.get(type); - if (superEntries == null) { - superEntries = new ArrayList(INITIAL_SUPER_TYPES); - fTypeToSuperTypes.put(type, superEntries); - } - Collection subTypes = (Collection) fTypeToSubTypes.get(superType); - if (subTypes == null) { - subTypes = new ArrayList(INITIAL_SUB_TYPES); - fTypeToSubTypes.put(superType, subTypes); - } - if (!subTypes.contains(type)) { - subTypes.add(type); - } - for (Iterator i = superEntries.iterator(); i.hasNext(); ) { - TypeEntry entry = (TypeEntry)i.next(); - if (entry.type.equals(superType)) { - // update the access - entry.access = access; - return; // don't add if already exists - } - } - TypeEntry typeEntry = new TypeEntry(superType, access); - superEntries.add(typeEntry); - } - - /** - * Adds the given subtype to the type. - */ - protected void addSubType(ITypeInfo type, ITypeInfo subType) { - Collection subTypes = (Collection) fTypeToSubTypes.get(type); - if (subTypes == null) { - subTypes = new ArrayList(INITIAL_SUB_TYPES); - fTypeToSubTypes.put(type, subTypes); - } - if (!subTypes.contains(subType)) { - subTypes.add(subType); - } - - Collection superEntries = (Collection) fTypeToSuperTypes.get(subType); - if (superEntries == null) { - superEntries = new ArrayList(INITIAL_SUPER_TYPES); - fTypeToSuperTypes.put(subType, superEntries); - } - for (Iterator i = superEntries.iterator(); i.hasNext(); ) { - TypeEntry entry = (TypeEntry)i.next(); - if (entry.type.equals(type)) - return; // don't add if already exists - } - // default to private access - TypeEntry typeEntry = new TypeEntry(type, ASTAccessVisibility.PRIVATE); - superEntries.add(typeEntry); - } - - /** - * Returns true if type already has the given supertype. - */ - public boolean hasSuperType(ITypeInfo type, ITypeInfo superType) { - Collection entries = (Collection) fTypeToSuperTypes.get(type); - if (entries != null) { - for (Iterator i = entries.iterator(); i.hasNext(); ) { - TypeEntry entry = (TypeEntry)i.next(); - if (entry.type.equals(superType)) - return true; - } - } - return false; - } - - /** - * Returns an array of supertypes for the given type - will never return null. - */ - public ITypeInfo[] getSuperTypes(ITypeInfo type) { - Collection entries = (Collection) fTypeToSuperTypes.get(type); - if (entries != null) { - ArrayList superTypes = new ArrayList(INITIAL_SUPER_TYPES); - for (Iterator i = entries.iterator(); i.hasNext(); ) { - TypeEntry entry = (TypeEntry)i.next(); - superTypes.add(entry.type); - } - return (ITypeInfo[])superTypes.toArray(new ITypeInfo[superTypes.size()]); - } - return NO_TYPES; - } - - /** - * Returns an array of subtypes for the given type - will never return null. - */ - public ITypeInfo[] getSubTypes(ITypeInfo type) { - Collection subTypes = (Collection) fTypeToSubTypes.get(type); - if (subTypes != null) { - return (ITypeInfo[])subTypes.toArray(new ITypeInfo[subTypes.size()]); - } - return NO_TYPES; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#addTypeHierarchyChangedListener(org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchyChangedListener) - */ - public void addTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener) { - ArrayList listeners = fChangeListeners; - if (listeners == null) { - fChangeListeners = listeners = new ArrayList(); - } - - // register with JavaCore to get Java element delta on first listener added - if (listeners.size() == 0) { - CoreModel.getDefault().addElementChangedListener(this); - } - - // add listener only if it is not already present - if (listeners.indexOf(listener) == -1) { - listeners.add(listener); - } - } - - - /** - * @see ITypeHierarchy - */ - public synchronized void removeTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener) { - ArrayList listeners = fChangeListeners; - if (listeners == null) { - return; - } - listeners.remove(listener); - - // deregister from JavaCore on last listener removed - if (listeners.isEmpty()) { - CoreModel.getDefault().removeElementChangedListener(this); - } - } - - /** - * Determines if the change effects this hierarchy, and fires - * change notification if required. - */ - public void elementChanged(ElementChangedEvent event) { - // type hierarchy change has already been fired - if (fNeedsRefresh) return; - - if (isAffected(event.getDelta())) { - fNeedsRefresh = true; - fireChange(); - } - } - - /** - * Returns true if the given delta could change this type hierarchy - */ - public synchronized boolean isAffected(ICElementDelta delta) { -// ICElement element= delta.getElement(); -// switch (element.getElementType()) { -// case ICElement.C_MODEL: -// return isAffectedByCModel(delta, element); -// case ICElement.C_PROJECT: -// return isAffectedByCProject(delta, element); -// case ICElement.C_UNIT: -// return isAffectedByOpenable(delta, element); -// } -// return false; - return true; - } - - /** - * Notifies listeners that this hierarchy has changed and needs - * refreshing. Note that listeners can be removed as we iterate - * through the list. - */ - public void fireChange() { - ArrayList listeners = fChangeListeners; - if (listeners == null) { - return; - } - if (DEBUG) { - System.out.println("FIRING hierarchy change ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ - if (fFocusType != null) { - System.out.println(" for hierarchy focused on " + fFocusType.toString()); //$NON-NLS-1$ - } - } - // clone so that a listener cannot have a side-effect on this list when being notified - listeners = (ArrayList)listeners.clone(); - for (int i= 0; i < listeners.size(); i++) { - final ITypeHierarchyChangedListener listener= (ITypeHierarchyChangedListener)listeners.get(i); - Platform.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - Util.log(exception, "Exception occurred in listener of Type hierarchy change notification", ICLogConstants.CDT); //$NON-NLS-1$ - } - public void run() throws Exception { - listener.typeHierarchyChanged(TypeHierarchy.this); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#contains(org.eclipse.cdt.core.model.ICElement) - */ - public boolean contains(ICElement type) { - // classes - ITypeInfo info = AllTypesCache.getTypeForElement(type, true, true, null); - - if (info == null) - return false; - - if (fTypeToSuperTypes.get(info) != null) { - return true; - } - - // root classes - if (fRootTypes.contains(type)) return true; - - return false; - } - - /** - * @see ITypeHierarchy - */ - public boolean exists() { - if (!fNeedsRefresh) return true; - - return (fFocusType == null || fFocusType.exists()) && cProject().exists(); - } - - /** - * Returns the C project this hierarchy was created in. - */ - public ICProject cProject() { - IProject project = fFocusType.getCache().getProject(); - return findCProject(project); - } - private ICProject findCProject(IProject project) { - try { - ICProject[] cProjects = CoreModel.getDefault().getCModel().getCProjects(); - if (cProjects != null) { - for (int i = 0; i < cProjects.length; ++i) { - ICProject cProject = cProjects[i]; - if (project.equals(cProjects[i].getProject())) - return cProject; - } - } - } catch (CModelException e) { - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#getAllClasses() - */ - public ICElement[] getAllClasses() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#getRootClasses() - */ - public ICElement[] getRootClasses() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#getSubtypes(org.eclipse.cdt.core.model.ICElement) - */ - public ICElement[] getSubtypes(ICElement type) { - List list = new ArrayList(); - ITypeInfo info = AllTypesCache.getTypeForElement(type, true, true, null); - Collection entries = (Collection) fTypeToSubTypes.get(info); - if (entries != null) { - for (Iterator i = entries.iterator(); i.hasNext(); ) { - ITypeInfo subType = (ITypeInfo)i.next(); - ICElement elem = AllTypesCache.getElementForType(subType, true, true, null); - if (elem != null) { - list.add(elem); - } - } - } - return (ICElement[])list.toArray(new ICElement[list.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#getAllSuperclasses(org.eclipse.cdt.core.model.ICElement) - */ - public ICElement[] getAllSubtypes(ICElement type) { - List list = new ArrayList(); - ITypeInfo info = AllTypesCache.getTypeForElement(type, true, true, null); - addSubs(info, list); - //convert list to ICElements - ICElement[] elems = new ICElement[list.size()]; - int count = 0; - for (Iterator i = list.iterator(); i.hasNext(); ) { - ITypeInfo subType = (ITypeInfo) i.next(); - elems[count++] = AllTypesCache.getElementForType(subType, true, true, null); - } - return elems; - } - - private void addSubs(ITypeInfo type, List list) { - Collection entries = (Collection) fTypeToSubTypes.get(type); - if (entries != null) { - for (Iterator i = entries.iterator(); i.hasNext(); ) { - ITypeInfo subType = (ITypeInfo)i.next(); - if (!list.contains(subType)) { - list.add(subType); - } - addSubs(subType, list); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#getSupertypes(org.eclipse.cdt.core.model.ICElement) - */ - public ICElement[] getSupertypes(ICElement type) { - List list = new ArrayList(); - ITypeInfo info = AllTypesCache.getTypeForElement(type, true, true, null); - Collection entries = (Collection) fTypeToSuperTypes.get(info); - if (entries != null) { - for (Iterator i = entries.iterator(); i.hasNext(); ) { - TypeEntry entry = (TypeEntry)i.next(); - ITypeInfo superType = entry.type; - ICElement elem = AllTypesCache.getElementForType(superType, true, true, null); - if (elem != null) { - list.add(elem); - } - } - } - return (ICElement[])list.toArray(new ICElement[list.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#getAllSuperclasses(org.eclipse.cdt.core.model.ICElement) - */ - public ICElement[] getAllSupertypes(ICElement type) { - List list = new ArrayList(); - ITypeInfo info = AllTypesCache.getTypeForElement(type, true, true, null); - addSupers(info, list); - //convert list to ICElements - ICElement[] elems = new ICElement[list.size()]; - int count = 0; - for (Iterator i = list.iterator(); i.hasNext(); ) { - ITypeInfo superType = (ITypeInfo) i.next(); - elems[count++] = AllTypesCache.getElementForType(superType, true, true, null); - } - return elems; - } - - private void addSupers(ITypeInfo type, List list) { - Collection entries = (Collection) fTypeToSuperTypes.get(type); - if (entries != null) { - for (Iterator i = entries.iterator(); i.hasNext(); ) { - TypeEntry entry = (TypeEntry)i.next(); - ITypeInfo superType = entry.type; - if (!list.contains(superType)) { - list.add(superType); - } - addSupers(superType, list); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#getType() - */ - public ICElement getType() { - if (fFocusType != null) - return AllTypesCache.getElementForType(fFocusType, true, true, null); - return null; - } - - /** - * @see ITypeHierarchy - * TODO (jerome) should use a PerThreadObject to build the hierarchy instead of synchronizing - * (see also isAffected(IJavaElementDelta)) - */ - public synchronized void refresh(IProgressMonitor monitor) throws CModelException { - try { - fProgressMonitor = monitor; - if (monitor != null) { - if (fFocusType != null) { - monitor.beginTask(TypeHierarchyMessages.getFormattedString("hierarchy.creatingOnType", fFocusType.getQualifiedTypeName().getFullyQualifiedName()), 100); //$NON-NLS-1$ - } else { - monitor.beginTask(TypeHierarchyMessages.getString("hierarchy.creating"), 100); //$NON-NLS-1$ - } - } - long start = -1; - if (DEBUG) { - start = System.currentTimeMillis(); - if (fComputeSubtypes) { - System.out.println("CREATING TYPE HIERARCHY [" + Thread.currentThread() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - System.out.println("CREATING SUPER TYPE HIERARCHY [" + Thread.currentThread() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ - } - if (fFocusType != null) { - System.out.println(" on type " + fFocusType.toString()); //$NON-NLS-1$ - } - } - - compute(); -// initializeRegions(); - fNeedsRefresh = false; -// fChangeCollector = null; - - if (DEBUG) { - if (fComputeSubtypes) { - System.out.println("CREATED TYPE HIERARCHY in " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - System.out.println("CREATED SUPER TYPE HIERARCHY in " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - } - System.out.println(this.toString()); - } - } finally { - if (monitor != null) { - monitor.done(); - } - fProgressMonitor = null; - } - } - - /** - * Compute this type hierarchy. - */ - protected void compute() { - if (fFocusType != null) { -// HierarchyBuilder builder = -// new IndexBasedHierarchyBuilder( -// this, -// this.scope); -// builder.build(this.computeSubtypes); - -// initialize(1); -// buildSupertypes(); - - } // else a RegionBasedTypeHierarchy should be used - } - - /** - * Initializes this hierarchy's internal tables with the given size. - */ - /* protected void initialize(int size) { - if (size < 10) { - size = 10; - } - int smallSize = (size / 2); - this.classToSuperclass = new HashMap(size); - this.interfaces = new ArrayList(smallSize); - this.missingTypes = new ArrayList(smallSize); - this.rootClasses = new TypeVector(); - this.typeToSubtypes = new HashMap(smallSize); - this.typeToSuperInterfaces = new HashMap(smallSize); - this.typeFlags = new HashMap(smallSize); - - this.projectRegion = new Region(); - this.packageRegion = new Region(); - this.files = new HashMap(5); - } -*/ - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy#store(java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor) - */ - public void store(OutputStream outputStream, IProgressMonitor monitor) throws CModelException { - // TODO Auto-generated method stub - - } - -} diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyBuilder.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyBuilder.java deleted file mode 100644 index cded12e9745..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyBuilder.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.browser.typehierarchy; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.cdt.core.browser.ITypeInfo; -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.ICModelStatusConstants; -import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; -import org.eclipse.cdt.internal.core.browser.cache.TypeCacheManager; -import org.eclipse.cdt.internal.core.model.CModelStatus; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; - -public class TypeHierarchyBuilder { - - public TypeHierarchyBuilder() { - } - - public ITypeHierarchy createTypeHierarchy(ITypeInfo info, boolean enableIndexing, IProgressMonitor monitor) throws CModelException { - TypeHierarchy typeHierarchy = new TypeHierarchy(info); - Set processedTypes = new HashSet(); - addSuperClasses(typeHierarchy, info, processedTypes, enableIndexing, monitor); - - typeHierarchy.addRootType(info); - processedTypes.clear(); - addSubClasses(typeHierarchy, info, processedTypes, enableIndexing, monitor); - - return typeHierarchy; - } - - private void addSuperClasses(TypeHierarchy typeHierarchy, ITypeInfo type, Set processedTypes, boolean enableIndexing, IProgressMonitor monitor) throws CModelException { - if (type.hasSuperTypes()) { - ITypeInfo[] superTypes = TypeCacheManager.getInstance().locateSuperTypesAndWait(type, enableIndexing, Job.SHORT, monitor); - if (superTypes == null) - throw new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST)); - - for (int i = 0; i < superTypes.length; ++i) { - ITypeInfo superType = superTypes[i]; - - // recursively process sub sub classes - if (!processedTypes.contains(superType)) { - processedTypes.add(superType); - addSuperClasses(typeHierarchy, superType, processedTypes, enableIndexing, monitor); - } - - ASTAccessVisibility access = type.getSuperTypeAccess(superType); - - typeHierarchy.addSuperType(type, superType, access); - } - } else { - typeHierarchy.addRootType(type); - } - } - - private void addSubClasses(TypeHierarchy typeHierarchy, ITypeInfo type, Set processedTypes, boolean enableIndexing, IProgressMonitor monitor) throws CModelException { - if (type.hasSubTypes()) { - ITypeInfo[] subTypes = TypeCacheManager.getInstance().locateSubTypesAndWait(type, enableIndexing, Job.SHORT, monitor); - if (subTypes == null) - throw new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST)); - - for (int i = 0; i < subTypes.length; ++i) { - ITypeInfo subType = subTypes[i]; - - // recursively process sub sub classes - if (!processedTypes.contains(subType)) { - processedTypes.add(subType); - addSubClasses(typeHierarchy, subType, processedTypes, enableIndexing, monitor); - } - - typeHierarchy.addSubType(type, subType); - } - } - } - -/* - private IStructure findCElementForType(ITypeInfo info, boolean enableIndexing, IProgressMonitor monitor) throws CModelException { - if (!info.exists()) - throw new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST)); - - if (!info.isClass()) - throw new CModelException(new CModelStatus(ICModelStatusConstants.INVALID_ELEMENT_TYPES)); - - // first we need to resolve the type location - ITypeReference location = TypeCacheManager.getInstance().locateTypeAndWait(info, enableIndexing, Job.SHORT, monitor); - if (location == null) - throw new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST)); - - ICElement cElem = location.getCElement(); - if (cElem == null) - throw new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST)); - - if (!(cElem instanceof IStructure)) - throw new CModelException(new CModelStatus(ICModelStatusConstants.INVALID_ELEMENT_TYPES)); - - IStructure cClass = (IStructure)cElem; - - // check if type exists in cache - ITypeInfo type = TypeCacheManager.getInstance().getTypeForElement(cElem); - if (type == null || !type.equals(info)) - throw new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST)); - - return cClass; - } - - private ITypeInfo findTypeInCache(ITypeCache cache, String name) { - IQualifiedTypeName qualName = new QualifiedTypeName(name); - ITypeInfo[] superTypes = cache.getTypes(qualName); - for (int i = 0; i < superTypes.length; ++i) { - ITypeInfo superType = superTypes[i]; - if (superType.isClass()) { - return superType; - } - } - return null; - } -*/ - -} diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyMessages.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyMessages.java deleted file mode 100644 index 467841057cf..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyMessages.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.browser.typehierarchy; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class TypeHierarchyMessages { - - private static final String RESOURCE_BUNDLE= TypeHierarchyMessages.class.getName(); - - private static ResourceBundle fgResourceBundle; - static { - try { - fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); - } catch (MissingResourceException x) { - fgResourceBundle = null; - } - } - - private TypeHierarchyMessages() { - } - - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } catch (NullPointerException e) { - return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - public static String getFormattedString(String key, String arg) { - return getFormattedString(key, new String[] { arg }); - } - - public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), args); - } -} diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyMessages.properties b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyMessages.properties deleted file mode 100644 index 760292b333c..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/typehierarchy/TypeHierarchyMessages.properties +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2004 QNX Software Systems and others. -# All rights reserved. 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: -# QNX Software Systems - Initial API and implementation -############################################################################### - -### hierarchy -hierarchy.nullProject = Project argument cannot be null -hierarchy.nullRegion = Region cannot be null -hierarchy.nullFocusType = Type focus cannot be null -hierarchy.creating = Creating type hierarchy... -hierarchy.creatingOnType = Creating type hierarchy on {0}... diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/BasicJob.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/BasicJob.java deleted file mode 100644 index 7bf631918b1..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/BasicJob.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.browser.cache; - -import org.eclipse.cdt.internal.core.browser.util.DelegatedProgressMonitor; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; - -public abstract class BasicJob extends Job { - - private Object fFamily; - private DelegatedProgressMonitor fProgressMonitor= new DelegatedProgressMonitor(); - private Object fRunLock = new Object(); - private boolean fIsRunning = false; - private static boolean VERBOSE = false; - - public BasicJob(String name, Object family) { - super(name); - fFamily = family; - setPriority(BUILD); - setSystem(true); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(IProgressMonitor) - */ - protected abstract IStatus runWithDelegatedProgress(IProgressMonitor monitor) throws InterruptedException; - - /* (non-Javadoc) - * @see org.eclipse.core.internal.jobs.InternalJob#belongsTo(java.lang.Object) - */ - public boolean belongsTo(Object family) { - if (fFamily != null) { - return fFamily.equals(family); - } - return false; - } - - public boolean isRunning() { - synchronized(fRunLock) { - return fIsRunning; - } - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(IProgressMonitor) - */ - public IStatus run(IProgressMonitor monitor) { - synchronized(fRunLock) { - fIsRunning = true; - } - - fProgressMonitor.init(); - fProgressMonitor.addDelegate(monitor); - - IStatus result = Status.CANCEL_STATUS; - try { - if (monitor.isCanceled()) - throw new InterruptedException(); - - result = runWithDelegatedProgress(fProgressMonitor); - - if (monitor.isCanceled()) - throw new InterruptedException(); - } catch(InterruptedException ex) { - return Status.CANCEL_STATUS; - } catch (OperationCanceledException ex) { - return Status.CANCEL_STATUS; - } finally { - fProgressMonitor.done(); - fProgressMonitor.removeAllDelegates(); - fProgressMonitor.init(); - - synchronized(fRunLock) { - fIsRunning = false; - } - } - return result; - } - - /** - * Forwards progress info to the progress monitor and - * blocks until the job is finished. - * - * @param monitor the progress monitor. - * @throws InterruptedException - * - * @see Job#join - */ - public void join(IProgressMonitor monitor) throws InterruptedException { - if (monitor != null) { - fProgressMonitor.addDelegate(monitor); - } - super.join(); - } - - /** - * Outputs message to console. - */ - protected static void trace(String msg) { - if (VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") " + msg); //$NON-NLS-1$ //$NON-NLS-2$ - } - } -} diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/ITypeCache.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/ITypeCache.java deleted file mode 100644 index d4e73fbdaef..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/ITypeCache.java +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.browser.cache; - -import org.eclipse.cdt.core.browser.IQualifiedTypeName; -import org.eclipse.cdt.core.browser.ITypeInfo; -import org.eclipse.cdt.core.browser.ITypeInfoVisitor; -import org.eclipse.cdt.core.browser.ITypeReference; -import org.eclipse.cdt.core.browser.ITypeSearchScope; -import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; - -public interface ITypeCache extends ISchedulingRule { - - /** Returns whether cache contains any types. - * - * @returntrue
if cache is empty
- */
- public boolean isEmpty();
-
- /** Returns whether cache is complete.
- *
- * @return true
if cache is up to date.
- */
- public boolean isUpToDate();
-
- /** Inserts type into cache.
- *
- * @param info
- */
- public void insert(ITypeInfo info);
-
- /** Adds subtype to type.
- *
- * @param type
- * @param subtype
- */
- public void addSubtype(ITypeInfo type, ITypeInfo subtype);
-
- /** Adds supertype to type.
- *
- * @param type the type
- * @param supertype the supertype
- * @param the access visibility (PUBLIC, PROTECTED, PRIVATE)
- * @param isVirtual true
if virtual base class
- */
- public void addSupertype(ITypeInfo type, ITypeInfo supertype, ASTAccessVisibility access, boolean isVirtual);
-
- /** Removes type from cache.
- *
- * @param info
- */
- public void remove(ITypeInfo info);
-
- /** Removes all types in the given scope.
- *
- * @param scope
- */
- public void flush(ITypeSearchScope scope);
-
- /** Removes all types referenced by the given path.
- *
- * @param path
- */
- public void flush(IPath path);
-
- /** Removes all types from the cache.
- */
- public void flushAll();
-
- /** Returns all paths in the cache which are enclosed by
- * the given scope. If no paths are found, an empty
- * array is returned.
- *
- * @param scope the scope to search, or null
to
- * search the entire cache.
- * @return A collection of paths in the given scope.
- */
- public IPath[] getPaths(ITypeSearchScope scope);
-
- /** Returns all types in the cache which are enclosed by
- * the given scope. If no types are found, an empty array
- * is returned.
- *
- * @param scope the scope to search, or null
to
- * search the entire cache.
- * @return Array of types in the given scope
- */
- public ITypeInfo[] getTypes(ITypeSearchScope scope);
-
- /** Returns all types in the cache which match the given
- * name. If no types are found, an empty array is returned.
- *
- * @param qualifiedName the qualified type name to match
- * @param matchEnclosed true
if enclosed types count as matches (foo::bar == bar)
- * @param ignoreCase true
if case-insensitive
- * @return Array of types
- */
- public ITypeInfo[] getTypes(IQualifiedTypeName qualifiedName, boolean matchEnclosed, boolean ignoreCase);
-
- /** Returns first type in the cache which matches the given
- * type and name. If no type is found, null
- * is returned.
- *
- * @param type the ICElement type
- * @param qualifiedName the qualified type name to match
- * @return the matching type
- */
- public ITypeInfo getType(int type, IQualifiedTypeName qualifiedName);
-
- /** Gets the first enclosing type which matches one of the given kinds.
- *
- * @param info the given type
- * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS, C_STRUCT
- *
- * @return the enclosing type, or null
if not found.
- */
- public ITypeInfo getEnclosingType(ITypeInfo info, int[] kinds);
-
- /** Returns the enclosing namespace for the given type, or
- * null
if none exists.
- *
- * @param type the ICElement type
- * @param includeGlobalNamespace true
if the global (default) namespace should be returned
- * @return the enclosing namespace, or null
if not found.
- */
- public ITypeInfo getEnclosingNamespace(ITypeInfo info, boolean includeGlobalNamespace);
-
- /** Gets the root namespace of which encloses the given type.
- *
- * @param info the given type
- * @param includeGlobalNamespace true
if the global (default) namespace should be returned
- * @return the enclosing namespace, or null
if not found.
- */
- public ITypeInfo getRootNamespace(ITypeInfo info, boolean includeGlobalNamespace);
-
- /** Returns whether any types are enclosed by the given type.
- *
- * @param info the given type
- * @return true
if the given type encloses other types.
- */
- public boolean hasEnclosedTypes(ITypeInfo info);
-
- /** Gets the types which are enclosed by the given type.
- *
- * @param info the given type
- * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS,
- * C_UNION, C_ENUMERATION, C_TYPEDEF
- * @return the enclosed types, or an empty array if not found.
- */
- public ITypeInfo[] getEnclosedTypes(ITypeInfo info, int kinds[]);
-
- /** Returns all types in the cache are supertypes of the given type.
- *
- * @param info the given type
- * @return Array of supertypes, or null
if none found.
- */
- public ITypeInfo[] getSupertypes(ITypeInfo info);
-
- /** Returns the supertype access visiblity.
- *
- * @param type the given type
- * @param supertype the supertype
- * @return the visibility (PRIVATE, PROTECTED, PUBLIC) or null
if none found.
- */
- public ASTAccessVisibility getSupertypeAccess(ITypeInfo type, ITypeInfo superType);
-
-
- /** Returns all types in the cache which extend the given type.
- *
- * @param info the given type
- * @return Array of subtypes, or null
if none found.
- */
- public ITypeInfo[] getSubtypes(ITypeInfo info);
-
- /** Returns the project associated with this cache.
- *
- * @return the project
- */
- public IProject getProject();
-
- /** Accepts a visitor and iterates over all types in the cache.
- *
- * @param visitor
- */
- public void accept(ITypeInfoVisitor visitor);
-
- public void addDelta(TypeCacheDelta delta);
- public void reconcile(boolean enableIndexing, int priority, int delay);
- public void reconcileAndWait(boolean enableIndexing, int priority, IProgressMonitor monitor);
- public void cancelJobs();
-
- public void locateType(ITypeInfo info, int priority, int delay);
- public ITypeReference locateTypeAndWait(ITypeInfo info, int priority, IProgressMonitor monitor);
-
- public void locateSupertypes(ITypeInfo info, int priority, int delay);
- public ITypeInfo[] locateSupertypesAndWait(ITypeInfo info, int priority, IProgressMonitor monitor);
-
- public void locateSubtypes(ITypeInfo info, int priority, int delay);
- public ITypeInfo[] locateSubtypesAndWait(ITypeInfo info, int priority, IProgressMonitor monitor);
-
- public ITypeInfo getGlobalNamespace();
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerDependenciesJob.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerDependenciesJob.java
deleted file mode 100644
index 3e87fdf7d50..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerDependenciesJob.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.internal.core.index.IEntryResult;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.cindexstorage.Index;
-import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class IndexerDependenciesJob extends IndexerJob {
-
- private ITypeCache fTypeCache;
- private ITypeSearchScope fScope;
-
- public IndexerDependenciesJob(IndexManager indexManager, ITypeCache typeCache, ITypeSearchScope scope) {
- super(indexManager, typeCache.getProject());
- fTypeCache = typeCache;
- fScope = scope;
- }
-
- protected boolean processIndex(IIndex index, IProject project, IProgressMonitor progressMonitor) throws InterruptedException {
- IndexInput input = new BlocksIndexInput(index.getIndexFile());
- try {
- input.open();
- flushDependencies(input, progressMonitor);
- return true;
- } catch (IOException e) {
- return false;
- } finally {
- try {
- input.close();
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- private void flushDependencies(IndexInput input, IProgressMonitor progressMonitor)
- throws InterruptedException, IOException {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult[] includeEntries = input.queryEntriesPrefixedBy(Index.encodeEntry(IIndex.INCLUDE, IIndex.ANY, IIndex.REFERENCE));
- if (includeEntries != null) {
- //TODO subprogress monitor
- for (int i = 0; i < includeEntries.length; ++i) {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult entry = includeEntries[i];
- IPath includePath = getIncludePath(entry);
-
- if (fScope != null && fScope.encloses(includePath)) {
- int[] references = entry.getFileReferences();
- if (references != null) {
- for (int j = 0; j < references.length; ++j) {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- IndexedFileEntry file = input.getIndexedFile(references[j]);
- if (file != null && file.getPath() != null) {
- IPath path = PathUtil.getWorkspaceRelativePath(file.getPath());
- fTypeCache.flush(path);
- }
- }
- }
- }
- }
- }
- }
-
- private IPath getIncludePath(IEntryResult entry) {
- return PathUtil.getWorkspaceRelativePath(entry.getName());
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerDependenciesJob2.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerDependenciesJob2.java
deleted file mode 100644
index 9b5718de1d7..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerDependenciesJob2.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.internal.core.index.IEntryResult;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.cindexstorage.Index;
-import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class IndexerDependenciesJob2 extends IndexerJob2 {
-
- private ITypeCache fTypeCache;
- private ITypeSearchScope fScope;
-
- public IndexerDependenciesJob2(IndexManager indexManager, ITypeCache typeCache, ITypeSearchScope scope) {
- super(indexManager, typeCache.getProject());
- fTypeCache = typeCache;
- fScope = scope;
- }
-
- protected boolean processIndex(IProgressMonitor progressMonitor) throws InterruptedException {
- IndexInput input = new BlocksIndexInput(fProjectIndex.getIndexFile());
- try {
- input.open();
- flushDependencies(input, progressMonitor);
- return true;
- } catch (IOException e) {
- return false;
- } finally {
- try {
- input.close();
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- private void flushDependencies(IndexInput input, IProgressMonitor progressMonitor)
- throws InterruptedException, IOException {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult[] includeEntries = input.queryEntriesPrefixedBy(Index.encodeEntry(IIndex.INCLUDE, IIndex.ANY, IIndex.REFERENCE));
- if (includeEntries != null) {
- //TODO subprogress monitor
- for (int i = 0; i < includeEntries.length; ++i) {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult entry = includeEntries[i];
- IPath includePath = getIncludePath(entry);
-
- if (fScope != null && fScope.encloses(includePath)) {
- int[] references = entry.getFileReferences();
- if (references != null) {
- for (int j = 0; j < references.length; ++j) {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- IndexedFileEntry file = input.getIndexedFile(references[j]);
- if (file != null && file.getPath() != null) {
- IPath path = PathUtil.getWorkspaceRelativePath(file.getPath());
- fTypeCache.flush(path);
- }
- }
- }
- }
- }
- }
- }
-
- private IPath getIncludePath(IEntryResult entry) {
- return PathUtil.getWorkspaceRelativePath(entry.getName());
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerJob.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerJob.java
deleted file mode 100644
index 4de9fba649a..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerJob.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial implementation
- * QNX Software Systems - adapted for type cache
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.index.ICDTIndexer;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
-import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-public abstract class IndexerJob implements IIndexJob {
-
- private IndexManager fIndexManager;
- private IProject fProject;
- private IIndex fProjectIndex = null;
- private DOMSourceIndexer fSourceIndexer = null;
-
- public static final String FAMILY= "BasicTypeIndexerJob"; //$NON-NLS-1$
-
- public IndexerJob(IndexManager indexManager, IProject project) {
- fIndexManager = indexManager;
- fProject = project;
- //Get the indexer assigned to this project; check to see if it's
- //a Source Indexder
- ICDTIndexer indexer = indexManager.getIndexerForProject(project);
- if (indexer instanceof DOMSourceIndexer)
- fSourceIndexer = (DOMSourceIndexer) indexer;
- }
-
- public boolean belongsTo(String family) {
- return family == FAMILY;
- }
-
- public void cancel() {
- }
-
- public boolean isReadyToRun() {
- if (fProjectIndex == null) { // only check once. As long as this job is used, it will keep the same index picture
- getIndexForProject(fProject); // will only cache answer if all indexes were available originally
- }
- return true;
- }
-
- public String toString() {
- return FAMILY;
- }
-
- protected abstract boolean processIndex(IIndex index, IProject project, IProgressMonitor progressMonitor) throws InterruptedException;
-
- public boolean execute(IProgressMonitor progressMonitor) {
- boolean success = false;
- try {
- fProjectIndex = getIndexForProject(fProject);
- if (fProjectIndex == null)
- return false;
-
- if (progressMonitor == null) {
- progressMonitor = new NullProgressMonitor();
- }
- if (progressMonitor.isCanceled())
- throw new OperationCanceledException();
-
- progressMonitor.beginTask("", 1); //$NON-NLS-1$
-
- success = prepareIndex(fProjectIndex, fProject, progressMonitor);
-
- if (progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- progressMonitor.worked(1);
-
- return success;
- } catch (InterruptedException e) {
- throw new OperationCanceledException();
- } finally {
- progressMonitor.done();
- }
- }
-
- private boolean prepareIndex(IIndex index, IProject project, IProgressMonitor progressMonitor) throws InterruptedException {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- if (index == null)
- return COMPLETE;
-
- if (fSourceIndexer == null)
- return FAILED;
-
- ReadWriteMonitor monitor = fSourceIndexer.getMonitorFor(index);
-
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
-
- try {
- monitor.enterRead(); // ask permission to read
- /* if index has changed, commit these before querying */
- if (index.hasChanged()) {
- try {
- monitor.exitRead(); // free read lock
- monitor.enterWrite(); // ask permission to write
- fSourceIndexer.saveIndex(index);
- } catch (IOException e) {
- return FAILED;
- } finally {
- monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
- }
- }
-
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- return processIndex(index, project, progressMonitor);
- } finally {
- monitor.exitRead(); // finished reading
- }
- }
-
- private IIndex getIndexForProject(IProject project) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IPath path = project.getFullPath();
- IPath location;
- if ((!root.getProject(path.lastSegment()).exists()) // if project does not exist
- && path.segmentCount() > 1
- && ((location = root.getFile(path).getLocation()) == null
- || !new java.io.File(location.toOSString()).exists()) // and internal jar file does not exist
- && !new java.io.File(path.toOSString()).exists()) { // and external jar file does not exist
- return null;
- }
-
- // may trigger some index recreation work
- if (fSourceIndexer != null)
- return fSourceIndexer.getIndex(path, true /*reuse index file*/, false /*do not create if none*/);
-
- return null;
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerJob2.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerJob2.java
deleted file mode 100644
index 51be068de3e..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerJob2.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004,2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- * QNX Software Systems - adapted for type cache
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.index.ICDTIndexer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
-import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-public abstract class IndexerJob2 implements IIndexJob {
-
- protected IProject fProject;
- protected IIndex fProjectIndex = null;
- protected ICDTIndexer fSourceIndexer = null;
-
- public static final String FAMILY= "IndexerJob2"; //$NON-NLS-1$
-
- public IndexerJob2(IndexManager indexManager, IProject project) {
- fProject = project;
- fSourceIndexer = indexManager.getIndexerForProject(project);
- fProjectIndex = getIndexForProject();
- }
-
- public boolean belongsTo(String family) {
- return family == FAMILY;
- }
-
- public void cancel() {
- }
-
- public boolean isReadyToRun() {
- return true;
- }
-
- public String toString() {
- return FAMILY;
- }
-
- protected abstract boolean processIndex(IProgressMonitor progressMonitor) throws InterruptedException;
-
- public boolean execute(IProgressMonitor progressMonitor) {
- boolean success = false;
- try {
- if (fProjectIndex == null)
- return false;
-
- if (progressMonitor == null) {
- progressMonitor = new NullProgressMonitor();
- }
- if (progressMonitor.isCanceled())
- throw new OperationCanceledException();
-
- progressMonitor.beginTask("", 1); //$NON-NLS-1$
-
- success = prepareIndex(progressMonitor);
-
- if (progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- progressMonitor.worked(1);
-
- return success;
- } catch (InterruptedException e) {
- throw new OperationCanceledException();
- } finally {
- progressMonitor.done();
- }
- }
-
- private boolean prepareIndex(IProgressMonitor progressMonitor) throws InterruptedException {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- if (fProjectIndex == null)
- return COMPLETE;
-
- if (fSourceIndexer == null)
- return FAILED;
-
- ReadWriteMonitor monitor = fSourceIndexer.getMonitorFor(fProjectIndex);
-
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
-
- try {
- monitor.enterRead(); // ask permission to read
- /* if index has changed, commit these before querying */
- if (fProjectIndex.hasChanged()) {
- try {
- monitor.exitRead(); // free read lock
- monitor.enterWrite(); // ask permission to write
- fSourceIndexer.saveIndex(fProjectIndex);
- } catch (IOException e) {
- return FAILED;
- } finally {
- monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
- }
- }
-
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- return processIndex(progressMonitor);
- } finally {
- monitor.exitRead(); // finished reading
- }
- }
-
- private IIndex getIndexForProject() {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IPath path = fProject.getFullPath();
- IPath location;
- if ((!root.getProject(path.lastSegment()).exists()) // if project does not exist
- && path.segmentCount() > 1
- && ((location = root.getFile(path).getLocation()) == null
- || !new java.io.File(location.toOSString()).exists()) // and internal jar file does not exist
- && !new java.io.File(path.toOSString()).exists()) { // and external jar file does not exist
- return null;
- }
-
- // may trigger some index recreation work
- if (fSourceIndexer != null)
- return fSourceIndexer.getIndex(path, true /*reuse index file*/, false /*do not create if none*/);
-
- return null;
- }
-
- protected int index2ICElement( int kind )
- {
- switch(kind) {
- case IIndex.TYPE_CLASS:
- return ICElement.C_CLASS;
- case IIndex.TYPE_STRUCT:
- return ICElement.C_STRUCT;
- case IIndex.TYPE_ENUM:
- return ICElement.C_ENUMERATION;
- case IIndex.TYPE_UNION:
- return ICElement.C_UNION;
- case IIndex.TYPE_TYPEDEF:
- return ICElement.C_TYPEDEF;
- default:
- return 0;
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob.java
deleted file mode 100644
index d5509522612..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeInfo;
-import org.eclipse.cdt.core.browser.TypeReference;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.core.index.IEntryResult;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.cindexstorage.Index;
-import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class IndexerTypesJob extends IndexerJob {
-
- private ITypeCache fTypeCache;
-
- public IndexerTypesJob(IndexManager indexManager, ITypeCache typeCache, ITypeSearchScope scope) {
- super(indexManager, typeCache.getProject());
- fTypeCache = typeCache;
- }
-
- protected boolean processIndex(IIndex index, IProject project, IProgressMonitor progressMonitor) throws InterruptedException {
- IndexInput input = new BlocksIndexInput(index.getIndexFile());
- try {
- input.open();
- updateNamespaces(input, project, progressMonitor);
- updateTypes(input, project, progressMonitor);
- return true;
- } catch (IOException e) {
- return false;
- } finally {
- try {
- input.close();
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- private void updateNamespaces(IndexInput input, IProject project, IProgressMonitor monitor)
- throws InterruptedException, IOException {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult[] namespaceEntries = input.queryEntriesPrefixedBy(Index.encodeEntry(IIndex.NAMESPACE, IIndex.ANY, IIndex.DECLARATION));
- if (namespaceEntries != null) {
- //TODO subprogress monitor
- for (int i = 0; i < namespaceEntries.length; ++i) {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult entry = namespaceEntries[i];
- String name = entry.getName();
- if (name.length() != 0) {
- String[] enclosingNames = entry.getEnclosingNames();
- addType(input, project, entry, ICElement.C_NAMESPACE, name, enclosingNames, monitor);
- }
- }
- }
- }
-
- private void updateTypes(IndexInput input, IProject project, IProgressMonitor monitor)
- throws InterruptedException, IOException {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult[] typeEntries = input.queryEntriesPrefixedBy(Index.encodeEntry(IIndex.TYPE, IIndex.ANY, IIndex.DECLARATION));
- if (typeEntries != null) {
- //TODO subprogress monitor
- for (int i = 0; i < typeEntries.length; ++i) {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult entry = typeEntries[i];
-
- String name = entry.getName();
- switch (entry.getKind() ) {
- case IIndex.TYPE_CLASS :
- case IIndex.TYPE_STRUCT :
- case IIndex.TYPE_TYPEDEF :
- case IIndex.TYPE_ENUM :
- case IIndex.TYPE_UNION :
- if (name.length() != 0) { // skip anonymous structs
- addType(input, project, entry, entry.getKind(), name, entry.getEnclosingNames(), monitor);
- }
- break;
- case IIndex.TYPE_DERIVED :
- if (name.length() != 0) { // skip anonymous structs
- addSuperTypeReference(input, project, entry, name, entry.getEnclosingNames(), monitor);
- }
- break;
- default:
- break;
- }
- }
- }
- }
-
- private void addType(IndexInput input, IProject project, IEntryResult entry, int type, String name, String[] enclosingNames, IProgressMonitor monitor)
- throws InterruptedException, IOException {
- QualifiedTypeName qualifiedName = new QualifiedTypeName(name, enclosingNames);
- ITypeInfo info = fTypeCache.getType(type, qualifiedName);
- if (info == null || info.isUndefinedType()) {
- int[] references = entry.getFileReferences();
- if (references != null && references.length > 0) {
- // add new type to cache
- if (info != null) {
- info.setCElementType(type);
- } else {
- info = new TypeInfo(type, qualifiedName);
- fTypeCache.insert(info);
- }
-
-// for (int i = 0; i < references.length; ++i) {
-// if (monitor.isCanceled())
-// throw new InterruptedException();
-//
-// IndexedFile file = input.getIndexedFile(references[i]);
-// if (file != null && file.getPath() != null) {
-// IPath path = PathUtil.getWorkspaceRelativePath(file.getPath());
-// info.addReference(new TypeReference(path, project));
-// }
-// }
- // just grab the first reference
- IndexedFileEntry file = input.getIndexedFile(references[0]);
- if (file != null && file.getPath() != null) {
- IPath path = PathUtil.getWorkspaceRelativePath(file.getPath());
- info.addReference(new TypeReference(path, project));
- }
- }
- }
- }
-
- private void addSuperTypeReference(IndexInput input, IProject project, IEntryResult entry, String name, String[] enclosingNames, IProgressMonitor monitor) throws InterruptedException, IOException {
- QualifiedTypeName qualifiedName = new QualifiedTypeName(name, enclosingNames);
- ITypeInfo info = fTypeCache.getType(ICElement.C_CLASS, qualifiedName);
- if (info == null)
- info = fTypeCache.getType(ICElement.C_STRUCT, qualifiedName);
- if (info == null) {
- // add dummy type to cache
- info = new TypeInfo(0, qualifiedName);
- fTypeCache.insert(info);
- }
- int[] references = entry.getFileReferences();
- if (references != null && references.length > 0) {
- for (int i = 0; i < references.length; ++i) {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IndexedFileEntry file = input.getIndexedFile(references[i]);
- if (file != null && file.getPath() != null) {
- IPath path = PathUtil.getWorkspaceRelativePath(file.getPath());
- info.addDerivedReference(new TypeReference(path, project));
-//
-// // get absolute path
-// IPath path = new Path(file.getPath());
-// IPath projectPath = project.getFullPath();
-// if (projectPath.isPrefixOf(path)) {
-// path = project.getLocation().append(path.removeFirstSegments(projectPath.segmentCount()));
-// }
-// info.addDerivedReference(new TypeReference(path, project));
- }
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java
deleted file mode 100644
index daecedab086..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/IndexerTypesJob2.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeInfo;
-import org.eclipse.cdt.core.browser.TypeReference;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.core.index.IEntryResult;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.IQueryResult;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class IndexerTypesJob2 extends IndexerJob2 {
-
- private ITypeCache fTypeCache;
-
- public IndexerTypesJob2(IndexManager indexManager, ITypeCache typeCache, ITypeSearchScope scope) {
- super(indexManager, typeCache.getProject());
- fTypeCache = typeCache;
- }
-
- protected boolean processIndex(IProgressMonitor progressMonitor) throws InterruptedException {
- IndexInput input = null;
- try {
- input = new BlocksIndexInput( fProjectIndex.getIndexFile() );
- input.open();
- updateNamespaces(input, progressMonitor);
- updateTypes(input, progressMonitor);
- return true;
- } catch (IOException e) {
- return false;
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- // do nothing
- }
- }
- }
- }
-
- private void updateNamespaces(IndexInput input, IProgressMonitor monitor)
- throws InterruptedException, IOException {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult[] namespaceEntries = fProjectIndex.getEntries( IIndex.NAMESPACE, IIndex.ANY, IIndex.DEFINITION );
- IQueryResult[] namespacePaths = fProjectIndex.getPrefix(IIndex.NAMESPACE, IIndex.ANY, IIndex.DEFINITION );
-// input.queryEntriesPrefixedBy(Index.encodeEntry(IIndex.NAMESPACE, IIndex.ANY, IIndex.DECLARATION));
- if (namespaceEntries != null) {
- //TODO subprogress monitor
- for (int i = 0; i < namespaceEntries.length; ++i) {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult entry = namespaceEntries[i];
- String name = entry.getName();
- if (name.length() != 0) {
- String[] enclosingNames = entry.getEnclosingNames();
- addType(input, entry, namespacePaths[i].getPath(), ICElement.C_NAMESPACE, name, enclosingNames, monitor);
- }
- }
- }
- }
-
- private void updateTypes(IndexInput input, IProgressMonitor monitor)
- throws InterruptedException, IOException {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- for( int counter = 0; counter < 2; ++counter )
- {
- IEntryResult[] typeEntries = fProjectIndex.getEntries( IIndex.TYPE, IIndex.ANY, ( counter == 0 ) ? IIndex.DECLARATION : IIndex.DEFINITION );
-
- if (typeEntries != null) {
- //TODO subprogress monitor
- for (int i = 0; i < typeEntries.length; ++i) {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult entry = typeEntries[i];
-
- String name = entry.extractSimpleName();
- switch (entry.getKind() ) {
- case IIndex.TYPE_CLASS :
- case IIndex.TYPE_STRUCT :
- case IIndex.TYPE_TYPEDEF :
- case IIndex.TYPE_ENUM :
- case IIndex.TYPE_UNION :
- if (counter != 0 && name.length() != 0) { // skip anonymous structs
- addType(input, entry, null, index2ICElement( entry.getKind() ), name, entry.getEnclosingNames(), monitor);
- }
- break;
- default:
- break;
- }
- }
- }
- }
-
- IEntryResult[] typeEntries = fProjectIndex.getEntries( IIndex.TYPE, IIndex.TYPE_DERIVED, IIndex.ANY );
- if (typeEntries != null){
- for( int j = 0; j < typeEntries.length; ++j )
- {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- IEntryResult entry = typeEntries[j];
- String name = entry.extractSimpleName();
- switch( entry.getKind() )
- {
- case IIndex.TYPE_DERIVED :
- if (name.length() != 0) { // skip anonymous structs
- addSuperTypeReference(input, entry, name, entry.getEnclosingNames(), monitor);
- }
- break;
- default:
- break;
- }
- }
- }
- }
-
- private void addType(IndexInput input, IEntryResult entry, String pth, int type, String name, String[] enclosingNames, IProgressMonitor monitor)
- throws InterruptedException, IOException {
- QualifiedTypeName qualifiedName = new QualifiedTypeName(name, enclosingNames);
- ITypeInfo info = fTypeCache.getType(type, qualifiedName);
- if (info == null || info.isUndefinedType()) {
- int[] references = entry.getFileReferences();
- if (references != null && references.length > 0) {
- // add new type to cache
- if (info != null) {
- info.setCElementType(type);
- } else {
- info = new TypeInfo(type, qualifiedName);
- fTypeCache.insert(info);
- }
-
-// for (int i = 0; i < references.length; ++i) {
-// if (monitor.isCanceled())
-// throw new InterruptedException();
-//
-// IndexedFile file = input.getIndexedFile(references[i]);
-// if (file != null && file.getPath() != null) {
-// IPath path = PathUtil.getWorkspaceRelativePath(file.getPath());
-// info.addReference(new TypeReference(path, project));
-// }
-// }
- if (pth == null) {
- pth = input.getIndexedFile( references[0] ).getPath();
- }
-
- final IPath workspaceRelativePath = PathUtil.getWorkspaceRelativePath(pth);
- int offset = entry.getOffsets()[0][0];
-// int offsetType = Integer.valueOf(String.valueOf(offsets[i][j]).substring(0,1)).intValue();
- int offsetType = offset;
- int m = 1;
- while (offsetType >= 10) {
- offsetType = offsetType / 10;
- m *= 10;
- }
- int value = offset - ( offsetType * m );
-// int value = Integer.valueOf(String.valueOf(offset).substring(1)).intValue();
-
- TypeReference typeReference = null;
- if (offsetType==IIndex.LINE){
- typeReference = new TypeReference(workspaceRelativePath, fProject, value, 0 );
- typeReference.offsetIsLineNumber = true;
- }else if (offsetType==IIndex.OFFSET){
- typeReference = new TypeReference(workspaceRelativePath, fProject, value, entry.getOffsetLengths()[0][0] );
- }
- if( typeReference != null )
- info.addReference(typeReference);
- }
- }
- }
-
- private void addSuperTypeReference(IndexInput input, IEntryResult entry, String name, String[] enclosingNames, IProgressMonitor monitor) throws InterruptedException, IOException {
- QualifiedTypeName qualifiedName = new QualifiedTypeName(name, enclosingNames);
- ITypeInfo info = fTypeCache.getType(ICElement.C_CLASS, qualifiedName);
- if (info == null)
- info = fTypeCache.getType(ICElement.C_STRUCT, qualifiedName);
- if (info == null) {
- // add dummy type to cache
- info = new TypeInfo(0, qualifiedName);
- fTypeCache.insert(info);
- }
- int[] references = entry.getFileReferences();
- if (references != null && references.length > 0) {
- for (int i = 0; i < references.length; ++i) {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- String pth = input.getIndexedFile( references[i] ).getPath();
- IPath path = PathUtil.getWorkspaceRelativePath(pth);
-
- info.addDerivedReference(new TypeReference(path, fProject));
-//
-// // get absolute path
-// IPath path = new Path(file.getPath());
-// IPath projectPath = project.getFullPath();
-// if (projectPath.isPrefixOf(path)) {
-// path = project.getLocation().append(path.removeFirstSegments(projectPath.segmentCount()));
-// }
-// info.addDerivedReference(new TypeReference(path, project));
-
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/SubTypeLocatorJob.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/SubTypeLocatorJob.java
deleted file mode 100644
index 7909c033a9d..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/SubTypeLocatorJob.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.IWorkingCopyProvider;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-public class SubTypeLocatorJob extends BasicJob {
-
- public static final Object FAMILY = new Object();
- private ITypeInfo fLocateType;
- private ITypeCache fTypeCache;
- private IWorkingCopyProvider fWorkingCopyProvider;
-
- public SubTypeLocatorJob(ITypeInfo info, ITypeCache typeCache, IWorkingCopyProvider workingCopyProvider) {
- super(TypeCacheMessages.getString("SubTypeLocatorJob.jobName"), FAMILY); //$NON-NLS-1$
- fLocateType = info;
- fTypeCache = typeCache;
- fWorkingCopyProvider= workingCopyProvider;
- }
-
- public ITypeInfo getType() {
- return fLocateType;
- }
-
- protected IStatus runWithDelegatedProgress(IProgressMonitor monitor) throws InterruptedException {
- boolean success = false;
- long startTime = System.currentTimeMillis();
- trace("SubTypeLocatorJob: started"); //$NON-NLS-1$
-
- try {
- monitor.beginTask(TypeCacheMessages.getString("SubTypeLocatorJob.taskName"), 100); //$NON-NLS-1$
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- TypeParser parser = new TypeParser(fTypeCache, fWorkingCopyProvider);
- success = parser.findSubTypes(fLocateType, new SubProgressMonitor(monitor, 100));
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- } finally {
- long executionTime = System.currentTimeMillis() - startTime;
- if (success)
- trace("SubTypeLocatorJob: completed ("+ executionTime + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$
- else
- trace("SubTypeLocatorJob: aborted ("+ executionTime + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$
-
- monitor.done();
- }
-
- return Status.OK_STATUS;
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCache.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCache.java
deleted file mode 100644
index 592f7d99d39..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCache.java
+++ /dev/null
@@ -1,895 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeCacheChangedListener;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeInfoVisitor;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeInfo;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.index.ICDTIndexer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IWorkingCopyProvider;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.internal.core.browser.util.ArrayUtil;
-import org.eclipse.cdt.internal.core.model.CModelManager;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.IJobChangeListener;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-
-public class TypeCache implements ITypeCache {
-
- private static final int INITIAL_TYPE_COUNT = 100;
- private final Map fTypeKeyMap = new HashMap(INITIAL_TYPE_COUNT);
- final IProject fProject;
- private final IWorkingCopyProvider fWorkingCopyProvider;
- final Collection fDeltas = new ArrayList();
- final ITypeInfo fGlobalNamespace;
- private final Map fTypeToSubTypes = new HashMap();
- private final Map fTypeToSuperTypes = new HashMap();
- ITypeCacheChangedListener fChangeListener = null;
-
- private static final class SuperTypeEntry {
- ITypeInfo superType;
- ASTAccessVisibility access;
- boolean isVirtual;
- SuperTypeEntry(ITypeInfo superType, ASTAccessVisibility access, boolean isVirtual) {
- this.superType = superType;
- this.access = access;
- this.isVirtual = isVirtual;
- }
- }
-
- private SuperTypeEntry findSuperTypeEntry(Collection entryCollection, ITypeInfo superType) {
- for (Iterator i = entryCollection.iterator(); i.hasNext(); ) {
- SuperTypeEntry e = (SuperTypeEntry) i.next();
- if (e.superType.equals(superType)) {
- return e;
- }
- }
- return null;
- }
-
- private static final int[] ENCLOSING_TYPES = {ICElement.C_NAMESPACE, ICElement.C_CLASS, ICElement.C_STRUCT, 0};
-
- private IJobChangeListener fJobChangeListener = new IJobChangeListener() {
- public void aboutToRun(IJobChangeEvent event) {
- }
-
- public void awake(IJobChangeEvent event) {
- }
-
- public void done(IJobChangeEvent event) {
- Job job = event.getJob();
- if (job instanceof TypeCacherJob) {
- TypeCacherJob deltaJob = (TypeCacherJob)job;
- IStatus status = event.getResult();
- if (status != null) {
- boolean jobFinished = (status.equals(Status.OK_STATUS)
- && !deltaJob.isIndexerBusy());
- // remove the completed deltas
- synchronized(fDeltas) {
- for (Iterator i = fDeltas.iterator(); i.hasNext(); ) {
- TypeCacheDelta delta = (TypeCacheDelta) i.next();
- if (delta.getJob() != null && delta.getJob().equals(deltaJob)) {
- if (jobFinished) {
- i.remove();
- } else {
- delta.assignToJob(null);
- }
- }
- }
- }
- }
- // TODO finer-grained change deltas
- if (fChangeListener != null)
- fChangeListener.typeCacheChanged(fProject);
- }
- }
-
- public void running(IJobChangeEvent event) {
- }
-
- public void scheduled(IJobChangeEvent event) {
- }
-
- public void sleeping(IJobChangeEvent event) {
- }
- };
-
- private static class GlobalNamespace implements IQualifiedTypeName {
-
- private static final String GLOBAL_NAMESPACE = TypeCacheMessages.getString("TypeCache.globalNamespace"); //$NON-NLS-1$
- private static final String[] segments = new String[] { GLOBAL_NAMESPACE };
-
- public GlobalNamespace() {
- }
-
- public String getName() {
- return GLOBAL_NAMESPACE;
- }
-
- public String[] getEnclosingNames() {
- return null;
- }
-
- public String getFullyQualifiedName() {
- return GLOBAL_NAMESPACE;
- }
-
- public IQualifiedTypeName getEnclosingTypeName() {
- return null;
- }
-
- public boolean isEmpty() {
- return false;
- }
-
- public boolean isGlobal() {
- return true;
- }
-
- public boolean isQualified() {
- return false;
- }
-
- public boolean isValidSegment(String segment) {
- return false;
- }
-
- public int segmentCount() {
- return 1;
- }
-
- public String[] segments() {
- return segments;
- }
-
- public String segment(int index) {
- if (index > 0)
- return null;
- return GLOBAL_NAMESPACE;
- }
-
- public String lastSegment() {
- return GLOBAL_NAMESPACE;
- }
-
- public int matchingFirstSegments(IQualifiedTypeName typeName) {
- return 1;
- }
-
- public boolean isPrefixOf(IQualifiedTypeName typeName) {
- return true;
- }
-
- public IQualifiedTypeName append(String[] names) {
- return new QualifiedTypeName(names);
- }
-
- public IQualifiedTypeName append(IQualifiedTypeName typeName) {
- return new QualifiedTypeName(typeName);
- }
-
- public IQualifiedTypeName append(String qualifiedName) {
- return new QualifiedTypeName(qualifiedName);
- }
-
- public IQualifiedTypeName removeFirstSegments(int count) {
- return this;
- }
-
- public IQualifiedTypeName removeLastSegments(int count) {
- return this;
- }
-
- public boolean isLowLevel() {
- return false;
- }
-
- public boolean isValid() {
- return true;
- }
-
- public int hashCode() {
- return GLOBAL_NAMESPACE.hashCode();
- }
-
- public String toString() {
- return getFullyQualifiedName();
- }
-
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof IQualifiedTypeName)) {
- return false;
- }
- return equals((IQualifiedTypeName)obj);
- }
-
- public int compareTo(Object obj) {
- if (obj == this) {
- return 0;
- }
- if (!(obj instanceof IQualifiedTypeName)) {
- throw new ClassCastException();
- }
- return compareTo((IQualifiedTypeName)obj);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.browser.IQualifiedTypeName#equals(org.eclipse.cdt.core.browser.IQualifiedTypeName)
- */
- public boolean equals(IQualifiedTypeName typeName) {
- return (typeName instanceof GlobalNamespace);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.browser.IQualifiedTypeName#equalsIgnoreCase(org.eclipse.cdt.core.browser.IQualifiedTypeName)
- */
- public boolean equalsIgnoreCase(IQualifiedTypeName typeName) {
- return (typeName instanceof GlobalNamespace);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.browser.IQualifiedTypeName#compareTo(org.eclipse.cdt.core.browser.IQualifiedTypeName)
- */
- public int compareTo(IQualifiedTypeName typeName) {
- return getFullyQualifiedName().compareTo(typeName.getFullyQualifiedName());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.browser.IQualifiedTypeName#compareToIgnoreCase(org.eclipse.cdt.core.browser.IQualifiedTypeName)
- */
- public int compareToIgnoreCase(IQualifiedTypeName typeName) {
- return getFullyQualifiedName().compareToIgnoreCase(typeName.getFullyQualifiedName());
- }
- }
-
- private static class HashKey {
- private IQualifiedTypeName name;
- private int type;
- public HashKey(IQualifiedTypeName name, int type) {
- this.name = name;
- this.type = type;
- }
- public int hashCode() {
- return (this.name.hashCode() + this.type);
- }
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof HashKey)) {
- return false;
- }
- HashKey otherKey = (HashKey)obj;
- return (this.type == otherKey.type && this.name.equals(otherKey.name));
- }
- }
-
- public TypeCache(IProject project, IWorkingCopyProvider workingCopyProvider) {
- fProject = project;
- fWorkingCopyProvider = workingCopyProvider;
- fDeltas.add(new TypeCacheDelta(fProject));
- fGlobalNamespace = new TypeInfo(ICElement.C_NAMESPACE, new GlobalNamespace());
- fGlobalNamespace.setCache(this);
- }
-
- public TypeCache(IProject project, IWorkingCopyProvider workingCopyProvider, ITypeCacheChangedListener listener) {
- this(project, workingCopyProvider);
- fChangeListener = listener;
- }
-
- public boolean contains(ISchedulingRule rule) {
- if (this == rule)
- return true;
- if (rule instanceof ITypeCache) {
- ITypeCache typeCache = (ITypeCache) rule;
- if (fProject.equals(typeCache.getProject()))
- return true;
- }
- return false;
- }
-
- public boolean isConflicting(ISchedulingRule rule) {
- if (rule instanceof ITypeCache) {
- ITypeCache typeCache = (ITypeCache) rule;
- if (fProject.equals(typeCache.getProject()))
- return true;
- }
- return false;
- }
-
- public IProject getProject() {
- return fProject;
- }
-
- public synchronized boolean isEmpty() {
- return fTypeKeyMap.isEmpty();
- }
-
- public synchronized void insert(ITypeInfo newType) {
- // check if enclosing types are already in cache
- IQualifiedTypeName enclosingName = newType.getQualifiedTypeName().getEnclosingTypeName();
- if (enclosingName != null) {
- while (!enclosingName.isEmpty()) {
- // try namespace, class, struct, then undefined
- ITypeInfo enclosingType = null;
- for (int i = 0; enclosingType == null && i < ENCLOSING_TYPES.length; ++i) {
- enclosingType = (ITypeInfo) fTypeKeyMap.get(new HashKey(enclosingName, ENCLOSING_TYPES[i]));
- }
- if (enclosingType == null) {
- // create a dummy type to take this place (type 0 == unknown)
- ITypeInfo dummyType = new TypeInfo(0, enclosingName);
- dummyType.setCache(this);
- fTypeKeyMap.put(new HashKey(enclosingName, 0), dummyType);
- }
- enclosingName = enclosingName.removeLastSegments(1);
- }
- }
-
- fTypeKeyMap.put(new HashKey(newType.getQualifiedTypeName(), newType.getCElementType()), newType);
- newType.setCache(this);
- }
-
- public synchronized void remove(ITypeInfo info) {
- fTypeKeyMap.remove(new HashKey(info.getQualifiedTypeName(), info.getCElementType()));
- info.setCache(null);
- }
-
- public synchronized void flush(ITypeSearchScope scope) {
- if (scope.encloses(fProject)) {
- flushAll();
- } else {
- for (Iterator mapIter = fTypeKeyMap.entrySet().iterator(); mapIter.hasNext(); ) {
- Map.Entry entry = (Map.Entry) mapIter.next();
- ITypeInfo info = (ITypeInfo) entry.getValue();
- if (info.isEnclosed(scope)) {
- mapIter.remove();
- }
- }
- }
- }
-
- public synchronized void flush(IPath path) {
- ITypeSearchScope scope = new TypeSearchScope();
- scope.add(path, false, null);
- flush(scope);
- }
-
- public synchronized void flushAll() {
- // flush the entire cache
- accept(new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo info) {
- info.setCache(null);
- return true;
- }
- public boolean shouldContinue() { return true; }
- });
- fTypeKeyMap.clear();
- }
-
- public synchronized void addSupertype(ITypeInfo type, ITypeInfo supertype, ASTAccessVisibility access, boolean isVirtual) {
- Collection entryCollection = (Collection) fTypeToSuperTypes.get(type);
- if (entryCollection == null) {
- entryCollection = new ArrayList();
- fTypeToSuperTypes.put(type, entryCollection);
- }
- if (findSuperTypeEntry(entryCollection, supertype) == null) {
- entryCollection.add(new SuperTypeEntry(supertype, access, isVirtual));
- supertype.setCache(this);
- }
- }
-
- public synchronized ITypeInfo[] getSupertypes(ITypeInfo type) {
- Collection entryCollection = (Collection) fTypeToSuperTypes.get(type);
- if (entryCollection != null && !entryCollection.isEmpty()) {
- ITypeInfo[] superTypes = new ITypeInfo[entryCollection.size()];
- int count = 0;
- for (Iterator i = entryCollection.iterator(); i.hasNext(); ) {
- SuperTypeEntry e = (SuperTypeEntry) i.next();
- superTypes[count++] = e.superType;
- }
- return superTypes;
- }
- return null;
- }
-
- public ASTAccessVisibility getSupertypeAccess(ITypeInfo type, ITypeInfo superType) {
- Collection entryCollection = (Collection) fTypeToSuperTypes.get(type);
- if (entryCollection != null && !entryCollection.isEmpty()) {
- SuperTypeEntry e = findSuperTypeEntry(entryCollection, superType);
- if (e != null)
- return e.access;
- }
- return null;
- }
-
- public synchronized void addSubtype(ITypeInfo type, ITypeInfo subtype) {
- Collection typeCollection = (Collection) fTypeToSubTypes.get(type);
- if (typeCollection == null) {
- typeCollection = new ArrayList();
- fTypeToSubTypes.put(type, typeCollection);
- }
- if (!typeCollection.contains(subtype)) {
- typeCollection.add(subtype);
- subtype.setCache(this);
- }
- }
-
- public synchronized ITypeInfo[] getSubtypes(ITypeInfo type) {
- Collection typeCollection = (Collection) fTypeToSubTypes.get(type);
- if (typeCollection != null && !typeCollection.isEmpty()) {
- return (ITypeInfo[]) typeCollection.toArray(new ITypeInfo[typeCollection.size()]);
- }
- return null;
- }
-
- public synchronized void accept(ITypeInfoVisitor visitor) {
- for (Iterator mapIter = fTypeKeyMap.entrySet().iterator(); mapIter.hasNext(); ) {
- Map.Entry entry = (Map.Entry) mapIter.next();
- ITypeInfo info = (ITypeInfo) entry.getValue();
- if (!visitor.shouldContinue())
- return; // stop visiting
- visitor.visit(info);
- }
- }
-
- public synchronized IPath[] getPaths(final ITypeSearchScope scope) {
- final Set pathSet = new HashSet();
- accept(new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo info) {
- if (scope == null || info.isEnclosed(scope)) {
- ITypeReference[] refs = info.getReferences();
- if (refs != null) {
- for (int i = 0; i < refs.length; ++i) {
- IPath path = refs[i].getPath();
- if (scope == null || scope.encloses(path))
- pathSet.add(path);
- }
- }
- }
- return true;
- }
- public boolean shouldContinue() { return true; }
- });
- return (IPath[]) pathSet.toArray(new IPath[pathSet.size()]);
- }
-
- public synchronized ITypeInfo[] getTypes(final ITypeSearchScope scope) {
- final Collection results = new ArrayList();
- accept(new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo info) {
- if (scope == null || info.isEnclosed(scope)) {
- results.add(info);
- }
- return true;
- }
- public boolean shouldContinue() { return true; }
- });
- return (ITypeInfo[]) results.toArray(new ITypeInfo[results.size()]);
- }
-
- public synchronized ITypeInfo[] getTypes(IQualifiedTypeName qualifiedName, boolean matchEnclosed, boolean ignoreCase) {
- Collection results = new ArrayList();
- if (!ignoreCase && !matchEnclosed) {
- for (int i = 0; i < ITypeInfo.KNOWN_TYPES.length; ++i) {
- ITypeInfo info = (ITypeInfo) fTypeKeyMap.get(new HashKey(qualifiedName, ITypeInfo.KNOWN_TYPES[i]));
- if (info != null) {
- results.add(info);
- }
- }
- ITypeInfo info = (ITypeInfo) fTypeKeyMap.get(new HashKey(qualifiedName, 0));
- if (info != null) {
- results.add(info);
- }
- } else {
- // TODO this should probably use a more efficient search algorithm
- for (Iterator mapIter = fTypeKeyMap.entrySet().iterator(); mapIter.hasNext(); ) {
- Map.Entry entry = (Map.Entry) mapIter.next();
- ITypeInfo info = (ITypeInfo) entry.getValue();
- IQualifiedTypeName currName = info.getQualifiedTypeName();
-
- if (ignoreCase) {
- if (matchEnclosed && currName.segmentCount() > qualifiedName.segmentCount()
- && currName.lastSegment().equalsIgnoreCase(qualifiedName.lastSegment())) {
- currName = currName.removeFirstSegments(currName.segmentCount() - qualifiedName.segmentCount());
- }
- if (currName.equalsIgnoreCase(qualifiedName)) {
- results.add(info);
- }
- } else {
- if (matchEnclosed && currName.segmentCount() > qualifiedName.segmentCount()
- && currName.lastSegment().equals(qualifiedName.lastSegment())) {
- currName = currName.removeFirstSegments(currName.segmentCount() - qualifiedName.segmentCount());
- }
- if (currName.equals(qualifiedName)) {
- results.add(info);
- }
- }
- }
- }
- return (ITypeInfo[]) results.toArray(new ITypeInfo[results.size()]);
- }
-
- public synchronized ITypeInfo getType(int type, IQualifiedTypeName qualifiedName) {
- ITypeInfo info = (ITypeInfo) fTypeKeyMap.get(new HashKey(qualifiedName, type));
- if (info == null && type != 0) {
- info = (ITypeInfo) fTypeKeyMap.get(new HashKey(qualifiedName, 0));
- }
- return info;
- }
-
- public synchronized ITypeInfo getEnclosingType(ITypeInfo info, final int[] kinds) {
- IQualifiedTypeName enclosingName = info.getQualifiedTypeName().getEnclosingTypeName();
- if (enclosingName != null) {
- // try namespace, class, struct, then undefined
- ITypeInfo enclosingType = null;
- for (int i = 0; enclosingType == null && i < ENCLOSING_TYPES.length; ++i) {
- if (ArrayUtil.contains(kinds, ENCLOSING_TYPES[i])) {
- enclosingType = (ITypeInfo) fTypeKeyMap.get(new HashKey(enclosingName, ENCLOSING_TYPES[i]));
- }
- }
- return enclosingType;
- }
- return null;
- }
-
- public synchronized ITypeInfo getEnclosingNamespace(ITypeInfo info, boolean includeGlobalNamespace) {
- IQualifiedTypeName enclosingName = info.getQualifiedTypeName().getEnclosingTypeName();
- if (enclosingName != null) {
- // look for namespace
- ITypeInfo enclosingType = (ITypeInfo) fTypeKeyMap.get(new HashKey(enclosingName, ICElement.C_NAMESPACE));
- if (enclosingType != null) {
- return enclosingType;
- }
- // try class, struct, then undefined
- final int[] kinds = {ICElement.C_CLASS, ICElement.C_STRUCT, 0};
- for (int i = 0; enclosingType == null && i < kinds.length; ++i) {
- enclosingType = (ITypeInfo) fTypeKeyMap.get(new HashKey(enclosingName, kinds[i]));
- }
- if (enclosingType != null) {
- return getEnclosingNamespace(enclosingType, includeGlobalNamespace);
- }
- }
- if (includeGlobalNamespace)
- return fGlobalNamespace;
- return null;
- }
-
- public synchronized ITypeInfo getRootNamespace(ITypeInfo info, boolean includeGlobalNamespace) {
- IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
- if (qualifiedName.isGlobal()) {
- if (info.getCElementType() == ICElement.C_NAMESPACE)
- return info;
- if (includeGlobalNamespace)
- return fGlobalNamespace;
- return null;
- }
- IQualifiedTypeName namespace = qualifiedName.removeLastSegments(qualifiedName.segmentCount()-1);
- // try namespace, then undefined
- ITypeInfo namespaceType = (ITypeInfo) fTypeKeyMap.get(new HashKey(namespace, ICElement.C_NAMESPACE));
- if (namespaceType == null)
- namespaceType = (ITypeInfo) fTypeKeyMap.get(new HashKey(namespace, 0));
- return namespaceType;
- }
-
- public synchronized boolean hasEnclosedTypes(final ITypeInfo info) {
- final IQualifiedTypeName parentName = info.getQualifiedTypeName();
- final boolean[] foundTypes = { false };
- accept(new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo type) {
- if (type != info && parentName.isPrefixOf(type.getQualifiedTypeName())) {
- foundTypes[0] = true;
- }
- return true;
- }
- public boolean shouldContinue() {
- return !foundTypes[0];
- }
- });
- return foundTypes[0];
- }
-
- public synchronized ITypeInfo[] getEnclosedTypes(final ITypeInfo enclosedBy, final int kinds[]) {
- final IQualifiedTypeName parentName = enclosedBy.getQualifiedTypeName();
- final Collection results = new ArrayList();
- accept(new ITypeInfoVisitor() {
- public boolean visit(ITypeInfo type) {
- if (ArrayUtil.contains(kinds, type.getCElementType())) {
- IQualifiedTypeName enclosingName = type.getQualifiedTypeName().getEnclosingTypeName();
- if (enclosedBy == fGlobalNamespace) {
- if (enclosingName == null) {
- results.add(type);
- } else {
-// // check if enclosing parent is namespace
-// getRootNamespace(type);
- }
- } else if (parentName.equals(enclosingName)) {
- results.add(type);
- }
- }
- return true;
- }
- public boolean shouldContinue() { return true; }
- });
-
- return (ITypeInfo[]) results.toArray(new ITypeInfo[results.size()]);
- }
-
- public ITypeInfo getGlobalNamespace() {
- return fGlobalNamespace;
- }
-
- public boolean isUpToDate() {
- synchronized(fDeltas) {
- return fDeltas.isEmpty();
- }
- }
-
- public void addDelta(TypeCacheDelta delta) {
- synchronized(fDeltas) {
- fDeltas.add(delta);
- }
- }
-
- public void reconcile(boolean enableIndexing, int priority, int delay) {
- // check if anything needs to be done
- if (deltasRemaining() == 0)
- return; // nothing to do
-
- // cancel any scheduled or running jobs for this project
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(TypeCacherJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- TypeCacherJob deltaJob = (TypeCacherJob) jobs[i];
- if (deltaJob.getCache().equals(this)) {
- deltaJob.cancel();
- }
- }
-
- // check again, in case some jobs finished in the meantime
- if (deltasRemaining() == 0)
- return; // nothing to do
-
- TypeCacherJob deltaJob = null;
- IndexManager indexManager = CModelManager.getDefault().getIndexManager();
- ICDTIndexer indexer = indexManager.getIndexerForProject( fProject );
- boolean haveIndexer = (indexer != null && indexer.isIndexEnabled( fProject ));
- synchronized(fDeltas) {
- if( haveIndexer ){
- // grab all the remaining deltas
- TypeCacheDelta[] jobDeltas = (TypeCacheDelta[]) fDeltas.toArray(new TypeCacheDelta[fDeltas.size()]);
-
- // create a new job
- deltaJob = new TypeCacherJob(this, jobDeltas, enableIndexing);
- // assign deltas to job
- if (jobDeltas != null) {
- for (int i = 0; i < jobDeltas.length; ++i) {
- jobDeltas[i].assignToJob(deltaJob);
- }
- }
- } else {
- //we don't have an indexer, don't create a job to do these deltas, throw them away
- fDeltas.clear();
- }
- }
-
- if( deltaJob != null ){
- // schedule the new job
- deltaJob.addJobChangeListener(fJobChangeListener);
- deltaJob.setPriority(priority);
- deltaJob.schedule(delay);
- }
- }
-
- public void reconcileAndWait(boolean enableIndexing, int priority, IProgressMonitor monitor) {
- reconcile(enableIndexing, priority, 0);
-
- // wait for jobs to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(TypeCacherJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- TypeCacherJob deltaJob = (TypeCacherJob) jobs[i];
- if (deltaJob.getCache().equals(this)) {
- try {
- deltaJob.join(monitor);
- } catch (InterruptedException e) {
- }
- }
- }
- }
-
- // returns the number of deltas either not assigned to a job,
- // or assigned to a job which is not yet running
- private int deltasRemaining() {
- // count the left-over deltas
- synchronized(fDeltas) {
- int count = 0;
- for (Iterator i = fDeltas.iterator(); i.hasNext(); ) {
- TypeCacheDelta delta = (TypeCacheDelta) i.next();
- TypeCacherJob job = delta.getJob();
- if (job == null || !job.isRunning()) {
- ++count;
- }
- }
- return count;
- }
- }
-
- public void cancelJobs() {
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(TypeCacherJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- TypeCacherJob deltaJob = (TypeCacherJob) jobs[i];
- if (deltaJob.getCache().equals(this)) {
- deltaJob.cancel();
- }
- }
- jobs = jobManager.find(TypeLocatorJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- TypeLocatorJob locatorJob = (TypeLocatorJob) jobs[i];
- if (locatorJob.getType().getEnclosingProject().equals(fProject)) {
- locatorJob.cancel();
- }
- }
- jobs = jobManager.find(SubTypeLocatorJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- SubTypeLocatorJob locatorJob = (SubTypeLocatorJob) jobs[i];
- if (locatorJob.getType().getEnclosingProject().equals(fProject)) {
- locatorJob.cancel();
- }
- }
- }
-
- public void locateType(ITypeInfo info, int priority, int delay) {
- ITypeReference location = info.getResolvedReference();
- if (location != null)
- return; // nothing to do
-
- // cancel any scheduled or running jobs for this type
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(TypeLocatorJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- TypeLocatorJob locatorJob = (TypeLocatorJob) jobs[i];
- if (locatorJob.getType().equals(info)) {
- locatorJob.cancel();
- }
- }
-
- // check again, in case some jobs finished in the meantime
- location = info.getResolvedReference();
- if (location != null)
- return; // nothing to do
-
- // create a new job
- TypeLocatorJob locatorJob = new TypeLocatorJob(info, this, fWorkingCopyProvider);
- // schedule the new job
- locatorJob.setPriority(priority);
- locatorJob.schedule(delay);
- }
-
- public ITypeReference locateTypeAndWait(ITypeInfo info, int priority, IProgressMonitor monitor) {
- locateType(info, priority, 0);
-
- // wait for jobs to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(TypeLocatorJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- TypeLocatorJob locatorJob = (TypeLocatorJob) jobs[i];
- if (locatorJob.getType().equals(info)) {
- try {
- locatorJob.join(monitor);
- } catch (InterruptedException e) {
- }
- }
- }
-
- return info.getResolvedReference();
- }
-
- public void locateSupertypes(ITypeInfo info, int priority, int delay) {
- ITypeInfo[] superTypes = getSupertypes(info);
- if (superTypes != null)
- return; // nothing to do
-
- locateType(info, priority, delay);
- }
-
- public ITypeInfo[] locateSupertypesAndWait(ITypeInfo info, int priority, IProgressMonitor monitor) {
- locateSupertypes(info, priority, 0);
-
- // wait for jobs to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(SubTypeLocatorJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- SubTypeLocatorJob locatorJob = (SubTypeLocatorJob) jobs[i];
- if (locatorJob.getType().equals(info)) {
- try {
- locatorJob.join(monitor);
- } catch (InterruptedException e) {
- }
- }
- }
-
- return getSupertypes(info);
- }
-
- public void locateSubtypes(ITypeInfo info, int priority, int delay) {
- ITypeInfo[] subTypes = getSubtypes(info);
- if (subTypes != null)
- return; // nothing to do
-
- // cancel any scheduled or running jobs for this type
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(SubTypeLocatorJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- SubTypeLocatorJob locatorJob = (SubTypeLocatorJob) jobs[i];
- if (locatorJob.getType().equals(info)) {
- locatorJob.cancel();
- }
- }
-
- // check again, in case some jobs finished in the meantime
- subTypes = getSubtypes(info);
- if (subTypes != null)
- return; // nothing to do
-
- // create a new job
- SubTypeLocatorJob locatorJob = new SubTypeLocatorJob(info, this, fWorkingCopyProvider);
- // schedule the new job
- locatorJob.setPriority(priority);
- locatorJob.schedule(delay);
- }
-
- public ITypeInfo[] locateSubtypesAndWait(ITypeInfo info, int priority, IProgressMonitor monitor) {
- locateSubtypes(info, priority, 0);
-
- // wait for jobs to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] jobs = jobManager.find(SubTypeLocatorJob.FAMILY);
- for (int i = 0; i < jobs.length; ++i) {
- SubTypeLocatorJob locatorJob = (SubTypeLocatorJob) jobs[i];
- if (locatorJob.getType().equals(info)) {
- try {
- locatorJob.join(monitor);
- } catch (InterruptedException e) {
- }
- }
- }
-
- return getSubtypes(info);
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheDelta.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheDelta.java
deleted file mode 100644
index 6b897bdb3ec..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheDelta.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.core.resources.IProject;
-
-
-public class TypeCacheDelta {
- private IProject fProject = null;
- private ICElementDelta fCElementDelta = null;
- private ITypeSearchScope fScope = null;
- private TypeCacherJob fJob = null;
-
- public TypeCacheDelta(IProject project, ICElementDelta delta) {
- fProject = project;
- fCElementDelta = delta;
- }
-
- public TypeCacheDelta(IProject project, ITypeSearchScope scope) {
- fProject = project;
- fScope = scope;
- }
-
- public TypeCacheDelta(IProject project) {
- fProject = project;
- fScope = new TypeSearchScope();
- fScope.add(project);
- }
-
- public IProject getProject() {
- return fProject;
- }
-
- public ITypeSearchScope getScope() {
- return fScope;
- }
-
- public ICElementDelta getCElementDelta() {
- return fCElementDelta;
- }
-
- public void assignToJob(TypeCacherJob job) {
- fJob = job;
- }
-
- public TypeCacherJob getJob() {
- return fJob;
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheManager.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheManager.java
deleted file mode 100644
index cee4acd1329..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheManager.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeCacheChangedListener;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.ElementChangedEvent;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopyProvider;
-import org.eclipse.cdt.internal.core.model.CModelManager;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-
-public class TypeCacheManager implements ITypeCacheChangedListener, IndexManager.IIndexerSelectionListener {
- private static final TypeCacheManager fgInstance = new TypeCacheManager();
- private Map fCacheMap;
- private IWorkingCopyProvider fWorkingCopyProvider;
- private ArrayList fChangeListeners = new ArrayList();
-
- private static final int INITIAL_TYPE_MAP_SIZE = 50;
- //TODO make this a WeakHashMap or LRUCache
- private Map fTypeToElementMap = new HashMap(INITIAL_TYPE_MAP_SIZE);
- private Map fElementToTypeMap = new HashMap(INITIAL_TYPE_MAP_SIZE);
- private boolean processTypeCacheEvents = true;
-
- private TypeCacheManager() {
- fCacheMap = new HashMap();
- CModelManager.getDefault().getIndexManager().subscribeForIndexerChangeNotifications( this );
- }
-
- public static TypeCacheManager getInstance() {
- return fgInstance;
- }
-
- protected void finalize() throws Throwable {
- CModelManager.getDefault().getIndexManager().unSubscribeForIndexerChangeNotifications( this );
- super.finalize();
- }
-
- public void setWorkingCopyProvider(IWorkingCopyProvider workingCopyProvider) {
- fWorkingCopyProvider = workingCopyProvider;
- }
-
- public synchronized void updateProject(IProject project) {
- // TODO finer-grained flush needed, for now just flush the whole map
- fTypeToElementMap.clear();
- fElementToTypeMap.clear();
- addCacheDelta(project, null);
- }
-
- public synchronized void processElementChanged(ElementChangedEvent event, boolean enableIndexing) {
- int deltaCount = processDelta(event.getDelta());
- if (deltaCount > 0) {
- // TODO finer-grained flush needed, for now just flush the whole map
- fTypeToElementMap.clear();
- fElementToTypeMap.clear();
- reconcile(enableIndexing, Job.BUILD, 0);
- }
- }
-
- private static final int PATH_ENTRY_FLAGS = ICElementDelta.F_ADDED_PATHENTRY_SOURCE
- | ICElementDelta.F_REMOVED_PATHENTRY_SOURCE
- | ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE
- | ICElementDelta.F_CHANGED_PATHENTRY_MACRO
- | ICElementDelta.F_PATHENTRY_REORDER;
-
- private int processDelta(ICElementDelta delta) {
- ICElement elem = delta.getElement();
- boolean added = (delta.getKind() == ICElementDelta.ADDED);
- boolean removed = (delta.getKind() == ICElementDelta.REMOVED);
- boolean contentChanged = ((delta.getFlags() & ICElementDelta.F_CONTENT) != 0);
- boolean pathEntryChanged = ((delta.getFlags() & PATH_ENTRY_FLAGS) != 0);
- boolean openedOrClosed = (((delta.getFlags() & ICElementDelta.F_CLOSED) != 0) || ((delta.getFlags() & ICElementDelta.F_OPENED) != 0));
- boolean hasChildren = ((delta.getFlags() & ICElementDelta.F_CHILDREN) != 0);
- int deltaCount = 0;
-
-
- switch (elem.getElementType()) {
- case ICElement.C_PROJECT:
- case ICElement.C_CCONTAINER: {
- ICProject cProject = elem.getCProject();
- IProject project = cProject.getProject();
- if (added || removed || pathEntryChanged || openedOrClosed) {
- addCacheDelta(project, delta);
- ++deltaCount;
- }
- }
- break;
-
- case ICElement.C_UNIT: {
- ICProject cProject = elem.getCProject();
- IProject project = cProject.getProject();
- ITranslationUnit unit = (ITranslationUnit) elem;
- if (unit.isWorkingCopy()) {
- deltaCount += processWorkingCopyDelta(delta);
- return deltaCount;
- }
- if (added || removed || pathEntryChanged || contentChanged) {
- addCacheDelta(project, delta);
- ++deltaCount;
- }
- }
- break;
-
- case ICElement.C_INCLUDE:
- case ICElement.C_NAMESPACE:
- case ICElement.C_TEMPLATE_CLASS:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF:
- {
- ICProject cProject = elem.getCProject();
- IProject project = cProject.getProject();
- if (added || removed) {
- addCacheDelta(project, delta);
- ++deltaCount;
- }
- }
- break;
- }
-
- if (hasChildren) {
- ICElementDelta[] children = delta.getAffectedChildren();
- if (children != null) {
- for (int i = 0; i < children.length; ++i) {
- deltaCount += processDelta(children[i]);
- }
- }
- }
-
- return deltaCount;
- }
-
- private void addCacheDelta(IProject project, ICElementDelta delta) {
- if (delta == null) {
- getCache(project).addDelta(new TypeCacheDelta(project));
- } else {
- getCache(project).addDelta(new TypeCacheDelta(project, delta));
- }
- }
-
- private int processWorkingCopyDelta(ICElementDelta delta) {
- // ignore workies copies for now
- return 0;
-/* ICElement elem = delta.getElement();
- boolean added = (delta.getKind() == ICElementDelta.ADDED);
- boolean removed = (delta.getKind() == ICElementDelta.REMOVED);
- boolean contentChanged = ((delta.getFlags() & ICElementDelta.F_CONTENT) != 0);
- boolean pathEntryChanged = ((delta.getFlags() & PATH_ENTRY_FLAGS) != 0);
- boolean hasChildren = ((delta.getFlags() & ICElementDelta.F_CHILDREN) != 0);
-
- switch (elem.getElementType()) {
- case ICElement.C_UNIT: {
- ICProject cProject = elem.getCProject();
- IProject project = cProject.getProject();
- if (added || removed || pathEntryChanged || contentChanged) {
- TypeCacheDelta cacheDelta = new TypeCacheDelta(project, delta);
- getCache(project).addDelta(cacheDelta);
- }
- }
- break;
-
- case ICElement.C_INCLUDE:
- case ICElement.C_NAMESPACE:
- case ICElement.C_TEMPLATE_CLASS:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF:
- {
- ICProject cProject = elem.getCProject();
- IProject project = cProject.getProject();
- if (added || removed) {
- TypeCacheDelta cacheDelta = new TypeCacheDelta(project, delta);
- getCache(project).addDelta(cacheDelta);
- }
- }
- break;
- }
-
- if (hasChildren) {
- ICElementDelta[] children = delta.getAffectedChildren();
- if (children != null) {
- for (int i = 0; i < children.length; ++i) {
- processWorkingCopyDelta(children[i]);
- }
- }
- }
-*/
- }
-
- public synchronized ITypeCache getCache(IProject project) {
- synchronized(fCacheMap) {
- ITypeCache cache = (ITypeCache) fCacheMap.get(project);
- if (cache == null) {
- cache = new TypeCache(project, fWorkingCopyProvider, this);
- fCacheMap.put(project, cache);
- }
- return cache;
- }
- }
-
- public synchronized void reconcile(boolean enableIndexing, int priority, int delay) {
- if (!(processTypeCacheEvents))
- return;
-
- TypeSearchScope workspaceScope = new TypeSearchScope(true);
- IProject[] projects = workspaceScope.getEnclosingProjects();
- for (int i = 0; i < projects.length; ++i) {
- ITypeCache cache = getCache(projects[i]);
- cache.reconcile(enableIndexing, priority, delay);
- }
- }
-
- public synchronized void reconcileAndWait(boolean enableIndexing, int priority, IProgressMonitor monitor) {
- if (!(processTypeCacheEvents))
- return;
-
- TypeSearchScope workspaceScope = new TypeSearchScope(true);
- IProject[] projects = workspaceScope.getEnclosingProjects();
- for (int i = 0; i < projects.length; ++i) {
- ITypeCache cache = getCache(projects[i]);
- cache.reconcileAndWait(enableIndexing, priority, monitor);
- }
- }
-
- public void cancelJobs() {
- IJobManager jobManager = Platform.getJobManager();
- jobManager.cancel(TypeCacherJob.FAMILY);
- jobManager.cancel(TypeLocatorJob.FAMILY);
- }
-
- public ITypeInfo[] locateSuperTypesAndWait(ITypeInfo info, boolean enableIndexing, int priority, IProgressMonitor monitor) {
- ITypeInfo[] superTypes = info.getSuperTypes();
- if (superTypes == null) {
- // cancel background jobs
- IProject project = info.getEnclosingProject();
- getCache(project).cancelJobs();
-
- // start the search job
- getCache(project).locateSupertypesAndWait(info, priority, monitor);
-
- superTypes = info.getSuperTypes();
-
- // resume background jobs
- reconcile(enableIndexing, Job.BUILD, 0);
- }
- return superTypes;
- }
-
- public ITypeInfo[] locateSubTypesAndWait(ITypeInfo info, boolean enableIndexing, int priority, IProgressMonitor monitor) {
- ITypeInfo[] subTypes = info.getSubTypes();
- if (subTypes == null) {
- // cancel background jobs
- IProject project = info.getEnclosingProject();
- getCache(project).cancelJobs();
-
- // start the search job
- getCache(project).locateSubtypesAndWait(info, priority, monitor);
-
- subTypes = info.getSubTypes();
-
- // resume background jobs
- reconcile(enableIndexing, Job.BUILD, 0);
- }
- return subTypes;
- }
-
- public void updateCache(ITypeSearchScope scope, IProgressMonitor monitor) {
- // schedule jobs to update cache
- IProject[] projects = scope.getEnclosingProjects();
- monitor.beginTask(TypeCacheMessages.getString("AllTypesCache.updateCache.taskName"), projects.length); //$NON-NLS-1$
- for (int i = 0; i < projects.length; ++i) {
- IProject project = projects[i];
- // wait for any running jobs to finish
- getCache(project).reconcileAndWait(true, Job.SHORT, new SubProgressMonitor(monitor, 1));
- }
- monitor.done();
- }
-
- /**
- * Resolves a type location.
- *
- * @param info the type to search for
- * @param monitor the progress monitor
- */
- public ITypeReference resolveTypeLocation(ITypeInfo info, IProgressMonitor monitor, boolean enableIndexing) {
- ITypeReference location = info.getResolvedReference();
- if (location == null) {
- // cancel background jobs
- IProject project = info.getEnclosingProject();
- ITypeCache cache = getCache(project);
- cache.cancelJobs();
-
- // start the search job
- cache.locateTypeAndWait(info, Job.SHORT, monitor);
-
- // get the newly parsed location
- location = info.getResolvedReference();
-
- // resume background jobs
- reconcile(enableIndexing, Job.BUILD, 0);
- }
- return location;
- }
-
- public void addTypeCacheChangedListener(ITypeCacheChangedListener listener) {
- // add listener only if it is not already present
- synchronized(fChangeListeners) {
- if (!fChangeListeners.contains(listener)) {
- fChangeListeners.add(listener);
- }
- }
- }
-
- public void removeTypeCacheChangedListener(ITypeCacheChangedListener listener) {
- synchronized(fChangeListeners) {
- fChangeListeners.remove(listener);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.browser.ITypeCacheChangedListener#typeCacheChanged(org.eclipse.core.resources.IProject)
- */
- public synchronized void typeCacheChanged(final IProject project) {
- // clone so that a listener cannot have a side-effect on this list when being notified
- ArrayList listeners;
- synchronized(fChangeListeners) {
- listeners = (ArrayList) fChangeListeners.clone();
- }
- for (Iterator i = listeners.iterator(); i.hasNext(); ) {
- final ITypeCacheChangedListener listener = (ITypeCacheChangedListener) i.next();
- Platform.run(new ISafeRunnable() {
- public void handleException(Throwable e) {
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR, "Exception occurred in listener of type cache change notification", e); //$NON-NLS-1$
- CCorePlugin.log(status);
- }
- public void run() throws Exception {
- listener.typeCacheChanged(project);
- }
- });
- }
- }
-
- public ITypeInfo getTypeForElement(ICElement element, boolean forceUpdate, boolean forceResolve, boolean enableIndexing, IProgressMonitor monitor) {
- if (element.exists()) {
- ITypeInfo cachedInfo = (ITypeInfo) fElementToTypeMap.get(element);
- if (cachedInfo != null && cachedInfo.exists())
- return cachedInfo;
- }
-
- IQualifiedTypeName qualifiedName = TypeUtil.getFullyQualifiedName(element);
- if (qualifiedName != null) {
- ICProject cProject = element.getCProject();
- IProject project = cProject.getProject();
- ITypeCache cache = getCache(project);
- if (!cache.isUpToDate() && forceUpdate) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- // wait for any running jobs to finish
- cache.reconcileAndWait(true, Job.SHORT, monitor);
- }
-
- ITypeInfo info = cache.getType(element.getElementType(), qualifiedName);
- if (info != null) {
- ITypeReference ref = info.getResolvedReference();
- if (ref == null && forceResolve) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- ref = resolveTypeLocation(info, monitor, enableIndexing);
- }
-
- // cache for later use
- fElementToTypeMap.put(element, info);
- return info;
- }
- }
- return null;
- }
-
- public ICElement getElementForType(ITypeInfo type, boolean forceUpdate, boolean forceResolve, boolean enableIndexing, IProgressMonitor monitor) {
- if (type.exists()) {
- ICElement cachedElem = (ICElement) fTypeToElementMap.get(type);
- if (cachedElem != null && cachedElem.exists())
- return cachedElem;
- }
-
- IProject project = type.getEnclosingProject();
- ITypeCache cache = getCache(project);
- if (!cache.isUpToDate() && forceUpdate) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- // wait for any running jobs to finish
- cache.reconcileAndWait(true, Job.SHORT, monitor);
-
- //TODO replace type with new type from cache???
- }
-
- ITypeReference ref = type.getResolvedReference();
- if (ref == null && forceResolve) {
- ref = resolveTypeLocation(type, monitor, enableIndexing);
- }
- if (ref != null) {
- ICElement[] elems = ref.getCElements();
- if (elems != null && elems.length > 0) {
- ICElement foundElem = elems[0];
- if (elems.length > 1) {
- for (int i = 0; i < elems.length; ++i) {
- ICElement elem = elems[i];
- if (elem.getElementType() == type.getCElementType() && elem.getElementName().equals(type.getName())) {
- //TODO should check fully qualified name
- foundElem = elem;
- break;
- }
- }
- }
-
- if (foundElem != null) {
- // cache for later use
- fTypeToElementMap.put(type, foundElem);
- return foundElem;
- }
- }
- }
- return null;
- }
- public boolean getProcessTypeCacheEvents() {
- return processTypeCacheEvents;
- }
- public void setProcessTypeCacheEvents(boolean processTypeCacheEvents) {
- this.processTypeCacheEvents = processTypeCacheEvents;
- }
-
- public void indexerSelectionChanged(IProject project) {
- addCacheDelta(project, null );
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheMessages.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheMessages.java
deleted file mode 100644
index 30e20e62572..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheMessages.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class TypeCacheMessages {
-
- private static final String RESOURCE_BUNDLE= TypeCacheMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle;
- static {
- try {
- fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
- } catch (MissingResourceException x) {
- fgResourceBundle = null;
- }
- }
-
- private TypeCacheMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- } catch (NullPointerException e) {
- return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public static String getFormattedString(String key, String arg) {
- return getFormattedString(key, new String[] { arg });
- }
-
- public static String getFormattedString(String key, String[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheMessages.properties b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheMessages.properties
deleted file mode 100644
index c4d26740d29..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacheMessages.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 QNX Software Systems and others.
-# All rights reserved. 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:
-# QNX Software Systems - Initial API and implementation
-###############################################################################
-
-AllTypesCache.updateCache.taskName=Updating Type Cache...
-
-TypeCacherJob.defaultJobName=Type Cache
-TypeCacherJob.jobName=Type Cache [{0}]
-TypeCacherJob.taskName=Updating Type Cache...
-
-TypeLocatorJob.jobName=Type Locator
-TypeLocatorJob.taskName=Searching for Type Declaration...
-SubTypeLocatorJob.jobName=Subtype Locator
-SubTypeLocatorJob.taskName=Searching for Subtypes...
-
-TypeCache.globalNamespace=(global)
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacherJob.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacherJob.java
deleted file mode 100644
index 3cb779f2e13..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeCacherJob.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.model.CModelManager;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-
-/**
- * Background job for filling the type cache.
- * @see org.eclipse.core.runtime.jobs.Job
- * @since 3.0
- */
-public class TypeCacherJob extends BasicJob {
-
- public static final Object FAMILY = new Object();
- private IndexManager fIndexManager;
- private ITypeCache fTypeCache;
- private TypeCacheDelta[] fDeltas;
- private boolean fEnableIndexing;
- private boolean fIndexerIsBusy;
-
- public TypeCacherJob(ITypeCache typeCache, TypeCacheDelta[] deltas, boolean enableIndexing) {
- super(TypeCacheMessages.getString("TypeCacherJob.defaultJobName"), FAMILY); //$NON-NLS-1$
- fTypeCache = typeCache;
- fDeltas = deltas;
- fEnableIndexing = enableIndexing;
- fIndexerIsBusy = false;
- fIndexManager = CModelManager.getDefault().getIndexManager();
- setPriority(BUILD);
- setSystem(true);
- setRule(typeCache);
- setName(TypeCacheMessages.getFormattedString("TypeCacherJob.jobName", fTypeCache.getProject().getName())); //$NON-NLS-1$
- }
-
- public ITypeCache getCache() {
- return fTypeCache;
- }
-
- public TypeCacheDelta[] getDeltas() {
- return fDeltas;
- }
-
- public boolean isIndexerBusy() {
- return fIndexerIsBusy;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(IProgressMonitor)
- */
- protected IStatus runWithDelegatedProgress(IProgressMonitor monitor) throws InterruptedException {
- boolean success = false;
- long startTime = System.currentTimeMillis();
- trace("TypeCacherJob: started"); //$NON-NLS-1$
-
- try {
- int totalWork = 100;
- monitor.beginTask(TypeCacheMessages.getString("TypeCacherJob.taskName"), totalWork); //$NON-NLS-1$
-
- // figure out what needs to be flushed
- TypeSearchScope flushScope = new TypeSearchScope();
- if (fDeltas != null) {
- for (int i = 0; i < fDeltas.length; ++i) {
- TypeCacheDelta delta = fDeltas[i];
- prepareToFlush(delta, flushScope);
- }
- }
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- // flush the cache
- int flushWork = 0;
- if (!flushScope.isEmpty()) {
- flushWork = totalWork / 4;
- IProgressMonitor subMonitor = new SubProgressMonitor(monitor, flushWork);
- flush(flushScope, subMonitor);
- }
-
- // update the cache
- IProgressMonitor subMonitor = new SubProgressMonitor(monitor, totalWork - flushWork);
- update(flushScope, subMonitor);
-
- if (monitor.isCanceled())
- throw new InterruptedException();
- } finally {
- long executionTime = System.currentTimeMillis() - startTime;
- if (success)
- trace("TypeCacherJob: completed ("+ executionTime + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$
- else
- trace("TypeCacherJob: aborted ("+ executionTime + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$
-
- monitor.done();
- }
-
- return Status.OK_STATUS;
- }
-
- private void flush(ITypeSearchScope scope, IProgressMonitor monitor) throws InterruptedException {
- // flush the cache
- boolean success = true;
- IProject project = fTypeCache.getProject();
-
- monitor.beginTask("", 100); //$NON-NLS-1$
-
- fTypeCache.flush(scope);
- if (!scope.encloses(project)) {
- if (project.exists() && project.isOpen()) {
- success = doIndexerJob(new IndexerDependenciesJob(fIndexManager, fTypeCache, scope), monitor);
- }
- }
-
- if (!success || monitor.isCanceled()) {
- throw new InterruptedException();
- }
-
- monitor.done();
- }
-
- private void update(ITypeSearchScope scope, IProgressMonitor monitor) throws InterruptedException {
- boolean success = true;
- IProject project = fTypeCache.getProject();
-
- monitor.beginTask("", 100); //$NON-NLS-1$
- if (project.exists() && project.isOpen()) {
- success = doIndexerJob(new IndexerTypesJob2(fIndexManager, fTypeCache, scope), monitor);
- }
-
- if (!success || monitor.isCanceled()) {
- throw new InterruptedException();
- }
-
- monitor.done();
- }
-
- private boolean doIndexerJob(IndexerJob job, IProgressMonitor monitor) {
- if (!fEnableIndexing) {
- return false;
- }
-
- // check if indexer is busy
- fIndexerIsBusy = false;
- try {
- fIndexManager.performConcurrentJob(new DummyIndexerJob(fIndexManager, fTypeCache.getProject()),
- ICSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, new NullProgressMonitor(), null);
- } catch (OperationCanceledException e) {
- fIndexerIsBusy = true;
- }
-
- // do an immediate (but possibly incomplete) search
- // if fIndexerIsBusy the cache will stay dirty and we'll hit the indexer again next time
- return fIndexManager.performConcurrentJob(job,
- ICSearchConstants.FORCE_IMMEDIATE_SEARCH, monitor, null);
- }
-
- private boolean doIndexerJob(IndexerJob2 job, IProgressMonitor monitor) {
- if (!fEnableIndexing) {
- return false;
- }
-
- // check if indexer is busy
- fIndexerIsBusy = false;
- try {
- fIndexManager.performConcurrentJob(new DummyIndexerJob(fIndexManager, fTypeCache.getProject()),
- ICSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, new NullProgressMonitor(), null);
- } catch (OperationCanceledException e) {
- fIndexerIsBusy = true;
- }
-
- // do an immediate (but possibly incomplete) search
- // if fIndexerIsBusy the cache will stay dirty and we'll hit the indexer again next time
- return fIndexManager.performConcurrentJob(job,
- ICSearchConstants.FORCE_IMMEDIATE_SEARCH, monitor, null);
- }
-
-
- private static final int PATH_ENTRY_FLAGS = ICElementDelta.F_ADDED_PATHENTRY_SOURCE
- | ICElementDelta.F_REMOVED_PATHENTRY_SOURCE
- | ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE
- | ICElementDelta.F_CHANGED_PATHENTRY_MACRO
- | ICElementDelta.F_PATHENTRY_REORDER;
-
- private void prepareToFlush(TypeCacheDelta cacheDelta, ITypeSearchScope scope) {
- ITypeSearchScope deltaScope = cacheDelta.getScope();
- if (deltaScope != null)
- scope.add(deltaScope);
-
- ICElementDelta delta = cacheDelta.getCElementDelta();
- if (delta != null) {
- ICElement elem = delta.getElement();
- boolean added = (delta.getKind() == ICElementDelta.ADDED);
- boolean removed = (delta.getKind() == ICElementDelta.REMOVED);
- boolean contentChanged = ((delta.getFlags() & ICElementDelta.F_CONTENT) != 0);
- boolean pathEntryChanged = ((delta.getFlags() & PATH_ENTRY_FLAGS) != 0);
-
- switch (elem.getElementType()) {
- case ICElement.C_MODEL: {
- if (added || removed) {
- scope.add(elem);
- }
- }
- break;
-
- case ICElement.C_PROJECT: {
- if (added || removed || pathEntryChanged) {
- scope.add(elem);
- }
- }
- break;
-
- case ICElement.C_CCONTAINER: {
- if (added || removed || pathEntryChanged) {
- scope.add(elem);
- }
- }
- break;
-
- case ICElement.C_UNIT: {
- if (added || removed || pathEntryChanged || contentChanged) {
- scope.add(elem);
- }
- }
- break;
-
- case ICElement.C_INCLUDE:
- case ICElement.C_NAMESPACE:
- case ICElement.C_TEMPLATE_CLASS:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF:
- {
- //TODO handle working copies
- if (added || removed) {
- scope.add(elem);
- }
- }
- break;
- }
- }
- }
-
- private static final class DummyIndexerJob extends IndexerJob {
- public DummyIndexerJob(IndexManager indexManager, IProject project) {
- super(indexManager, project);
- }
- protected boolean processIndex(IIndex index, IProject project, IProgressMonitor progressMonitor) {
- return false;
- }
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeLocatorJob.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeLocatorJob.java
deleted file mode 100644
index 6e07320b324..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeLocatorJob.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.IWorkingCopyProvider;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-public class TypeLocatorJob extends BasicJob {
-
- public static final Object FAMILY = new Object();
- private ITypeInfo fLocateType;
- private ITypeCache fTypeCache;
- private IWorkingCopyProvider fWorkingCopyProvider;
-
- public TypeLocatorJob(ITypeInfo info, ITypeCache typeCache, IWorkingCopyProvider workingCopyProvider) {
- super(TypeCacheMessages.getString("TypeLocatorJob.jobName"), FAMILY); //$NON-NLS-1$
- fLocateType = info;
- fTypeCache = typeCache;
- fWorkingCopyProvider= workingCopyProvider;
- }
-
- public ITypeInfo getType() {
- return fLocateType;
- }
-
- protected IStatus runWithDelegatedProgress(IProgressMonitor monitor) throws InterruptedException {
- boolean success = false;
- long startTime = System.currentTimeMillis();
- trace("TypeLocatorJob: started"); //$NON-NLS-1$
-
- try {
- monitor.beginTask(TypeCacheMessages.getString("TypeLocatorJob.taskName"), 100); //$NON-NLS-1$
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- TypeParser parser = new TypeParser(fTypeCache, fWorkingCopyProvider);
- success = parser.findType(fLocateType, new SubProgressMonitor(monitor, 100));
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- } finally {
- long executionTime = System.currentTimeMillis() - startTime;
- if (success)
- trace("TypeLocatorJob: completed ("+ executionTime + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$
- else
- trace("TypeLocatorJob: aborted ("+ executionTime + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$
-
- monitor.done();
- }
-
- return Status.OK_STATUS;
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeParser.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeParser.java
deleted file mode 100644
index dc5aa9e65cf..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/cache/TypeParser.java
+++ /dev/null
@@ -1,955 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial implementation
- * QNX Software Systems - adapted for type search
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.cache;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeInfo;
-import org.eclipse.cdt.core.browser.TypeReference;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.core.model.IWorkingCopyProvider;
-import org.eclipse.cdt.core.parser.CodeReader;
-import org.eclipse.cdt.core.parser.DefaultProblemHandler;
-import org.eclipse.cdt.core.parser.IParser;
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.core.parser.IScanner;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
-import org.eclipse.cdt.core.parser.ISourceElementRequestor;
-import org.eclipse.cdt.core.parser.ParseError;
-import org.eclipse.cdt.core.parser.ParserFactory;
-import org.eclipse.cdt.core.parser.ParserFactoryError;
-import org.eclipse.cdt.core.parser.ParserLanguage;
-import org.eclipse.cdt.core.parser.ParserMode;
-import org.eclipse.cdt.core.parser.ParserTimeOut;
-import org.eclipse.cdt.core.parser.ParserUtil;
-import org.eclipse.cdt.core.parser.ScannerInfo;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.core.parser.ast.ASTClassKind;
-import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
-import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTClassReference;
-import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
-import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
-import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
-import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTEnumeratorReference;
-import org.eclipse.cdt.core.parser.ast.IASTField;
-import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
-import org.eclipse.cdt.core.parser.ast.IASTFunction;
-import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
-import org.eclipse.cdt.core.parser.ast.IASTInclusion;
-import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
-import org.eclipse.cdt.core.parser.ast.IASTMacro;
-import org.eclipse.cdt.core.parser.ast.IASTMethod;
-import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
-import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
-import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
-import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
-import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
-import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
-import org.eclipse.cdt.core.parser.ast.IASTReference;
-import org.eclipse.cdt.core.parser.ast.IASTScope;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateParameterReference;
-import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
-import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
-import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
-import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
-import org.eclipse.cdt.core.parser.ast.IASTVariable;
-import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
-import org.eclipse.cdt.internal.core.browser.util.SimpleStack;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-public class TypeParser implements ISourceElementRequestor {
-
- private ITypeCache fTypeCache;
- private ITypeSearchScope fScope;
- private IProject fProject;
- private IWorkingCopyProvider fWorkingCopyProvider;
- private IProgressMonitor fProgressMonitor;
- ISourceElementCallbackDelegate fLastDeclaration;
- private final SimpleStack fScopeStack = new SimpleStack();
- private final SimpleStack fResourceStack = new SimpleStack();
- private ITypeInfo fTypeToFind;
- private ITypeInfo fSuperTypeToFind;
- private Set fProcessedTypes = new HashSet();
- private boolean fFoundType;
- IParser fParser = null;
- ParserTimeOut fTimeoutThread = null;
-
- public TypeParser(ITypeCache typeCache, IWorkingCopyProvider provider) {
- fTypeCache = typeCache;
- fWorkingCopyProvider = provider;
-
- fTimeoutThread = new ParserTimeOut("TypeParser TimeOut Thread"); //$NON-NLS-1$
- fTimeoutThread.setThreadPriority(Thread.MAX_PRIORITY);
- }
-
- public void parseTypes(TypeSearchScope scope, IProgressMonitor monitor) throws InterruptedException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- fScope = new TypeSearchScope(scope);
- Map workingCopyMap = null;
- if (fWorkingCopyProvider != null) {
- IWorkingCopy[] workingCopies = fWorkingCopyProvider.getWorkingCopies();
- if (workingCopies != null && workingCopies.length > 0) {
- workingCopyMap = new HashMap(workingCopies.length);
- for (int i = 0; i < workingCopies.length; ++i) {
- IWorkingCopy workingCopy = workingCopies[i];
- IPath wcPath = workingCopy.getOriginalElement().getPath();
- if (fScope.encloses(wcPath)) {
-// // always flush working copies from cache?
-// fTypeCache.flush(wcPath);
- fScope.add(wcPath, false, null);
- workingCopyMap.put(wcPath, workingCopy);
- }
- }
- }
- }
-
- fProject = fTypeCache.getProject();
- IPath[] searchPaths = fTypeCache.getPaths(fScope);
- Collection workingCopyPaths = new HashSet();
- if (workingCopyMap != null) {
- collectWorkingCopiesInProject(workingCopyMap, fProject, workingCopyPaths);
- //TODO what about working copies outside the workspace?
- }
-
- monitor.beginTask("", searchPaths.length + workingCopyPaths.size()); //$NON-NLS-1$
- try {
- for (Iterator pathIter = workingCopyPaths.iterator(); pathIter.hasNext(); ) {
- IPath path = (IPath) pathIter.next();
- parseSource(path, fProject, workingCopyMap, new SubProgressMonitor(monitor, 1));
- }
- for (int i = 0; i < searchPaths.length; ++i) {
- IPath path = searchPaths[i];
- if (!workingCopyPaths.contains(path)) {
- parseSource(path, fProject, workingCopyMap, new SubProgressMonitor(monitor, 1));
- } else {
- monitor.worked(1);
- }
- }
- } finally {
- monitor.done();
- }
- }
-
- public boolean findType(ITypeInfo info, IProgressMonitor monitor) throws InterruptedException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- fScope = new TypeSearchScope();
- ITypeReference[] refs = info.getReferences();
- if (refs == null || refs.length == 0)
- return false; // no source references
-
- fScope.add(refs[0].getPath(), false, null);
-// for (int i = 0; i < refs.length; ++i) {
-// ITypeReference location = refs[i];
-// IPath path = location.getPath();
-// fScope.add(path, false, null);
-// }
-
- Map workingCopyMap = null;
- if (fWorkingCopyProvider != null) {
- IWorkingCopy[] workingCopies = fWorkingCopyProvider.getWorkingCopies();
- if (workingCopies != null && workingCopies.length > 0) {
- workingCopyMap = new HashMap(workingCopies.length);
- for (int i = 0; i < workingCopies.length; ++i) {
- IWorkingCopy workingCopy = workingCopies[i];
- IPath wcPath = workingCopy.getOriginalElement().getPath();
- if (fScope.encloses(wcPath)) {
-// // always flush working copies from cache?
-// fTypeCache.flush(wcPath);
- fScope.add(wcPath, false, null);
- workingCopyMap.put(wcPath, workingCopy);
- }
- }
- }
- }
-
- fProject = fTypeCache.getProject();
- IPath[] searchPaths = fTypeCache.getPaths(fScope);
- Collection workingCopyPaths = new HashSet();
- if (workingCopyMap != null) {
- collectWorkingCopiesInProject(workingCopyMap, fProject, workingCopyPaths);
- //TODO what about working copies outside the workspace?
- }
-
- monitor.beginTask("", searchPaths.length + workingCopyPaths.size()); //$NON-NLS-1$
- try {
- fTypeToFind = info;
- fFoundType = false;
- for (Iterator pathIter = workingCopyPaths.iterator(); pathIter.hasNext(); ) {
- IPath path = (IPath) pathIter.next();
- parseSource(path, fProject, workingCopyMap, new SubProgressMonitor(monitor, 1));
- if (fFoundType)
- return true;
- }
- for (int i = 0; i < searchPaths.length; ++i) {
- IPath path = searchPaths[i];
- if (!workingCopyPaths.contains(path)) {
- parseSource(path, fProject, workingCopyMap, new SubProgressMonitor(monitor, 1));
- } else {
- monitor.worked(1);
- }
-
- if (fFoundType)
- return true;
- }
- } finally {
- fTypeToFind = null;
- fFoundType = false;
- monitor.done();
- }
- return false;
- }
-
- public boolean findSubTypes(ITypeInfo info, IProgressMonitor monitor) throws InterruptedException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
-
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- fScope = new TypeSearchScope();
- ITypeReference[] refs = info.getDerivedReferences();
- if (refs == null || refs.length == 0)
- return false; // no source references
-
- for (int i = 0; i < refs.length; ++i) {
- ITypeReference location = refs[i];
- IPath path = location.getPath();
- fScope.add(path, false, null);
- }
-
- Map workingCopyMap = null;
- if (fWorkingCopyProvider != null) {
- IWorkingCopy[] workingCopies = fWorkingCopyProvider.getWorkingCopies();
- if (workingCopies != null && workingCopies.length > 0) {
- workingCopyMap = new HashMap(workingCopies.length);
- for (int i = 0; i < workingCopies.length; ++i) {
- IWorkingCopy workingCopy = workingCopies[i];
- IPath wcPath = workingCopy.getOriginalElement().getPath();
- if (fScope.encloses(wcPath)) {
-// // always flush working copies from cache?
-// fTypeCache.flush(wcPath);
- fScope.add(wcPath, false, null);
- workingCopyMap.put(wcPath, workingCopy);
- }
- }
- }
- }
-
- fProject = fTypeCache.getProject();
- IPath[] searchPaths = fTypeCache.getPaths(fScope);
- Collection workingCopyPaths = new HashSet();
- if (workingCopyMap != null) {
- collectWorkingCopiesInProject(workingCopyMap, fProject, workingCopyPaths);
- //TODO what about working copies outside the workspace?
- }
-
- monitor.beginTask("", searchPaths.length + workingCopyPaths.size()); //$NON-NLS-1$
- try {
- fTypeToFind = null;
- fSuperTypeToFind = info;
- fFoundType = false;
- for (Iterator pathIter = workingCopyPaths.iterator(); pathIter.hasNext(); ) {
- IPath path = (IPath) pathIter.next();
- parseSource(path, fProject, workingCopyMap, new SubProgressMonitor(monitor, 1));
- }
- for (int i = 0; i < searchPaths.length; ++i) {
- IPath path = searchPaths[i];
- if (!workingCopyPaths.contains(path)) {
- parseSource(path, fProject, workingCopyMap, new SubProgressMonitor(monitor, 1));
- } else {
- monitor.worked(1);
- }
- }
- } finally {
- fTypeToFind = null;
- fFoundType = false;
- monitor.done();
- }
- return false;
- }
-
- private void collectWorkingCopiesInProject(Map workingCopyMap, IProject project, Collection workingCopyPaths) {
- for (Iterator mapIter = workingCopyMap.entrySet().iterator(); mapIter.hasNext(); ) {
- Map.Entry entry = (Map.Entry) mapIter.next();
- IPath path = (IPath) entry.getKey();
- IWorkingCopy copy = (IWorkingCopy) entry.getValue();
-
- ICProject cProject = copy.getCProject();
- if (cProject != null && cProject.getProject().equals(project)) {
- workingCopyPaths.add(path);
- }
- }
- }
-
- private void parseSource(IPath path, IProject project, Map workingCopyMap, IProgressMonitor progressMonitor) throws InterruptedException {
- if (progressMonitor.isCanceled())
- throw new InterruptedException();
-
- // count how many types were indexed for this path
- TypeSearchScope pathScope = new TypeSearchScope();
- pathScope.add(path, false, project);
- int typeCount = fTypeCache.getTypes(pathScope).length;
-
- progressMonitor.beginTask("", typeCount); //$NON-NLS-1$
- try {
- IWorkingCopy workingCopy = null;
- if (workingCopyMap != null) {
- workingCopy = (IWorkingCopy) workingCopyMap.get(path);
- }
-
- ParserLanguage language = getLanguage(project, workingCopy);
- if (language == null) {
- return; // not C or C++
- }
-
- CodeReader reader = null;
- Object stackObject = null;
-
- IResource resource = null;
- if (workingCopy != null) {
- reader = createWorkingCopyReader(workingCopy);
- resource = workingCopy.getResource();
- if (resource != null) {
- path = resource.getLocation();
- }
- stackObject = workingCopy;
- } else {
- IWorkspace workspace = CCorePlugin.getWorkspace();
- if (workspace != null) {
- IWorkspaceRoot wsRoot = workspace.getRoot();
- if (wsRoot != null) {
- resource = wsRoot.findMember(path, true);
- }
- }
- if (resource != null) {
- reader = createResourceReader(resource);
- path = resource.getLocation();
- stackObject = resource;
- } else {
- reader = createFileReader(path);
- stackObject = path;
- }
- }
-
- if (reader != null) {
- fResourceStack.clear();
- fScopeStack.clear();
- fResourceStack.push(stackObject);
- parseContents(path, resource, project, reader, language, progressMonitor);
- fResourceStack.pop();
- }
- } finally {
- progressMonitor.done();
- }
- }
-
- private ParserLanguage getLanguage(IProject project, IWorkingCopy workingCopy) {
- ParserLanguage projectLanguage = null;
- if (project != null) {
- if (CoreModel.hasCCNature(project)) {
- projectLanguage = ParserLanguage.CPP;
- } else if (CoreModel.hasCNature(project)) {
- projectLanguage = ParserLanguage.C;
- }
- }
-
- if (workingCopy != null) {
- ParserLanguage workingCopyLanguage = null;
- ITranslationUnit unit = workingCopy.getTranslationUnit();
- if (unit != null) {
- if (unit.isCLanguage()) {
- workingCopyLanguage = ParserLanguage.C;
- } else if (unit.isCXXLanguage()) {
- workingCopyLanguage = ParserLanguage.CPP;
- }
- }
- if (workingCopyLanguage != null) {
- if (projectLanguage == null) {
- return workingCopyLanguage;
- } else if (projectLanguage.equals(ParserLanguage.CPP)) {
- // if project is CPP then working copy must be CPP
- return projectLanguage;
- } else {
- return workingCopyLanguage;
- }
- }
- }
- return projectLanguage;
- }
-
- private CodeReader createWorkingCopyReader(IWorkingCopy workingCopy) {
- CodeReader reader = null;
- IResource resource = workingCopy.getResource();
- if (resource != null && resource.isAccessible()) {
- char[] contents = workingCopy.getContents();
- if (contents != null)
- reader = new CodeReader(resource.getLocation().toOSString(), contents);
- }
- return reader;
- }
-
- private CodeReader createResourceReader(IResource resource) {
- CodeReader reader = null;
- if (resource.isAccessible() && resource instanceof IFile) {
- IFile file = (IFile) resource;
- InputStream contents = null;
- try {
- contents = file.getContents();
- if (contents != null)
- reader = new CodeReader(resource.getLocation().toOSString(), file.getCharset(), contents);
- } catch (CoreException ex) {
- ex.printStackTrace();
- } catch (IOException e) {
- } finally {
- if (contents != null) {
- try {
- contents.close();
- } catch (IOException io) {
- // ignore
- }
- }
- }
- }
- return reader;
- }
-
- private CodeReader createFileReader(IPath path) {
- CodeReader reader = null;
- try {
- reader = new CodeReader(path.toOSString());
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- return reader;
- }
-
- private void parseContents(IPath realPath, IResource resource, IProject project, CodeReader reader, ParserLanguage language, IProgressMonitor progressMonitor) throws InterruptedException {
- IScannerInfo scanInfo = null;
-
- if (project != null) {
- //TODO temporary workaround to catch managed build exceptions
- try {
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- if (provider != null) {
- IScannerInfo buildScanInfo = provider.getScannerInformation(resource != null ? resource : project);
- if (buildScanInfo != null)
- scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- if (scanInfo == null)
- scanInfo = new ScannerInfo();
-
- try {
- fProgressMonitor = progressMonitor;
- IScanner scanner = ParserFactory.createScanner(reader, scanInfo,
- ParserMode.STRUCTURAL_PARSE, language, this, ParserUtil.getScannerLogService(), null);
- fParser = ParserFactory.createParser(scanner, this, ParserMode.STRUCTURAL_PARSE, language, ParserUtil.getParserLogService());
-
- // start timer
- int timeout = getParserTimeout();
- if (timeout > 0) {
- fTimeoutThread.setTimeout(timeout);
- fTimeoutThread.setParser(fParser);
- while (!fTimeoutThread.isReadyToRun()){
- try {
- Thread.sleep(20);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- fTimeoutThread.startTimer();
- }
-
- fParser.parse();
- } catch (ParserFactoryError e) {
- CCorePlugin.log(e);
- } catch (ParseError e) {
- // no need to log
- // CCorePlugin.log(e);
- } catch (OperationCanceledException e) {
- throw new InterruptedException();
- } catch (Exception e) {
- CCorePlugin.log(e);
- } finally {
- // stop timer
- fTimeoutThread.stopTimer();
- fTimeoutThread.setParser(null);
- fProgressMonitor = null;
- fParser = null;
- }
- }
-
- public boolean acceptProblem(IProblem problem) {
- return DefaultProblemHandler.ruleOnProblem(problem, ParserMode.COMPLETE_PARSE);
- }
- public void acceptUsingDirective(IASTUsingDirective usageDirective) {}
- public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {}
- public void acceptASMDefinition(IASTASMDefinition asmDefinition) {}
- public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {}
- public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {}
- public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {}
- public void enterTemplateInstantiation(IASTTemplateInstantiation instantiation) {}
- public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {}
- public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {}
- public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {}
- public void acceptParameterReference(IASTParameterReference reference) {}
- public void acceptTemplateParameterReference(IASTTemplateParameterReference reference) {}
- public void acceptTypedefReference(IASTTypedefReference reference) {}
- public void acceptEnumeratorReference(IASTEnumeratorReference reference) {}
- public void acceptClassReference(IASTClassReference reference) {}
- public void acceptNamespaceReference(IASTNamespaceReference reference) {}
- public void acceptVariableReference(IASTVariableReference reference) {}
- public void acceptFieldReference(IASTFieldReference reference) {}
- public void acceptEnumerationReference(IASTEnumerationReference reference) {}
- public void acceptFunctionReference(IASTFunctionReference reference) {}
- public void acceptMethodReference(IASTMethodReference reference) {}
- public void acceptField(IASTField field) {}
- public void acceptMacro(IASTMacro macro) {}
- public void acceptVariable(IASTVariable variable) {}
- public void acceptFunctionDeclaration(IASTFunction function) {}
- public void acceptMethodDeclaration(IASTMethod method) {}
- public void enterCodeBlock(IASTCodeScope scope) {}
- public void exitCodeBlock(IASTCodeScope scope) {}
- public void acceptFriendDeclaration(IASTDeclaration declaration) {}
-
- public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- pushScope(linkageSpec);
- }
-
- public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
- popScope();
- }
-
- public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
- pushScope(compilationUnit);
- }
-
- public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {
- popScope();
- }
-
- public void enterFunctionBody(IASTFunction function) {
- pushScope(function);
- }
-
- public void exitFunctionBody(IASTFunction function) {
- popScope();
- }
-
- public void enterMethodBody(IASTMethod method) {
- pushScope(method);
- }
-
- public void exitMethodBody(IASTMethod method) {
- popScope();
- }
-
- public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- fLastDeclaration = namespaceDefinition;
- acceptType(namespaceDefinition);
- pushScope(namespaceDefinition);
- }
-
- public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
- popScope();
- }
-
- public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
- fLastDeclaration = classSpecification;
- acceptType(classSpecification);
- pushScope(classSpecification);
- }
-
- public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
- popScope();
- }
-
- private void pushScope(IASTScope scope) {
- if (fProgressMonitor.isCanceled())
- throw new OperationCanceledException();
- fScopeStack.push(scope);
- }
-
- private IASTScope popScope() {
- if (fProgressMonitor.isCanceled())
- throw new OperationCanceledException();
- return (IASTScope) fScopeStack.pop();
- }
-
- public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) {
- fLastDeclaration = typedef;
- acceptType(typedef);
- }
-
- public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
- fLastDeclaration = enumeration;
- acceptType(enumeration);
- }
-
- public void acceptElaboratedForewardDeclaration(IASTElaboratedTypeSpecifier elaboratedType) {
- // acceptType(elaboratedType);
- }
-
- public void enterInclusion(IASTInclusion inclusion) {
- if (fProgressMonitor.isCanceled())
- throw new OperationCanceledException();
-
- String includePath = inclusion.getFullFileName();
- IPath path = new Path(includePath);
- path = PathUtil.getWorkspaceRelativePath(path);
-
- IResource resource = null;
- IWorkspace workspace = CCorePlugin.getWorkspace();
- if (workspace != null) {
- IWorkspaceRoot wsRoot = workspace.getRoot();
- if (wsRoot != null) {
- resource = wsRoot.findMember(path, true);
- }
- }
- //TODO do inclusions get parsed as working copies?
-
- Object stackObject = path;
- if (resource != null)
- stackObject = resource;
-
- fResourceStack.push(stackObject);
- }
-
- public void exitInclusion(IASTInclusion inclusion) {
- if (fProgressMonitor.isCanceled())
- throw new OperationCanceledException();
- fResourceStack.pop();
- }
-
- private class NodeTypeInfo {
- int type;
- String name;
- String[] enclosingNames;
- int offset;
- int end;
- IASTOffsetableNamedElement offsetable;
-
- void init() {
- type = 0;
- name = null;
- enclosingNames = null;
- offset = 0;
- end = 0;
- offsetable = null;
- }
-
- boolean parseNodeForTypeInfo(ISourceElementCallbackDelegate node) {
- init();
-
- if (node instanceof IASTReference) {
- IASTReference reference = (IASTReference) node;
- offset = reference.getOffset();
- end = offset + reference.getName().length();
- } else if (node instanceof IASTOffsetableNamedElement) {
- offsetable = (IASTOffsetableNamedElement) node;
- offset = offsetable.getNameOffset() != 0 ? offsetable.getNameOffset() : offsetable.getStartingOffset();
- end = offsetable.getNameEndOffset();
- if (end == 0) {
- end = offset + offsetable.getName().length();
- }
- }
-
- if (node instanceof IASTReference)
- node = fLastDeclaration;
- if (node instanceof IASTReference) {
- offsetable = (IASTOffsetableNamedElement) ((IASTReference) node).getReferencedElement();
- name = ((IASTReference) node).getName();
- } else if (node instanceof IASTOffsetableNamedElement) {
- offsetable = (IASTOffsetableNamedElement) node;
- name = offsetable.getName();
- } else {
- return false;
- }
-
- // skip unnamed structs
- if (name == null || name.length() == 0)
- return false;
-
- // skip unused types
- type = getElementType(offsetable);
- if (type == 0) {
- return false;
- }
-
- // collect enclosing names
- if (offsetable instanceof IASTQualifiedNameElement) {
- String[] names = ((IASTQualifiedNameElement) offsetable).getFullyQualifiedName();
- if (names != null && names.length > 1) {
- enclosingNames = new String[names.length - 1];
- System.arraycopy(names, 0, enclosingNames, 0, names.length - 1);
- }
- }
-
- return true;
- }
-
- }
-
- private void acceptType(ISourceElementCallbackDelegate node) {
- if (fProgressMonitor.isCanceled())
- throw new OperationCanceledException();
-
- // skip local declarations
- IASTScope currentScope = (IASTScope) fScopeStack.top();
- if (currentScope instanceof IASTFunction || currentScope instanceof IASTMethod) {
- return;
- }
-
- NodeTypeInfo nodeInfo = new NodeTypeInfo();
- if (nodeInfo.parseNodeForTypeInfo(node)) {
- TypeReference originalLocation = null;
- Object originalRef = fResourceStack.bottom();
- if (originalRef instanceof IWorkingCopy) {
- IWorkingCopy workingCopy = (IWorkingCopy) originalRef;
- originalLocation = new TypeReference(workingCopy, fProject);
- } else if (originalRef instanceof IResource) {
- IResource resource = (IResource) originalRef;
- originalLocation = new TypeReference(resource, fProject);
- } else if (originalRef instanceof IPath) {
- IPath path = PathUtil.getProjectRelativePath((IPath)originalRef, fProject);
- originalLocation = new TypeReference(path, fProject);
- }
-
- TypeReference resolvedLocation = null;
- Object resolvedRef = fResourceStack.top();
- if (resolvedRef instanceof IWorkingCopy) {
- IWorkingCopy workingCopy = (IWorkingCopy) resolvedRef;
- resolvedLocation = new TypeReference(workingCopy, fProject, nodeInfo.offset, nodeInfo.end - nodeInfo.offset);
- } else if (resolvedRef instanceof IResource) {
- IResource resource = (IResource) resolvedRef;
- resolvedLocation = new TypeReference(resource, fProject, nodeInfo.offset, nodeInfo.end - nodeInfo.offset);
- } else if (resolvedRef instanceof IPath) {
- IPath path = PathUtil.getProjectRelativePath((IPath)resolvedRef, fProject);
- resolvedLocation = new TypeReference(path, fProject, nodeInfo.offset, nodeInfo.end - nodeInfo.offset);
- }
-
- if (fTypeToFind != null) {
- if ((fTypeToFind.getCElementType() == nodeInfo.type || fTypeToFind.isUndefinedType()) && nodeInfo.name.equals(fTypeToFind.getName())) {
- QualifiedTypeName qualifiedName = new QualifiedTypeName(nodeInfo.name, nodeInfo.enclosingNames);
- if (qualifiedName.equals(fTypeToFind.getQualifiedTypeName())) {
- // add types to cache
- ITypeInfo newType = addType(nodeInfo.type, qualifiedName, originalLocation, resolvedLocation);
- if (newType != null && node instanceof IASTClassSpecifier) {
- addSuperClasses(newType, (IASTClassSpecifier)node, originalLocation, fProcessedTypes);
- }
- fProgressMonitor.worked(1);
-
- fFoundType = true;
- // terminate the parser
- fParser.cancel();
- }
- }
- } else {
- // add types to cache
- QualifiedTypeName qualifiedName = new QualifiedTypeName(nodeInfo.name, nodeInfo.enclosingNames);
- ITypeInfo newType = addType(nodeInfo.type, qualifiedName, originalLocation, resolvedLocation);
- if (newType != null && node instanceof IASTClassSpecifier) {
- addSuperClasses(newType, (IASTClassSpecifier)node, originalLocation, fProcessedTypes);
- }
- fProgressMonitor.worked(1);
- }
- }
- }
-
- int getElementType(IASTOffsetableNamedElement offsetable) {
- if (offsetable instanceof IASTClassSpecifier || offsetable instanceof IASTElaboratedTypeSpecifier) {
- ASTClassKind kind = null;
- if (offsetable instanceof IASTClassSpecifier) {
- kind = ((IASTClassSpecifier) offsetable).getClassKind();
- } else {
- kind = ((IASTElaboratedTypeSpecifier) offsetable).getClassKind();
- }
- if (kind == ASTClassKind.CLASS) {
- return ICElement.C_CLASS;
- } else if (kind == ASTClassKind.STRUCT) {
- return ICElement.C_STRUCT;
- } else if (kind == ASTClassKind.UNION) {
- return ICElement.C_UNION;
- }
- } else if (offsetable instanceof IASTNamespaceDefinition) {
- return ICElement.C_NAMESPACE;
- } else if (offsetable instanceof IASTEnumerationSpecifier) {
- return ICElement.C_ENUMERATION;
- } else if (offsetable instanceof IASTTypedefDeclaration) {
- return ICElement.C_TYPEDEF;
- }
- return 0;
- }
-
- private void addSuperClasses(ITypeInfo type, IASTClassSpecifier classSpec, TypeReference location, Set processedClasses) {
- Iterator baseIter = classSpec.getBaseClauses();
- if (baseIter != null) {
- while (baseIter.hasNext()) {
- IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) baseIter.next();
- try {
- ASTAccessVisibility baseAccess = baseSpec.getAccess();
-
- IASTClassSpecifier parentClass = null;
- IASTTypeSpecifier parentSpec = baseSpec.getParentClassSpecifier();
- if (parentSpec instanceof IASTClassSpecifier)
- parentClass = (IASTClassSpecifier) parentSpec;
-
- if (parentClass != null) {
- NodeTypeInfo nodeInfo = new NodeTypeInfo();
- if (nodeInfo.parseNodeForTypeInfo(parentClass)) {
- // add type to cache
- ITypeInfo superType = addSuperType(type, nodeInfo.type, nodeInfo.name, nodeInfo.enclosingNames, location, baseAccess, baseSpec.isVirtual());
-
- // recursively process super super classes
- if (!processedClasses.contains(parentClass)) {
- processedClasses.add(parentClass);
- addSuperClasses(superType, parentClass, location, processedClasses);
- }
- }
- }
- } catch (ASTNotImplementedException e) {
- }
- }
- }
- }
-
- private ITypeInfo addType(int type, QualifiedTypeName qualifiedName, TypeReference originalLocation, TypeReference resolvedLocation) {
- ITypeInfo info = fTypeCache.getType(type, qualifiedName);
- if (info == null || info.isUndefinedType()) {
- // add new type to cache
- if (info != null) {
- info.setCElementType(type);
- } else {
- info = new TypeInfo(type, qualifiedName);
- fTypeCache.insert(info);
- }
-
- info.addReference(originalLocation);
- }
-
- info.addReference(resolvedLocation);
-
- return info;
- }
-
- private ITypeInfo addSuperType(ITypeInfo addToType, int type, String name, String[] enclosingNames, TypeReference location, ASTAccessVisibility access, boolean isVirtual) {
- QualifiedTypeName qualifiedName = new QualifiedTypeName(name, enclosingNames);
- ITypeInfo superType = fTypeCache.getType(type, qualifiedName);
- if (superType == null || superType.isUndefinedType()) {
- if (superType != null) {
- // merge with existing type
- superType.setCElementType(type);
- } else {
- // add new type to cache
- superType = new TypeInfo(type, qualifiedName);
- fTypeCache.insert(superType);
- }
- }
- superType.addDerivedReference(location);
-
- if (fSuperTypeToFind != null && fSuperTypeToFind.equals(superType)) {
- //TODO don't need to do anything here?
- }
- fTypeCache.addSupertype(addToType, superType, access, isVirtual);
- fTypeCache.addSubtype(superType, addToType);
- return superType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#createReader(java.lang.String)
- */
- public CodeReader createReader(String finalPath, Iterator workingCopies) {
- return ParserUtil.createReader(finalPath, workingCopies);
- }
-
- private static final int DEFAULT_PARSER_TIMEOUT = 30;
-
- public int getParserTimeout() {
- //TODO we shouldn't be trying to access the indexer prefs
- //TODO clean this up
- int timeout = 0;
- try {
- // here we just reuse the indexer timeout
- String str = CCorePlugin.getDefault().getPluginPreferences().getString("CDT_INDEXER_TIMEOUT"); //$NON-NLS-1$
- if (str != null && str.length() > 0) {
- int val = Integer.valueOf(str).intValue();
- if (val > 0) {
- timeout = val;
- }
- }
- } catch (NumberFormatException e) {
- // do nothing
- }
-
- if (timeout == 0) {
- timeout = DEFAULT_PARSER_TIMEOUT;
- }
- return timeout;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/ArrayUtil.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/ArrayUtil.java
deleted file mode 100644
index a7f62f29445..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/ArrayUtil.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.util;
-
-/**
- * A helper class which allows you to perform some
- * simple set operations on int arrays.
- */
-public class ArrayUtil {
- private ArrayUtil() {
- }
-
- // returns true if set contains elem
- public static boolean contains(int[] set, int elem) {
- if (set == null)
- return false;
- for (int i= 0; i < set.length; ++i) {
- if (set[i] == elem)
- return true;
- }
- return false;
- }
-
- // returns true if set contains all of subset
- public static boolean containsAll(int[] set, int[] subset) {
- if (set == null || subset == null)
- return false;
- for (int i= 0; i < subset.length; ++i) {
- if (!contains(set, subset[i]))
- return false;
- }
- return true;
- }
-
- // return a copy of fromSet
- public static int[] clone(int[] fromSet) {
- if (fromSet == null)
- return null;
- int[] newSet= new int[fromSet.length];
- for (int i= 0; i < fromSet.length; ++i) {
- newSet[i]= fromSet[i];
- }
- return newSet;
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/DelegatedProgressMonitor.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/DelegatedProgressMonitor.java
deleted file mode 100644
index 4c229af80ca..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/DelegatedProgressMonitor.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IProgressMonitorWithBlocking;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * A wrapper around one or more progress monitors. Forwards
- * IProgressMonitor
and IProgressMonitorWithBlocking
- * methods to the delegate monitors.
- */
-public class DelegatedProgressMonitor implements IProgressMonitor, IProgressMonitorWithBlocking {
-
- private static int INITIAL_DELEGATE_COUNT = 2;
- private final ArrayList fDelegateList = new ArrayList(INITIAL_DELEGATE_COUNT);
- String fTaskName;
- String fSubTask;
- int fTotalWork;
- private double fWorked;
- private boolean fIsBlocked;
- boolean fIsCanceled;
-
- /**
- * Creates a new delegated monitor.
- */
- public DelegatedProgressMonitor() {
- init();
- }
-
- /**
- * Creates a new delegated monitor, and adds a delegate.
- */
- public DelegatedProgressMonitor(IProgressMonitor delegate) {
- init();
- addDelegate(delegate);
- }
-
- /**
- * Resets delegated monitor to initial state.
- */
- public synchronized void init() {
- fTaskName= null;
- fSubTask= null;
- fTotalWork= IProgressMonitor.UNKNOWN;
- fWorked= 0.0f;
- fIsBlocked= false;
- fIsCanceled= false;
- }
-
- /*
- * @see IProgressMonitor#beginTask
- */
- public synchronized void beginTask(String name, int totalWork) {
- fTaskName = name;
- fTotalWork = totalWork;
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- delegate.beginTask(fTaskName, fTotalWork);
- }
- });
- }
-
- /*
- * @see IProgressMonitor#done
- */
- public synchronized void done() {
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- delegate.done();
- }
- });
- }
-
- /*
- * @see IProgressMonitor#setTaskName
- */
- public synchronized void setTaskName(String name) {
- fTaskName = name;
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- delegate.setTaskName(fTaskName);
- }
- });
- }
-
- /*
- * @see IProgressMonitor#subTask
- */
- public synchronized void subTask(String name) {
- fSubTask = name;
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- delegate.subTask(fSubTask);
- }
- });
- }
-
- /*
- * @see IProgressMonitor#worked
- */
- public void worked(int work) {
- internalWorked(work);
- }
-
- /*
- * @see IProgressMonitor#internalWorked
- */
- public synchronized void internalWorked(double internalWork) {
- fWorked += internalWork;
- final double fInternalWork = internalWork;
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- delegate.internalWorked(fInternalWork);
- }
- });
- }
-
- /*
- * @see IProgressMonitor#isCanceled
- */
- public synchronized boolean isCanceled() {
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- fIsCanceled |= delegate.isCanceled();
- }
- });
- return fIsCanceled;
- }
-
- /*
- * @see IProgressMonitor#setCanceled
- */
- public synchronized void setCanceled(boolean canceled) {
- fIsCanceled = canceled;
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- delegate.setCanceled(fIsCanceled);
- }
- });
- }
-
- /*
- * @see IProgressMonitor#setBlocked
- */
- public synchronized void setBlocked(IStatus reason) {
- fIsBlocked = true;
- final IStatus fReason = reason;
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- if (delegate instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) delegate).setBlocked(fReason);
- }
- });
- }
-
- /*
- * @see IProgressMonitor#clearBlocked
- */
- public synchronized void clearBlocked() {
- fIsBlocked = false;
- visitDelegates(new IDelegateVisitor() {
- public void visit(IProgressMonitor delegate) {
- if (delegate instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) delegate).clearBlocked();
- }
- });
- }
-
- /**
- * Adds a delegate.
- */
- public synchronized void addDelegate(IProgressMonitor delegate) {
- if (fDelegateList.indexOf(delegate) == -1) {
- if (fTaskName != null)
- syncUp(delegate);
- fDelegateList.add(delegate);
- }
- }
-
- /**
- * Brings delegate in sync with current progress.
- */
- private void syncUp(IProgressMonitor delegate) {
- delegate.beginTask(fTaskName, fTotalWork);
- delegate.internalWorked(fWorked);
- if (fSubTask != null && fSubTask.length() > 0)
- delegate.subTask(fSubTask);
- if (fIsBlocked && delegate instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) delegate).setBlocked(null);
- }
-
- /**
- * Removes a delegate.
- */
- public synchronized void removeDelegate(IProgressMonitor delegate) {
- int index = fDelegateList.indexOf(delegate);
- if (index != -1) {
- fDelegateList.remove(index);
- }
- }
-
- /**
- * Removes all delegates.
- */
- public synchronized void removeAllDelegates() {
- fDelegateList.clear();
- }
-
- /**
- * Returns the delegate list.
- *
- * @return An array of progress monitors added using addDelegate()
.
- */
- public synchronized IProgressMonitor[] getDelegates() {
- return (IProgressMonitor[]) fDelegateList.toArray();
- }
-
- /**
- * Defines a delegate visitor.
- */
- private static interface IDelegateVisitor {
- public void visit(IProgressMonitor delegate);
- }
-
- /**
- * Visits each delegate in the delegates list.
- */
- private void visitDelegates(IDelegateVisitor visitor) {
- // Clone the delegates since they could remove themselves when called
- ArrayList delegatesList = (ArrayList) fDelegateList.clone();
- for (Iterator i = delegatesList.iterator(); i.hasNext(); ) {
- IProgressMonitor delegate = (IProgressMonitor) i.next();
- visitor.visit(delegate);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/SimpleStack.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/SimpleStack.java
deleted file mode 100644
index 433439af856..00000000000
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/util/SimpleStack.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.browser.util;
-
-import java.util.ArrayList;
-
-/**
- * A helper class which allows you to perform some simple
- * stack operations. Avoids the extra overhead of
- * synchronization in Java.Util.Stack.
- */
-public class SimpleStack {
-
- private static int INITIAL_STACK_SIZE = 10;
- private ArrayList items;
- private static boolean VERBOSE = false;
-
- public SimpleStack() {
- items = new ArrayList(INITIAL_STACK_SIZE);
- }
-
- public SimpleStack(int initialSize) {
- items = new ArrayList(initialSize);
- }
-
- public void clear() {
- items.clear();
- }
-
- public Object push(Object item) {
- items.add(item);
- if (VERBOSE)
- trace("push on stack: " + item); //$NON-NLS-1$
- return item;
- }
-
- public Object pop() {
- int top = items.size()-1;
- if (top < 0)
- return null;
- Object item = items.get(top);
- items.remove(top);
- if (VERBOSE)
- trace("pop from stack: " + item); //$NON-NLS-1$
- return item;
- }
-
- public Object top() {
- int top = items.size()-1;
- if (top < 0)
- return null;
- return items.get(top);
- }
-
- public Object bottom() {
- if (items.size() == 0)
- return null;
- return items.get(0);
- }
-
- public boolean isEmpty() {
- return (items.size() == 0);
- }
-
- public Object[] toArray() {
- return items.toArray();
- }
-
- public Object[] toArray(Object a[]) {
- return items.toArray(a);
- }
-
- private static void trace(String msg) {
- System.out.println("(" + Thread.currentThread() + ") " + msg); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/core/org.eclipse.cdt.core/dependency/ChangeLog b/core/org.eclipse.cdt.core/dependency/ChangeLog
deleted file mode 100644
index 05411b253a7..00000000000
--- a/core/org.eclipse.cdt.core/dependency/ChangeLog
+++ /dev/null
@@ -1,74 +0,0 @@
-2005-03-12 Bogdan Gheorghe
- - Updated references from IndexManager to SourceIndexer due to new indexer framework
-
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
-
-2004-02-25 Bogdan Gheorghe
- - Check to see if the resource has a location before using it in
- UpdateDependency
-
-2003-11-10 Bogdan Gheorghe
- - Added a null resource check in UpdateDependency to fix up
- a potential NPE in the test suite
-
-2003-10-23 Bogdan Gheorghe
- - Added UpdateDependency job
-
-2003-09-25 Bogdan Gheorghe
- - As a result of folding the dependency service into the indexer
- have removed the following files:
-
- * src/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencySelector.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/RemoveFromDependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
-
-
-
-2003-09-22 Bogdan Gheorghe
- - Took out enable section for DependencyManager
-
-2003-09-11 Bogdan Gheorghe
- - Added null guard to DependencyManager.getDependencyTree(),
- DependencyTree.getFileDependencies()
-
-2003-09-08 Andrew Niefer
- - Modified calls to ParserFactory to specify which language to use
- - Modified IDependencyTree.add to take ParserLanguage as a parameter so that it can
- be passed on when creating the preprocessor
-
-2003-07-23 Bogdan Gheorghe
-
- Added initial dependency implementation
-
- * src/org/eclipse/cdt/internal/core/sourcedependency/AddFileToDependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyManager.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DenpendencyQueryJob.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequest.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyRequestor.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/DependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/EntireProjectDependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/IDependencyTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/IPreprocessorOutput.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/ISourceDependency.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/PreprocessorOutput.java
-
- * src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntry.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/impl/IncludeEntryHashedArray.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
- * src/org/eclipse/cdt/internal/core/sourcedependency/impl/Node.java
-
--
-
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java b/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java
deleted file mode 100644
index 295f44e674b..00000000000
--- a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.sourcedependency;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.cindexstorage.IncludeEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
-import org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer;
-import org.eclipse.cdt.internal.core.search.IndexSelector;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
-import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
-import org.eclipse.cdt.internal.core.search.processing.JobManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-/**
- * @author bgheorgh
- */
-public class DependencyQueryJob implements IIndexJob {
-
- IProject project;
- IFile file;
- ArrayList includeFiles;
- DOMSourceIndexer indexer;
- IndexManager indexManager;
- protected IndexSelector indexSelector;
- protected long executionTime = 0;
-
- public DependencyQueryJob(IProject project, IFile file, DOMSourceIndexer indexer, List includeFiles) {
- this.project = project;
- this.file = file;
- this.indexer = indexer;
- this.includeFiles = (ArrayList) includeFiles;
- this.indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.search.processing.IJob#belongsTo(java.lang.String)
- */
- public boolean belongsTo(String jobFamily) {
- // TODO Auto-generated method stub
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.search.processing.IJob#cancel()
- */
- public void cancel() {}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.search.processing.IJob#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean execute(IProgressMonitor progressMonitor) {
- if ((project == null) ||(file == null)) return false;
- //
- if (progressMonitor != null && progressMonitor.isCanceled())
- throw new OperationCanceledException();
- boolean isComplete = COMPLETE;
- executionTime = 0;
- if (this.indexSelector == null) {
- this.indexSelector =
- new IndexSelector(SearchEngine.createWorkspaceScope(), null, false, indexManager);
- }
- IIndex[] searchIndexes = this.indexSelector.getIndexes();
- try {
- int max = searchIndexes.length;
- int min=0;
- if (progressMonitor != null) {
- progressMonitor.beginTask("", max); //$NON-NLS-1$
- }
- for (int i = 0; i < max; i++) {
- isComplete &= getFileDeps(searchIndexes[i], progressMonitor);
- if (progressMonitor != null) {
- if (progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- } else {
- progressMonitor.worked(1);
- }
- }
- }
- if (JobManager.VERBOSE) {
- JobManager.verbose("-> execution time: " + executionTime + "ms - " + this);//$NON-NLS-1$//$NON-NLS-2$
- }
- return isComplete;
- } finally {
- if (progressMonitor != null) {
- progressMonitor.done();
- }
- }
- }
-
- /**
- * @param index
- * @param progressMonitor
- * @return
- */
- public boolean getFileDeps(IIndex index, IProgressMonitor progressMonitor){
-
- if (progressMonitor != null && progressMonitor.isCanceled())
- throw new OperationCanceledException();
-
- if (index == null)
- return COMPLETE;
-
-
- if (!(indexer instanceof DOMSourceIndexer))
- return FAILED;
-
-
- DOMSourceIndexer sourceIndexer = (DOMSourceIndexer)indexer;
-
- ReadWriteMonitor monitor = sourceIndexer.getMonitorFor(index);
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
- try {
- monitor.enterRead(); // ask permission to read
-
- /* if index has changed, commit these before querying */
- if (index.hasChanged()) {
- try {
- monitor.exitRead(); // free read lock
- monitor.enterWrite(); // ask permission to write
- sourceIndexer.saveIndex(index);
- } catch (IOException e) {
- return FAILED;
- } finally {
- monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
- }
- }
- long start = System.currentTimeMillis();
- //
- IndexInput input = new BlocksIndexInput(index.getIndexFile());
- try {
- input.open();
- findDep(input);
- } finally {
- input.close();
- }
-
- executionTime += System.currentTimeMillis() - start;
- return COMPLETE;
- }
- catch (IOException e){
- return FAILED;
- }
- finally {
- monitor.exitRead(); // finished reading
- }
- }
-
- /**
- * @param input
- * @param includeFiles
- */
- private void findDep(IndexInput input) throws IOException {
-
- IndexedFileEntry indexedFile = input.getIndexedFile(file.getFullPath().toString());
- if (indexedFile == null) return;
-
-
- int fileNum =indexedFile.getFileID();
- IncludeEntry[] tempEntries = input.queryIncludeEntries(fileNum);
- if (tempEntries != null){
- for (int r=0; rICDTIndexer
provides.
- */
- public int getIndexerFeatures();
-
- /**
- * The IndexManager
calls addRequest when it receives an event from the DeltaProcessor
.
- * The IResourcDelta
and (TODO: IResourceChangeEvent
are provided for indexers
- * to decide how to schedule this event).
- */
- public void addRequest(IProject project, IResourceDelta delta, int kind);
-
- /**
- * The IndexManager
calls addRequest when it receives an event from the DeltaProcessor
.
- * The IResourcDelta
and (TODO:IResourceChangeEvent
are provided for the indexder
- * to decide how to schedule this event).
- */
- public void removeRequest(IProject project, IResourceDelta delta, int kind);
-
- /**
- * Adds the given resource to the IProject's index
- */
- public void addResource(IProject project, IResource resource);
-
- /**
- * Removes the given resource from the IProject's index
- */
- public void removeResource(IProject project, IResource resource);
-
- /**
- * Attempts to add the resource type specified by the path to the project's index
- */
- public void addResourceByPath(IProject project, IPath path, int resourceType);
-
- /**
- * The IndexManager
will send out a jobFinishedEvent to the indexer that
- * had scheduled the previous runnign job to give that indexer a chance to update its
- * state info.
- */
- public void indexJobFinishedNotification(IIndexJob job);
-
- /**
- * The IndexManager
will notify all indexers of impending shutdown events
- * in order to allow indexers to perform whatever clean up they need to do.
- */
- public void shutdown();
-
- /**
- * Called by the index manager when there are no index jobs queued up - can be
- * used by the indexer to save indexes etc.
- * @param idlingTime
- */
- public void notifyIdle(long idlingTime);
-
- /**
- * Called by the index manager when a project has switched indexers to this
- * type of indexer - can be used by the indexer to schedule initial jobs
- * @param project - the project that has changed indexers
- */
- public void notifyIndexerChange(IProject project);
-
- /**
- * Called by the index manager when a project has switched indexers to this
- * type of indexer - can be used by the indexer to schedule initial jobs
- * @param project - the project that has changed indexers
- */
- public void notifyListeners(IndexDelta indexDelta);
-
- /**
- * Returns if this indexer is enabled
- * @param project
- * @return
- */
- public boolean isIndexEnabled(IProject project);
-
- /**
- * Returns the storage used by this indexer.
- * @return
- */
- public IIndexStorage getIndexStorage();
-
- /**
- * Returns the index for the given path.
- *
- * @param path
- * @param reuseExistingFile
- * @param createIfMissing
- * @return
- */
- public IIndex getIndex(IPath path, boolean reuseExistingFile, boolean createIfMissing);
-
- /**
- * Called by the index manager when this indexer is about to be removed from a project.
- * @param project
- */
- public void indexerRemoved(IProject project);
-
- /**
- * Don't ask.
- *
- * @param index
- * @return
- */
- public ReadWriteMonitor getMonitorFor(IIndex index);
-
- /**
- * Don't tell.
- *
- * @param index
- */
- public void saveIndex(IIndex index) throws IOException;
-
- /**
- * Associate a project with indexer
- *
- * @param project
- */
- public void setIndexerProject(IProject project);
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexChangeListener.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexChangeListener.java
deleted file mode 100644
index 4ebb94b5e59..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexChangeListener.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-
-package org.eclipse.cdt.core.index;
-
-public interface IIndexChangeListener {
- /**
- * @param event the change event
- */
- public void indexChanged(IndexChangeEvent event);
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java
deleted file mode 100644
index 7500b82e94e..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexDelta.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.index;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-
-public interface IIndexDelta {
-
- public class IndexDeltaType {
-
- private IndexDeltaType( int value )
- {
- this.value = value;
- }
- private final int value;
- }
-
- public static final IndexDeltaType MERGE_DELTA = new IndexDeltaType( 0 );
-
- public static final IndexDeltaType INDEX_FINISHED_DELTA = new IndexDeltaType( 1 );
-
- /**
- * @return Returns the files.
- */
- public List getFiles();
- /**
- * @return Returns the project.
- */
- public IProject getProject();
- /**
- * @return Returns the delta type.
- */
- public IndexDeltaType getDeltaType();
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexStorage.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexStorage.java
deleted file mode 100644
index 1697a33bac9..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IIndexStorage.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.index;
-
-/**
- * @author Bogdan Gheorghe
- *
- * IIndexStorage must be implemented by all indexStorage providers
- */
-public interface IIndexStorage {
-
- //Indexer that use this indexer storage
- public ICDTIndexer[] getIndexers();
-
- //Get path variables that are used
- public String[] getPathVariables();
- public void resolvePathVariables();
-
- //Merge functionality for the storage
- public void merge();
- public boolean canMergeWith(IIndexStorage storage);
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IndexChangeEvent.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IndexChangeEvent.java
deleted file mode 100644
index 0d812fa0f82..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/IndexChangeEvent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-
-package org.eclipse.cdt.core.index;
-
-import java.util.EventObject;
-
-public class IndexChangeEvent extends EventObject {
-
- /**
- * @param source
- */
- public IndexChangeEvent(IIndexDelta delta) {
- super(delta);
- }
-
- /**
- * Returns the delta describing the change.
- *
- */
- public IIndexDelta getDelta() {
- return (IIndexDelta) source;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/Indexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/Indexer.java
deleted file mode 100644
index d88a8ce1385..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/core/index/Indexer.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on May 28, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.cdt.core.index;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.internal.core.index.nullindexer.NullIndexer;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.core.resources.IProject;
-
-/**
- * @author bgheorgh
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class Indexer {
- private static Indexer indexer = null;
- private static IndexManager manager= CCorePlugin.getDefault().getCoreModel().getIndexManager();
-
- public static boolean indexEnabledOnAllProjects(){
- IProject[] projects= CCorePlugin.getWorkspace().getRoot().getProjects();
- boolean allEnabled = true;
- for (int i=0; iIIndex
.The caller should use
- * shouldIndex()
first to determine whether this indexer handles
- * the given type of file, and only call this method if so.
- */
-
- void index(IFile document, IIndexerOutput output) throws java.io.IOException;
-
- /**
- * Returns whether the IIndexer
can index the given IFile or not.
- */
-
- public boolean shouldIndex(IFile file);
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/INamedEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/INamedEntry.java
deleted file mode 100644
index ca0b58b6eef..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/INamedEntry.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.index;
-
-public interface INamedEntry extends IIndexEntry, ICIndexStorageEntry {
- /**
- * @return Returns the fully qualified name of this entry
- */
- public char[][] getFullName();
- /**
- * @return Returns the modifier bit field
- */
- public int getModifiers();
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IQueryResult.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IQueryResult.java
deleted file mode 100644
index a70ce3c9b0a..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IQueryResult.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index;
-
-public interface IQueryResult {
- String getPath();
- int getFileID();
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ITypeEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ITypeEntry.java
deleted file mode 100644
index 1501eee520f..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ITypeEntry.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.index;
-
-/**
- * Interface used to encode type entries for the CIndexStorgage format
- * Type entry constants are defined in IIndex. The list of types are:
- *
- * TYPE_CLASS
- * TYPE_STRUCT
- * TYPE_UNION
- * TYPE_ENUM
- * TYPE_VAR
- * TYPE_TYPEDEF
- * TYPE_DERIVED
- * TYPE_FRIEND
- * TYPE_FWD_CLASS
- * TYPE_FWD_STRUCT
- * TYPE_FWD_UNION
- *
- * @author bgheorgh
- * @since 3.0
- */
-public interface ITypeEntry extends INamedEntry {
-
- /**
- * Returns the kind of this type entry
- * @return int representing type kind defined in IIndex.
- */
- public int getTypeKind();
- /**
- * Returns the types that are inherited
- * @return an array of index entries - each representing a separate type that this entry inherits from
- */
- public IIndexEntry[] getBaseTypes();
- /**
- * Return friend types
- * @return an array of index entries - each representing a friend to this type
- */
- public IIndexEntry[] getFriends();
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IndexRequest.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IndexRequest.java
deleted file mode 100644
index 5afafd11ca9..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IndexRequest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index;
-
-import org.eclipse.cdt.internal.core.index.cindexstorage.CIndexStorage;
-import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
-import org.eclipse.core.runtime.IPath;
-
-public abstract class IndexRequest implements IIndexJob {
-
- protected boolean isCancelled = false;
- protected IPath indexPath = null;
-
- public IndexRequest(IPath indexPath) {
- this.indexPath = indexPath;
- }
-
- public boolean belongsTo(String projectName) {
- return projectName.equals(this.indexPath.segment(0));
- }
-
- protected Integer updatedIndexState() {
- return CIndexStorage.UPDATING_STATE;
- }
-
- public IPath getIndexPath(){
- return indexPath;
- }
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/NamedEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/NamedEntry.java
deleted file mode 100644
index e647f7e375a..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/NamedEntry.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.index;
-
-public class NamedEntry extends CIndexStorageEntry implements INamedEntry {
-
- char[][] fullName;
- int modifiers;
-
- public NamedEntry(int meta_kind, int entry_type, char[][] fullName, int modifiers, int fileNumber){
- super(meta_kind, entry_type, fileNumber);
- this.fullName = fullName;
- this.modifiers = modifiers;
- }
-
- public NamedEntry(int meta_kind, int entry_type, String simpleName, int modifiers, int fileNumber){
- super(meta_kind, entry_type, fileNumber);
- this.fullName = new char[][]{simpleName.toCharArray()};
- this.modifiers = modifiers;
- }
- public char[][] getFullName(){
- return fullName;
- }
-
- public int getModifiers(){
- return modifiers;
- }
-
- public void serialize(IIndexerOutput output) {
- output.addIndexEntry(this);
- }
-
- /* BugZilla ID#124618 */
- public void setNamedEntry(int meta_kind, int entry_type, char[][] fullName, int modifiers, int fileNumber) {
- this.entry_type = entry_type;
- this.fileNumber = fileNumber;
- this.fullName = fullName;
- this.modifiers = modifiers;
- }
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/StringMatcher.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/StringMatcher.java
deleted file mode 100644
index 8a2ce2b2da3..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/StringMatcher.java
+++ /dev/null
@@ -1,395 +0,0 @@
-package org.eclipse.cdt.internal.core.index;
-
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-import java.util.Vector;
-
-public class StringMatcher {
- protected String fPattern;
- protected int fLength; // pattern length
- protected boolean fIgnoreWildCards;
- protected boolean fIgnoreCase;
- protected boolean fHasLeadingStar;
- protected boolean fHasTrailingStar;
- protected String fSegments[]; //the given pattern is split into * separated segments
-
- /* boundary value beyond which we don't need to search in the text */
- protected int fBound= 0;
-
- protected static final char fSingleWildCard= '\u0000';
-
- public static class Position {
- int start; //inclusive
- int end; //exclusive
- public Position(int start, int end) {
- this.start= start;
- this.end= end;
- }
- public int getStart() {
- return start;
- }
- public int getEnd() {
- return end;
- }
- }
-
- /**
- * Find the first occurrence of the pattern between start
end(exclusive).
- * @param text
, the String object to search in
- * @param start
, the starting index of the search range, inclusive
- * @param end
, the ending index of the search range, exclusive
- * @return an StringMatcher.Position
object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
- */
-
- public StringMatcher.Position find(String text, int start, int end) {
- if (fPattern == null || text == null)
- throw new IllegalArgumentException();
-
- int tlen= text.length();
- if (start < 0)
- start= 0;
- if (end > tlen)
- end= tlen;
- if (end < 0 || start >= end)
- return null;
- if (fLength == 0)
- return new Position(start, start);
- if (fIgnoreWildCards) {
- int x= posIn(text, start, end);
- if (x < 0)
- return null;
- return new Position(x, x + fLength);
- }
-
- int segCount= fSegments.length;
- if (segCount == 0) //pattern contains only '*'(s)
- return new Position(start, end);
-
- int curPos= start;
- int matchStart= -1;
- for (int i= 0; i < segCount && curPos < end; ++i) {
- String current= fSegments[i];
- int nextMatch= regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0)
- return null;
- if (i == 0)
- matchStart= nextMatch;
- curPos= nextMatch + current.length();
- }
- return new Position(matchStart, curPos);
- }
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern which may contain * for 0 and many characters and
- * ? for exactly one character. Also takes as parameter a boolean object
- * specifying if case should be ignored
- * @deprecated Use StringMatcher(pattern, ignoreCase, ignoreWildCards).
- */
- public StringMatcher(String aPattern, boolean ignoreCase) {
- this(aPattern, ignoreCase, false);
- }
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern which may contain * for 0 and many characters and
- * ? for exactly one character.
- *
- * Literal '*' and '?' characters must be escaped in the pattern
- * e.g., "\*" means literal "*", etc.
- *
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern.
- * e.g., "\a" means "a" and "\\" means "\"
- *
- * If invoking the StringMatcher with string literals in Java, don't forget
- * escape characters are represented by "\\".
- *
- * @param aPattern the pattern to match text against
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
- */
- public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) {
- fIgnoreCase= ignoreCase;
- fIgnoreWildCards= ignoreWildCards;
- fLength= aPattern.length();
-
- /* convert case */
- if (fIgnoreCase) {
- fPattern= aPattern.toUpperCase();
- } else {
- fPattern= aPattern;
- }
-
- if (fIgnoreWildCards) {
- parseNoWildCards();
- } else {
- parseWildCards();
- }
- }
- /**
- * Given the starting (inclusive) and the ending (exclusive) poisitions in the
- * text
, determine if the given substring matches with aPattern
- * @return true if the specified portion of the text matches the pattern
- * @param String text
, a String object that contains the substring to match
- * @param int start marks the starting position (inclusive) of the substring
- * @param int end marks the ending index (exclusive) of the substring
- */
- public boolean match(String text, int start, int end) {
- if (null == fPattern || null == text)
- throw new IllegalArgumentException();
-
- if (start > end)
- return false;
-
- if (fIgnoreWildCards)
- return fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
- int segCount= fSegments.length;
- if (segCount == 0) //pattern contains only '*'(s) or empty pattern
- return true;
- if (start == end)
- return fLength == 0;
- if (fLength == 0)
- return start == end;
-
- int tlen= text.length();
- if (start < 0)
- start= 0;
- if (end > tlen)
- end= tlen;
-
- int tCurPos= start;
- int bound= end - fBound;
- if (bound < 0)
- return false;
- int i= 0;
- String current= fSegments[i];
- int segLength= current.length();
-
- /* process first segment */
- if (!fHasLeadingStar) {
- if (!regExpRegionMatches(text, start, current, 0, segLength)) {
- return false;
- } else {
- ++i;
- tCurPos= tCurPos + segLength;
- }
- }
-
- /* process middle segments */
- for (; i < segCount && tCurPos <= bound; ++i) {
- current= fSegments[i];
- int currentMatch;
- int k= current.indexOf(fSingleWildCard);
- if (k < 0) {
- currentMatch= textPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- } else {
- currentMatch= regExpPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- }
- tCurPos= currentMatch + current.length();
- }
-
- /* process final segment */
- if (!fHasTrailingStar && tCurPos != end) {
- int clen= current.length();
- return regExpRegionMatches(text, end - clen, current, 0, clen);
- }
- return i == segCount;
- }
- /**
- * match the given text
with the pattern
- * @return true if matched eitherwise false
- * @param text
, a String object
- */
- public boolean match(String text) {
- return match(text, 0, text.length());
- }
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
- */
- private void parseNoWildCards() {
- fSegments= new String[1];
- fSegments[0]= fPattern;
- fBound= fLength;
- }
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * @param p, a String object that is a simple regular expression with * and/or ?
- */
- private void parseWildCards() {
- if (fPattern.startsWith("*")) //$NON-NLS-1$
- fHasLeadingStar= true;
- if (fPattern.endsWith("*")) { //$NON-NLS-1$
- /* make sure it's not an escaped wildcard */
- if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar= true;
- }
- }
-
- Vector temp= new Vector();
-
- int pos= 0;
- StringBuffer buf= new StringBuffer();
- while (pos < fLength) {
- char c= fPattern.charAt(pos++);
- switch (c) {
- case '\\' :
- if (pos >= fLength) {
- buf.append(c);
- } else {
- char next= fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
- }
- break;
- case '*' :
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
- break;
- case '?' :
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default :
- buf.append(c);
- }
- }
-
- /* add last buffer to segment list */
- if (buf.length() > 0) {
- temp.addElement(buf.toString());
- fBound += buf.length();
- }
-
- fSegments= new String[temp.size()];
- temp.copyInto(fSegments);
- }
- /**
- * @param text
, a string which contains no wildcard
- * @param start
, the starting index in the text for search, inclusive
- * @param end
, the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int posIn(String text, int start, int end) { //no wild card in pattern
- int max= end - fLength;
-
- if (!fIgnoreCase) {
- int i= text.indexOf(fPattern, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i= start; i <= max; ++i) {
- if (text.regionMatches(true, i, fPattern, 0, fLength))
- return i;
- }
-
- return -1;
- }
- /**
- * @param text
, a simple regular expression that may only contain '?'(s)
- * @param start
, the starting index in the text for search, inclusive
- * @param end
, the stopping point of search, exclusive
- * @param p
, a simple regular expression that may contains '?'
- * @param caseIgnored
, wether the pattern is not casesensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int regExpPosIn(String text, int start, int end, String p) {
- int plen= p.length();
-
- int max= end - plen;
- for (int i= start; i <= max; ++i) {
- if (regExpRegionMatches(text, i, p, 0, plen))
- return i;
- }
- return -1;
- }
- /**
- *
- * @return boolean
- * @param text
, a String to match
- * @param start
, int that indicates the starting index of match, inclusive
- * @param end
int that indicates the ending index of match, exclusive
- * @param p
, String, String, a simple regular expression that may contain '?'
- * @param ignoreCase
, boolean indicating wether code>p
is case sensitive
- */
- protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
- while (plen-- > 0) {
- char tchar= text.charAt(tStart++);
- char pchar= p.charAt(pStart++);
-
- /* process wild cards */
- if (!fIgnoreWildCards) {
- /* skip single wild cards */
- if (pchar == fSingleWildCard) {
- continue;
- }
- }
- if (pchar == tchar)
- continue;
- if (fIgnoreCase) {
- char tc= Character.toUpperCase(tchar);
- if (tc == pchar)
- continue;
- }
- return false;
- }
- return true;
- }
- /**
- * @param text
, the string to match
- * @param start
, the starting index in the text for search, inclusive
- * @param end
, the stopping point of search, exclusive
- * @param code>p
, a string that has no wildcard
- * @param ignoreCase
, boolean indicating wether code>p
is case sensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen= p.length();
- int max= end - plen;
-
- if (!fIgnoreCase) {
- int i= text.indexOf(p, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i= 0; i <= max; ++i) {
- if (text.regionMatches(true, i, p, 0, plen))
- return i;
- }
-
- return -1;
- }
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/TypeEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/TypeEntry.java
deleted file mode 100644
index 047692a6b81..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/TypeEntry.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.index;
-
-
-public class TypeEntry extends NamedEntry implements ITypeEntry {
-
- int type_kind;
- IIndexEntry[] baseTypes;
- IIndexEntry[] friends;
-
- public TypeEntry(int type_kind, int entry_type, char[][] fullName, int modifiers, int fileNumber){
- super(IIndex.TYPE, entry_type, fullName, modifiers, fileNumber);
- this.type_kind = type_kind;
- }
-
- public void serialize(IIndexerOutput output) {
- output.addIndexEntry(this);
- }
-
- public int getTypeKind() {
- return type_kind;
- }
-
- public void setBaseTypes(IIndexEntry[] baseTypes) {
- this.baseTypes=baseTypes;
- }
-
- public IIndexEntry[] getBaseTypes() {
- return baseTypes;
- }
-
- public IIndexEntry[] getFriends() {
- return friends;
- }
-
- public void setFriends(IIndexEntry[] friends) {
- this.friends = friends;
- }
-
- /* BugZilla ID#124618 */
- public void setTypeEntry(int type_kind, int entry_type, char[][] fullName, int modifiers, int fileNumber) {
- this.entry_type = entry_type;
- this.fileNumber = fileNumber;
- this.fullName = fullName;
- this.modifiers = modifiers;
- this.type_kind = type_kind;
- // since we reuse TypeEntry instance,
- // the following vars should be cleared.
- this.baseTypes = null;
- this.friends = null;
- }
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/CIndexStorage.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/CIndexStorage.java
deleted file mode 100644
index 2e9ff7ac71c..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/CIndexStorage.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.zip.CRC32;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.index.ICDTIndexer;
-import org.eclipse.cdt.core.index.IIndexStorage;
-import org.eclipse.cdt.internal.core.CharOperation;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.IndexRequest;
-import org.eclipse.cdt.internal.core.index.domsourceindexer.DOMIndexRequest;
-import org.eclipse.cdt.internal.core.search.CWorkspaceScope;
-import org.eclipse.cdt.internal.core.search.IndexSelector;
-import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor;
-import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
-import org.eclipse.cdt.internal.core.search.processing.JobManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * @author Bogdan Gheorghe
- */
-public class CIndexStorage implements IIndexStorage {
-
- /* number of file contents in memory */
- public static int MAX_FILES_IN_MEMORY = 0;
-
- public IWorkspace workspace;
- public SimpleLookupTable indexNames = new SimpleLookupTable();
-
- /* index */
- private IIndex index;
- /* read write monitor */
- private ReadWriteMonitor monitor;
-
- /* need to save ? */
- private boolean needToSave = false;
- private static final CRC32 checksumCalculator = new CRC32();
- private IPath cCorePluginLocation = null;
-
- /* can only replace a current state if its less than the new one */
- private SimpleLookupTable indexStates = null;
- private File savedIndexNamesFile =
- new File(getCCorePluginWorkingLocation().append("savedIndexNames.txt").toOSString()); //$NON-NLS-1$
-
- private SimpleLookupTable encounteredHeaders = null;
-
- public static Integer SAVED_STATE = new Integer(0);
- public static Integer UPDATING_STATE = new Integer(1);
- public static Integer UNKNOWN_STATE = new Integer(2);
- public static Integer REBUILDING_STATE = new Integer(3);
-
- public static boolean VERBOSE = false;
-
- private ICDTIndexer indexer = null;
- private IndexManager indexManager = null;
-
- public ReadWriteMonitor indexAccessMonitor = null;
-
- public CIndexStorage(ICDTIndexer indexer){
- this.indexer = indexer;
- this.indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
- }
-
- public void aboutToUpdateIndex(IPath path, Integer newIndexState) {
- // newIndexState is either UPDATING_STATE or REBUILDING_STATE
- // must tag the index as inconsistent, in case we exit before the update job is started
- String indexName = computeIndexName(path);
- Object state = getIndexStates().get(indexName);
- Integer currentIndexState = state == null ? UNKNOWN_STATE : (Integer) state;
- if (currentIndexState.equals(REBUILDING_STATE)) return; // already rebuilding the index
-
- int compare = newIndexState.compareTo(currentIndexState);
- if (compare > 0) {
- // so UPDATING_STATE replaces SAVED_STATE and REBUILDING_STATE replaces everything
- updateIndexState(indexName, newIndexState);
- } else if (compare < 0 && index == null) {
- // if already cached index then there is nothing more to do
- rebuildIndex(indexName, path);
- }
- }
-
- String computeIndexName(IPath path) {
- String name = (String) indexNames.get(path);
- if (name == null) {
- String pathString = path.toOSString();
- checksumCalculator.reset();
- checksumCalculator.update(pathString.getBytes());
- String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
- name = getCCorePluginWorkingLocation().append(fileName).toOSString();
- indexNames.put(path, name);
- }
- return name;
- }
-
-
- /**
- * Returns the index for a given project, according to the following algorithm:
- * - if index is already in memory: answers this one back
- * - if (reuseExistingFile) then read it and return this index and record it in memory
- * - if (createIfMissing) then create a new empty index and record it in memory
- *
- * Warning: Does not check whether index is consistent (not being used)
- */
- public synchronized IIndex getIndex(IPath path, boolean reuseExistingFile, boolean createIfMissing) {
- // Path is already canonical per construction
- if (index == null) {
- String indexName = computeIndexName(path);
- Object state = getIndexStates().get(indexName);
- Integer currentIndexState = state == null ? UNKNOWN_STATE : (Integer) state;
- if (currentIndexState == UNKNOWN_STATE) {
- // should only be reachable for query jobs
- rebuildIndex(indexName, path);
- return null;
- }
-
- // index isn't cached, consider reusing an existing index file
- if (reuseExistingFile) {
- File indexFile = new File(indexName);
- if (indexFile.exists()) { // check before creating index so as to avoid creating a new empty index if file is missing
- try {
- index = new Index(indexName, "Index for " + path.toOSString(), true /*reuse index file*/, indexer); //$NON-NLS-1$
- monitor= new ReadWriteMonitor();
- return index;
- } catch (IOException e) {
- // failed to read the existing file or its no longer compatible
- if (currentIndexState != REBUILDING_STATE) { // rebuild index if existing file is corrupt, unless the index is already being rebuilt
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> cannot reuse existing index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
- rebuildIndex(indexName, path);
- return null;
- }
- index = null; // will fall thru to createIfMissing & create a empty index for the rebuild all job to populate
- }
- }
- if (currentIndexState == SAVED_STATE) { // rebuild index if existing file is missing
- rebuildIndex(indexName, path);
- return null;
- }
- }
- // index wasn't found on disk, consider creating an empty new one
- if (createIfMissing) {
- try {
- if (VERBOSE)
- JobManager.verbose("-> create empty index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
- index = new Index(indexName, "Index for " + path.toOSString(), false /*do not reuse index file*/, indexer); //$NON-NLS-1$
- monitor=new ReadWriteMonitor();
- return index;
- } catch (IOException e) {
- if (VERBOSE)
- JobManager.verbose("-> unable to create empty index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
- // The file could not be created. Possible reason: the project has been deleted.
- return null;
- }
- }
- }
- //System.out.println(" index name: " + path.toOSString() + " <----> " + index.getIndexFile().getName());
- return index;
- }
-
- private SimpleLookupTable getIndexStates() {
- if (indexStates != null) return indexStates;
-
- this.indexStates = new SimpleLookupTable();
- char[] savedIndexNames = readIndexState();
- if (savedIndexNames.length > 0) {
- char[][] names = CharOperation.splitOn('\n', savedIndexNames);
- for (int i = 0, l = names.length; i < l; i++) {
- char[] name = names[i];
- if (name.length > 0)
- this.indexStates.put(new String(name), SAVED_STATE);
- }
- }
- return this.indexStates;
- }
-
- public SimpleLookupTable getEncounteredHeaders(){
-
- if (encounteredHeaders == null){
- this.encounteredHeaders = new SimpleLookupTable();
- }
-
-
- return this.encounteredHeaders;
- }
-
- /**
- * Resets the headers table
- */
- public void resetEncounteredHeaders() {
- this.encounteredHeaders = null;
- }
-
- private IPath getCCorePluginWorkingLocation() {
- if (this.cCorePluginLocation != null) return this.cCorePluginLocation;
-
- return this.cCorePluginLocation = CCorePlugin.getDefault().getStateLocation();
- }
- /**
- * Index access is controlled through a read-write monitor so as
- * to ensure there is no concurrent read and write operations
- * (only concurrent reading is allowed).
- */
- public ReadWriteMonitor getMonitorForIndex(){
- return monitor;
- }
- private void rebuildIndex(String indexName, IPath path) {
- Object target = org.eclipse.cdt.internal.core.Util.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
- if (target == null) return;
-
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> request to rebuild index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
-
- updateIndexState(indexName, REBUILDING_STATE);
- DOMIndexRequest request = null;
- if (target instanceof IProject) {
- IProject p = (IProject) target;
- if( p.exists() && indexer.isIndexEnabled( p ) )
- //request = new IndexAllProject(p, indexer);
- indexer.addRequest(p, null, ICDTIndexer.PROJECT);
- }
-
- if (request != null)
- indexManager.request(request);
- }
-
- /**
- * Recreates the index for a given path, keeping the same read-write monitor.
- * Returns the new empty index or null if it didn't exist before.
- * Warning: Does not check whether index is consistent (not being used)
- */
- public synchronized IIndex recreateIndex(IPath path) {
- // only called to over write an existing cached index...
- try {
- // Path is already canonical
- String indexPath = computeIndexName(path);
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> recreating index: "+indexPath+" for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
- index = new Index(indexPath, "Index for " + path.toOSString(), false /*reuse index file*/,indexer); //$NON-NLS-1$
- //Monitor can be left alone - no need to recreate
- return index;
- } catch (IOException e) {
- // The file could not be created. Possible reason: the project has been deleted.
- if (IndexManager.VERBOSE) {
- JobManager.verbose("-> failed to recreate index for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
- e.printStackTrace();
- }
- return null;
- }
- }
-
- /**
- * Removes the index for a given path.
- * This is a no-op if the index did not exist.
- */
- public synchronized void removeIndex(IPath path) {
- if (IndexManager.VERBOSE)
- JobManager.verbose("removing index " + path); //$NON-NLS-1$
- String indexName = computeIndexName(path);
- File indexFile = new File(indexName);
- if (indexFile.exists())
- indexFile.delete();
- index=null;
- monitor=null;
- updateIndexState(indexName, null);
- }
-
- /**
- * Removes all indexes whose paths start with (or are equal to) the given path.
- */
- public synchronized void removeIndexFamily(IPath path) {
- // only finds cached index files... shutdown removes all non-cached index files
- this.removeIndex(path);
- }
-
- public void saveIndex(IIndex index) throws IOException {
- // must have permission to write from the write monitor
- if (index.hasChanged()) {
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> saving index " + index.getIndexFile()); //$NON-NLS-1$
- index.save();
- }
- String indexName = index.getIndexFile().getPath();
- if (indexManager.getJobEnd() > indexManager.getJobStart()) {
- Object indexPath = indexNames.keyForValue(indexName);
- if (indexPath != null) {
- for (int i = indexManager.getJobEnd(); i > indexManager.getJobStart(); i--) { // skip the current job
- IIndexJob job = indexManager.getAwaitingJobAt(i);
- if (job instanceof DOMIndexRequest)
- if (((IndexRequest) job).getIndexPath().equals(indexPath)) return;
- }
- }
- }
- updateIndexState(indexName, SAVED_STATE);
- }
-
- /**
- * Commit all index memory changes to disk
- */
- public void saveIndexes() {
- // only save cached indexes... the rest were not modified
- ReadWriteMonitor monitor = getMonitorForIndex();
- if (monitor == null) return; // index got deleted since acquired
- try {
- monitor.enterWrite();
- try {
- saveIndex(index);
- } catch(IOException e){
- if (IndexManager.VERBOSE) {
- JobManager.verbose("-> got the following exception while saving:"); //$NON-NLS-1$
- e.printStackTrace();
- }
- //Util.log(e);
- }
- } finally {
- monitor.exitWrite();
- }
- needToSave = false;
- }
-
-
- public void shutdown() {
- if (IndexManager.VERBOSE)
- JobManager.verbose("Shutdown"); //$NON-NLS-1$
- //Get index entries for all projects in the workspace, store their absolute paths
- IndexSelector indexSelector = new IndexSelector(new CWorkspaceScope(), null, false, indexManager);
- IIndex[] selectedIndexes = indexSelector.getIndexes();
- SimpleLookupTable knownPaths = new SimpleLookupTable();
- for (int i = 0, max = selectedIndexes.length; i < max; i++) {
- String path = selectedIndexes[i].getIndexFile().getAbsolutePath();
- knownPaths.put(path, path);
- }
- //Any index entries that are in the index state must have a corresponding
- //path entry - if not they are removed from the saved indexes file
- if (indexStates != null) {
- Object[] indexNames = indexStates.keyTable;
- for (int i = 0, l = indexNames.length; i < l; i++) {
- String key = (String) indexNames[i];
- if (key != null && !knownPaths.containsKey(key)) //here is an index that is in t
- updateIndexState(key, null);
- }
- }
-
- //Clean up the .metadata folder - if there are any files in the directory that
- //are not associated to an index we delete them
- File indexesDirectory = new File(getCCorePluginWorkingLocation().toOSString());
- if (indexesDirectory.isDirectory()) {
- File[] indexesFiles = indexesDirectory.listFiles();
- if (indexesFiles != null) {
- for (int i = 0, indexesFilesLength = indexesFiles.length; i < indexesFilesLength; i++) {
- String fileName = indexesFiles[i].getAbsolutePath();
- if (!knownPaths.containsKey(fileName) && fileName.toLowerCase().endsWith(".index")) { //$NON-NLS-1$
- if (IndexManager.VERBOSE)
- JobManager.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
- indexesFiles[i].delete();
- }
- }
- }
- }
-
-
- }
-
-
-
- public String toString() {
- StringBuffer buffer = new StringBuffer(10);
- buffer.append(super.toString());
- buffer.append("In-memory indexes:\n"); //$NON-NLS-1$
- int count = 0;
- buffer.append(++count).append(" - ").append(index.toString()).append('\n'); //$NON-NLS-1$
- return buffer.toString();
- }
-
- private char[] readIndexState() {
- try {
- return org.eclipse.cdt.internal.core.Util.getFileCharContent(savedIndexNamesFile, null);
- } catch (IOException ignored) {
- if (IndexManager.VERBOSE)
- JobManager.verbose("Failed to read saved index file names"); //$NON-NLS-1$
- return new char[0];
- }
- }
-
- private void updateIndexState(String indexName, Integer indexState) {
- getIndexStates(); // ensure the states are initialized
- if (indexState != null) {
- if (indexState.equals(indexStates.get(indexName))) return; // not changed
- indexStates.put(indexName, indexState);
- } else {
- if (!indexStates.containsKey(indexName)) return; // did not exist anyway
- indexStates.removeKey(indexName);
- }
-
- BufferedWriter writer = null;
- try {
- writer = new BufferedWriter(new FileWriter(savedIndexNamesFile));
- Object[] indexNames = indexStates.keyTable;
- Object[] states = indexStates.valueTable;
- for (int i = 0, l = states.length; i < l; i++) {
- if (states[i] == SAVED_STATE) {
- writer.write((String) indexNames[i]);
- writer.write('\n');
- }
- }
- } catch (IOException ignored) {
- if (IndexManager.VERBOSE)
- JobManager.verbose("Failed to write saved index file names"); //$NON-NLS-1$
- } finally {
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e) {}
- }
- }
- if (IndexManager.VERBOSE) {
- String state = "?"; //$NON-NLS-1$
- if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
- else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
- else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$
- else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$
- JobManager.verbose("-> index state updated to: " + state + " for: "+indexName); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.index2.IIndexStorage#getIndexers()
- */
- public ICDTIndexer[] getIndexers() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.index2.IIndexStorage#getPathVariables()
- */
- public String[] getPathVariables() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.index2.IIndexStorage#resolvePathVariables()
- */
- public void resolvePathVariables() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.index2.IIndexStorage#merge()
- */
- public void merge() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.index2.IIndexStorage#canMergeWith(org.eclipse.cdt.core.index2.IIndexStorage)
- */
- public boolean canMergeWith(IIndexStorage storage) {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- public boolean getNeedToSave() {
- return needToSave;
- }
- public void setNeedToSave(boolean needToSave) {
- this.needToSave = needToSave;
- }
-
- public void jobWasCancelled(IPath path) {
- index=null;
- monitor=null;
- updateIndexState(computeIndexName(path), UNKNOWN_STATE);
- }
- public ReadWriteMonitor getIndexAccessMonitor() {
- return indexAccessMonitor;
- }
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java
deleted file mode 100644
index 14c77790507..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/EntryResult.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import org.eclipse.cdt.internal.core.CharOperation;
-import org.eclipse.cdt.internal.core.index.IEntryResult;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
-import org.eclipse.cdt.internal.core.search.processing.JobManager;
-
-
-public class EntryResult implements IEntryResult {
- private int[] fileRefs;
- private int[][] offsets;
- private int[][] offsetLengths;
-
- private int meta_type;
- private int kind;
- private int reftype;
- private String longname;
-
-public EntryResult(char[] word, int[] refs, int[][] offsets, int[][] offsetLengths) {
- this.fileRefs = refs;
- this.offsets = offsets;
- this.offsetLengths = offsetLengths;
- decode(word);
-}
-public boolean equals(Object anObject){
-
- if (this == anObject) {
- return true;
- }
- if ((anObject != null) && (anObject instanceof EntryResult)) {
- EntryResult anEntryResult = (EntryResult) anObject;
- if( this.meta_type != anEntryResult.meta_type ||
- this.kind != anEntryResult.kind ||
- this.reftype != anEntryResult.reftype ||
- ! this.longname.equals(anEntryResult.longname))
- return false;
-
- int length;
- int[] refs, otherRefs;
- if ((length = (refs = this.fileRefs).length) != (otherRefs = anEntryResult.fileRefs).length) return false;
- for (int i = 0; i < length; i++){
- if (refs[i] != otherRefs[i]) return false;
- }
- return true;
- }
- return false;
-
-}
-public int[] getFileReferences() {
- return fileRefs;
-}
-public char[] getWord() {
- return Index.encodeEntry(meta_type, kind, reftype, longname);
-}
-public int hashCode(){
- return CharOperation.hashCode(getWord());
-}
-public String toString(){
- StringBuffer buffer = new StringBuffer();
- buffer.append("EntryResult: " + getName() + "\n\tmeta="); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append(ICIndexStorageConstants.encodings[meta_type]);
- if(meta_type == IIndex.TYPE) {
- buffer.append(" type="); //$NON-NLS-1$
- buffer.append(ICIndexStorageConstants.typeConstantNames[kind]);
- }
- buffer.append(" Reference="); //$NON-NLS-1$
- buffer.append(ICIndexStorageConstants.encodingTypes[reftype]);
-
- buffer.append(", refs={"); //$NON-NLS-1$
- for (int i = 0; i < fileRefs.length; i++){
- if (i > 0) buffer.append(',');
- buffer.append(' ');
- buffer.append(fileRefs[i]);
- }
- buffer.append(" }, offsets={"); //$NON-NLS-1$
- for (int i = 0; i < offsets.length; i++){
- if (i > 0) buffer.append(',');
- buffer.append(' ');
- buffer.append('[');
- for (int j=0; j 0) buffer.append(',');
- buffer.append(' ');
- buffer.append(offsets[i][j]);
- }
- buffer.append(']');
- }
- buffer.append(" }\n"); //$NON-NLS-1$
- return buffer.toString();
-}
-/* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.index.IEntryResult#getOffsets()
- */
-public int[][] getOffsets() {
- return offsets;
-}
-/* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.index.IEntryResult#getOffsetLengths()
- */
-public int[][] getOffsetLengths() {
- return offsetLengths;
-}
-/* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.index.IEntryResult#extractSimpleName()
- */
-public String extractSimpleName() {
- int sepPos=longname.indexOf(IndexerOutput.SEPARATOR);
- if (sepPos>=0)
- return longname.substring(0, sepPos);
- else
- return longname;
-}
-
-private void decode(char [] word) {
- int pos = 0;
- meta_type = 0;
- for (int i = 1; i < ICIndexStorageConstants.encodings.length; i ++){
- if (CharOperation.prefixEquals(ICIndexStorageConstants.encodings[i], word)) {
- meta_type = i;
- pos += ICIndexStorageConstants.encodings[i].length;
- break;
- }
- }
-
- for ( int i = 1; i < ICIndexStorageConstants.encodingTypes.length; i++) {
- if (CharOperation.fragmentEquals(ICIndexStorageConstants.encodingTypes[i], word, pos, true)) {
- reftype = i;
- pos += ICIndexStorageConstants.encodingTypes[i].length;
- break;
- }
- }
-
- if (meta_type == IIndex.TYPE) {
- for (int i = 1; i < Index.typeConstants.length; i++) {
- if (word[pos] == Index.typeConstants[i]) {
- kind = i;
- pos++;
- break;
- }
- }
- // skip over separator
- if (word[pos] != ICIndexStorageConstants.SEPARATOR) {
- if (IndexManager.VERBOSE)
- JobManager.verbose("Invalid encoding encoutered while decoding Entry Result"); //$NON-NLS-1$
- }
- pos++;
- }
- else
- kind = IIndex.ANY;
-
- longname = new String(word, pos, word.length - pos);
-}
-
-public String[] getEnclosingNames() {
- int slash=longname.indexOf(IndexerOutput.SEPARATOR);
-
- String[] enclosingNames= null;
- if (slash != -1 && slash + 1 < longname.length()) {
- char[][] temp = CharOperation.splitOn('/', CharOperation.subarray(longname.toCharArray(), slash + 1, -1));
- enclosingNames= new String[temp.length];
- for (int i = 0; i < temp.length; i++) {
- enclosingNames[i] = String.valueOf(temp[temp.length - i - 1]);
- }
- }
- return enclosingNames;
-}
-public int getMetaKind() {
- return meta_type;
-}
-public int getKind() {
- return kind;
-}
-public int getRefKind() {
- return reftype;
-}
-public String getName() {
- return longname;
-}
-public String getStringMetaKind() {
- return String.valueOf(ICIndexStorageConstants.encodings[meta_type]);
-}
-public String getStringKind() {
- return ICIndexStorageConstants.typeConstantNames[kind];
-}
-public String getStringRefKind() {
- return String.valueOf(ICIndexStorageConstants.encodingTypes[reftype]);
-}
-
-public String getDisplayString() {
- switch (meta_type) {
- case IIndex.FUNCTION:
- case IIndex.METHOD:
- int startReturn = longname.indexOf(")R/"); //$NON-NLS-1$
- int finishReturn = longname.indexOf("/R("); //$NON-NLS-1$
- int startParam = longname.indexOf("/)", finishReturn); //$NON-NLS-1$
- int finishParam = longname.indexOf("/(", startParam); //$NON-NLS-1$
-
- String functionName;
- String arguments = ""; //$NON-NLS-1$
- if (startParam + 2 < finishParam)
- arguments = longname.substring(startParam + 3, finishParam);
-
- // TODO: flip arguments
- arguments = arguments.replace('/',',');
-
- arguments = '(' + arguments + ')';
-
- if (startReturn == -1 || finishReturn == -1) {
- // there is no return type !!!
- functionName = longname.substring(0, startParam -1);
- return functionName + arguments ;
- }
- else {
- String returnType = ""; //$NON-NLS-1$
- if (startReturn + 3 < finishReturn) {
- returnType = longname.substring(startReturn + 3, finishReturn);
- }
- functionName = longname.substring(0, startReturn -1);
- return functionName + arguments + ':' + returnType;
- }
-
- default:
- return longname;
- }
-}
-
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java
deleted file mode 100644
index 9d4180c1063..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-
-public interface ICIndexStorageConstants {
- /**
- * The signature of the index file.
- */
-
- public static final String SIGNATURE= "INDEX FILE 0.017"; //$NON-NLS-1$
-
- /**
- * The size of a block for a Block
.
- */
- public static final int BLOCK_SIZE= 8192;
-
- final public static char SEPARATOR= '/';
-
- final static char [][] encodings = {
- "".toCharArray(), // not used //$NON-NLS-1$
- "type".toCharArray(), // TYPES //$NON-NLS-1$
- "function".toCharArray(), // FUNCTIONS //$NON-NLS-1$
- "method".toCharArray(), // METHODS //$NON-NLS-1$
- "field".toCharArray(), // FIELDS //$NON-NLS-1$
- "macro".toCharArray(), // MACROS //$NON-NLS-1$
- "namespace".toCharArray(), // NAMESPACES //$NON-NLS-1$
- "enumtor".toCharArray(), // ENUMERATORS //$NON-NLS-1$
- "include" .toCharArray(), // INCLUDES //$NON-NLS-1$
- "variable" .toCharArray() // VARIABLE //$NON-NLS-1$
- };
-
- final static char [][] encodingTypes = {
- "".toCharArray(), // not used //$NON-NLS-1$
- "Decl/".toCharArray(), // DECLARATIONS //$NON-NLS-1$
- "Ref/".toCharArray(), // REFERENCES //$NON-NLS-1$
- "Defn/".toCharArray() // DEFINTIONS //$NON-NLS-1$
- };
-
- final static char[] typeConstants = { ' ', // not used
- 'C', // CLASS
- 'S', // STRUCT
- 'U', // UNION
- 'E', // ENUM
- 'T', // TYPEDEF
- 'D', // DERIVED
- 'F' // FRIEND
- };
-
- final static String[] typeConstantNames = { "", // not used //$NON-NLS-1$
- "Class", //$NON-NLS-1$
- "Struct", //$NON-NLS-1$
- "Union", //$NON-NLS-1$
- "Enum", //$NON-NLS-1$
- "Typedef", //$NON-NLS-1$
- "Derived", //$NON-NLS-1$
- "Friend", //$NON-NLS-1$
-};
-
- final static String[] allSpecifiers = {"", //not used //$NON-NLS-1$
- "private", // private //$NON-NLS-1$
- "public", // public //$NON-NLS-1$
- "protected", // protected //$NON-NLS-1$
- "const", // const //$NON-NLS-1$
- "volatile", // volatile //$NON-NLS-1$
- "static", // static //$NON-NLS-1$
- "extern", // extern //$NON-NLS-1$
- "inline", // inline //$NON-NLS-1$
- "virtual", // virtual //$NON-NLS-1$
- "pure virtual", // pure virtual //$NON-NLS-1$
- "explicit", // explicit //$NON-NLS-1$
- "auto", // auto //$NON-NLS-1$
- "register", // register //$NON-NLS-1$
- "mutable" // mutable //$NON-NLS-1$
- };
-
-
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/InMemoryIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/InMemoryIndex.java
deleted file mode 100644
index a151452ba07..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/InMemoryIndex.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexOutput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexOutput;
-
-
-/**
- * This index stores the document names in an ObjectVector
, and the words in
- * an HashtableOfObjects
.
- */
-
-public class InMemoryIndex {
-
- /**
- * hashtable of IncludeEntrys = includeFiles+numbers of the files they appear in.
- */
- protected IncludeEntryHashedArray includes;
- /**
- * Array of WordEntry
- */
- protected WordEntryHashedArray words;
- /**
- * Array of IndexedFileEntry
- */
- protected IndexedFileEntryHashedArray files;
- /**
- * Array of IndexedPathVariableEntry = file name + a unique number.
- */
- protected IndexPathVariableEntryHashedArray pathVars;
- /**
- * Size of the index.
- */
- protected long footprint;
-
- private IncludeEntry[] sortedIncludeEntries;
- private WordEntry[] sortedWordEntries;
- private IndexedFileEntry[] sortedFiles;
- private IndexPathVariableEntry[] sortedPathVars;
- private int lastId;
-
- public InMemoryIndex() {
- init();
- }
-
- public IndexedFileEntry addFile(String path){
- IndexedFileEntry indexedFileEntry = this.files.add(path);
- this.footprint += indexedFileEntry.footprint() + 4;
- this.sortedFiles = null;
- return indexedFileEntry;
- }
-
- public void addIncludeRef(IndexedFileEntry indexedFile, char[] include) {
- addIncludeRef(include, indexedFile.getFileID());
- }
-
- public void addIncludeRef(IndexedFileEntry indexedFile, String include) {
- addIncludeRef(include.toCharArray(), indexedFile.getFileID());
- }
-
- /**
- * Adds the references of the include to the tree (reference = number of the file the include belongs to).
- */
- protected void addIncludeRef(char[] include, int[] references) {
- int size= references.length;
- int i= 0;
- while (i < size) {
- if (references[i] != 0)
- addIncludeRef(include, references[i]);
- i++;
- }
- }
- /**
- * Looks if the include already exists to the tree and adds the fileNum to this include.
- * If the include does not exist, it adds it to the tree.
- */
- protected void addIncludeRef(char[] include, int fileNum) {
- IncludeEntry entry= this.includes.get(include);
- if (entry == null) {
- entry= new IncludeEntry(include, ++lastId);
- entry.addRef(fileNum);
- this.includes.add(entry);
- this.sortedIncludeEntries= null;
- this.footprint += entry.footprint();
- } else {
- this.footprint += entry.addRef(fileNum);
- }
- }
- /**
- * Looks if the word already exists in the index and add the fileNum to this word.
- * If the word does not exist, it adds it in the index.
- * @param indexFlags
- */
- protected void addRef(char[] word, int fileNum, int offset, int offsetLength, int offsetType, int modifiers) {
- WordEntry entry= this.words.get(word);
-
- if (entry == null) {
- entry= new WordEntry(word);
- entry.addRef(fileNum);
- entry.addOffset(offset, offsetLength, fileNum, offsetType);
- entry.addModifiers(modifiers, fileNum);
- this.words.add(entry);
- this.sortedWordEntries= null;
- this.footprint += entry.footprint();
- } else {
- this.footprint += entry.addRef(fileNum);
- entry.addOffset(offset, offsetLength, fileNum, offsetType);
- entry.addModifiers(modifiers, fileNum);
- }
- }
-
- public void addRef(IndexedFileEntry indexedFile, char[] word, int offset, int offsetLength, int offsetType, int modifiers) {
- addRef(word, indexedFile.getFileID(), offset, offsetLength, offsetType, modifiers);
- }
-
- public void addRef(IndexedFileEntry indexedFile, String word, int offset, int offsetLength, int offsetType, int modifiers) {
- addRef(word.toCharArray(), indexedFile.getFileID(), offset, offsetLength, offsetType, modifiers);
- }
-
- public void addRelatives(int fileNumber, String inclusion, String parent) {
- addRelatives(fileNumber,inclusion.toCharArray(),(parent != null ) ? parent.toCharArray() : null);
- }
-
- protected void addRelatives(int fileNumber, char[] inclusion, char[] parent) {
- IncludeEntry childEntry=null;
- IncludeEntry parentEntry=null;
-
- if (inclusion != null)
- childEntry= this.includes.get(inclusion);
-
- if (parent != null)
- parentEntry= this.includes.get(parent);
-
-
- childEntry.addParent(fileNumber,(parentEntry!=null) ? parentEntry.getID() : -1);
-
- if (parent!=null)
- parentEntry.addChild(fileNumber,(childEntry!=null) ? childEntry.getID() : -1);
- }
- /**
- * Returns the footprint of the index.
- */
- public long getFootprint() {
- return this.footprint;
- }
- /**
- * Returns the indexed files contained in the hashtable of includes.
- */
- public IndexedFileEntry[] getIndexedFiles(){
- return this.files.asArray();
- }
- /**
- * Returns the indexed file with the given path, or null if such file does not exist.
- */
- public IndexedFileEntry getIndexedFile(String path) {
- return files.get(path);
- }
- /**
- * Returns the include entries contained in the hashtable of includes.
- */
- public IncludeEntry[] getIncludeEntries() {
- return this.includes.asArray();
- }
- /**
- * Returns the include entry corresponding to the given include.
- */
- protected IncludeEntry getIncludeEntry(char[] include) {
- return includes.get(include);
- }
-
- public int getNumFiles() {
- return files.size();
- }
-
- public int getNumWords() {
- return words.elementSize;
- }
-
- public int getNumIncludes() {
- return includes.elementSize;
- }
-
- /**
- * Returns the words contained in the hashtable of words, sorted by alphabetical order.
- */
- public IndexedFileEntry[] getSortedFiles() {
- if (this.sortedFiles == null) {
- IndexedFileEntry[] indexedFiles= files.asArray();
- Util.sort(indexedFiles);
- this.sortedFiles= indexedFiles;
- }
- return this.sortedFiles;
- }
- /**
- * Returns the word entries contained in the hashtable of words, sorted by alphabetical order.
- */
- public WordEntry[] getSortedWordEntries() {
- if (this.sortedWordEntries == null) {
- WordEntry[] words= this.words.asArray();
- Util.sort(words);
- this.sortedWordEntries= words;
- }
- return this.sortedWordEntries;
- }
- /**
- * Returns the include entries contained in the hashtable of includeas, sorted by alphabetical order.
- */
- public IncludeEntry[] getSortedIncludeEntries() {
- if (this.sortedIncludeEntries == null) {
- IncludeEntry[] includes= this.includes.asArray();
- Util.sort(includes);
- this.sortedIncludeEntries= includes;
- }
- return this.sortedIncludeEntries;
- }
- /**
- * Returns the word entry corresponding to the given word.
- */
- public WordEntry getWordEntry(char[] word) {
- return words.get(word);
- }
- /**
- * Initialises the fields of the index
- */
- public void init() {
- includes= new IncludeEntryHashedArray(501);
- words= new WordEntryHashedArray(501);
- files= new IndexedFileEntryHashedArray(101);
- pathVars= new IndexPathVariableEntryHashedArray(101);
- footprint= 0;
- lastId=0;
- sortedWordEntries= null;
- sortedFiles= null;
- sortedIncludeEntries=null;
- }
- /**
- * Saves the index in the given file.
- * Structure of the saved Index :
- * - IndexedFiles in sorted order.
- * + example:
- * "c:/com/a.cpp 1"
- * "c:/com/b.cpp 2"
- * - References with the words in sorted order
- * + example:
- * "classDecl/a 1"
- * "classDecl/b 2"
- * "ref/String 1 2"
- */
- public void save(File file) throws IOException {
- BlocksIndexOutput output= new BlocksIndexOutput(file);
- save(output);
- }
- /**
- * Saves the index in the given IndexOutput.
- * Structure of the saved Index :
- * - IndexedFiles in sorted order.
- * + example:
- * "c:/com/a.cpp 1"
- * "c:/com/b.cpp 2"
- * - References with the words in sorted order
- * + example:
- * "classDecl/a 1"
- * "classDecl/b 2"
- * "ref/String 1 2"
- */
- protected void save(IndexOutput output) throws IOException {
- boolean ok= false;
- try {
- output.open();
- IndexedFileEntry[] indexedFiles= files.asArray();
- for (int i= 0, length = indexedFiles.length; i < length; ++i)
- output.addFile(indexedFiles[i]); // written out in order BUT not alphabetical
- getSortedWordEntries(); // init the slot
- for (int i= 0, numWords= sortedWordEntries.length; i < numWords; ++i)
- output.addWord(sortedWordEntries[i]);
- output.flush();
- output.close();
- ok= true;
- } finally {
- if (!ok && output != null)
- output.close();
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IncludeEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IncludeEntry.java
deleted file mode 100644
index 706a4e618ca..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IncludeEntry.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.cdt.internal.core.CharOperation;
-import org.eclipse.cdt.internal.core.sourcedependency.Node;
-
-/**
- * @author bgheorgh
- */
-public class IncludeEntry {
-
- protected char[] fFile;
- protected int fId;
- protected int fNumRefs;
- protected int[] fRefs;
- //TODO: BOG Consider making these arrays...
- protected ArrayList fParent;
- protected ArrayList fChild;
- protected int fNumParent;
- protected int fNumChild;
-
- public IncludeEntry(int id) {
- this(CharOperation.NO_CHAR,id);
- }
-
- public IncludeEntry(char[] file, int id) {
- fFile = file;
- fNumRefs= 0;
- fRefs= new int[1];
- fId=id;
-
- fParent = new ArrayList(5);
- fChild = new ArrayList(5);
- fNumParent = 0;
- fNumChild = 0;
- }
- /**
- * Adds a reference and records the change in footprint.
- */
- public int addRef(int fileNum) {
- if (fNumRefs > 0 && fRefs[fNumRefs - 1] == fileNum) {
- return 0;
- }
- if (fNumRefs < fRefs.length) {
- fRefs[fNumRefs++]= fileNum;
- return 0;
- }
-
- int newSize= fNumRefs < 4 ? 4 : fNumRefs * 2; // so will start @ 1, grow to 4, 8, 16, 32, 64 etc.
- System.arraycopy(fRefs, 0, fRefs= new int[newSize], 0, fNumRefs);
- fRefs[fNumRefs++]= fileNum;
- return (newSize - fNumRefs + 1) * 4;
- }
-
- public void addParent(int fileRef, int parentId){
- Node newParent = new Node(fileRef,parentId);
- fParent.add(newParent);
- fNumParent++;
- }
- /**
- * @param is
- */
- public void addRefs(int[] refs) {
- int[] newRefs= new int[fNumRefs + refs.length];
- int pos1= 0;
- int pos2= 0;
- int posNew= 0;
- int compare;
- int r1= 0;
- int r2= 0;
- while (pos1 < fNumRefs || pos2 < refs.length) {
- if (pos1 >= fNumRefs) {
- r2= refs[pos2];
- compare= -1;
- } else if (pos2 >= refs.length) {
- compare= 1;
- r1= fRefs[pos1];
- } else {
- r1= fRefs[pos1];
- r2= refs[pos2];
- compare= r2 - r1;
- }
- if (compare > 0) {
- newRefs[posNew]= r1;
- posNew++;
- pos1++;
- } else {
- if (r2 != 0) {
- newRefs[posNew]= r2;
- posNew++;
- }
- pos2++;
- }
- }
- fRefs= newRefs;
- fNumRefs= posNew;
- /*for (int i = 0; i < refs.length; i++)
- addRef(refs[i]);
- int[] newRefs = new int[fNumRefs];
- System.arraycopy(fRefs, 0, newRefs, 0, fNumRefs);
- fRefs = newRefs;
- Util.sort(fRefs);*/
-
- }
-
- public void addChild(int fileRef, int parentId){
- Node newChild = new Node(fileRef,parentId);
- fChild.add(newChild);
- fNumChild++;
- }
- /**
- * Returns the number of references, e.g. the number of files this word appears in.
- */
- public int getNumRefs() {
- return fNumRefs;
- }
- /**
- * returns the file number in the i position in the list of references.
- */
- public int getRef(int i) {
- if (i < fNumRefs) return fRefs[i];
- throw new IndexOutOfBoundsException();
- }
- /**
- * Returns the references of the includeEntry (the number of the files it appears in).
- */
- public int[] getRefs() {
- int[] result= new int[fNumRefs];
- System.arraycopy(fRefs, 0, result, 0, fNumRefs);
- return result;
- }
- /**
- * returns the word of the includeEntry.
- */
- public char[] getFile() {
- return fFile;
- }
- /**
- * Changes the references of the wordEntry to match the mapping. For example,
- * if the current references are [1 3 4]
- * and mapping is [1 2 3 4 5]
- * in references 1 becomes mapping[1] = 2, 3->4, and 4->5
- * => references = [2 4 5].
- */
- public void mapRefs(int[] mappings) {
- int position= 0;
-
- for (int i= 0; i < fNumRefs; i++) {
- //Take care that the reference is actually within the bounds of the mapping
- int map= -1;
- if(fRefs[i] >= 0 && fRefs[i] < mappings.length)
- map= mappings[fRefs[i]];
- if (map != -1 && map != 0)
- fRefs[position++]= map;
- }
- fNumRefs= position;
-
- //to be changed!
- System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs);
- Util.sort(fRefs);
- }
- /**
- * Clears the includeEntry.
- */
- public void reset(char[] word) {
- for (int i= fNumRefs; i-- > 0;) {
- fRefs[i]= 0;
- }
- fNumRefs= 0;
- fFile= word;
- }
-
- public int getID(){
- return fId;
- }
-
- public String toString() {
- StringBuffer tempBuffer = new StringBuffer();
- tempBuffer.append(" 0) tempBuffer.append(',');
- tempBuffer.append(' ');
- tempBuffer.append(fRefs[i]);
- }
- tempBuffer.append("}, Parents:{"); //$NON-NLS-1$
- Iterator x = fParent.iterator();
- while (x.hasNext())
- {
- Node tempNode = (Node) x.next();
- tempBuffer.append(tempNode.toString());
- if (x.hasNext()) {
- tempBuffer.append(',');
- tempBuffer.append(' ');
- }
- }
- tempBuffer.append("}, Children:{"); //$NON-NLS-1$
- Iterator y = fChild.iterator();
- while (y.hasNext())
- {
- Node tempNode = (Node) y.next();
- tempBuffer.append(tempNode.toString());
- if (y.hasNext()) {
- tempBuffer.append(',');
- tempBuffer.append(' ');
- }
- }
- tempBuffer.append("} >"); //$NON-NLS-1$
- return tempBuffer.toString();
- }
-
- /**
- * @return
- */
- public long footprint() {
- //Size of Object + (number of fields * size of Fields) +
- //(Size of ArrayListObject + (Number of Nodes * sizeof Node)) + (Size of ArrayObject + (Number of fFile * sizeof char)) +
- //(Size of ArrayListObject + (Number of Nodes * sizeof Node)) +
- //(Size of ArrayObject + (Number of refs * sizeof int))
- return 8 + (8 * 4) +
- (8 + fChild.size() * (8 + 2 * 4)) + (8 + fFile.length * 2) +
- (8 + fParent.size() * (8 + 2 * 4)) + (8 + fRefs.length * 4);
- }
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IncludeEntryHashedArray.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IncludeEntryHashedArray.java
deleted file mode 100644
index 923830ab779..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IncludeEntryHashedArray.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import org.eclipse.cdt.internal.core.CharOperation;
-
-public final class IncludeEntryHashedArray {
-
- public IncludeEntry elements[];
- public int elementSize; // number of elements in the table
- public int threshold;
-
- public IncludeEntryHashedArray(int size) {
- if (size < 7) size = 7;
- this.elements = new IncludeEntry[2 * size + 1];
- this.elementSize = 0;
- this.threshold = size + 1; // size is the expected number of elements
- }
-
- public IncludeEntry add(IncludeEntry entry) {
- int length = elements.length;
- char[] word = entry.getFile();
- int index = CharOperation.hashCode(word) % length;
- IncludeEntry current;
- while ((current = elements[index]) != null) {
- if (CharOperation.equals(current.getFile(), word)) return elements[index] = entry;
- if (++index == length) index = 0;
- }
- elements[index] = entry;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold) grow();
- return entry;
- }
-
- public IncludeEntry[] asArray() {
- IncludeEntry[] array = new IncludeEntry[elementSize];
- for (int i = 0, j = 0, length = elements.length; i < length; i++) {
- IncludeEntry current = elements[i];
- if (current != null) array[j++] = current;
- }
- return array;
- }
-
- public IncludeEntry get(char[] word) {
- int length = elements.length;
- int index = CharOperation.hashCode(word) % length;
- IncludeEntry current;
- while ((current = elements[index]) != null) {
- if (CharOperation.equals(current.getFile(), word)) return current;
- if (++index == length) index = 0;
- }
- return null;
- }
-
- private void grow() {
- IncludeEntryHashedArray newArray = new IncludeEntryHashedArray(elementSize * 2); // double the number of expected elements
- for (int i = 0, length = elements.length; i < length; i++)
- if (elements[i] != null)
- newArray.add(elements[i]);
-
- this.elements = newArray.elements;
- this.elementSize = newArray.elementSize;
- this.threshold = newArray.threshold;
- }
-
- public String toString() {
- String s = ""; //$NON-NLS-1$
- IncludeEntry[] entries = asArray();
- for (int i = 0, length = entries.length; i < length; i++)
- s += entries[i].toString() + "\n"; //$NON-NLS-1$
- return s;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/Index.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/Index.java
deleted file mode 100644
index c12d58eb09d..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/Index.java
+++ /dev/null
@@ -1,825 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.index.ICDTIndexer;
-import org.eclipse.cdt.core.index.IIndexDelta;
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.LimitTo;
-import org.eclipse.cdt.core.search.SearchFor;
-import org.eclipse.cdt.internal.core.CharOperation;
-import org.eclipse.cdt.internal.core.index.IEntryResult;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.IIndexerRunner;
-import org.eclipse.cdt.internal.core.index.IQueryResult;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexOutput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexOutput;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.MergeFactory;
-import org.eclipse.cdt.internal.core.index.cindexstorage.io.SimpleIndexInput;
-import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
-import org.eclipse.cdt.internal.core.index.impl.Int;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * An Index is used to create an index on the disk, and to make queries. It uses a set of
- * indexers and a mergeFactory. The index fills an inMemoryIndex up
- * to it reaches a certain size, and then merges it with a main index on the disk.
- *
- * The changes are only taken into account by the queries after a merge.
- */
-
-public class Index implements IIndex, ICIndexStorageConstants, ICSearchConstants {
- /**
- * Maximum size of the index in memory.
- */
- public static final int MAX_FOOTPRINT= 10000000;
-
- /**
- * Index in memory, who is merged with mainIndex each times it
- * reaches a certain size.
- */
- protected InMemoryIndex addsIndex;
- protected IndexInput addsIndexInput;
-
- /**
- * State of the indexGenerator: addsIndex empty <=> MERGED, or
- * addsIndex not empty <=> CAN_MERGE
- */
- protected int state;
-
- /**
- * Files removed form the addsIndex.
- */
- protected Map removedInAdds;
-
- /**
- * Files removed form the oldIndex.
- */
- protected Map removedInOld;
- protected static final int CAN_MERGE= 0;
- protected static final int MERGED= 1;
- private File indexFile;
-
- private ICDTIndexer indexer = null;
-
-
- /**
- * String representation of this index.
- */
- public String toString;
-
- public Index(String indexName, String toString, boolean reuseExistingFile, ICDTIndexer indexer) throws IOException {
- super();
- state= MERGED;
- indexFile= new File(indexName);
- this.toString = toString;
- this.indexer = indexer;
- initialize(reuseExistingFile);
- }
- /**
- * Indexes the given document, using the appropriate indexer registered in the indexerRegistry.
- * If the document already exists in the index, it overrides the previous one. The changes will be
- * taken into account after a merge.
- */
- public void add(IFile file, IIndexerRunner indexer) throws IOException {
- if (timeToMerge()) {
- merge();
- }
- IndexedFileEntry indexedFile= addsIndex.getIndexedFile(file.getFullPath().toString());
- if (indexedFile != null /*&& removedInAdds.get(document.getName()) == null*/
- )
- remove(indexedFile, MergeFactory.ADDS_INDEX);
- IndexerOutput output= new IndexerOutput(addsIndex);
- indexer.index(file, output);
- state= CAN_MERGE;
- }
- /**
- * Returns true if the index in memory is not empty, so
- * merge() can be called to fill the mainIndex with the files and words
- * contained in the addsIndex.
- */
- protected boolean canMerge() {
- return state == CAN_MERGE;
- }
- /**
- * Initialises the indexGenerator.
- */
- public void empty() throws IOException {
-
- if (indexFile.exists()){
- indexFile.delete();
- //initialisation of mainIndex
- InMemoryIndex mainIndex= new InMemoryIndex();
- IndexOutput mainIndexOutput= new BlocksIndexOutput(indexFile);
- if (!indexFile.exists())
- mainIndex.save(mainIndexOutput);
- }
-
- //initialisation of addsIndex
- addsIndex= new InMemoryIndex();
- addsIndexInput= new SimpleIndexInput(addsIndex);
-
- //vectors who keep track of the removed Files
- removedInAdds= new HashMap(11);
- removedInOld= new HashMap(11);
- }
- /**
- * @see IIndex#getIndexFile
- */
- public File getIndexFile() {
- return indexFile;
- }
- /**
- * @see IIndex#getNumDocuments
- */
- public int getNumDocuments() throws IOException {
- //save();
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- input.open();
- return input.getNumFiles();
- } finally {
- input.close();
- }
- }
- /**
- * @see IIndex#getNumWords
- */
- public int getNumWords() throws IOException {
- //save();
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- input.open();
- return input.getNumWords();
- } finally {
- input.close();
- }
- }
- /**
- * @see IIndex#getNumWords
- */
- public int getNumIncludes() throws IOException {
- //save();
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- input.open();
- return input.getNumIncludes();
- } finally {
- input.close();
- }
- }
- /**
- * Returns the path corresponding to a given document number
- */
- public String getPath(int documentNumber) throws IOException {
- //save();
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- input.open();
- IndexedFileEntry file = input.getIndexedFile(documentNumber);
- if (file == null) return null;
- return file.getPath();
- } finally {
- input.close();
- }
- }
-
- /**
- * Returns the path list
- */
- public String [] getDocumentList() throws IOException {
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- input.open();
- int num = input.getNumFiles();
- String [] result = new String[num+1];
- for(int i = 1; i < num+1; i++) {
- //i+1 since reference encoding starts at 1
- IndexedFileEntry file = input.getIndexedFile(i);
- if (file != null)
- result[i] = file.getPath();
- else
- result[i] = null;
- }
-
- return result;
- } finally {
- input.close();
- }
- }
- /**
- * see IIndex.hasChanged
- */
- public boolean hasChanged() {
- return canMerge();
- }
- /**
- * Initialises the indexGenerator.
- */
- public void initialize(boolean reuseExistingFile) throws IOException {
- //initialisation of addsIndex
- addsIndex= new InMemoryIndex();
- addsIndexInput= new SimpleIndexInput(addsIndex);
-
- //vectors who keep track of the removed Files
- removedInAdds= new HashMap(11);
- removedInOld= new HashMap(11);
-
- // check whether existing index file can be read
- if (reuseExistingFile && indexFile.exists()) {
- IndexInput mainIndexInput= new BlocksIndexInput(indexFile);
- try {
- mainIndexInput.open();
- } catch(IOException e) {
- BlocksIndexInput input = (BlocksIndexInput)mainIndexInput;
- try {
- input.setOpened(true);
- input.close();
- } finally {
- input.setOpened(false);
- }
- indexFile.delete();
- mainIndexInput = null;
- throw e;
- }
- mainIndexInput.close();
- } else {
- InMemoryIndex mainIndex= new InMemoryIndex();
- IndexOutput mainIndexOutput= new BlocksIndexOutput(indexFile);
- mainIndex.save(mainIndexOutput);
- }
- }
- /**
- * Merges the in memory index and the index on the disk, and saves the results on the disk.
- */
- protected void merge() throws IOException {
- //initialisation of tempIndex
- File tempFile= new File(indexFile.getAbsolutePath() + "TempVA"); //$NON-NLS-1$
-
- IndexInput mainIndexInput= new BlocksIndexInput(indexFile);
- BlocksIndexOutput tempIndexOutput= new BlocksIndexOutput(tempFile);
-
- try {
- //invoke a mergeFactory
- new MergeFactory(
- mainIndexInput,
- addsIndexInput,
- tempIndexOutput,
- removedInOld,
- removedInAdds).merge();
-
- //rename the file created to become the main index
- File mainIndexFile= (File) mainIndexInput.getSource();
- File tempIndexFile= (File) tempIndexOutput.getDestination();
- boolean deleted = mainIndexFile.delete();
-
- int counter=0;
- while (!deleted && counter<5){
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {}
- counter++;
- deleted=mainIndexFile.delete();
- }
-
- tempIndexFile.renameTo(mainIndexFile);
- } finally {
- //initialise remove vectors and addsindex, and change the state
- removedInAdds.clear();
- removedInOld.clear();
- addsIndex.init();
- addsIndexInput= new SimpleIndexInput(addsIndex);
- state= MERGED;
- //flush the CDT log
- CCorePlugin.getDefault().cdtLog.flushLog();
-
- //Send out notification to listeners;
- IndexDelta indexDelta = new IndexDelta(null,null,IIndexDelta.MERGE_DELTA);
- indexer.notifyListeners(indexDelta);
- }
- }
-
- public IEntryResult[] queryEntries(char[] prefix) throws IOException {
- //save();
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- return input.queryEntriesPrefixedBy(prefix);
- } finally {
- input.close();
- }
- }
- /**
- * @see IIndex#queryInDocumentNames
- */
- public IQueryResult[] queryInDocumentNames(String word) throws IOException {
- //save();
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- return input.queryInDocumentNames(word);
- } finally {
- input.close();
- }
- }
- /**
- * @see IIndex#queryPrefix
- */
- public IQueryResult[] queryPrefix(char[] prefix) throws IOException {
- //save();
- IndexInput input= new BlocksIndexInput(indexFile);
- try {
- return input.queryFilesReferringToPrefix(prefix);
- } finally {
- input.close();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.sourcedependency.IDependencyTree#getFileDepencies(int)
- */
- public String[] getFileDependencies(IPath filePath) throws IOException {
-// List tempFileReturn = new ArrayList();
-//
-// IndexedFile indexFile = addsIndex.getIndexedFile(filePath.toString());
-//
-// if (indexFile == null)
-// return new String[0];
-//
-// int fileNum = indexFile.getFileNumber();
-// IncludeEntry[] tempEntries = addsIndex.getIncludeEntries();
-// for (int i=0; i= MAX_FOOTPRINT);
- }
- public String toString() {
- String str = this.toString;
- if (str == null)
- str = super.toString();
- str += "(length: " + getIndexFile().length() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- return str;
- }
-
- public org.eclipse.cdt.core.index.ICDTIndexer getIndexer(){
- return (org.eclipse.cdt.core.index.ICDTIndexer) indexer;
- }
- public IEntryResult[] queryEntries(char[] prefix, char optionalType, char[] name, char[][] containingTypes, int matchMode, boolean isCaseSensitive) throws IOException {
- return queryEntries(Index.bestPrefix(prefix, optionalType, name, containingTypes, matchMode, isCaseSensitive));
- }
-
- public static final char[] bestTypePrefix( SearchFor searchFor, LimitTo limitTo, char[] typeName, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
- char [] prefix = null;
- if( limitTo == DECLARATIONS ){
- prefix = encodeEntry(IIndex.TYPE, ANY, DECLARATION);
- } else if (limitTo == DEFINITIONS){
- prefix = encodeEntry(IIndex.TYPE, ANY, DEFINITION);
- } else if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.TYPE, ANY, REFERENCE);
- } else {
- return encodeEntry(IIndex.TYPE, ANY, ANY);
- }
-
- char classType = 0;
-
- if( searchFor == ICSearchConstants.CLASS ){
- classType = typeConstants[IIndex.TYPE_CLASS];
- } else if ( searchFor == ICSearchConstants.STRUCT ){
- classType = typeConstants[IIndex.TYPE_STRUCT];
- } else if ( searchFor == ICSearchConstants.UNION ){
- classType = typeConstants[IIndex.TYPE_UNION];
- } else if ( searchFor == ICSearchConstants.ENUM ){
- classType = typeConstants[IIndex.TYPE_ENUM];
- } else if ( searchFor == ICSearchConstants.TYPEDEF ){
- classType = typeConstants[IIndex.TYPE_TYPEDEF];
- } else if ( searchFor == ICSearchConstants.DERIVED){
- classType = typeConstants[IIndex.TYPE_DERIVED];
- } else if ( searchFor == ICSearchConstants.FRIEND){
- classType = typeConstants[IIndex.TYPE_FRIEND];
- } else {
- //could be TYPE or CLASS_STRUCT, best we can do for these is the prefix
- return prefix;
- }
-
- return bestPrefix( prefix, classType, typeName, containingTypes, matchMode, isCaseSensitive );
- }
-
- public static final char[] bestNamespacePrefix(LimitTo limitTo, char[] namespaceName, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
- char [] prefix = null;
- if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.NAMESPACE, ANY, REFERENCE);
- } else if ( limitTo == DEFINITIONS ) {
- prefix = encodeEntry(IIndex.NAMESPACE, ANY, DEFINITION);
- } else {
- return encodeEntry(IIndex.NAMESPACE, ANY, ANY);
- }
-
- return bestPrefix( prefix, (char) 0, namespaceName, containingTypes, matchMode, isCaseSensitive );
- }
-
- public static final char[] bestVariablePrefix( LimitTo limitTo, char[] varName, char[][] containingTypes, int matchMode, boolean isCaseSenstive ){
- char [] prefix = null;
- if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.VAR, ANY, REFERENCE);
- } else if( limitTo == DECLARATIONS ){
- prefix = encodeEntry(IIndex.VAR, ANY, DECLARATION);
- } else if( limitTo == DEFINITIONS ){
- prefix = encodeEntry(IIndex.VAR, ANY, DEFINITION);
- } else {
- return encodeEntry(IIndex.VAR, ANY, ANY);
- }
-
- return bestPrefix( prefix, (char)0, varName, containingTypes, matchMode, isCaseSenstive );
- }
-
- public static final char[] bestFieldPrefix( LimitTo limitTo, char[] fieldName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
- char [] prefix = null;
- if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.FIELD, ANY, REFERENCE);
- } else if( limitTo == DECLARATIONS ){
- prefix = encodeEntry(IIndex.FIELD, ANY, DECLARATION);
- } else if( limitTo == DEFINITIONS ){
- prefix = encodeEntry(IIndex.FIELD, ANY, DEFINITION);
- } else {
- return encodeEntry(IIndex.FIELD, ANY, ANY);
- }
-
- return bestPrefix( prefix, (char)0, fieldName, containingTypes, matchMode, isCaseSensitive );
- }
-
- public static final char[] bestEnumeratorPrefix( LimitTo limitTo, char[] enumeratorName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
- char [] prefix = null;
- if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.ENUMTOR, ANY, REFERENCE);
- } else if( limitTo == DECLARATIONS ){
- prefix = encodeEntry(IIndex.ENUMTOR, ANY, DECLARATION);
- } else if ( limitTo == DEFINITIONS ) {
- prefix = encodeEntry(IIndex.ENUMTOR, ANY, DEFINITION);
- } else if (limitTo == ALL_OCCURRENCES){
- return encodeEntry(IIndex.ENUMTOR, ANY, ANY);
- }
-
- return bestPrefix( prefix, (char)0, enumeratorName, containingTypes, matchMode, isCaseSensitive );
- }
-
- public static final char[] bestMethodPrefix( LimitTo limitTo, char[] methodName,char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
- char [] prefix = null;
- if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.METHOD, ANY, REFERENCE);
- } else if( limitTo == DECLARATIONS ){
- prefix = encodeEntry(IIndex.METHOD, ANY, DECLARATION);
- } else if( limitTo == DEFINITIONS ){
- return encodeEntry(IIndex.METHOD, ANY, DEFINITION);
- } else {
- return encodeEntry(IIndex.METHOD, ANY, ANY);
- }
-
- return bestPrefix( prefix, (char)0, methodName, containingTypes, matchMode, isCaseSensitive );
- }
-
- public static final char[] bestFunctionPrefix( LimitTo limitTo, char[] functionName, int matchMode, boolean isCaseSensitive) {
- char [] prefix = null;
- if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.FUNCTION, ANY, REFERENCE);
- } else if( limitTo == DECLARATIONS ){
- prefix = encodeEntry(IIndex.FUNCTION, ANY, DECLARATION);
- } else if ( limitTo == DEFINITIONS ){
- return encodeEntry(IIndex.FUNCTION, ANY, DEFINITION);
- } else {
- return encodeEntry(IIndex.FUNCTION, ANY, ANY);
- }
- return bestPrefix( prefix, (char)0, functionName, null, matchMode, isCaseSensitive );
- }
-
- public static final char[] bestPrefix( char [] prefix, char optionalType, char[] name, char[][] containingTypes, int matchMode, boolean isCaseSensitive) {
- char[] result = null;
- int pos = 0;
-
- int wildPos, starPos = -1, questionPos;
-
- //length of prefix + separator
- int length = prefix.length;
-
- //add length for optional type + another separator
- if( optionalType != 0 )
- length += 2;
-
- if (!isCaseSensitive){
- //index is case sensitive, thus in case attempting case insensitive search, cannot consider
- //type name.
- name = null;
- } else if( matchMode == PATTERN_MATCH && name != null ){
- int start = 0;
-
- char [] temp = new char [ name.length ];
- boolean isEscaped = false;
- int tmpIdx = 0;
- for( int i = 0; i < name.length; i++ ){
- if( name[i] == '\\' ){
- if( !isEscaped ){
- isEscaped = true;
- continue;
- }
- isEscaped = false;
- } else if( name[i] == '*' && !isEscaped ){
- starPos = i;
- break;
- }
- temp[ tmpIdx++ ] = name[i];
- }
-
- name = new char [ tmpIdx ];
- System.arraycopy( temp, 0, name, 0, tmpIdx );
-
- //starPos = CharOperation.indexOf( '*', name );
- questionPos = CharOperation.indexOf( '?', name );
-
- if( starPos >= 0 ){
- if( questionPos >= 0 )
- wildPos = ( starPos < questionPos ) ? starPos : questionPos;
- else
- wildPos = starPos;
- } else {
- wildPos = questionPos;
- }
-
- switch( wildPos ){
- case -1 : break;
- case 0 : name = null; break;
- default : name = CharOperation.subarray( name, 0, wildPos ); break;
- }
- }
- //add length for name
- if( name != null ){
- length += name.length;
- } else {
- //name is null, don't even consider qualifications.
- result = new char [ length ];
- System.arraycopy( prefix, 0, result, 0, pos = prefix.length );
- if( optionalType != 0){
- result[ pos++ ] = optionalType;
- result[ pos++ ] = SEPARATOR;
- }
- return result;
- }
-
- //add the total length of the qualifiers
- //we don't want to mess with the contents of this array (treat it as constant)
- //so check for wild cards later.
- if( containingTypes != null ){
- for( int i = 0; i < containingTypes.length; i++ ){
- if( containingTypes[i].length > 0 ){
- length += containingTypes[ i ].length;
- length++; //separator
- }
- }
- }
-
- //because we haven't checked qualifier wild cards yet, this array might turn out
- //to be too long. So fill a temp array, then check the length after
- char [] temp = new char [ length ];
-
- System.arraycopy( prefix, 0, temp, 0, pos = prefix.length );
-
- if( optionalType != 0 ){
- temp[ pos++ ] = optionalType;
- temp[ pos++ ] = SEPARATOR;
- }
-
- System.arraycopy( name, 0, temp, pos, name.length );
- pos += name.length;
-
- if( containingTypes != null ){
- for( int i = containingTypes.length - 1; i >= 0; i-- ){
- if( matchMode == PATTERN_MATCH ){
- starPos = CharOperation.indexOf( '*', containingTypes[i] );
- questionPos = CharOperation.indexOf( '?', containingTypes[i] );
-
- if( starPos >= 0 ){
- if( questionPos >= 0 )
- wildPos = ( starPos < questionPos ) ? starPos : questionPos;
- else
- wildPos = starPos;
- } else {
- wildPos = questionPos;
- }
-
- if( wildPos >= 0 ){
- temp[ pos++ ] = SEPARATOR;
- System.arraycopy( containingTypes[i], 0, temp, pos, wildPos );
- pos += starPos;
- break;
- }
- }
-
- if( containingTypes[i].length > 0 ){
- temp[ pos++ ] = SEPARATOR;
- System.arraycopy( containingTypes[i], 0, temp, pos, containingTypes[i].length );
- pos += containingTypes[i].length;
- }
- }
- }
-
- if( pos < length ){
- result = new char[ pos ];
- System.arraycopy( temp, 0, result, 0, pos );
- } else {
- result = temp;
- }
-
- return result;
- }
-
- /**
- * @param _limitTo
- * @param simpleName
- * @param _matchMode
- * @param _caseSensitive
- * @return
- */
- public static final char[] bestMacroPrefix( LimitTo limitTo, char[] macroName, int matchMode, boolean isCaseSenstive ){
- //since we only index macro declarations we already know the prefix
- char [] prefix = null;
- if( limitTo == DECLARATIONS ){
- prefix = Index.encodeEntry(IIndex.MACRO, IIndex.ANY, IIndex.DECLARATION);
- } else {
- return null;
- }
-
- return bestPrefix( prefix, (char)0, macroName, null, matchMode, isCaseSenstive );
- }
-
- /**
- * @param _limitTo
- * @param simpleName
- * @param _matchMode
- * @param _caseSensitive
- * @return
- */
- public static final char[] bestIncludePrefix( LimitTo limitTo, char[] incName, int matchMode, boolean isCaseSenstive ){
- //since we only index macro declarations we already know the prefix
- char [] prefix = null;
- if( limitTo == REFERENCES ){
- prefix = encodeEntry(IIndex.INCLUDE, IIndex.ANY, IIndex.REFERENCE);
- } else {
- return null;
- }
-
- return bestPrefix( prefix, (char)0, incName, null, matchMode, isCaseSenstive );
- }
-
- public static String getDescriptionOf (int meta_kind, int kind, int ref) {
- StringBuffer buff = new StringBuffer();
- buff.append(encodings[meta_kind]);
- buff.append(encodingTypes[ref]);
- if(kind != 0) {
- buff.append(typeConstants[kind]);
- buff.append(SEPARATOR);
- }
- return buff.toString();
- }
- public static char [] encodeEntry (int meta_kind, int kind, int ref, String name) {
-// if( kind == ANY && ref == ANY )
-// return encodings[meta_kind];
- StringBuffer buff = new StringBuffer();
- buff.append(encodings[meta_kind]);
- buff.append(encodingTypes[ref]);
- if(kind != 0) {
- buff.append(typeConstants[kind]);
- buff.append( SEPARATOR );
- }
- buff.append ( name );
-
- return buff.toString().toCharArray();
- }
-
- public static char [] encodeEntry (int meta_kind, int kind, int ref) {
- StringBuffer buff = new StringBuffer();
- buff.append(encodings[meta_kind]);
- buff.append(encodingTypes[ref]);
- if(kind != 0)
- buff.append(typeConstants[kind]);
- return buff.toString().toCharArray();
- }
- public IEntryResult[] getEntries(int meta_kind, int kind, int ref, String name) throws IOException {
- return queryEntries(encodeEntry(meta_kind, kind, ref, name));
- }
- public IEntryResult[] getEntries(int meta_kind, int kind, int ref) throws IOException {
- return queryEntries(encodeEntry(meta_kind, kind, ref));
- }
-
- public IQueryResult[] getPrefix(int meta_kind, int kind, int ref, String name) throws IOException {
- return queryPrefix(encodeEntry(meta_kind, kind, ref, name));
- }
- public IQueryResult[] getPrefix(int meta_kind, int kind, int ref) throws IOException {
- return queryPrefix(encodeEntry(meta_kind, kind, ref));
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexEntryNotSupportedException.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexEntryNotSupportedException.java
deleted file mode 100644
index 0ad837c3340..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexEntryNotSupportedException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-public class IndexEntryNotSupportedException extends Exception {
-
- public IndexEntryNotSupportedException(String string) {
- super(string);
- }
-
- private static final long serialVersionUID = 3257002138168211513L;
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexPathVariableEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexPathVariableEntry.java
deleted file mode 100644
index 542448d7d65..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexPathVariableEntry.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-/**
- * @author Bogdan Gheorghe
- */
-public class IndexPathVariableEntry {
- //All indexes will reserve 1 in the PathVariable block to represent
- //the workspace location
- public static final int WORKSPACE_ID = 1;
-
- private String pathVariableName;
- private String pathVariablePath;
- private int pathVarID;
-
- public IndexPathVariableEntry(String pathVarName, String pathVarPath, int id){
- this.pathVariableName = pathVarName;
- this.pathVariablePath = pathVarPath;
- this.pathVarID = id;
- }
-
- /**
- * @return Returns the id.
- */
- public int getId() {
- return pathVarID;
- }
- /**
- * @param id The id to set.
- */
- public void setId(int id) {
- this.pathVarID = id;
- }
- /**
- * @return Returns the pathVariableName.
- */
- public String getPathVariableName() {
- return pathVariableName;
- }
- /**
- * @return Returns the pathVariablePath.
- */
- public String getPathVariablePath() {
- return pathVariablePath;
- }
-
- /**
- * Returns the size of the indexedFile.
- */
- public int footprint() {
- //object+ 3 slots + size of the string (Object size + (4 fields in String class)
- //+ 8 for char array in string + (2 for each char * number of chars in string)) + {another String}
- return 8 + (3 * 4) + (8 + (4 * 4) + 8 + (pathVariableName.length() * 2)) + (8 + (4 * 4) + 8 + (pathVariablePath.length() * 2));
- }
-
- public String toString() {
- return "IndexPathVariableEntry(" + pathVarID + ": " + pathVariableName + " + " + pathVariablePath + ")"; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexPathVariableEntryHashedArray.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexPathVariableEntryHashedArray.java
deleted file mode 100644
index f1271341c12..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexPathVariableEntryHashedArray.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import java.util.ArrayList;
-
-public final class IndexPathVariableEntryHashedArray {
-
-private IndexPathVariableEntry elements[];
-private int elementSize; // number of elements in the table
-private int threshold;
-private int lastId;
-private ArrayList replacedElements;
-
-public IndexPathVariableEntryHashedArray(int size) {
- if (size < 7) size = 7;
- this.elements = new IndexPathVariableEntry[2 * size + 1];
- this.elementSize = 0;
- this.threshold = size + 1; // size is the expected number of elements
- this.lastId = 1; //start at 2; 1 is reserved for workspace variable
- this.replacedElements = null;
-}
-
-public IndexPathVariableEntry add(String pathVarName, String path){
- return add(new IndexPathVariableEntry(pathVarName, path, ++lastId));
-}
-
-/**
- * Adds the IndexPathVariableEntry to the list, hashed by path
- * @param pathVar
- */
-private IndexPathVariableEntry add(IndexPathVariableEntry pathVar) {
- int length = elements.length;
- String path = pathVar.getPathVariablePath();
- int index = (path.hashCode() & 0x7FFFFFFF) % length;
- IndexPathVariableEntry current;
- while ((current = elements[index]) != null) {
- if (current.getPathVariablePath().equals(path)) {
- if (replacedElements == null) replacedElements = new ArrayList(5);
- replacedElements.add(current);
- return elements[index] = pathVar;
- }
- if (++index == length) index = 0;
- }
- elements[index] = pathVar;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold) grow();
- return pathVar;
-}
-
-public IndexPathVariableEntry[] asArray() {
- IndexPathVariableEntry[] array = new IndexPathVariableEntry[lastId];
- for (int i = 0, length = elements.length; i < length; i++) {
- IndexPathVariableEntry current = elements[i];
- if (current != null)
- array[current.getId() - 1] = current;
- }
- if (replacedElements != null) {
- for (int i = 0, length = replacedElements.size(); i < length; i++) {
- IndexPathVariableEntry current = (IndexPathVariableEntry) replacedElements.get(i);
- array[current.getId() - 1] = current;
- }
- }
- return array;
-}
-
-/**
- * Returns corresponing IndexPathVariableEntry for the given path or
- * null if it hasn't been added to the array
- * @param path
- * @return
- */
-public IndexPathVariableEntry get(String path) {
- int length = elements.length;
- int index = (path.hashCode() & 0x7FFFFFFF) % length;
- IndexPathVariableEntry current;
- while ((current = elements[index]) != null) {
- if (current.getPathVariablePath().equals(path)) return current;
- if (++index == length) index = 0;
- }
- return null;
-}
-
-private void grow() {
- IndexPathVariableEntryHashedArray newArray = new IndexPathVariableEntryHashedArray(elementSize * 2); // double the number of expected elements
- for (int i = 0, length = elements.length; i < length; i++)
- if (elements[i] != null)
- newArray.add(elements[i]);
-
- // leave replacedElements as is
- this.elements = newArray.elements;
- this.elementSize = newArray.elementSize;
- this.threshold = newArray.threshold;
-}
-
-public int size() {
- return elementSize + (replacedElements == null ? 0 : replacedElements.size());
-}
-
-public String toString() {
- String s = ""; //$NON-NLS-1$
- IndexPathVariableEntry[] files = asArray();
- for (int i = 0, length = files.length; i < length; i++)
- s += files[i].toString() + "\n"; //$NON-NLS-1$
- return s;
-}
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexedFileEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexedFileEntry.java
deleted file mode 100644
index ee17cd4ef14..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexedFileEntry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import org.eclipse.cdt.internal.core.index.IQueryResult;
-
-/**
- * @author Bogdan Gheorghe
- */
-public class IndexedFileEntry implements IQueryResult {
-
- /**
- * Path relative to the workspace root for this file
- */
- private String path;
- /**
- * Unique file id
- */
- private int fileID;
- /**
- * Index Path Var id - links this file entry to a corresponding entry
- * in IndexPathVariableEntry.
- */
- private int pathVarID;
- /**
- * MD5 for this file
- */
- private byte[] MD5;
-
- public IndexedFileEntry(String path, int fileNum) {
- if (fileNum < 1)
- throw new IllegalArgumentException();
- this.fileID= fileNum;
- this.path= path;
- }
-
- /**
- * Returns the size of the indexedFile.
- */
- public int footprint() {
- //object+ 4 slots + size of the string (header + 4 slots + char[]) + size of byte array
- return 8 + (4 * 4) + (8 + (4 * 4) + 8 + path.length() * 2); //Put in when you put in MD5 + (8 + MD5.length);
- }
- /**
- * Returns the file number.
- */
- public int getFileID() {
- return fileID;
- }
- /**
- * Returns the path.
- */
- public String getPath() {
- return path;
- }
- /**
- * Sets the file number.
- */
- public void setFileNumber(int fileNumber) {
- this.fileID= fileNumber;
- }
- public String toString() {
- return "IndexedFile(" + fileID + ": " + path + ")"; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
- }
-
-
-
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexedFileEntryHashedArray.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexedFileEntryHashedArray.java
deleted file mode 100644
index e5c6e45a5ef..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexedFileEntryHashedArray.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import java.util.ArrayList;
-
-public final class IndexedFileEntryHashedArray {
-
-private IndexedFileEntry elements[];
-private int elementSize; // number of elements in the table
-private int threshold;
-private int lastId;
-private ArrayList replacedElements;
-
-public IndexedFileEntryHashedArray(int size) {
- if (size < 7) size = 7;
- this.elements = new IndexedFileEntry[2 * size + 1];
- this.elementSize = 0;
- this.threshold = size + 1; // size is the expected number of elements
- this.lastId = 0;
- this.replacedElements = null;
-}
-
-public IndexedFileEntry add(String path){
- return add(new IndexedFileEntry(path, ++lastId));
-}
-
-private IndexedFileEntry add(IndexedFileEntry file) {
- int length = elements.length;
- String path = file.getPath();
- int index = (path.hashCode() & 0x7FFFFFFF) % length;
- IndexedFileEntry current;
- while ((current = elements[index]) != null) {
- if (current.getPath().equals(path)) {
- if (replacedElements == null) replacedElements = new ArrayList(5);
- replacedElements.add(current);
- return elements[index] = file;
- }
- if (++index == length) index = 0;
- }
- elements[index] = file;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold) grow();
- return file;
-}
-
-public IndexedFileEntry[] asArray() {
- IndexedFileEntry[] array = new IndexedFileEntry[lastId];
- for (int i = 0, length = elements.length; i < length; i++) {
- IndexedFileEntry current = elements[i];
- if (current != null)
- array[current.getFileID() - 1] = current;
- }
- if (replacedElements != null) {
- for (int i = 0, length = replacedElements.size(); i < length; i++) {
- IndexedFileEntry current = (IndexedFileEntry) replacedElements.get(i);
- array[current.getFileID() - 1] = current;
- }
- }
- return array;
-}
-
-public IndexedFileEntry get(String path) {
- int length = elements.length;
- int index = (path.hashCode() & 0x7FFFFFFF) % length;
- IndexedFileEntry current;
- while ((current = elements[index]) != null) {
- if (current.getPath().equals(path)) return current;
- if (++index == length) index = 0;
- }
- return null;
-}
-
-private void grow() {
- IndexedFileEntryHashedArray newArray = new IndexedFileEntryHashedArray(elementSize * 2); // double the number of expected elements
- for (int i = 0, length = elements.length; i < length; i++)
- if (elements[i] != null)
- newArray.add(elements[i]);
-
- // leave replacedElements as is
- this.elements = newArray.elements;
- this.elementSize = newArray.elementSize;
- this.threshold = newArray.threshold;
-}
-
-public int size() {
- return elementSize + (replacedElements == null ? 0 : replacedElements.size());
-}
-
-public String toString() {
- String s = ""; //$NON-NLS-1$
- IndexedFileEntry[] files = asArray();
- for (int i = 0, length = files.length; i < length; i++)
- s += files[i].toString() + "\n"; //$NON-NLS-1$
- return s;
-}
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java
deleted file mode 100644
index d39e19ad614..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import org.eclipse.cdt.internal.core.index.IFunctionEntry;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.IIndexEntry;
-import org.eclipse.cdt.internal.core.index.IIndexerOutput;
-import org.eclipse.cdt.internal.core.index.INamedEntry;
-import org.eclipse.cdt.internal.core.index.ITypeEntry;
-import org.eclipse.cdt.internal.core.index.domsourceindexer.AbstractIndexerRunner;
-
-/**
- * An indexerOutput is used by an indexer to add files and word references to
- * an inMemoryIndex.
- */
-
-public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
- public static int entryCount = 0;
- protected InMemoryIndex index;
- /**
- * IndexerOutput constructor comment.
- */
- public IndexerOutput(InMemoryIndex index) {
- this.index= index;
- }
-
- protected void addRef(int indexedFileNumber, char [][] name, char suffix, int type, int offset, int offsetLength, int offsetType, int modifiers) {
- if (indexedFileNumber == 0) {
- throw new IllegalStateException();
- }
-
- if (offsetLength <= 0)
- offsetLength = 1;
-
- if (modifiers <=0)
- modifiers = 1;
-
- entryCount++;
- index.addRef(
- encodeTypeEntry(name, suffix, type),
- indexedFileNumber, offset, offsetLength, offsetType, modifiers);
- }
-
- protected void addRef(int indexedFileNumber, char[][] name, int meta_kind, int ref, int offset, int offsetLength, int offsetType, int modifiers) {
- if (indexedFileNumber == 0) {
- throw new IllegalStateException();
- }
-
- if (offsetLength <= 0)
- offsetLength = 1;
-
- if (modifiers <=0)
- modifiers = 1;
- entryCount++;
- index.addRef(
- encodeEntry(name, meta_kind, ref),
- indexedFileNumber, offset, offsetLength, offsetType, modifiers);
-
- }
-
- public void addRelatives(int indexedFileNumber, String inclusion, String parent) {
- if (indexedFileNumber == 0) {
- throw new IllegalStateException();
- }
- index.addRelatives(indexedFileNumber, inclusion, parent);
- }
-
- public void addIncludeRef(int indexedFileNumber, char[] word) {
- if (indexedFileNumber == 0) {
- throw new IllegalStateException();
- }
- index.addIncludeRef(word, indexedFileNumber);
- }
-
- public void addIncludeRef(int indexedFileNumber, String word) {
- addIncludeRef(indexedFileNumber, word.toCharArray());
- }
-
- public IndexedFileEntry getIndexedFile(String path) {
- return index.getIndexedFile(path);
- }
-
- /**
- * Adds the file path to the index, creating a new file entry
- * for it
- */
- public IndexedFileEntry addIndexedFile(String path) {
- return index.addFile(path);
- }
-
- public void addIncludeRef(int indexedFileNumber, char[][] name, int offset, int offsetLength, int offsetType) {
- addRef(indexedFileNumber, name, IIndex.INCLUDE, IIndex.REFERENCE, offset,offsetLength, offsetType,1);
- }
-
- /**
- * Type entries are encoded as follow: 'typeDecl/' ('C' | 'S' | 'U' | 'E' ) '/' TypeName ['/' Qualifier]*
- */
- protected static final char[] encodeTypeEntry(char[][] fullTypeName, char suffix, int type) {
-
- int pos = 0, nameLength = 0;
- for (int i=0; i 0){
- //Extract the name first
- char [] tempName = fullTypeName[fullTypeName.length-1];
- System.arraycopy(tempName, 0, result, pos, tempName.length);
- pos += tempName.length;
- }
- //Extract the qualifiers
- for (int i=fullTypeName.length - 2; i >= 0; i--){
- result[pos++] = SEPARATOR;
- char [] tempName = fullTypeName[i];
- System.arraycopy(tempName, 0, result, pos, tempName.length);
- pos+=tempName.length;
- }
-
- if (AbstractIndexerRunner.VERBOSE)
- AbstractIndexerRunner.verbose(new String(result));
-
- return result;
- }
- /**
- * Namespace entries are encoded as follow: '[prefix]/' TypeName ['/' Qualifier]*
- */
- protected static final char[] encodeEntry(char[][] elementName, int meta_kind, int ref) {
- int pos, nameLength = 0;
- for (int i=0; i 0){
- //Extract the name first
- char [] tempName = elementName[elementName.length-1];
- System.arraycopy(tempName, 0, result, pos, tempName.length);
- pos += tempName.length;
- }
- //Extract the qualifiers
- for (int i=elementName.length - 2; i>=0; i--){
- result[pos++] = SEPARATOR;
- char [] tempName = elementName[i];
- System.arraycopy(tempName, 0, result, pos, tempName.length);
- pos+=tempName.length;
- }
-
- if (AbstractIndexerRunner.VERBOSE)
- AbstractIndexerRunner.verbose(new String(result));
-
- return result;
- }
-
- public void addIndexEntry(IIndexEntry indexEntry) throws IndexEntryNotSupportedException {
-
- if (indexEntry == null)
- return;
-
- throw new IndexEntryNotSupportedException("Index Entry type not supported - need to add handler"); //$NON-NLS-1$
- }
-
- public void addIndexEntry(ITypeEntry typeEntry) {
- int indexedFileNumber=typeEntry.getFileNumber();
- int meta_type = typeEntry.getMetaKind();
- int type_kind = typeEntry.getTypeKind();
- int entryType = typeEntry.getEntryType();
- int modifiers = typeEntry.getModifiers();
-
- char[][]name=typeEntry.getFullName();
-
- int nameOffset=typeEntry.getNameOffset();
- int nameOffsetLength=typeEntry.getNameLength();
- int nameOffsetType=typeEntry.getNameOffsetType();
-
- int elementOffset=typeEntry.getElementOffset();
- int elementOffsetLength=typeEntry.getElementLength();
- int elementOffsetType=typeEntry.getElementOffsetType();
-
- if (modifiers <= 0)
- modifiers = 1;
-
- addRef(indexedFileNumber, name, ICIndexStorageConstants.typeConstants[type_kind], entryType, nameOffset,nameOffsetLength, nameOffsetType, modifiers);
-
- IIndexEntry[] baseClasses = typeEntry.getBaseTypes();
- if (baseClasses != null &&
- baseClasses.length > 0){
- for (int i=0; i0
if the str1 is equal to str2;
- * a value less than 0
if str1
- * is lexicographically less than str2;
- * and a value greater than 0
if str1 is
- * lexicographically greater than str2.
- */
- public static int compare(char[] str1, char[] str2) {
- int len1= str1.length;
- int len2= str2.length;
- int n= Math.min(len1, len2);
- int i= 0;
- while (n-- != 0) {
- char c1= str1[i];
- char c2= str2[i++];
- if (c1 != c2) {
- return c1 - c2;
- }
- }
- return len1 - len2;
- }
-
- /**
- * Returns the length of the common prefix between s1 and s2.
- */
- public static int prefixLength(char[] s1, char[] s2) {
- int len= 0;
- int max= Math.min(s1.length, s2.length);
- for (int i= 0; i < max && s1[i] == s2[i]; ++i)
- ++len;
- return len;
- }
- /**
- * Returns the length of the common prefix between s1 and s2.
- */
- public static int prefixLength(String s1, String s2) {
- int len= 0;
- int max= Math.min(s1.length(), s2.length());
- for (int i= 0; i < max && s1.charAt(i) == s2.charAt(i); ++i)
- ++len;
- return len;
- }
- private static void quickSort(char[][] list, int left, int right) {
- int original_left= left;
- int original_right= right;
- char[] mid= list[(left + right) / 2];
- do {
- while (compare(list[left], mid) < 0) {
- left++;
- }
- while (compare(mid, list[right]) < 0) {
- right--;
- }
- if (left <= right) {
- char[] tmp= list[left];
- list[left]= list[right];
- list[right]= tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
- private static void quickSort(int[] list, int left, int right) {
- int original_left= left;
- int original_right= right;
- int mid= list[(left + right) / 2];
- do {
- while (list[left] < mid) {
- left++;
- }
- while (mid < list[right]) {
- right--;
- }
- if (left <= right) {
- int tmp= list[left];
- list[left]= list[right];
- list[right]= tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
- private static void quickSort(String[] list, int left, int right) {
- int original_left= left;
- int original_right= right;
- String mid= list[(left + right) / 2];
- do {
- while (list[left].compareTo(mid) < 0) {
- left++;
- }
- while (mid.compareTo(list[right]) < 0) {
- right--;
- }
- if (left <= right) {
- String tmp= list[left];
- list[left]= list[right];
- list[right]= tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
- private static void quickSort(IndexedFileEntry[] list, int left, int right) {
- int original_left= left;
- int original_right= right;
- String mid= list[(left + right) / 2].getPath();
- do {
- while (list[left].getPath().compareTo(mid) < 0) {
- left++;
- }
- while (mid.compareTo(list[right].getPath()) < 0) {
- right--;
- }
- if (left <= right) {
- IndexedFileEntry tmp= list[left];
- list[left]= list[right];
- list[right]= tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
- private static void quickSort(WordEntry[] list, int left, int right) {
- int original_left= left;
- int original_right= right;
- char[] mid= list[(left + right) / 2].getWord();
- do {
- while (compare(list[left].getWord(), mid) < 0) {
- left++;
- }
- while (compare(mid, list[right].getWord()) < 0) {
- right--;
- }
- if (left <= right) {
- WordEntry tmp= list[left];
- list[left]= list[right];
- list[right]= tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
-
- private static void quickSort(IncludeEntry[] list, int left, int right) {
- int original_left= left;
- int original_right= right;
- char[] mid= list[(left + right) / 2].fFile;
- do {
- while (compare(list[left].fFile, mid) < 0) {
- left++;
- }
- while (compare(mid, list[right].fFile) < 0) {
- right--;
- }
- if (left <= right) {
- IncludeEntry tmp= list[left];
- list[left]= list[right];
- list[right]= tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
- /**
- * Reads in a string from the specified data input stream. The
- * string has been encoded using a modified UTF-8 format.
- *
- * The first two bytes are read as if by
- * readUnsignedShort
. This value gives the number of
- * following bytes that are in the encoded string, not
- * the length of the resulting string. The following bytes are then
- * interpreted as bytes encoding characters in the UTF-8 format
- * and are converted into characters.
- *
- * This method blocks until all the bytes are read, the end of the - * stream is detected, or an exception is thrown. - * - * @param in a data input stream. - * @return a Unicode string. - * @exception EOFException if the input stream reaches the end - * before all the bytes. - * @exception IOException if an I/O error occurs. - * @exception UTFDataFormatException if the bytes do not represent a - * valid UTF-8 encoding of a Unicode string. - * @see java.io.DataInputStream#readUnsignedShort() - */ - public final static char[] readUTF(DataInput in) throws IOException { - int utflen= in.readUnsignedShort(); - char str[]= new char[utflen]; - int count= 0; - int strlen= 0; - while (count < utflen) { - int c= in.readUnsignedByte(); - int char2, char3; - switch (c >> 4) { - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - // 0xxxxxxx - count++; - str[strlen++]= (char) c; - break; - case 12 : - case 13 : - // 110x xxxx 10xx xxxx - count += 2; - if (count > utflen) - throw new UTFDataFormatException(); - char2= in.readUnsignedByte(); - if ((char2 & 0xC0) != 0x80) - throw new UTFDataFormatException(); - str[strlen++]= (char) (((c & 0x1F) << 6) | (char2 & 0x3F)); - break; - case 14 : - // 1110 xxxx 10xx xxxx 10xx xxxx - count += 3; - if (count > utflen) - throw new UTFDataFormatException(); - char2= in.readUnsignedByte(); - char3= in.readUnsignedByte(); - if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) - throw new UTFDataFormatException(); - str[strlen++]= (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)); - break; - default : - // 10xx xxxx, 1111 xxxx - throw new UTFDataFormatException(); - } - } - if (strlen < utflen) { - System.arraycopy(str, 0, str= new char[strlen], 0, strlen); - } - return str; - } - public static void sort(char[][] list) { - if (list.length > 1) - quickSort(list, 0, list.length - 1); - } - public static void sort(int[] list) { - if (list.length > 1) - quickSort(list, 0, list.length - 1); - } - public static void sort(String[] list) { - if (list.length > 1) - quickSort(list, 0, list.length - 1); - } - public static void sort(IndexedFileEntry[] list) { - if (list.length > 1) - quickSort(list, 0, list.length - 1); - } - public static void sort(WordEntry[] list) { - if (list.length > 1) - quickSort(list, 0, list.length - 1); - } - public static void sort(IncludeEntry[] list) { - if (list.length > 1) - quickSort(list, 0, list.length - 1); - } - /** - * Writes a string to the given output stream using UTF-8 - * encoding in a machine-independent manner. - *
- * First, two bytes are written to the output stream as if by the
- *
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
index ce4bde33afd..93034bc3c82 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
@@ -12,6 +12,7 @@
package org.eclipse.cdt.core.model;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.core.runtime.IAdaptable;
@@ -75,6 +76,18 @@ public interface ILanguage extends IAdaptable {
*/
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset);
+ /**
+ * Gather the list of IASTNames that appear the selection with the given start offset
+ * and length in the given ITranslationUnit.
+ *
+ * @param tu
+ * @param start
+ * @param length
+ * @param style
+ * @return
+ */
+ public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length);
+
/**
* Used to override the default model building behavior for a translation unit.
*
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IQualifiedTypeName.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/IQualifiedTypeName.java
similarity index 97%
rename from core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IQualifiedTypeName.java
rename to core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/IQualifiedTypeName.java
index 2d7836201c9..1a2d786c8c2 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IQualifiedTypeName.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/IQualifiedTypeName.java
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.browser;
+package org.eclipse.cdt.core.model.util;
public interface IQualifiedTypeName extends Comparable {
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/QualifiedTypeName.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/QualifiedTypeName.java
similarity index 99%
rename from core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/QualifiedTypeName.java
rename to core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/QualifiedTypeName.java
index fac1632764f..fbdf1bf8bcc 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/QualifiedTypeName.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/QualifiedTypeName.java
@@ -8,7 +8,7 @@
* Contributors:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.browser;
+package org.eclipse.cdt.core.model.util;
import org.eclipse.cdt.core.CConventions;
import org.eclipse.core.runtime.IStatus;
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/Signature.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/Signature.java
similarity index 99%
rename from core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/Signature.java
rename to core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/Signature.java
index 9786f678247..51679c51772 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/Signature.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/Signature.java
@@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation
* IBM Corporation - added J2SE 1.5 support
*******************************************************************************/
-package org.eclipse.cdt.core.browser;
+package org.eclipse.cdt.core.model.util;
import org.eclipse.cdt.internal.core.CharOperation;
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/TypeUtil.java
similarity index 92%
rename from core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeUtil.java
rename to core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/TypeUtil.java
index 9c86849c845..7c98786e521 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeUtil.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/TypeUtil.java
@@ -8,12 +8,11 @@
* Contributors:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.browser;
+package org.eclipse.cdt.core.model.util;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMember;
@@ -21,7 +20,6 @@ import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class TypeUtil {
@@ -300,20 +298,20 @@ public class TypeUtil {
* @return The first method found or null, if nothing found
*/
// TODO move methods to CModelUtil
- public static IMethodDeclaration findMethodDeclarationInHierarchy(ITypeHierarchy hierarchy, ICElement type, String name, String[] paramTypes, boolean isConstructor, boolean isDestructor) throws CModelException {
- ICElement[] superTypes= hierarchy.getAllSupertypes(type);
- for (int i= superTypes.length - 1; i >= 0; i--) {
- IMethodDeclaration first= findMethod(name, paramTypes, isConstructor, isDestructor, superTypes[i]);
- if (first != null && first.getVisibility() != ASTAccessVisibility.PRIVATE) {
- // the order getAllSupertypes does make assumptions of the order of inner elements -> search recursivly
- IMethodDeclaration res= findMethodDeclarationInHierarchy(hierarchy, TypeUtil.getDeclaringClass(first), name, paramTypes, isConstructor, isDestructor);
- if (res != null) {
- return res;
- }
- return first;
- }
- }
- return null;
- }
+// public static IMethodDeclaration findMethodDeclarationInHierarchy(ITypeHierarchy hierarchy, ICElement type, String name, String[] paramTypes, boolean isConstructor, boolean isDestructor) throws CModelException {
+// ICElement[] superTypes= hierarchy.getAllSupertypes(type);
+// for (int i= superTypes.length - 1; i >= 0; i--) {
+// IMethodDeclaration first= findMethod(name, paramTypes, isConstructor, isDestructor, superTypes[i]);
+// if (first != null && first.getVisibility() != ASTAccessVisibility.PRIVATE) {
+// // the order getAllSupertypes does make assumptions of the order of inner elements -> search recursivly
+// IMethodDeclaration res= findMethodDeclarationInHierarchy(hierarchy, TypeUtil.getDeclaringClass(first), name, paramTypes, isConstructor, isDestructor);
+// if (res != null) {
+// return res;
+// }
+// return first;
+// }
+// }
+// return null;
+// }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
index 7fb149ce463..f49ad3807d4 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
@@ -165,8 +165,9 @@ public class CModelBuilder {
scanInfo = new ExtendedScannerInfo();
}
+ IResource resource = translationUnit.getUnderlyingResource();
CodeReader reader =
- translationUnit.getUnderlyingResource() != null
+ resource != null && resource.getLocation() != null
? new CodeReader(translationUnit.getUnderlyingResource().getLocation().toOSString(), code)
: new CodeReader(code);
parser = ParserFactory.createParser(
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 a30297c338d..943662ea232 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
@@ -48,7 +48,6 @@ import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -1111,10 +1110,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
*
*/
public void shutdown() {
- if (this.fDeltaProcessor.indexManager != null) { // no more indexing
- this.fDeltaProcessor.indexManager.shutdown();
- }
-
// Remove ourself from the DescriptorManager.
CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(factory);
// Remove ourself from the ContentTypeManager
@@ -1129,13 +1124,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
}
- public IndexManager getIndexManager() {
- return this.fDeltaProcessor.indexManager;
- }
-
public void deleting(IProject project) {
- // discard all indexing jobs for this project
- this.getIndexManager().discardJobs(project.getName());
// stop the binary runner for this project
removeBinaryRunner(project);
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
index debf48bd441..74fe1f61189 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
@@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.core.model;
-import org.eclipse.cdt.core.index.ICDTIndexer;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IArchive;
@@ -23,7 +22,6 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
@@ -43,8 +41,6 @@ public class DeltaProcessor {
*/
protected CElementDelta fCurrentDelta;
- protected IndexManager indexManager = new IndexManager();
-
/* The C element that was last created (see createElement(IResource).
* This is used as a stack of C elements (using getParent() to pop it, and
* using the various get*(...) to push it. */
@@ -543,7 +539,6 @@ public class DeltaProcessor {
switch (delta.getKind()) {
case IResourceDelta.ADDED :
if (element != null) {
- updateIndexAddResource(element, delta, false);
elementAdded(element, delta);
return element instanceof ICContainer;
}
@@ -551,7 +546,6 @@ public class DeltaProcessor {
case IResourceDelta.REMOVED :
if (element != null) {
- updateIndexRemoveResource(element, delta);
elementRemoved(element, delta);
}
return element instanceof ICContainer;
@@ -562,10 +556,6 @@ public class DeltaProcessor {
// content has changed
if (element != null) {
elementChanged(element, delta);
- updateIndexAddResource(element, delta, true);
- //check to see if any projects need to be reindexed
- updateDependencies(element);
-
}
} else if (resource.getType() == IResource.PROJECT) {
if ((flags & IResourceDelta.OPEN) != 0) {
@@ -574,11 +564,9 @@ public class DeltaProcessor {
if (element != null) {
if (project.isOpen()) {
elementOpened(element, delta);
- updateIndexAddResource(element, delta, true);
return false;
}
elementClosed(element, delta);
- updateIndexRemoveResource(element, delta);
//Don't process children
return false;
}
@@ -594,10 +582,8 @@ public class DeltaProcessor {
// note its resources are still visible as roots to other projects
if (isCProject) {
elementOpened(element, delta);
- updateIndexAddResource(element, delta, true);
} else {
elementRemoved(element, delta);
- updateIndexRemoveResource(element, delta);
}
return true;
}
@@ -609,62 +595,4 @@ public class DeltaProcessor {
return true;
}
- protected void updateIndexAddResource(ICElement element, IResourceDelta delta, boolean elementHasChanged) {
-
- if (indexManager == null)
- return;
-
- switch (element.getElementType()){
- case ICElement.C_PROJECT:
- indexManager.addResourceEvent(element.getCProject().getProject(),delta, ICDTIndexer.PROJECT);
- break;
-
- case ICElement.C_CCONTAINER:
- indexManager.addResourceEvent(element.getCProject().getProject(),delta, ICDTIndexer.FOLDER);
- break;
-
- case ICElement.C_UNIT:
- indexManager.addResourceEvent(element.getCProject().getProject(),delta, ICDTIndexer.COMPILATION_UNIT);
- break;
- }
-
-
- }
-
- protected void updateIndexRemoveResource(ICElement element, IResourceDelta delta) {
-
- if (indexManager == null)
- return;
-
- switch (element.getElementType()){
- case ICElement.C_PROJECT:
- indexManager.removeResourceEvent(element.getCProject().getProject(),delta, ICDTIndexer.PROJECT);
- break;
-
- case ICElement.C_CCONTAINER:
- indexManager.removeResourceEvent(element.getCProject().getProject(),delta, ICDTIndexer.FOLDER);
- break;
-
- case ICElement.C_UNIT:
- indexManager.removeResourceEvent(element.getCProject().getProject(),delta, ICDTIndexer.COMPILATION_UNIT);
- break;
-
- }
-
- }
-
- private void updateDependencies(ICElement element){
-
- IResource resource = element.getResource();
- if (resource == null)
- return;
-
- IProject project = resource.getProject();
- String filename = resource.getName();
-
- if (CoreModel.isValidHeaderUnitName(project, filename)) {
- indexManager.updateDependencies(project, resource);
- }
- }
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/DOMSearchUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/DOMSearchUtil.java
new file mode 100644
index 00000000000..3bfc4f23ddd
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/DOMSearchUtil.java
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
+import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.content.IContentType;
+
+/**
+ * Utility class to have commonly used algorithms in one place for searching with the DOM.
+ *
+ * @author dsteffle
+ */
+public class DOMSearchUtil {
+ private static final IASTName[] BLANK_NAME_ARRAY = new IASTName[0];
+ private static final IASTName[] EMPTY_NAME_LIST = BLANK_NAME_ARRAY;
+
+ public static final int DECLARATIONS = 1;
+ public static final int DEFINITIONS = 2;
+ public static final int DECLARATIONS_DEFINITIONS = 3;
+ public static final int REFERENCES = 4;
+ public static final int ALL_OCCURRENCES = 5;
+ /**
+ * This retrieves the ParserLanguage from an IFile.
+ *
+ * @param file
+ * @return
+ */
+ public static ParserLanguage getLanguageFromFile(IFile file) {
+ IProject project = file.getProject();
+ IContentType contentType = CCorePlugin.getContentType(project, file.getFullPath().lastSegment());
+ if (contentType != null) {
+ String lid = contentType.getId();
+ if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(lid)) {
+ return ParserLanguage.CPP;
+ }
+ }
+ return ParserLanguage.C;
+ }
+
+ /**
+ * The CPPNameCollector used to get IASTNames from an IASTNode.
+ *
+ * @author dsteffle
+ */
+ static public class CPPNameCollector extends CPPASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+ public List nameList = new ArrayList();
+ public int visit( IASTName name ){
+ nameList.add( name );
+ return PROCESS_CONTINUE;
+ }
+ public IASTName getName( int idx ){
+ if( idx < 0 || idx >= nameList.size() )
+ return null;
+ return (IASTName) nameList.get( idx );
+ }
+ public int size() { return nameList.size(); }
+ }
+
+ /**
+ * The CNameCollector used to get IASTNames from an IASTNode.
+ *
+ * @author dsteffle
+ */
+ static public class CNameCollector extends CASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+ public List nameList = new ArrayList();
+ public int visit( IASTName name ){
+ nameList.add( name );
+ return PROCESS_CONTINUE;
+ }
+ public IASTName getName( int idx ){
+ if( idx < 0 || idx >= nameList.size() )
+ return null;
+ return (IASTName) nameList.get( idx );
+ }
+ public int size() { return nameList.size(); }
+ }
+
+ /**
+ * Returns the ParserLanguage corresponding to the IPath and IProject. Returns ParserLanguage.CPP if the file type is a header.
+ *
+ * @param path
+ * @param project
+ * @return
+ */
+ public static ParserLanguage getLanguage( IPath path, IProject project )
+ {
+ //FIXME: ALAIN, for headers should we assume CPP ??
+ // The problem is that it really depends on how the header was included.
+ String id = null;
+ IContentType contentType = CCorePlugin.getContentType(project, path.lastSegment());
+ if (contentType != null) {
+ id = contentType.getId();
+ }
+ if (id != null) {
+ if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
+ return ParserLanguage.CPP;
+ } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
+ return ParserLanguage.CPP;
+ } else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
+ return ParserLanguage.CPP; // <============== is that right ? should not this be C ?
+ } else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) {
+ return ParserLanguage.C;
+ } else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) {
+ // ???
+ // What do we do here ?
+ }
+ }
+ return ParserLanguage.CPP;
+ }
+
+ /**
+ * This is used to get the names from the TU that the IASTName searchName belongs to.
+ *
+ * @param searchName the IASTName whose references/delcarations are to be retrieved
+ * @param limitTo used to specify whether to get declarations, references, or both, one of:
+ * ( CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES )
+ * @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
+ */
+ public static IASTName[] getNamesFromDOM(IASTName searchName, int limitTo) {
+ IASTName[] names = null;
+ IASTTranslationUnit tu = searchName.getTranslationUnit();
+
+ if (tu == null) {
+ return BLANK_NAME_ARRAY;
+ }
+
+ IBinding binding = searchName.resolveBinding();
+ if (binding instanceof PDOMBinding) {
+ try {
+ ArrayList pdomNames = new ArrayList();
+ // First decls
+ PDOMName name = ((PDOMBinding)binding).getFirstDeclaration();
+ while (name != null) {
+ pdomNames.add(name);
+ name = name.getNextInBinding();
+ }
+ // Next defs
+ name = ((PDOMBinding)binding).getFirstDefinition();
+ while (name != null) {
+ pdomNames.add(name);
+ name = name.getNextInBinding();
+ }
+ names = (IASTName[])pdomNames.toArray(new IASTName[pdomNames.size()]);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ } else {
+ names = getNames(tu, binding, limitTo);
+
+ if (names == null || names.length == 0) { // try alternate strategies
+ try {
+ // fix for 86829, 95224
+ if ((binding instanceof ICPPConstructor || (binding instanceof ICPPMethod && ((ICPPMethod)binding).isDestructor()))
+ && binding.getScope() instanceof ICPPClassScope) {
+ binding = ((ICPPClassScope)binding.getScope()).getClassType();
+ names = getNames(tu, binding, limitTo);
+ }
+ } catch (DOMException e) {}
+ }
+ }
+
+ return names;
+ }
+
+ private static IASTName[] getNames(IASTTranslationUnit tu, IBinding binding, int limitTo) {
+ IASTName[] names = null;
+ if (limitTo == DECLARATIONS ||
+ limitTo == DECLARATIONS_DEFINITIONS) {
+ names = tu.getDeclarations(binding);
+ } else if (limitTo == REFERENCES) {
+ names = tu.getReferences(binding);
+ } else if (limitTo == DEFINITIONS) {
+ names = tu.getDefinitions(binding);
+ } else if (limitTo == ALL_OCCURRENCES){
+ names = tu.getDeclarations(binding);
+ names = (IASTName[])ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
+ } else { // assume ALL
+ names = tu.getDeclarations(binding);
+ names = (IASTName[])ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
+ }
+
+ return names;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
index c02c74260a8..347a8fc26ae 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java
@@ -10,27 +10,28 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom;
-import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
/**
- * @author Doug Schaefer
+ * This is the reader interface to the PDOM. It is used by general
+ * clients that need access to the information stored there.
*
- * This is the interface to the Persisted DOM (PDOM).
- * It provides services to allow access to DOM information
- * persisted between parses.
+ * @author Doug Schaefer
*/
public interface IPDOM extends IAdaptable {
- public IBinding resolveBinding(IASTName name);
-
+ /**
+ * Find all the bindings that match the pattern.
+ *
+ * @param pattern
+ * @return
+ * @throws CoreException
+ */
public IBinding[] findBindings(String pattern) throws CoreException;
- public IASTName[] getDeclarations(IBinding binding);
-
/**
* Recursively visit the nodes in this PDOM using the given visitor.
*
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMResolver.java
new file mode 100644
index 00000000000..e56dc353b39
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMResolver.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2006 QNX Software Systems and others.
+ * All rights reserved. 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:
+ * QNX - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.dom;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * This is the interface used by the DOM to help with resolving
+ * bindings amongst other things.
+ *
+ * @author Doug Schaefer
+ */
+public interface IPDOMResolver extends IAdaptable {
+
+ public IBinding resolveBinding(IASTName name);
+
+ public IASTName[] getDeclarations(IBinding binding);
+
+ public IASTName[] getDefinitions(IBinding binding);
+
+}
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/LimitTo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMWriter.java
similarity index 61%
rename from core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/LimitTo.java
rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMWriter.java
index 74c756a562e..4bb5fd0fc1b 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/LimitTo.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOMWriter.java
@@ -6,15 +6,19 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - initial API and implementation
+ * QNX - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.search;
+package org.eclipse.cdt.core.dom;
-public class LimitTo {
- LimitTo( int value )
- {
- this.value = value;
- }
- private final int value;
-}
\ No newline at end of file
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * This is the interface used by clients, such as indexers, to
+ * write content to the PDOM.
+ *
+ * @author Doug Schaefer
+ */
+public interface IPDOMWriter extends IAdaptable {
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
index 55e25aac803..905d9130dc7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
@@ -11,10 +11,16 @@
package org.eclipse.cdt.core.dom.ast.gnu.c;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ILanguage;
@@ -86,7 +92,7 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project).getAdapter(PDOM.class);
ICodeReaderFactory fileCreator;
- if ((style & ILanguage.AST_SKIP_INDEXED_HEADERS) != 0)
+ if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0)
fileCreator = new PDOMCodeReaderFactory(pdom);
else
fileCreator = SavedCodeReaderFactory.getInstance();
@@ -169,6 +175,34 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
return node;
}
+ private static class NameCollector extends CASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+ private List nameList = new ArrayList();
+ public int visit( IASTName name ){
+ nameList.add( name );
+ return PROCESS_CONTINUE;
+ }
+ public IASTName[] getNames() {
+ return (IASTName[])nameList.toArray(new IASTName[nameList.size()]);
+ }
+ }
+
+ public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
+ IASTNode selectedNode = ast.selectNodeForLocation(ast.getFilePath(), start, length);
+
+ if (selectedNode == null)
+ return new IASTName[0];
+
+ if (selectedNode instanceof IASTName)
+ return new IASTName[] { (IASTName)selectedNode };
+
+ NameCollector collector = new NameCollector();
+ selectedNode.accept(collector);
+ return collector.getNames();
+ }
+
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
// Use the default CDT model builder
return null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
index e664b0c2c99..cf8f470a6ce 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
@@ -11,10 +11,16 @@
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ILanguage;
@@ -85,21 +91,18 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project).getAdapter(PDOM.class);
ICodeReaderFactory fileCreator;
- if ((style & ILanguage.AST_SKIP_INDEXED_HEADERS) != 0)
+ if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0)
fileCreator = new PDOMCodeReaderFactory(pdom);
else
fileCreator = SavedCodeReaderFactory.getInstance();
CodeReader reader;
IFile rfile = (IFile)file.getResource();
+ String path = rfile != null ? rfile.getLocation().toOSString() : file.getPath().toOSString();
if (file instanceof IWorkingCopy) {
// get the working copy contents
- reader = new CodeReader(((IWorkingCopy)file).getOriginalElement().getPath().toOSString(), file.getContents());
+ reader = new CodeReader(path, file.getContents());
} else {
- String path
- = rfile != null
- ? rfile.getLocation().toOSString()
- : file.getPath().toOSString();
reader = fileCreator.createCodeReaderForTranslationUnit(path);
if (reader == null)
return null;
@@ -164,7 +167,34 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
return node;
}
-
+ private static class NameCollector extends CPPASTVisitor {
+ {
+ shouldVisitNames = true;
+ }
+ private List nameList = new ArrayList();
+ public int visit( IASTName name ){
+ nameList.add( name );
+ return PROCESS_CONTINUE;
+ }
+ public IASTName[] getNames() {
+ return (IASTName[])nameList.toArray(new IASTName[nameList.size()]);
+ }
+ }
+
+ public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
+ IASTNode selectedNode = ast.selectNodeForLocation(ast.getFilePath(), start, length);
+
+ if (selectedNode == null)
+ return new IASTName[0];
+
+ if (selectedNode instanceof IASTName)
+ return new IASTName[] { (IASTName)selectedNode };
+
+ NameCollector collector = new NameCollector();
+ selectedNode.accept(collector);
+ return collector.getNames();
+ }
+
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
// Use the default CDT model builder
return null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
index ecbd6cfdef8..3f5ea80846a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOM;
+import org.eclipse.cdt.core.dom.IPDOMResolver;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
@@ -47,6 +49,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
+import org.eclipse.cdt.internal.core.pdom.PDOM;
+import org.eclipse.core.runtime.CoreException;
/**
* @author jcamelon
@@ -125,8 +129,18 @@ public class CASTTranslationUnit extends CASTNode implements
return resolver.getDeclarations( (IMacroBinding)binding );
}
IASTName[] names = CVisitor.getDeclarations(this, binding);
- if (names.length == 0 && pdom != null)
- names = pdom.getDeclarations(binding);
+
+ if (names.length == 0 && pdom != null) {
+ try {
+ binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
+ if (binding != null)
+ names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(binding);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return names;
+ }
+ }
+
return names;
}
@@ -135,15 +149,32 @@ public class CASTTranslationUnit extends CASTNode implements
*
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDefinitions(org.eclipse.cdt.core.dom.ast.IBinding)
*/
- public IASTName[] getDefinitions(IBinding aBinding) {
- IASTName[] foundDefs = getDeclarations(aBinding);
-
- for(int i=0; i
- * This interface declares constants only; it is not intended to be implemented.
- *
- * This class may be instantiated; it is not intended to be subclassed.
- *
- * This class may be instantiated; it is not intended to be subclassed.
- *
- * This interface is not intended to be implemented by clients.
- *
- * The action is applicable to selections containing elements of type
- *
- * This class may be instantiated; it is not intended to be subclassed.
- *
- *
- *
- * Calling
- *
- *
- *
- *
- * NOTE: This interface is not intended to be implemented or extended. Use Refactoring.getUndoManager()
- * to access the undo manager.
- *
- *
- *
- *
- * Note: API is under construction
- *
- * Note: API is under construction
- *
- * Assertion failure exceptions, like most runtime exceptions, are
- * thrown when something is misbehaving. Assertion failures are invariably
- * unspecified behavior; consequently, clients should never rely on
- * these being thrown (or not thrown). If you find yourself in the
- * position where you need to catch an assertion failure, you have most
- * certainly written your program incorrectly.
- *
- * Note that an
- * This class is not declared public to prevent some misuses; programs that catch
- * or otherwise depend on assertion failures are susceptible to unexpected
- * breakage when assertions in the code are added or removed.
- *
- * As a general rule, parameters passed to API methods must not be
- *
- * As a general rule, parameters passed to API methods must not be
- *
- * This class may be instantiated; it is not intended to be subclassed.
- * writeShort
method giving the number of bytes to
- * follow. This value is the number of bytes actually written out,
- * not the length of the string. Following the length, each character
- * of the string is output, in sequence, using the UTF-8 encoding
- * for the character.
- *
- * @param str a string to be written.
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public static void writeUTF(OutputStream out, char[] str) throws IOException {
- int strlen= str.length;
- int utflen= 0;
- for (int i= 0; i < strlen; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- utflen++;
- } else if (c > 0x07FF) {
- utflen += 3;
- } else {
- utflen += 2;
- }
- }
- if (utflen > 65535)
- throw new UTFDataFormatException();
- out.write((utflen >>> 8) & 0xFF);
- out.write((utflen >>> 0) & 0xFF);
- for (int i= 0; i < strlen; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- out.write(c);
- } else if (c > 0x07FF) {
- out.write(0xE0 | ((c >> 12) & 0x0F));
- out.write(0x80 | ((c >> 6) & 0x3F));
- out.write(0x80 | ((c >> 0) & 0x3F));
- } else {
- out.write(0xC0 | ((c >> 6) & 0x1F));
- out.write(0x80 | ((c >> 0) & 0x3F));
- }
- }
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/WordEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/WordEntry.java
deleted file mode 100644
index 5835217be24..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/WordEntry.java
+++ /dev/null
@@ -1,534 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage;
-
-import org.eclipse.cdt.internal.core.CharOperation;
-
-public class WordEntry {
-
- //Prefix used for index encoding as defined in ICIndexStorageConstants
- private int encodings;
- //Second part of encoding string as definined in ICIndexStorageConstants
- private int encodingType;
- //Used for type encodings only; defined in ICIndexStorageConstants
- private int typeConstant;
-
- //Fully qualified name for ref
- private char[] word;
-
- //Number of file references for this word entry
- private int fileRefCount;
- //File reference id's
- private int[] fileRefs;
-
- //Modifier bit fields - one for each fileRef
- private int[] modifiers;
-
- //Offset arrays - each fileRef's position in the fileRef array is the
- //key into the offsets
- //Offsets are prefixed with LINE or OFFSET designation
- private int[][] offsets;
- //Lengths of the offsets - all offsets will have an entry in here; OFFSET entries
- //will have the real offset value, LINE entires will have a place holder value of 1
- private int[][] offsetLengths;
-
- //Number of offsets in each offset array
- private int[] offsetCount;
-
- public WordEntry() {
- this(CharOperation.NO_CHAR);
- }
- public WordEntry(char[] word) {
- this.word= word;
- fileRefCount= 0;
- fileRefs= new int[1];
- modifiers= new int[1];
- offsets = new int [1][1];
- offsetLengths = new int[1][1];
- offsetCount = new int[1];
- }
- /**
- * Adds a reference and records the change in footprint.
- * @return returns the size increase for this instance
- */
- public int addRef(int fileNum) {
- //Ensure that this is a unique fileNum that hasn't been added
- //already to the refs
- if (fileRefCount > 0 && fileAlreadyAdded(fileNum)) {
- return 0;
- }
- //Ensure that there is still space to add this ref - if so,
- //add the reference
- if (fileRefCount < fileRefs.length) {
- fileRefs[fileRefCount++]= fileNum;
- return 0;
- }
- //Need to grow arrays - arrays will start at 1, grow to 4, 8, 16, 32, 64 etc.
- int newSize= fileRefCount < 4 ? 4 : fileRefCount * 2;
- //Grow the fileRefs array
- System.arraycopy(fileRefs, 0, fileRefs= new int[newSize], 0, fileRefCount);
- //Grow the modifier array
- System.arraycopy(modifiers, 0, modifiers= new int[newSize], 0, fileRefCount);
- //Grow the offset array
- System.arraycopy(offsets, 0, offsets= new int[newSize][1], 0, fileRefCount);
- //Grow the offsetLengths array
- System.arraycopy(offsetLengths, 0, offsetLengths=new int[newSize][1],0,fileRefCount);
- //Grow the offset count array
- System.arraycopy(offsetCount, 0, offsetCount= new int[newSize], 0, fileRefCount);
- //Add the new file reference
- fileRefs[fileRefCount++]= fileNum;
- return (newSize - fileRefCount + 1) * 4;
- }
- /**
- * Checks to see if this file number has already been added
- */
- private boolean fileAlreadyAdded(int fileNum) {
- for (int i=0; i
- * and mapping is [1 2 3 4 5]
- * in references 1 becomes mapping[1] = 2, 3->4, and 4->5
- * => references = [2 4 5].
- */
- public void mapRefs(int[] mappings) {
- int position= 0;
-
- for (int i= 0; i < fileRefCount; i++) {
- //Take care that the reference is actually within the bounds of the mapping
- int map= -1;
-
- if(fileRefs[i] >= 0 && fileRefs[i] < mappings.length)
- map= mappings[fileRefs[i]];
- if (map != -1 && map != 0)
- fileRefs[position++]= map;
- }
- fileRefCount= position;
-
- //Trim all arrays of excess flab
- System.arraycopy(fileRefs, 0, (fileRefs= new int[fileRefCount]), 0, fileRefCount);
- System.arraycopy(offsets, 0, (offsets = new int[fileRefCount][]), 0,fileRefCount);
- System.arraycopy(offsetLengths, 0, (offsetLengths = new int[fileRefCount][]), 0,fileRefCount);
- System.arraycopy(offsetCount, 0,(offsetCount=new int[fileRefCount]),0,fileRefCount);
- System.arraycopy(modifiers, 0, (modifiers=new int[fileRefCount]),0,fileRefCount);
-
- //Store original ref positions in order to generate map
- int[] originalRefs;
- System.arraycopy(fileRefs, 0, (originalRefs = new int[fileRefCount]),0,fileRefCount);
- //Sort file refs
- Util.sort(fileRefs);
-
- //Sort the original file refs
- int[] mapping = new int[fileRefs.length];
- figureOutMapping(originalRefs, fileRefs, mapping);
- mapOffsets(mapping);
- mapModiers(mapping);
- }
-
- /**
- * @param mapping
- */
- private void mapOffsets(int[] mapping) {
- int fileRefLength = fileRefs.length;
- int[][] tempOffsetsArray = new int[fileRefLength][];
- int[][] tempOffsetsLengthArray = new int[fileRefLength][];
- int[] tempOffsetCountArray = new int[fileRefLength];
-
- for (int i=0; i
- * - FileListBlocks;
- * - IndexBlocks;
- * - Summary of the index.
- */
-
-public class BlocksIndexOutput extends IndexOutput {
-
- protected RandomAccessFile indexOut;
- protected int blockNum;
- protected boolean opened= false;
- protected File indexFile;
-
- protected FileListBlock fileListBlock;
- protected IndexBlock indexBlock;
- protected IndexBlock includeIndexBlock;
-
- protected int numWords= 0;
- protected int numFiles= 0;
- protected int numIncludes= 0;
- protected IndexSummary summary;
-
- protected boolean firstInBlock;
- protected boolean firstIndexBlock;
- protected boolean firstFileListBlock;
- protected boolean firstIncludeIndexBlock;
-
- public BlocksIndexOutput(File indexFile) {
- this.indexFile= indexFile;
- summary= new IndexSummary();
- blockNum= 1;
- firstInBlock= true;
- firstIndexBlock= true;
- firstFileListBlock= true;
- firstIncludeIndexBlock=true;
- }
- /**
- * @see IndexOutput#addFile
- */
- public void addFile(IndexedFileEntry indexedFile) throws IOException {
- if (firstFileListBlock) {
- firstInBlock= true;
- fileListBlock= new FileListBlock(ICIndexStorageConstants.BLOCK_SIZE);
- firstFileListBlock= false;
- }
- if (fileListBlock.addFile(indexedFile)) {
- if (firstInBlock) {
- summary.addFirstFileInBlock(indexedFile, blockNum);
- firstInBlock= false;
- }
- numFiles++;
- } else {
- if (fileListBlock.isEmpty()) {
- return;
- }
- flushFiles();
- addFile(indexedFile);
- }
- }
- /**
- * @see IndexOutput#addWord
- */
- public void addWord(WordEntry entry) throws IOException {
- if (firstIndexBlock) {
- indexBlock= new GammaCompressedIndexBlock(ICIndexStorageConstants.BLOCK_SIZE);
- firstInBlock= true;
- firstIndexBlock= false;
- }
- if (entry.getNumRefs() == 0)
- return;
- if (indexBlock.addEntry(entry)) {
- if (firstInBlock) {
- summary.addFirstWordInBlock(entry.getWord(), blockNum);
- firstInBlock= false;
- }
- numWords++;
- } else {
- if (indexBlock.isEmpty()) {
- return;
- }
- flushWords();
- addWord(entry);
- }
- }
- /**
- * @see IndexOutput#addInclude
- */
- public void addInclude(IncludeEntry entry) throws IOException {
- if (firstIncludeIndexBlock) {
- includeIndexBlock= new GammaCompressedIndexBlock(ICIndexStorageConstants.BLOCK_SIZE);
- firstInBlock= true;
- firstIncludeIndexBlock= false;
- }
- if (entry.getNumRefs() == 0)
- return;
- if (includeIndexBlock.addIncludeEntry(entry)) {
- if (firstInBlock) {
- summary.addFirstIncludeInBlock(entry.getFile(), blockNum);
- firstInBlock= false;
- }
- numIncludes++;
- } else {
- if (includeIndexBlock.isEmpty()) {
- return;
- }
- flushIncludes();
- addInclude(entry);
- }
- }
- /**
- * @see IndexOutput#close
- */
- public void close() throws IOException {
- if (opened) {
- indexOut.close();
- summary= null;
- numFiles= 0;
- opened= false;
- }
- }
- /**
- * @see IndexOutput#flush
- */
- public void flush() throws IOException {
-
- summary.setNumFiles(numFiles);
- summary.setNumWords(numWords);
- summary.setNumIncludes(numIncludes);
- indexOut.seek(blockNum * (long) ICIndexStorageConstants.BLOCK_SIZE);
- summary.write(indexOut);
- indexOut.seek(0);
- indexOut.writeUTF(ICIndexStorageConstants.SIGNATURE);
- indexOut.writeInt(blockNum);
- }
- /**
- * Writes the current fileListBlock on the disk and initialises it
- * (when it's full or it's the end of the index).
- */
- protected void flushFiles() throws IOException {
- if (!firstFileListBlock
- && fileListBlock != null) {
- fileListBlock.flush();
- fileListBlock.write(indexOut, blockNum++);
- fileListBlock.clear();
- firstInBlock= true;
- }
- }
- /**
- * Writes the current indexBlock on the disk and initialises it
- * (when it's full or it's the end of the index).
- */
- protected void flushWords() throws IOException {
- if (!firstInBlock
- && indexBlock != null) { // could have added a document without any indexed word, no block created yet
- indexBlock.flush();
- indexBlock.write(indexOut, blockNum++);
- indexBlock.clear();
- firstInBlock= true;
- }
- }
- /**
- *
- */
- protected void flushIncludes() throws IOException {
- if (!firstInBlock
- && includeIndexBlock != null) { // could have added a document without any indexed word, no block created yet
- includeIndexBlock.flush();
- includeIndexBlock.write(indexOut, blockNum++);
- includeIndexBlock.clear();
- firstInBlock= true;
- }
-
- }
- /**
- * @see IndexOutput#getDestination
- */
- public Object getDestination() {
- return indexFile;
- }
- /**
- * @see IndexOutput#open
- */
- public void open() throws IOException {
- if (!opened) {
- summary= new IndexSummary();
- numFiles= 0;
- numWords= 0;
- numIncludes=0;
- blockNum= 1;
- firstInBlock= true;
- firstIndexBlock= true;
- firstFileListBlock= true;
- firstIncludeIndexBlock=true;
- indexOut= new SafeRandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$
- opened= true;
- }
- }
-}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/CodeByteStream.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/CodeByteStream.java
deleted file mode 100644
index 5b809a24102..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/CodeByteStream.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage.io;
-
-import java.io.UTFDataFormatException;
-
-public class CodeByteStream {
- protected byte[] bytes;
- protected int byteOffset= 0;
- protected int bitOffset= 0;
- protected int markByteOffset= -1;
- protected int markBitOffset= -1;
-
- public CodeByteStream() {
- this(16);
- }
- public CodeByteStream(byte[] bytes) {
- this.bytes= bytes;
- }
- public CodeByteStream(int initialByteLength) {
- bytes= new byte[initialByteLength];
- }
- public int byteLength() {
- return (bitOffset + 7) / 8 + byteOffset;
- }
- public byte[] getBytes(int startOffset, int endOffset) {
- int byteLength= byteLength();
- if (startOffset > byteLength || endOffset > byteLength || startOffset > endOffset)
- throw new IndexOutOfBoundsException();
- int length= endOffset - startOffset;
- byte[] result= new byte[length];
- System.arraycopy(bytes, startOffset, result, 0, length);
- if (endOffset == byteLength && bitOffset != 0) {
- int mask= (1 << bitOffset) - 1;
- result[length - 1] &= (mask << 8 - bitOffset);
- }
- return result;
- }
- protected void grow() {
- byte[] newBytes= new byte[bytes.length * 2 + 1];
- System.arraycopy(bytes, 0, newBytes, 0, bytes.length);
- bytes= newBytes;
- }
- public void mark() {
- markByteOffset= byteOffset;
- markBitOffset= bitOffset;
- }
- /**
- * Reads a single bit (value == 0 or == 1).
- */
- public int readBit() {
- int value= (bytes[byteOffset] >> (7 - bitOffset)) & 1;
- if (++bitOffset >= 8) {
- bitOffset= 0;
- ++byteOffset;
- }
- return value;
- }
- /**
- * Read up to 32 bits from the stream.
- */
- public int readBits(int numBits) {
- int value= 0;
- while (numBits > 0) {
- int bitsToRead= 8 - bitOffset;
- if (bitsToRead > numBits)
- bitsToRead= numBits;
- int mask= (1 << bitsToRead) - 1;
- value |= ((bytes[byteOffset] >> (8 - bitOffset - bitsToRead)) & mask) << (numBits - bitsToRead);
- numBits -= bitsToRead;
- bitOffset += bitsToRead;
- if (bitOffset >= 8) {
- bitOffset -= 8;
- byteOffset += 1;
- }
- }
- return value;
- }
- public final int readByte() {
-
- // no need to rebuild byte value from bit sequences
- if (bitOffset == 0) return bytes[byteOffset++] & 255;
-
- int value= 0;
- int numBits = 8;
- while (numBits > 0) {
- int bitsToRead= 8 - bitOffset;
- if (bitsToRead > numBits)
- bitsToRead= numBits;
- int mask= (1 << bitsToRead) - 1;
- value |= ((bytes[byteOffset] >> (8 - bitOffset - bitsToRead)) & mask) << (numBits - bitsToRead);
- numBits -= bitsToRead;
- bitOffset += bitsToRead;
- if (bitOffset >= 8) {
- bitOffset -= 8;
- byteOffset += 1;
- }
- }
- return value;
- }
- /**
- * Reads a value using Gamma coding.
- */
- public int readGamma() {
- int numBits= readUnary();
- return readBits(numBits - 1) | (1 << (numBits - 1));
- }
- public char[] readUTF() throws UTFDataFormatException {
- int utflen= readByte();
- if (utflen == 255) {
- // long UTF
- int high = readByte();
- int low = readByte();
- utflen = (high << 8) + low;
- }
- char str[]= new char[utflen];
- int count= 0;
- int strlen= 0;
- while (count < utflen) {
- int c= readByte();
- int char2, char3;
- switch (c >> 4) {
- case 0 :
- case 1 :
- case 2 :
- case 3 :
- case 4 :
- case 5 :
- case 6 :
- case 7 :
- // 0xxxxxxx
- count++;
- str[strlen++]= (char) c;
- break;
- case 12 :
- case 13 :
- // 110x xxxx 10xx xxxx
- count += 2;
- if (count > utflen)
- throw new UTFDataFormatException();
- char2= readByte();
- if ((char2 & 0xC0) != 0x80)
- throw new UTFDataFormatException();
- str[strlen++]= (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
- break;
- case 14 :
- // 1110 xxxx 10xx xxxx 10xx xxxx
- count += 3;
- if (count > utflen)
- throw new UTFDataFormatException();
- char2= readByte();
- char3= readByte();
- if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
- throw new UTFDataFormatException();
- str[strlen++]= (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
- break;
- default :
- // 10xx xxxx, 1111 xxxx
- throw new UTFDataFormatException();
- }
- }
- if (strlen < utflen)
- System.arraycopy(str, 0, str= new char[strlen], 0, strlen);
- return str;
- }
- /**
- * Reads a value in unary.
- */
- public int readUnary() {
- int value= 1;
- int mask= 1 << (7 - bitOffset);
- while ((bytes[byteOffset] & mask) != 0) {
- ++value;
- if (++bitOffset >= 8) {
- bitOffset= 0;
- ++byteOffset;
- mask= 0x80;
- } else {
- mask >>>= 1;
- }
- }
- // skip the 0 bit
- if (++bitOffset >= 8) {
- bitOffset= 0;
- ++byteOffset;
- }
- return value;
- }
- public void reset() {
- byteOffset= bitOffset= 0;
- markByteOffset= markBitOffset= -1;
- }
- public void reset(byte[] bytes) {
- this.bytes= bytes;
- reset();
- }
- public void reset(byte[] bytes, int byteOffset) {
- reset(bytes);
- this.byteOffset= byteOffset;
- }
- public boolean resetToMark() {
- if (markByteOffset == -1)
- return false;
- byteOffset= markByteOffset;
- bitOffset= markBitOffset;
- markByteOffset= markBitOffset= -1;
- return true;
- }
- public void skipBits(int numBits) {
- int newOffset= byteOffset * 8 + bitOffset + numBits;
- if (newOffset < 0 || (newOffset + 7) / 8 >= bytes.length)
- throw new IllegalArgumentException();
- byteOffset= newOffset / 8;
- bitOffset= newOffset % 8;
- }
- public byte[] toByteArray() {
- return getBytes(0, byteLength());
- }
- /**
- * Writes a single bit (value == 0 or == 1).
- */
- public void writeBit(int value) {
- bytes[byteOffset] |= (value & 1) << (7 - bitOffset);
- if (++bitOffset >= 8) {
- bitOffset= 0;
- if (++byteOffset >= bytes.length)
- grow();
- }
- }
- /**
- * Write up to 32 bits to the stream.
- * The least significant numBits bits of value are written.
- */
- public void writeBits(int value, int numBits) {
- while (numBits > 0) {
- int bitsToWrite= 8 - bitOffset;
- if (bitsToWrite > numBits)
- bitsToWrite= numBits;
- int shift= 8 - bitOffset - bitsToWrite;
- int mask= ((1 << bitsToWrite) - 1) << shift;
- bytes[byteOffset]= (byte) ((bytes[byteOffset] & ~mask) | (((value >>> (numBits - bitsToWrite)) << shift) & mask));
- numBits -= bitsToWrite;
- bitOffset += bitsToWrite;
- if (bitOffset >= 8) {
- bitOffset -= 8;
- if (++byteOffset >= bytes.length)
- grow();
- }
- }
- }
- public void writeByte(int value) {
- writeBits(value, 8);
- }
- /**
- * Writes the given value using Gamma coding, in which positive integer x
- * is represented by coding floor(log2(x) in unary followed by the value
- * of x - 2**floor(log2(x)) in binary.
- * The value must be >= 1.
- */
- public void writeGamma(int value) {
- if (value < 1)
- throw new IllegalArgumentException();
- int temp= value;
- int numBits= 0;
- while (temp != 0) {
- temp >>>= 1;
- ++numBits;
- }
- writeUnary(numBits);
- writeBits(value, numBits - 1);
- }
- public void writeUTF(char[] str, int start, int end) {
- int utflen= 0;
- for (int i= start; i < end; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- utflen++;
- } else if (c > 0x07FF) {
- utflen += 3;
- } else {
- utflen += 2;
- }
- }
- if (utflen < 255) {
- writeByte(utflen & 0xFF);
- } else if (utflen > 65535) {
- throw new IllegalArgumentException();
- } else {
- writeByte(255); // marker for long UTF
- writeByte((utflen >>> 8) & 0xFF); // high byte
- writeByte((utflen >>> 0) & 0xFF); // low byte
- }
- for (int i= start; i < end; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- writeByte(c);
- } else if (c > 0x07FF) {
- writeByte(0xE0 | ((c >> 12) & 0x0F));
- writeByte(0x80 | ((c >> 6) & 0x3F));
- writeByte(0x80 | ((c >> 0) & 0x3F));
- } else {
- writeByte(0xC0 | ((c >> 6) & 0x1F));
- writeByte(0x80 | ((c >> 0) & 0x3F));
- }
- }
- }
- /**
- * Write the given value in unary. The value must be >= 1.
- */
- public void writeUnary(int value) {
- if (value < 1)
- throw new IllegalArgumentException();
- int mask= 1 << (7 - bitOffset);
- // write N-1 1-bits
- while (--value > 0) {
- bytes[byteOffset] |= mask;
- if (++bitOffset >= 8) {
- bitOffset= 0;
- if (++byteOffset >= bytes.length)
- grow();
- mask= 0x80;
- } else {
- mask >>>= 1;
- }
- }
- // write a 0-bit
- bytes[byteOffset] &= ~mask;
- if (++bitOffset >= 8) {
- bitOffset= 0;
- if (++byteOffset >= bytes.length)
- grow();
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/Field.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/Field.java
deleted file mode 100644
index 02a679c7b20..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/Field.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage.io;
-
-import java.io.UTFDataFormatException;
-
-public class Field {
- protected byte[] buffer; // contents
- protected int offset; // offset of the field within the byte array
- protected int length; // length of the field
-
- /**
- * ByteSegment constructor comment.
- */
- public Field(byte[] bytes) {
- this.buffer= bytes;
- this.offset= 0;
- this.length= bytes.length;
- }
- /**
- * ByteSegment constructor comment.
- */
- public Field(byte[] bytes, int length) {
- this.buffer= bytes;
- this.offset= 0;
- this.length= length;
- }
- /**
- * ByteSegment constructor comment.
- */
- public Field(byte[] bytes, int offset, int length) {
- this.buffer= bytes;
- this.offset= offset;
- this.length= length;
- }
- /**
- * Creates a new field containing an empty buffer of the given length.
- */
- public Field(int length) {
- this.buffer= new byte[length];
- this.offset= 0;
- this.length= length;
- }
- public byte[] buffer() {
- return buffer;
- }
- public Field buffer(byte[] buffer) {
- this.buffer= buffer;
- return this;
- }
- public Field clear() {
- clear(buffer, offset, length);
- return this;
- }
- protected static void clear(byte[] buffer, int offset, int length) {
- int n= offset;
- for (int i= 0; i < length; i++) {
- buffer[n]= 0;
- n++;
- }
- }
- public Field clear(int length) {
- clear(buffer, offset, length);
- return this;
- }
- public Field clear(int offset, int length) {
- clear(buffer, this.offset + offset, length);
- return this;
- }
- protected static int compare(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2) {
- int n= Math.min(length1, length2);
- for (int i= 0; i < n; i++) {
- int j1= buffer1[offset1 + i] & 255;
- int j2= buffer2[offset2 + i] & 255;
- if (j1 > j2)
- return 1;
- if (j1 < j2)
- return -1;
- }
- if (length1 > n) {
- for (int i= n; i < length1; i++)
- if (buffer1[offset1 + i] != 0)
- return 1;
- return 0;
- }
- for (int i= n; i < length2; i++)
- if (buffer2[offset2 + i] != 0)
- return -1;
- return 0;
- }
- public static int compare(Field f1, Field f2) {
- return compare(f1.buffer, f1.offset, f1.length, f2.buffer, f2.offset, f2.length);
- }
- // copy bytes from one offset to another within the field
- public Field copy(int fromOffset, int toOffset, int length) {
- System.arraycopy(buffer, offset + fromOffset, buffer, offset + toOffset, length);
- return this;
- }
- public Field dec(int n) {
- offset -= n;
- return this;
- }
- public byte[] get() {
- byte[] result= new byte[length];
- System.arraycopy(buffer, offset, result, 0, length);
- return result;
- }
- public byte[] get(int offset, int length) {
- byte[] result= new byte[length];
- System.arraycopy(buffer, this.offset + offset, result, 0, length);
- return result;
- }
- public Field getField(int offset, int length) {
- return new Field(buffer, this.offset + offset, length);
- }
- public int getInt1() {
- return buffer[this.offset];
- }
- public int getInt1(int offset) {
- return buffer[this.offset + offset];
- }
- public int getInt2() {
- int i= this.offset;
- int v= buffer[i++];
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getInt2(int offset) {
- int i= this.offset + offset;
- int v= buffer[i++];
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getInt3() {
- int i= this.offset;
- int v= buffer[i++];
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getInt3(int offset) {
- int i= this.offset + offset;
- int v= buffer[i++];
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getInt4() {
- int i= this.offset;
- int v= buffer[i++];
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getInt4(int offset) {
- int i= this.offset + offset;
- int v= buffer[i++];
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getUInt1() {
- return buffer[this.offset] & 255;
- }
- public int getUInt1(int offset) {
- return buffer[this.offset + offset] & 255;
- }
- public int getUInt2() {
- int i= this.offset;
- int v= (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getUInt2(int offset) {
- int i= this.offset + offset;
- int v= (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getUInt3() {
- int i= this.offset;
- int v= (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public int getUInt3(int offset) {
- int i= this.offset + offset;
- int v= (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- v= (v << 8) | (buffer[i++] & 255);
- return v;
- }
- public char[] getUTF(int offset) throws UTFDataFormatException {
- int pos= this.offset + offset;
- int utflen= getUInt2(pos);
- pos += 2;
- char str[]= new char[utflen];
- int count= 0;
- int strlen= 0;
- while (count < utflen) {
- int c= buffer[pos++] & 0xFF;
- int char2, char3;
- switch (c >> 4) {
- case 0 :
- case 1 :
- case 2 :
- case 3 :
- case 4 :
- case 5 :
- case 6 :
- case 7 :
- // 0xxxxxxx
- count++;
- str[strlen++]= (char) c;
- break;
- case 12 :
- case 13 :
- // 110x xxxx 10xx xxxx
- count += 2;
- if (count > utflen)
- throw new UTFDataFormatException();
- char2= buffer[pos++] & 0xFF;
- if ((char2 & 0xC0) != 0x80)
- throw new UTFDataFormatException();
- str[strlen++]= (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
- break;
- case 14 :
- // 1110 xxxx 10xx xxxx 10xx xxxx
- count += 3;
- if (count > utflen)
- throw new UTFDataFormatException();
- char2= buffer[pos++] & 0xFF;
- char3= buffer[pos++] & 0xFF;
- if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
- throw new UTFDataFormatException();
- str[strlen++]= (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
- break;
- default :
- // 10xx xxxx, 1111 xxxx
- throw new UTFDataFormatException();
- }
- }
- if (strlen < utflen)
- System.arraycopy(str, 0, str= new char[strlen], 0, strlen);
- return str;
- }
- public Field inc(int n) {
- offset += n;
- return this;
- }
- public int length() {
- return length;
- }
- public Field length(int length) {
- this.length= length;
- return this;
- }
- /**
- Returns the offset into the underlying byte array that this field is defined over.
- */
- public int offset() {
- return offset;
- }
- public Field offset(int offset) {
- this.offset= offset;
- return this;
- }
- public Field pointTo(int offset) {
- return new Field(buffer, this.offset + offset, 0);
- }
- public Field put(byte[] b) {
- return put(0, b);
- }
- public Field put(int offset, byte[] b) {
- System.arraycopy(b, 0, buffer, this.offset + offset, b.length);
- return this;
- }
- public Field put(int offset, Field f) {
- System.arraycopy(f.buffer, f.offset, buffer, this.offset + offset, f.length);
- return this;
- }
- public Field put(Field f) {
- System.arraycopy(f.buffer, f.offset, buffer, offset, f.length);
- return this;
- }
- public Field putInt1(int n) {
- buffer[offset]= (byte) (n);
- return this;
- }
- public Field putInt1(int offset, int n) {
- buffer[this.offset + offset]= (byte) (n);
- return this;
- }
- public Field putInt2(int n) {
- int i= offset;
- buffer[i++]= (byte) (n >> 8);
- buffer[i++]= (byte) (n >> 0);
- return this;
- }
- public Field putInt2(int offset, int n) {
- int i= this.offset + offset;
- buffer[i++]= (byte) (n >> 8);
- buffer[i++]= (byte) (n >> 0);
- return this;
- }
- public Field putInt3(int n) {
- int i= offset;
- buffer[i++]= (byte) (n >> 16);
- buffer[i++]= (byte) (n >> 8);
- buffer[i++]= (byte) (n >> 0);
- return this;
- }
- public Field putInt3(int offset, int n) {
- int i= this.offset + offset;
- buffer[i++]= (byte) (n >> 16);
- buffer[i++]= (byte) (n >> 8);
- buffer[i++]= (byte) (n >> 0);
- return this;
- }
- public Field putInt4(int n) {
- int i= offset;
- buffer[i++]= (byte) (n >> 24);
- buffer[i++]= (byte) (n >> 16);
- buffer[i++]= (byte) (n >> 8);
- buffer[i++]= (byte) (n >> 0);
- return this;
- }
- public Field putInt4(int offset, int n) {
- int i= this.offset + offset;
- buffer[i++]= (byte) (n >> 24);
- buffer[i++]= (byte) (n >> 16);
- buffer[i++]= (byte) (n >> 8);
- buffer[i++]= (byte) (n >> 0);
- return this;
- }
- public int putUTF(int offset, char[] str) {
- int strlen= str.length;
- int utflen= 0;
- for (int i= 0; i < strlen; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- utflen++;
- } else if (c > 0x07FF) {
- utflen += 3;
- } else {
- utflen += 2;
- }
- }
- if (utflen > 65535)
- throw new IllegalArgumentException();
- int pos= this.offset + offset;
- buffer[pos++]= (byte) ((utflen >>> 8) & 0xFF);
- buffer[pos++]= (byte) ((utflen >>> 0) & 0xFF);
- for (int i= 0; i < strlen; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- buffer[pos++]= ((byte) c);
- } else if (c > 0x07FF) {
- buffer[pos++]= ((byte) (0xE0 | ((c >> 12) & 0x0F)));
- buffer[pos++]= ((byte) (0x80 | ((c >> 6) & 0x3F)));
- buffer[pos++]= ((byte) (0x80 | ((c >> 0) & 0x3F)));
- } else {
- buffer[pos++]= ((byte) (0xC0 | ((c >> 6) & 0x1F)));
- buffer[pos++]= ((byte) (0x80 | ((c >> 0) & 0x3F)));
- }
- }
- return 2 + utflen;
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/FileListBlock.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/FileListBlock.java
deleted file mode 100644
index 8c63b5a4b10..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/FileListBlock.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage.io;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.Util;
-
-public class FileListBlock extends Block {
-
- protected int offset= 0;
- protected String prevPath= null;
- protected String[] paths= null;
-
- public FileListBlock(int blockSize) {
- super(blockSize);
- }
- /**
- * add the name of the indexedfile to the buffr of the field.
- * The name is not the entire name of the indexedfile, but the
- * difference between its name and the name of the previous indexedfile ...
- */
- public boolean addFile(IndexedFileEntry indexedFile) {
- int offset= this.offset;
- if (isEmpty()) {
- field.putInt4(offset, indexedFile.getFileID());
- offset += 4;
- }
- String path= indexedFile.getPath();
- int prefixLen= prevPath == null ? 0 : Util.prefixLength(prevPath, path);
- int sizeEstimate= 2 + 2 + (path.length() - prefixLen) * 3;
- if (offset + sizeEstimate > blockSize - 2)
- return false;
- field.putInt2(offset, prefixLen);
- offset += 2;
- char[] chars= new char[path.length() - prefixLen];
- path.getChars(prefixLen, path.length(), chars, 0);
- offset += field.putUTF(offset, chars);
- this.offset= offset;
- prevPath= path;
- return true;
- }
- public void clear() {
- reset();
- super.clear();
- }
- public void flush() {
- if (offset > 0) {
- field.putInt2(offset, 0);
- field.putInt2(offset + 2, 0);
- offset= 0;
- }
- }
- public IndexedFileEntry getFile(int fileNum) throws IOException {
- IndexedFileEntry resp= null;
- try {
- String[] paths= getPaths();
- int i= fileNum - field.getInt4(0);
- if(i >= paths.length) { //fileNum was too large
- return null;
- }
- resp= new IndexedFileEntry(paths[i], fileNum);
- } catch (Exception e) {
- //Cover ourselves in case something happens getting the indexed file
- }
- return resp;
- }
- /**
- * Creates a vector of paths reading the buffer of the field.
- */
- protected String[] getPaths() throws IOException {
- if (paths == null) {
- ArrayList v= new ArrayList();
- int offset= 4;
- char[] prevPath= null;
- for (;;) {
- int prefixLen= field.getUInt2(offset);
- offset += 2;
- int utfLen= field.getUInt2(offset);
- char[] path= field.getUTF(offset);
- offset += 2 + utfLen;
- if (prefixLen != 0) {
- char[] temp= new char[prefixLen + path.length];
- System.arraycopy(prevPath, 0, temp, 0, prefixLen);
- System.arraycopy(path, 0, temp, prefixLen, path.length);
- path= temp;
- }
- if (path.length == 0)
- break;
- v.add(new String(path));
- prevPath= path;
- }
- paths= new String[v.size()];
- v.toArray(paths);
- }
- return paths;
- }
- public boolean isEmpty() {
- return offset == 0;
- }
- public void reset() {
- offset= 0;
- prevPath= null;
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/GammaCompressedIndexBlock.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/GammaCompressedIndexBlock.java
deleted file mode 100644
index 0adfe0855b0..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/GammaCompressedIndexBlock.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage.io;
-
-import java.io.UTFDataFormatException;
-
-import org.eclipse.cdt.internal.core.index.cindexstorage.IncludeEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.Util;
-import org.eclipse.cdt.internal.core.index.cindexstorage.WordEntry;
-
-/**
- * Uses prefix coding on words, and gamma coding of document numbers differences.
- */
-public class GammaCompressedIndexBlock extends IndexBlock {
- CodeByteStream writeCodeStream= new CodeByteStream();
- CodeByteStream readCodeStream;
- char[] prevWord= null;
- int offset= 0;
-
- public GammaCompressedIndexBlock(int blockSize) {
- super(blockSize);
- readCodeStream= new CodeByteStream(field.buffer());
- }
- /**
- * @see IndexBlock#addEntry
- */
- public boolean addEntry(WordEntry entry) {
- writeCodeStream.reset();
- encodeEntry(entry, prevWord, writeCodeStream);
- if (offset + writeCodeStream.byteLength() > this.blockSize - 2) {
- return false;
- }
- byte[] bytes= writeCodeStream.toByteArray();
- field.put(offset, bytes);
- offset += bytes.length;
- prevWord= entry.getWord();
- return true;
- }
- protected void encodeEntry(WordEntry entry, char[] prevWord, CodeByteStream codeStream) {
- char[] word= entry.getWord();
- int prefixLen= prevWord == null ? 0 : Util.prefixLength(prevWord, word);
- codeStream.writeByte(prefixLen);
- codeStream.writeUTF(word, prefixLen, word.length);
- int n= entry.getNumRefs();
- codeStream.writeGamma(n);
- //encode file references
- int prevRef= 0;
- for (int i= 0; i < n; ++i) {
- int ref= entry.getRef(i);
- if (ref <= prevRef)
- throw new IllegalArgumentException();
- codeStream.writeGamma(ref - prevRef);
- prevRef= ref;
- }
- //encode offsets
- //same number of offsets arrays as file references
- for (int i=0; i
- * - The files are sorted in alphabetical order;
- * - if a file is in oldIndex and addsIndex, the one which is added
- * is the one in the addsIndex.
- */
-public class MergeFactory {
- /**
- * Input on the addsIndex.
- */
- protected IndexInput addsInput;
- /**
- * Input on the oldIndex.
- */
- protected IndexInput oldInput;
- /**
- * Output to write the result of the merge in.
- */
- protected BlocksIndexOutput mergeOutput;
- /**
- * Files removed from oldIndex.
- */
- protected Map removedInOld;
- /**
- * Files removed from addsIndex.
- */
- protected Map removedInAdds;
- protected int[] mappingOld;
- protected int[] mappingAdds;
- public static final int ADDS_INDEX= 0;
- public static final int OLD_INDEX= 1;
- /**
- * MergeFactory constructor comment.
- * @param directory java.io.File
- */
- public MergeFactory(IndexInput oldIndexInput, IndexInput addsIndexInput, BlocksIndexOutput mergeIndexOutput, Map removedInOld, Map removedInAdds) {
- oldInput= oldIndexInput;
- addsInput= addsIndexInput;
- mergeOutput= mergeIndexOutput;
- this.removedInOld= removedInOld;
- this.removedInAdds= removedInAdds;
- }
- /**
- * Initialise the merge.
- */
- protected void init() {
- mappingOld= new int[oldInput.getNumFiles() + 1];
- mappingAdds= new int[addsInput.getNumFiles() + 1];
-
- }
- /**
- * Merges the 2 indexes into a new one on the disk.
- */
- public void merge() throws IOException {
- long startTime = 0;
- if (IndexManager.VERBOSE){
- JobManager.verbose("-> starting merge"); //$NON-NLS-1$
- startTime = System.currentTimeMillis();
- }
- try {
- //init
- addsInput.open();
- oldInput.open();
- mergeOutput.open();
- init();
- //merge
- //findChanges();
- mergeFiles();
- mergeReferences();
- mergeIncludes();
- mergeOutput.flush();
- }
- catch ( Exception ex ){
- if (ex instanceof IOException)
- throw (IOException) ex;
- else {
- if (IndexManager.VERBOSE) {
- JobManager.verbose("-> got the following exception during merge:"); //$NON-NLS-1$
- ex.printStackTrace();
- }
- }
- }
- catch ( VirtualMachineError er ) {
- if (IndexManager.VERBOSE) {
- JobManager.verbose("-> got the following exception during merge:"); //$NON-NLS-1$
- er.printStackTrace();
- }
- }
- finally {
- //closes everything
- oldInput.close();
- addsInput.close();
- mergeOutput.close();
-
- if (IndexManager.VERBOSE){
- long elapsedTime = System.currentTimeMillis() - startTime;
- JobManager.verbose("-> merge complete: " + (elapsedTime > 0 ? elapsedTime : 0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- /**
- * Merges the files of the 2 indexes in the new index, removes the files
- * to be removed, and records the changes made to propagate them to the
- * word references.
- */
-
- protected void mergeFiles() throws IOException {
- int positionInMerge= 1;
- int compare;
-
- while (oldInput.hasMoreFiles() || addsInput.hasMoreFiles()) {
- IndexedFileEntry file1= oldInput.getCurrentFile();
- IndexedFileEntry file2= addsInput.getCurrentFile();
-
- //if the file has been removed we don't take it into account
- while (file1 != null && wasRemoved(file1, OLD_INDEX)) {
- oldInput.moveToNextFile();
- file1= oldInput.getCurrentFile();
- }
- while (file2 != null && wasRemoved(file2, ADDS_INDEX)) {
- addsInput.moveToNextFile();
- file2= addsInput.getCurrentFile();
- }
-
- //the addsIndex was empty, we just removed files from the oldIndex
- if (file1 == null && file2 == null)
- break;
-
- //test if we reached the end of one the 2 index
- if (file1 == null)
- compare= 1;
- else if (file2 == null)
- compare= -1;
- else
- compare= file1.getPath().compareTo(file2.getPath());
-
- //records the changes to Make
- if (compare == 0) {
- //the file has been modified:
- //we remove it from the oldIndex and add it to the addsIndex
- removeFile(file1, OLD_INDEX);
- mappingAdds[file2.getFileID()]= positionInMerge;
- file1.setFileNumber(positionInMerge);
- mergeOutput.addFile(file1);
- oldInput.moveToNextFile();
- addsInput.moveToNextFile();
- } else if (compare < 0) {
- mappingOld[file1.getFileID()]= positionInMerge;
- file1.setFileNumber(positionInMerge);
- mergeOutput.addFile(file1);
- oldInput.moveToNextFile();
- } else {
- mappingAdds[file2.getFileID()]= positionInMerge;
- file2.setFileNumber(positionInMerge);
- mergeOutput.addFile(file2);
- addsInput.moveToNextFile();
- }
- positionInMerge++;
- }
- mergeOutput.flushFiles();
- }
- /**
- * Merges the files of the 2 indexes in the new index, according to the changes
- * recorded during mergeFiles().
- */
- protected void mergeReferences() throws IOException {
- int compare;
- while (oldInput.hasMoreWords() || addsInput.hasMoreWords()) {
- WordEntry word1= oldInput.getCurrentWordEntry();
- WordEntry word2= addsInput.getCurrentWordEntry();
-
- if (word1 == null && word2 == null)
- break;
-
- if (word1 == null)
- compare= 1;
- else if (word2 == null)
- compare= -1;
- else
- compare= Util.compare(word1.getWord(), word2.getWord());
- if (compare < 0) {
- word1.mapRefs(mappingOld);
- mergeOutput.addWord(word1);
- oldInput.moveToNextWordEntry();
- } else if (compare > 0) {
- word2.mapRefs(mappingAdds);
- mergeOutput.addWord(word2);
- addsInput.moveToNextWordEntry();
- } else {
- word1.mapRefs(mappingOld);
- word2.mapRefs(mappingAdds);
- word1.addWordInfo(word2.getRefs(), word2.getOffsets(),word2.getOffsetLengths(), word2.getOffsetCount(), word2.getModifiers());
- mergeOutput.addWord(word1);
- addsInput.moveToNextWordEntry();
- oldInput.moveToNextWordEntry();
- }
- }
- mergeOutput.flushWords();
- }
- /**
- * Merges the files of the 2 indexes in the new index, according to the changes
- * recorded during mergeFiles().
- */
- protected void mergeIncludes() throws IOException {
- int compare;
-
- while (oldInput.hasMoreIncludes() || addsInput.hasMoreIncludes()) {
- IncludeEntry inc1= oldInput.getCurrentIncludeEntry();
- IncludeEntry inc2= addsInput.getCurrentIncludeEntry();
-
- if (inc1 == null && inc2 == null)
- break;
-
- if (inc1 == null)
- compare= 1;
- else if (inc2 == null)
- compare= -1;
- else
- compare= Util.compare(inc1.getFile(), inc2.getFile());
- if (compare < 0) {
- inc1.mapRefs(mappingOld);
- mergeOutput.addInclude(inc1);
- oldInput.moveToNextIncludeEntry();
- } else if (compare > 0) {
- inc2.mapRefs(mappingAdds);
- mergeOutput.addInclude(inc2);
- addsInput.moveToNextIncludeEntry();
- } else {
- inc1.mapRefs(mappingOld);
- inc2.mapRefs(mappingAdds);
- inc1.addRefs(inc2.getRefs());
- mergeOutput.addInclude(inc1);
- addsInput.moveToNextIncludeEntry();
- oldInput.moveToNextIncludeEntry();
- }
- }
- mergeOutput.flushIncludes();
- }
- /**
- * Records the deletion of one file.
- */
- protected void removeFile(IndexedFileEntry file, int index) {
- if (index == OLD_INDEX)
- mappingOld[file.getFileID()]= -1;
- else
- mappingAdds[file.getFileID()]= -1;
- }
- /**
- * Returns whether the given file has to be removed from the given index
- * (ADDS_INDEX or OLD_INDEX). If it has to be removed, the mergeFactory
- * deletes it and records the changes.
- */
-
- protected boolean wasRemoved(IndexedFileEntry indexedFile, int index) {
- String path= indexedFile.getPath();
- if (index == OLD_INDEX) {
- if (removedInOld.remove(path) != null) {
- mappingOld[indexedFile.getFileID()]= -1;
- return true;
- }
- } else if (index == ADDS_INDEX) {
- Int lastRemoved= (Int) removedInAdds.get(path);
- if (lastRemoved != null) {
- int fileNum= indexedFile.getFileID();
- if (lastRemoved.value >= fileNum) {
- mappingAdds[fileNum]= -1;
- //if (lastRemoved.value == fileNum) // ONLY if files in sorted order for names AND fileNums
- //removedInAdds.remove(path);
- return true;
- }
- }
- }
- return false;
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/SafeRandomAccessFile.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/SafeRandomAccessFile.java
deleted file mode 100644
index e857a524ff6..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/SafeRandomAccessFile.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage.io;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-/**
- * A safe subclass of RandomAccessFile, which ensure that it's closed
- * on finalize.
- */
-public class SafeRandomAccessFile extends RandomAccessFile {
- public SafeRandomAccessFile(java.io.File file, String mode) throws java.io.IOException {
- super(file, mode);
- }
- public SafeRandomAccessFile(String name, String mode) throws java.io.IOException {
- super(name, mode);
- }
- protected void finalize() throws IOException {
- close();
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/SimpleIndexInput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/SimpleIndexInput.java
deleted file mode 100644
index 672ab839c50..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/io/SimpleIndexInput.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.cindexstorage.io;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.eclipse.cdt.internal.core.index.IEntryResult;
-import org.eclipse.cdt.internal.core.index.IQueryResult;
-import org.eclipse.cdt.internal.core.index.cindexstorage.InMemoryIndex;
-import org.eclipse.cdt.internal.core.index.cindexstorage.IncludeEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.WordEntry;
-
-/**
- * A simpleIndexInput is an input on an in memory Index.
- */
-
-public class SimpleIndexInput extends IndexInput {
- protected WordEntry[] sortedWordEntries;
- protected IncludeEntry[] sortedIncludes;
- protected IndexedFileEntry currentFile;
- protected IndexedFileEntry[] sortedFiles;
- protected InMemoryIndex index;
-
- public SimpleIndexInput(InMemoryIndex index) {
- super();
- this.index= index;
- }
- /**
- * @see IndexInput#clearCache()
- */
- public void clearCache() {
- }
- /**
- * @see IndexInput#close()
- */
- public void close() throws IOException {
- sortedFiles= null;
- }
- /**
- * @see IndexInput#getCurrentFile()
- */
- public IndexedFileEntry getCurrentFile() throws IOException {
- if (!hasMoreFiles())
- return null;
- return currentFile;
- }
- /**
- * @see IndexInput#getIndexedFile(int)
- */
- public IndexedFileEntry getIndexedFile(int fileNum) throws IOException {
- for (int i= 0; i < sortedFiles.length; i++)
- if (sortedFiles[i].getFileID() == fileNum)
- return sortedFiles[i];
- return null;
- }
- /**
- * @see IndexInput#getIndexedFile(String)
- */
- public IndexedFileEntry getIndexedFile(String fullPath) throws IOException {
- for (int i= index.getNumFiles(); i >= 1; i--) {
- IndexedFileEntry file= getIndexedFile(i);
- if (fullPath.equals(file.getPath()))
- return file;
- }
- return null;
- }
- /**
- * @see IndexInput#getNumFiles()
- */
- public int getNumFiles() {
- return index.getNumFiles();
- }
- /**
- * @see IndexInput#getNumIncludes()
- */
- public int getNumIncludes() {
- return sortedIncludes.length;
- }
- /**
- * @see IndexInput#getNumWords()
- */
- public int getNumWords() {
- return sortedWordEntries.length;
- }
- /**
- * @see IndexInput#getSource()
- */
- public Object getSource() {
- return index;
- }
- public void init() {
- index.init();
-
- }
- /**
- * @see IndexInput#moveToNextFile()
- */
- public void moveToNextFile() throws IOException {
- filePosition++;
- if (!hasMoreFiles()) {
- return;
- }
- currentFile= sortedFiles[filePosition - 1];
- }
- /**
- * @see IndexInput#moveToNextWordEntry()
- */
- public void moveToNextWordEntry() throws IOException {
- wordPosition++;
- if (hasMoreWords())
- currentWordEntry= sortedWordEntries[wordPosition - 1];
- }
- /**
- * @see IndexInput#moveToNextIncludeEntry()
- */
- public void moveToNextIncludeEntry() throws IOException {
- includePosition++;
- if (hasMoreIncludes())
- currentIncludeEntry= sortedIncludes[includePosition - 1];
- }
- /**
- * @see IndexInput#open()
- */
- public void open() throws IOException {
- sortedWordEntries= index.getSortedWordEntries();
- sortedFiles= index.getSortedFiles();
- sortedIncludes = index.getSortedIncludeEntries();
- filePosition= 1;
- wordPosition= 1;
- includePosition=1;
- setFirstFile();
- setFirstWord();
- setFirstInclude();
- }
- /**
- * @see IndexInput#query(String)
- */
- public IQueryResult[] query(String word) throws IOException {
- char[] wordChar= word.toCharArray();
- WordEntry wordEntry= index.getWordEntry(wordChar);
- int[] fileNums= wordEntry.getRefs();
- IQueryResult[] files= new IQueryResult[fileNums.length];
- for (int i= 0; i < files.length; i++)
- files[i]= getIndexedFile(fileNums[i]);
- return files;
- }
- public IEntryResult[] queryEntriesPrefixedBy(char[] prefix) throws IOException {
- return null;
- }
- public IQueryResult[] queryFilesReferringToPrefix(char[] prefix) throws IOException {
- return null;
- }
- /**
- * @see IndexInput#queryInDocumentNames(String)
- */
- public IQueryResult[] queryInDocumentNames(String word) throws IOException {
- setFirstFile();
- ArrayList matches= new ArrayList();
- while (hasMoreFiles()) {
- IndexedFileEntry file= getCurrentFile();
- if (file.getPath().indexOf(word) != -1)
- matches.add(file.getPath());
- moveToNextFile();
- }
- IQueryResult[] match= new IQueryResult[matches.size()];
- matches.toArray(match);
- return match;
- }
- /**
- * @see IndexInput#setFirstFile()
- */
- protected void setFirstFile() throws IOException {
- filePosition= 1;
- if (sortedFiles.length > 0) {
- currentFile= sortedFiles[0];
- }
- }
- /**
- * @see IndexInput#setFirstWord()
- */
- protected void setFirstWord() throws IOException {
- wordPosition= 1;
- if (sortedWordEntries.length > 0)
- currentWordEntry= sortedWordEntries[0];
- }
- /**
- * @see IndexInput#setFirstInclude()
- */
- protected void setFirstInclude() throws IOException {
- includePosition=1;
- if (sortedIncludes.length >0)
- currentIncludeEntry=sortedIncludes[0];
- }
- public IncludeEntry[] queryIncludeEntries() {
- return null;
- }
- public IncludeEntry[] queryIncludeEntries(int fileNum) throws IOException {
- return null;
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java
deleted file mode 100644
index a099ab25f85..00000000000
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.index.ctagsindexer;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.StringTokenizer;
-
-import org.eclipse.cdt.internal.core.index.FunctionEntry;
-import org.eclipse.cdt.internal.core.index.IIndex;
-import org.eclipse.cdt.internal.core.index.IIndexerOutput;
-import org.eclipse.cdt.internal.core.index.INamedEntry;
-import org.eclipse.cdt.internal.core.index.NamedEntry;
-import org.eclipse.cdt.internal.core.index.TypeEntry;
-import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
-import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
-
-
-class CTagEntry{
- private final CTagsConsoleParser parser;
- String elementName;
- String fileName;
- int lineNumber;
-
- /* Miscellaneous extension fields */
- HashMap tagExtensionField;
-
- String line;
-
- public CTagEntry(CTagsConsoleParser parser, String line) {
- this.line = line;
- this.parser = parser;
- elementName = ""; //$NON-NLS-1$
- fileName =""; //$NON-NLS-1$
- lineNumber = 0;
- tagExtensionField = new HashMap();
- parse();
- }
-
- void parse () {
- String delim = CTagsConsoleParser.TAB_SEPARATOR;
- StringTokenizer st = new StringTokenizer(line, delim);
- for (int state = 0; st.hasMoreTokens(); state++) {
- String token = st.nextToken();
-
- switch (state) {
- case 0: // ELEMENT_NAME:
- elementName = token;
- break;
-
- case 1: // FILE_NAME:
- fileName = token;
- break;
-
- case 2: // LINE NUMBER;
- try {
- String sub = token.trim();
- int i = sub.indexOf(';');
- String num = sub.substring(0, i);
- if (Character.isDigit(num.charAt(0))) {
- lineNumber = Integer.parseInt(num);
- }
- } catch (NumberFormatException e) {
- } catch (IndexOutOfBoundsException e) {
- }
- break;
-
- default: // EXTENSION_FIELDS:
- int i = token.indexOf(':');
- if (i != -1) {
- String key = token.substring(0, i);
- String value = token.substring(i + 1);
- tagExtensionField.put(key, value);
- }
- break;
- }
- }
- }
-
- /**
- * @param tempTag
- * @return
- */
- public char[][] getQualifiedName() {
- char[][] fullName = null;
- String name = null;
- String[] types = {CTagsConsoleParser.NAMESPACE, CTagsConsoleParser.CLASS, CTagsConsoleParser.STRUCT, CTagsConsoleParser.UNION, CTagsConsoleParser.FUNCTION, CTagsConsoleParser.ENUM};
-
- for (int i=0; i
- * synchronized(monitor) {
- * monitor.exitWrite();
- * monitor.enterRead();
- * }
- *
- */
- public synchronized void exitWriteEnterRead() {
- this.exitWrite();
- this.enterRead();
- }
-}
-
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
index 2ac6a848c40..1b2e6c6a274 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
@@ -31,7 +31,6 @@ import org.eclipse.cdt.internal.core.model.OutputEntry;
import org.eclipse.cdt.internal.core.model.PathEntryManager;
import org.eclipse.cdt.internal.core.model.ProjectEntry;
import org.eclipse.cdt.internal.core.model.SourceEntry;
-import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -1215,14 +1214,6 @@ public class CoreModel {
}
}
- public void startIndexing() {
- manager.getIndexManager().reset();
- }
-
- public IndexManager getIndexManager() {
- return manager.getIndexManager();
- }
-
/**
* The method returns whether scanner information for a resource is empty or not.
* org.eclipse.core.runtime.OperationCanceledException
- * if the underlying indexer has not finished indexing the workspace.
- */
- int CANCEL_IF_NOT_READY_TO_SEARCH = IIndexJob.CancelIfNotReady;
- /**
- * The search operation waits for the underlying indexer to finish indexing
- * the workspace before starting the search.
- */
- int WAIT_UNTIL_READY_TO_SEARCH = IIndexJob.WaitUntilReady;
-
- public static final String EXTERNAL_SEARCH_LINK_PREFIX = "cdtlnk"; //$NON-NLS-1$
-}
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchPattern.java
deleted file mode 100644
index 7fe4c1f3b73..00000000000
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchPattern.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-/*
- * Created on Jun 13, 2003
- */
-package org.eclipse.cdt.core.search;
-
-import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public interface ICSearchPattern extends ICSearchConstants{
-
- public static final int IMPOSSIBLE_MATCH = 0;
- public static final int POSSIBLE_MATCH = 1;
- public static final int ACCURATE_MATCH = 2;
- public static final int INACCURATE_MATCH = 3;
-
- /**
- * @param node
- * @return
- */
- int matchLevel( ISourceElementCallbackDelegate node, LimitTo limit );
-
- LimitTo getLimitTo();
- boolean canAccept( LimitTo limit );
-}
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java
deleted file mode 100644
index a88c65a4d1c..00000000000
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchResultCollector.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-/*
- * Created on Jun 11, 2003
- */
-package org.eclipse.cdt.core.search;
-
-import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public interface ICSearchResultCollector {
- /**
- * The search result corresponds exactly to the search pattern.
- */
- int EXACT_MATCH = 0;
-
- /**
- * The search result is potentially a match for the search pattern,
- * but a problem prevented the search engine from being more accurate
- * (typically because of the classpath was not correctly set).
- */
- int POTENTIAL_MATCH = 1;
-
- /**
- * Called before the actual search starts.
- */
- public void aboutToStart();
-
- /**
- * Called when the search has ended.
- */
- public void done();
-
- public IMatch createMatch( Object fileResource, int start, int end,
- ISourceElementCallbackDelegate node, IPath referringElement) throws CoreException;
-
- //return whether or not the match was accepted
- public boolean acceptMatch( IMatch match ) throws CoreException;
-
- /**
- * Returns the progress monitor used to report progress.
- *
- * @return a progress monitor or null if no progress monitor is provided
- */
- public IProgressMonitor getProgressMonitor();
-}
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchScope.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchScope.java
deleted file mode 100644
index 9f3e3d1d381..00000000000
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/ICSearchScope.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-/*
- * Created on Jun 12, 2003
- */
-package org.eclipse.cdt.core.search;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.core.runtime.IPath;
-
-public interface ICSearchScope {
- /**
- * Checks whether the resource at the given path is enclosed by this scope.
- *
- * @param resourcePath if the resource is contained in
- * @return whether the resource is enclosed by this scope
- */
- public boolean encloses(String resourcePath);
- /**
- * Checks whether this scope encloses the given element.
- *
- * @param element the given element
- * @return true
if the element is in this scope
- */
- public boolean encloses(ICElement element);
- /**
- * Returns the paths to the enclosing projects for this search scope.
- *
- *
IResource.getFullPath()
).
- * For example, /MyProject
- * null
- * otherwise.
- */
- protected Label createLabel(Composite parent, String name) {
- if (name == null)
- return null;
- Label label = new Label(parent, SWT.NONE);
- label.setText(name);
- label.setFont(parent.getFont());
- return label;
- }
-
- /**
- * Creates a type filter checkbox.
- */
- private void createTypeCheckbox(Composite parent, int type) {
- String name = getStringDescription(type);
- Image icon = IndexerViewPluginImages.get(type);
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginHeight = 0;
- composite.setLayout(layout);
-
- final int type1 = type;
- Button checkbox = new Button(composite, SWT.CHECK);
- checkbox.setFont(composite.getFont());
- checkbox.setText(name);
- checkbox.setImage(icon);
- checkbox.setSelection(fFilterMatcher[type]);
- checkbox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget instanceof Button) {
- Button aCheckbox = (Button) e.widget;
- fFilterMatcher[type1] = aCheckbox.getSelection();
- }
- }
- });
-
- Label label = new Label(composite, SWT.LEFT);
- label.setFont(composite.getFont());
- label.setText(name);
-
- buttons[type] = checkbox;
- }
-
-
- /**
- * Creates an area to filter types.
- *
- * @param parent
- * area to create controls in
- */
- private void createTypeFilterArea(Composite parent) {
- createLabel(parent,TYPESELECTIONDIALOG_DeclLABEL);
-
- Composite upperRow = new Composite(parent, SWT.NONE);
- GridLayout upperLayout = new GridLayout(3, true);
- upperLayout.verticalSpacing = 2;
- upperLayout.marginHeight = 0;
- upperLayout.marginWidth = 0;
- upperRow.setLayout(upperLayout);
-
- // the for loop is here to guarantee we always
- // create the checkboxes in the same order
- for (int i = 0; i < iAllTypes.length; ++i) {
- if(iAllTypes[i][2] == IIndex.DECLARATION)
- createTypeCheckbox(upperRow, i);
- }
-
- createLabel(parent,TYPESELECTIONDIALOG_RefLABEL);
-
- Composite lowerRow = new Composite(parent, SWT.NONE);
- lowerRow.setLayout(upperLayout);
-
- // the for loop is here to guarantee we always
- // create the checkboxes in the same order
- for (int i = 0; i < iAllTypes.length; ++i) {
- if(iAllTypes[i][2] == IIndex.REFERENCE)
- createTypeCheckbox(lowerRow, i);
- }
- }
-
- private void createGroupedArea(Composite parent) {
- createLabel(parent, GROUPED_SELECTIONS_LABEL);
-
- Composite upperRow = new Composite(parent, SWT.NONE);
- GridLayout upperLayout = new GridLayout(8, true);
- upperLayout.verticalSpacing = 2;
- upperLayout.marginHeight = 0;
- upperLayout.marginWidth = 0;
- upperRow.setLayout(upperLayout);
-
- allButton = new Button(upperRow, SWT.CHECK);
- allButton.setFont(upperRow.getFont());
- allButton.setText(ALL_BUTTON);
- allButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_ALL));
- allButton.setSelection(groupedButtonSelections[ALL_BUTTON_ID]);
- allButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget instanceof Button) {
- Button aCheckbox = (Button) e.widget;
- boolean isChecked = aCheckbox.getSelection();
-
- Event event = new Event();
-
- // select/deselect all of the buttons in the buttons array
- for(int i=0; iIShowInSource
for this view.
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(
- null,
- getSite().getSelectionProvider().getSelection());
- }
- };
- }
-
-// protected DecoratingLabelProvider createDecoratingLabelProvider(CUILabelProvider provider) {
-//// XXX: Work in progress for problem decorator being a workbench decorator//
-//// return new ExcludingDecoratingLabelProvider(provider, decorationMgr, "org.eclipse.jdt.ui.problem.decorator"); //$NON-NLS-1$
-// return new DecoratingCLabelProvider(provider);
-// }
-
- protected StatusBarUpdater createStatusBarUpdater(IStatusLineManager slManager) {
- return new StatusBarUpdater(slManager);
- }
-
- protected void createContextMenu() {
- MenuManager menuManager= new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuManager.setRemoveAllWhenShown(true);
- menuManager.addMenuListener(this);
- Menu contextMenu= menuManager.createContextMenu(fViewer.getControl());
- fViewer.getControl().setMenu(contextMenu);
- getSite().registerContextMenu(menuManager, fViewer);
- }
-
- protected void initDragAndDrop() {
-/* int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- // drop
- Transfer[] dropTransfers= new Transfer[] {
- LocalSelectionTransfer.getInstance()
- };
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(fViewer)
- };
- fViewer.addDropSupport(ops | DND.DROP_DEFAULT, dropTransfers, new DelegatingDropAdapter(dropListeners));
-
- // Drag
- Transfer[] dragTransfers= new Transfer[] {
- LocalSelectionTransfer.getInstance(),
- ResourceTransfer.getInstance()};
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(fViewer),
- new ResourceTransferDragAdapter(fViewer)
- };
- fViewer.addDragSupport(ops, dragTransfers, new JdtViewerDragAdapter(fViewer, dragListeners));
-*/ }
-
- protected void fillActionBars(IActionBars actionBars) {
- IToolBarManager toolBar= actionBars.getToolBarManager();
- fillToolBar(toolBar);
-
-
- if (fHasWorkingSetFilter)
- fWorkingSetFilterActionGroup.fillActionBars(getViewSite().getActionBars());
-
- actionBars.updateActionBars();
-
-// fActionGroups.fillActionBars(actionBars);
-//
-// if (fHasCustomFilter)
-// fCustomFiltersActionGroup.fillActionBars(actionBars);
-//
- IMenuManager menu= actionBars.getMenuManager();
- menu.add(fToggleLinkingAction);
- }
-
- //---- IWorkbenchPart ------------------------------------------------------
-
-
- public void setFocus() {
- fViewer.getControl().setFocus();
- }
-
- public void dispose() {
- if (fViewer != null) {
- getViewSite().getPage().removePostSelectionListener(this);
- getViewSite().getPage().removePartListener(fPartListener);
- fViewer= null;
- }
-// if (fActionGroups != null)
-// fActionGroups.dispose();
-
- if (fWorkingSetFilterActionGroup != null) {
- fWorkingSetFilterActionGroup.dispose();
- }
-
- super.dispose();
- }
-
- /**
- * Adds the KeyListener
- */
- protected void addKeyListener() {
- fViewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- handleKeyReleased(event);
- }
- });
- }
-
- protected void handleKeyReleased(KeyEvent event) {
- if (event.stateMask != 0)
- return;
-
- int key= event.keyCode;
- if (key == SWT.F5) {
-// IAction action= fBuildActionGroup.getRefreshAction();
-// if (action.isEnabled())
-// action.run();
- }
- }
-
- //---- Adding Action to Toolbar -------------------------------------------
-
- protected void fillToolBar(IToolBarManager tbm) {
- }
-
- /**
- * Called when the context menu is about to open.
- * Override to add your own context dependent menu contributions.
- */
- public void menuAboutToShow(IMenuManager menu) {
- CUIPlugin.createStandardGroups(menu);
-
- IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection();
- int size= selection.size();
- Object element= selection.getFirstElement();
-
- if (size == 1)
- addOpenNewWindowAction(menu, element);
-// fActionGroups.setContext(new ActionContext(selection));
-// fActionGroups.fillContextMenu(menu);
-// fActionGroups.setContext(null);
- }
-
- private void addOpenNewWindowAction(IMenuManager menu, Object element) {
- if (element instanceof ICElement) {
- element= ((ICElement)element).getResource();
- }
- if (!(element instanceof IContainer))
- return;
-// menu.appendToGroup(
-// IContextMenuConstants.GROUP_OPEN,
-// new PatchedOpenInNewWindowAction(getSite().getWorkbenchWindow(), (IContainer)element));
- }
-
- protected void createActions() {
-// fActionGroups= new CompositeActionGroup(new ActionGroup[] {
-// new NewWizardsActionGroup(this.getSite()),
-// fOpenEditorGroup= new OpenEditorActionGroup(this),
-// new OpenViewActionGroup(this),
-// fCCPActionGroup= new CCPActionGroup(this),
-// new GenerateActionGroup(this),
-// new RefactorActionGroup(this),
-// new ImportActionGroup(this),
-// fBuildActionGroup= new BuildActionGroup(this),
-// new JavaSearchActionGroup(this)});
-
-
- if (fHasWorkingSetFilter) {
- String viewId= getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
- Assert.isNotNull(viewId);
- IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doWorkingSetChanged(event);
- }
- };
- fWorkingSetFilterActionGroup= new WorkingSetFilterActionGroup(viewId, getShell(), workingSetListener);
- fViewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
- }
-
-// // Custom filter group
-// if (fHasCustomFilter)
-// fCustomFiltersActionGroup= new CustomFiltersActionGroup(this, fViewer);
-//
- fToggleLinkingAction= new ToggleLinkingAction(this);
- }
-
- void doWorkingSetChanged(PropertyChangeEvent event) {
- String property= event.getProperty();
- if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property))
- updateTitle();
- else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- updateTitle();
- fViewer.getControl().setRedraw(false);
- fViewer.refresh();
- fViewer.getControl().setRedraw(true);
- }
-
- }
-
-
- /**
- * Returns the shell to use for opening dialogs.
- * Used in this class, and in the actions.
- */
- Shell getShell() {
- return fViewer.getControl().getShell();
- }
-
- protected final Display getDisplay() {
- return fViewer.getControl().getDisplay();
- }
-
- /**
- * Returns the selection provider.
- */
- ISelectionProvider getSelectionProvider() {
- return fViewer;
- }
-
- /**
- * Answers if the given element
is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return element
is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return true
if the input has to be set
- * @since 3.0
- */
- private boolean mustSetNewInput(Object elementToSelect, Object oldInput, Object newInput) {
- if (newInput == null || oldInput == null || !newInput.equals(oldInput)) {
- return true;
- }
- if (elementToSelect == null) {
- return false;
- }
-// return !findInputForElement(elementToSelect).equals(newInput);
- return false;
-// return !(inputContainsElement(newInput, elementToSelect));
-// return (newInput == null || !newInput.equals(oldInput))
-// && (elementToSelect == null
-// || oldInput == null);
-// return (newInput == null || !newInput.equals(oldInput))
-// && (elementToSelect == null
-// || oldInput == null
-// || (!((elementToSelect instanceof IDeclaration)
-// && (elementToSelect.getParent().equals(oldInput.getParent()))
-// && (!isAncestorOf(getViewPartInput(), elementToSelect)))));
- }
-
- /**
- * Finds the closest C element which can be used as input for
- * this part and has the given C element as child
- *
- * @param element the C element for which to search the closest input
- * @return the closest C element used as input for this part
- */
- abstract protected Object findInputForElement(Object element);
-
- /**
- * Finds the element which has to be selected in this part.
- *
- * @param element the C element which has the focus
- */
- abstract protected Object findElementToSelect(Object element);
-
- /**
- * Converts the given C element to one which is suitable for this
- * view. It takes into account wether the view shows working copies or not.
- *
- * @param element the C element to be converted
- * @return an element suitable for this view
- */
- Object getSuitableElement(Object obj) {
- if (!(obj instanceof ICElement) && !(obj instanceof ITypeInfo))
- return null;
- if (fTypeComparator.compare(obj, ICElement.C_UNIT) > 0)
- return obj;
- return obj;
-// if (element.getElementType() == IJavaElement.CLASS_FILE)
-// return element;
-// if (isInputAWorkingCopy()) {
-// IJavaElement wc= getWorkingCopy(element);
-// if (wc != null)
-// element= wc;
-// return element;
-// }
-// else {
-// return element.getPrimaryElement();
-// }
- }
-
- protected ICElement getTypeForTU(ITranslationUnit tu) {
- tu = (ITranslationUnit) getSuitableElement(tu);
-
-// // Use primary type if possible
-// IType primaryType= cu.findPrimaryType();
-// if (primaryType != null)
-// return primaryType;
-
- // Use first top-level type
- try {
- ICElement[] types = TypeUtil.getTypes(tu);
- if (types.length > 0)
- return types[0];
- return null;
- } catch (CModelException ex) {
- return null;
- }
- }
-
- protected final Object getSingleElementFromSelection(ISelection selection) {
- if (!(selection instanceof StructuredSelection) || selection.isEmpty())
- return null;
-
- Iterator iter= ((StructuredSelection)selection).iterator();
- Object firstElement= iter.next();
- if (!(firstElement instanceof ICElement) && !(firstElement instanceof ITypeInfo)) {
-// if (SearchUtil.isISearchResultViewEntry(firstElement)) {
-// ICElement je= SearchUtil.getJavaElement(firstElement);
-// if (je != null)
-// return je;
-// firstElement= SearchUtil.getResource(firstElement);
-// }
- if (firstElement instanceof IAdaptable) {
- ICElement je= (ICElement)((IAdaptable)firstElement).getAdapter(ICElement.class);
- if (je == null && firstElement instanceof IFile) {
- IContainer parent= ((IFile)firstElement).getParent();
- if (parent != null)
- return (ICElement)parent.getAdapter(ICElement.class);
- return null;
- }
- return je;
- }
- return firstElement;
- }
- Object currentInput= getViewer().getInput();
- if (currentInput == null || !currentInput.equals(findInputForElement(firstElement))) {
- if (iter.hasNext()) {
- // multi selection and view is empty
- return null;
- }
- // ok: single selection and view is empty
- return firstElement;
- }
-
- // be nice to multi selection
- while (iter.hasNext()) {
- Object element= iter.next();
- if (!(element instanceof ICElement) && !(element instanceof ITypeInfo))
-// if (!(element instanceof ICElement))
- return null;
- if (!currentInput.equals(findInputForElement(element)))
- return null;
- }
- return firstElement;
- }
-
- /**
- * Gets the typeComparator.
- * @return Returns a JavaElementTypeComparator
- */
- protected Comparator getTypeComparator() {
- return fTypeComparator;
- }
-
- /**
- * Links to editor (if option enabled)
- */
- void linkToEditor(IStructuredSelection selection) {
- Object obj= selection.getFirstElement();
-
- if (selection.size() == 1) {
- IEditorPart part= EditorUtility.isOpenInEditor(obj);
- if (part != null) {
- IWorkbenchPage page= getSite().getPage();
- page.bringToTop(part);
- if (obj instanceof ICElement)
- EditorUtility.revealInEditor(part, (ICElement) obj);
- }
- }
- }
-
- void setSelectionFromEditor(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- setSelectionFromEditor(part);
- }
-
- void setSelectionFromEditor(IWorkbenchPart part) {
- if (!linkBrowsingViewSelectionToEditor())
- return;
-
- if (part == null)
- return;
- IWorkbenchPartSite site= part.getSite();
- if (site == null)
- return;
- ISelectionProvider provider= site.getSelectionProvider();
- if (provider != null)
- setSelectionFromEditor(part, provider.getSelection());
- }
-
- private void setSelectionFromEditor(IWorkbenchPart part, ISelection selection) {
- if (part instanceof IEditorPart) {
- ICElement element= null;
- if (selection instanceof IStructuredSelection) {
- Object obj= getSingleElementFromSelection(selection);
- if (obj instanceof ICElement)
- element= (ICElement)obj;
- }
- IEditorInput ei= ((IEditorPart)part).getEditorInput();
- if (selection instanceof ITextSelection) {
- int offset= ((ITextSelection)selection).getOffset();
- element= getElementAt(ei, offset);
- }
- if (element != null) {
- adjustInputAndSetSelection(element);
- return;
- }
- if (ei instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)ei).getFile();
- ICElement ce= (ICElement)file.getAdapter(ICElement.class);
- if (ce == null) {
- IContainer container= ((IFileEditorInput)ei).getFile().getParent();
- if (container != null)
- ce= (ICElement)container.getAdapter(ICElement.class);
- }
- if (ce == null) {
- setSelection(null, false);
- return;
- }
- adjustInputAndSetSelection(ce);
-// } else if (ei instanceof IClassFileEditorInput) {
-// IClassFile cf= ((IClassFileEditorInput)ei).getClassFile();
-// adjustInputAndSetSelection(cf);
- }
- }
- }
-
- /**
- * Returns the element contained in the EditorInput
- */
- Object getElementOfInput(IEditorInput input) {
-// if (input instanceof IClassFileEditorInput)
-// return ((IClassFileEditorInput)input).getClassFile();
-// else
- if (input instanceof IFileEditorInput)
- return ((IFileEditorInput)input).getFile();
-// else if (input instanceof JarEntryEditorInput)
-// return ((JarEntryEditorInput)input).getStorage();
- return null;
- }
-
- protected void setSelection(ISelection selection, boolean reveal) {
- if (selection != null && selection.equals(fViewer.getSelection()))
- return;
- fProcessSelectionEvents= false;
- fViewer.setSelection(selection, reveal);
- fProcessSelectionEvents= true;
- }
-
- /**
- * Tries to find the given element in a workingcopy.
- */
- protected static ICElement getWorkingCopy(ICElement input) {
- // MA: with new working copy story original == working copy
- return input;
- }
-
-//
-// boolean isInputAWorkingCopy() {
-// return ((BaseCElementContentProvider)getViewer().getContentProvider()).getProvideWorkingCopy();
-// }
-
- /**
- * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getElementAt(int)
- */
- protected ICElement getElementAt(IEditorInput input, int offset) {
-// if (input instanceof IClassFileEditorInput) {
-// try {
-// return ((IClassFileEditorInput)input).getClassFile().getElementAt(offset);
-// } catch (CModelException ex) {
-// return null;
-// }
-// }
-
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
- ITranslationUnit unit= manager.getWorkingCopy(input);
- if (unit != null)
- try {
- if (unit.isConsistent()) {
- return unit.getElementAtOffset(offset);
- }
- /*
- * XXX: We should set the selection later when the
- * CU is reconciled.
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290
- */
- } catch (CModelException ex) {
- // fall through
- }
- return null;
- }
-
-/* protected ICElement getTypeForCU(ITranslationUnit cu) {
- cu= (ITranslationUnit)getSuitableCElement(cu);
-
-// // Use primary type if possible
-// ICElement primaryType= cu.findPrimaryType();
-// if (primaryType != null)
-// return primaryType;
-
- // Use first top-level type
- try {
- final ICElement[] fTypes = new ICElement[]{ null };
- cu.accept(new ICElementVisitor() {
- public boolean visit(ICElement element) throws CoreException {
- // TODO Auto-generated method stub
- switch(element.getElementType()) {
- case ICElement.C_NAMESPACE:
- case ICElement.C_TEMPLATE_CLASS:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF:
- fTypes[0] = element;
- return false;
- }
- return true;
- }
- });
-// ICElement[] types= cu.getTypes();
-// if (types.length > 0)
-// return types[0];
-// else
-// return null;
- return fTypes[0];
- } catch (CoreException ex) {
- return null;
- }
- }
-*/
- void setProcessSelectionEvents(boolean state) {
- fProcessSelectionEvents= state;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- if (fViewer != null) {
- return fViewer.getInput();
- }
- return null;
- }
-
-// protected void setActionGroups(CompositeActionGroup actionGroups) {
-// fActionGroups= actionGroups;
-// }
-//
-// protected void setBuildActionGroup(BuildActionGroup actionGroup) {
-// fBuildActionGroup= actionGroup;
-// }
-//
-// protected void setCCPActionGroup(CCPActionGroup actionGroup) {
-// fCCPActionGroup= actionGroup;
-// }
-//
-// protected void setCustomFiltersActionGroup(CustomFiltersActionGroup customFiltersActionGroup) {
-// fCustomFiltersActionGroup= customFiltersActionGroup;
-// }
-
- protected boolean hasCustomFilter() {
- return fHasCustomFilter;
- }
-
- protected boolean hasWorkingSetFilter() {
- return fHasWorkingSetFilter;
- }
-
-// protected void setOpenEditorGroup(OpenEditorActionGroup openEditorGroup) {
-// fOpenEditorGroup= openEditorGroup;
-// }
-//
-// protected OpenEditorActionGroup getOpenEditorGroup() {
-// return fOpenEditorGroup;
-// }
-//
-// protected BuildActionGroup getBuildActionGroup() {
-// return fBuildActionGroup;
-// }
-//
-// protected CCPActionGroup getCCPActionGroup() {
-// return fCCPActionGroup;
-// }
-
- private boolean linkBrowsingViewSelectionToEditor() {
- return isLinkingEnabled();
- }
-
- public void setLinkingEnabled(boolean enabled) {
- fLinkingEnabled= enabled;
- PreferenceConstants.getPreferenceStore().setValue(getLinkToEditorKey(), enabled);
- if (enabled) {
- IEditorPart editor = getSite().getPage().getActiveEditor();
- if (editor != null) {
- setSelectionFromEditor(editor);
- }
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java
deleted file mode 100644
index 7fd72a75366..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.wizards.CWizardRegistry;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.console.IConsoleConstants;
-
-public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
-
- /*
- * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070
- */
- static ICElement fgCElementFromAction;
-
- /**
- * Constructs a new Default layout engine.
- */
- public CBrowsingPerspectiveFactory() {
- super();
- }
-
- /**
- * @see IPerspectiveFactory#createInitialLayout
- */
- public void createCViewInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
-
- IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
- folder1.addView(CUIPlugin.CVIEW_ID);
- folder1.addView(IPageLayout.ID_RES_NAV);
- folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-
- IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
- folder2.addView(IPageLayout.ID_PROBLEM_VIEW);
- folder2.addView(IConsoleConstants.ID_CONSOLE_VIEW);
- folder2.addView(IPageLayout.ID_PROP_SHEET);
-
- IFolderLayout folder3= layout.createFolder("topRight", IPageLayout.RIGHT,(float)0.75, editorArea); //$NON-NLS-1$
- folder3.addView(IPageLayout.ID_OUTLINE);
-
- layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
- layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
-
- // views - build console
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - searching
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
- layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
-
- // link - things we should do
- layout.addShowInPart(CUIPlugin.CVIEW_ID);
- layout.addShowInPart(IPageLayout.ID_RES_NAV);
-
- addCWizardShortcuts(layout);
- }
-
- public void createInitialLayout(IPageLayout layout) {
- if (stackBrowsingViewsVertically())
- createVerticalLayout(layout);
- else
- createHorizontalLayout(layout);
-
- // action sets
- layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
-// layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
-// layout.addActionSet(JavaUI.ID_ACTION_SET);
- layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
- layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
-
- // views - java
- layout.addShowViewShortcut(CUIPlugin.ID_TYPE_HIERARCHY);
- layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
- layout.addShowViewShortcut(CUIPlugin.ID_PROJECTS_VIEW);
- layout.addShowViewShortcut(CUIPlugin.ID_NAMESPACES_VIEW);
- layout.addShowViewShortcut(CUIPlugin.ID_TYPES_VIEW);
- layout.addShowViewShortcut(CUIPlugin.ID_MEMBERS_VIEW);
-// layout.addShowViewShortcut(CUIPlugin.ID_SOURCE_VIEW);
-// layout.addShowViewShortcut(CUIPlugin.ID_JAVADOC_VIEW);
-
- // views - search
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - debugging
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
-
- addCWizardShortcuts(layout);
- }
-
- private void addCWizardShortcuts(IPageLayout layout) {
- // new actions - C project creation wizard
- String[] wizIDs = CWizardRegistry.getProjectWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- // new actions - C folder creation wizard
- wizIDs = CWizardRegistry.getFolderWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- // new actions - C file creation wizard
- wizIDs = CWizardRegistry.getFileWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- // new actions - C type creation wizard
- wizIDs = CWizardRegistry.getTypeWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- }
-
- private void createVerticalLayout(IPageLayout layout) {
- String relativePartId= IPageLayout.ID_EDITOR_AREA;
- int relativePos= IPageLayout.LEFT;
-
- IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderLeft.addPlaceholder(CUIPlugin.ID_TYPE_HIERARCHY);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
- placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- if (shouldShowProjectsView()) {
- layout.addView(CUIPlugin.ID_PROJECTS_VIEW, IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA);
- relativePartId= CUIPlugin.ID_PROJECTS_VIEW;
- relativePos= IPageLayout.BOTTOM;
- }
- if (shouldShowNamespacesView()) {
- layout.addView(CUIPlugin.ID_NAMESPACES_VIEW, relativePos, (float)0.25, relativePartId);
- relativePartId= CUIPlugin.ID_NAMESPACES_VIEW;
- relativePos= IPageLayout.BOTTOM;
- }
- layout.addView(CUIPlugin.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId);
- layout.addView(CUIPlugin.ID_MEMBERS_VIEW, IPageLayout.BOTTOM, (float)0.50, CUIPlugin.ID_TYPES_VIEW);
-
- IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_SOURCE_VIEW);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_JAVADOC_VIEW);
- }
-
- private void createHorizontalLayout(IPageLayout layout) {
- String relativePartId= IPageLayout.ID_EDITOR_AREA;
- int relativePos= IPageLayout.TOP;
-
- if (shouldShowProjectsView()) {
- layout.addView(CUIPlugin.ID_PROJECTS_VIEW, IPageLayout.TOP, (float)0.25, IPageLayout.ID_EDITOR_AREA);
- relativePartId= CUIPlugin.ID_PROJECTS_VIEW;
- relativePos= IPageLayout.RIGHT;
- }
- if (shouldShowNamespacesView()) {
- layout.addView(CUIPlugin.ID_NAMESPACES_VIEW, relativePos, (float)0.25, relativePartId);
- relativePartId= CUIPlugin.ID_NAMESPACES_VIEW;
- relativePos= IPageLayout.RIGHT;
- }
- layout.addView(CUIPlugin.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId);
- layout.addView(CUIPlugin.ID_MEMBERS_VIEW, IPageLayout.RIGHT, (float)0.50, CUIPlugin.ID_TYPES_VIEW);
-
- IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderLeft.addPlaceholder(CUIPlugin.ID_TYPE_HIERARCHY);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
- placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_SOURCE_VIEW);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_JAVADOC_VIEW);
- }
-
- private boolean shouldShowProjectsView() {
- return true;
-// RETURN FGCELEMENTFROMACTION == NULL || FGCELEMENTFROMACTION.GETELEMENTTYPE() == ICELEMENT.C_MODEL;
- }
-
- private boolean shouldShowNamespacesView() {
- return true;
-// if (fgCElementFromAction == null)
-// return true;
-// int type= fgCElementFromAction.getElementType();
-// return type == ICElement.C_MODEL || type == ICElement.C_PROJECT;
-//// return type == ICElement.C_MODEL || type == ICElement.C_PROJECT || type == ICElement.PACKAGE_FRAGMENT_ROOT;
- }
-
- private boolean stackBrowsingViewsVertically() {
- return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.BROWSING_STACK_VERTICALLY);
- }
-
- /*
- * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070
- */
- static void setInputFromAction(IAdaptable input) {
- if (input instanceof ICElement)
- fgCElementFromAction= (ICElement)input;
- else
- fgCElementFromAction= null;
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java
deleted file mode 100644
index 9728e2ff211..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.ui.CElementSorter;
-
-public class CBrowsingViewerSorter extends CElementSorter {
-
- public CBrowsingViewerSorter() {
- super();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java
deleted file mode 100644
index a1c8d0dcfc3..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Sep 1, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-
-/**
- * @author CWiebe
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class ElementTableViewer extends ProblemTableViewer {
-
- /**
- * @param parent
- */
- public ElementTableViewer(Composite parent) {
- super(parent);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param parent
- * @param style
- */
- public ElementTableViewer(Composite parent, int style) {
- super(parent, style);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param table
- */
- public ElementTableViewer(Table table) {
- super(table);
- // TODO Auto-generated constructor stub
- }
-
- protected void handleInvalidSelection(ISelection invalidSelection,
- ISelection newSelection) {
- updateSelection(newSelection);
- SelectionChangedEvent event = new SelectionChangedEvent(this,
- newSelection);
- firePostSelectionChanged(event);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java
deleted file mode 100644
index 1dc814521e7..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Sep 1, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-
-/**
- * @author CWiebe
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class ElementTreeViewer extends ProblemTreeViewer {
-
- /**
- * @param parent
- */
- public ElementTreeViewer(Composite parent) {
- super(parent);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param parent
- * @param style
- */
- public ElementTreeViewer(Composite parent, int style) {
- super(parent, style);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param tree
- */
- public ElementTreeViewer(Tree tree) {
- super(tree);
- // TODO Auto-generated constructor stub
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java
deleted file mode 100644
index d8b00b25228..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/*
- * XXX: This class should become part of the MemberFilterActionGroup
- * which should be renamed to MemberActionsGroup
- */
-public class LexicalSortingAction extends Action {
- CBrowsingViewerSorter fSorter= new CBrowsingViewerSorter();
- StructuredViewer fViewer;
- private String fPreferenceKey;
-
- public LexicalSortingAction(StructuredViewer viewer, String id) {
- super();
- fViewer= viewer;
- fPreferenceKey= "LexicalSortingAction." + id + ".isChecked"; //$NON-NLS-1$ //$NON-NLS-2$
- setText(CBrowsingMessages.getString("LexicalSortingAction.label")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ALPHA_SORTING); //$NON-NLS-1$ //$NON-NLS-2$
- setToolTipText(CBrowsingMessages.getString("LexicalSortingAction.tooltip")); //$NON-NLS-1$
- setDescription(CBrowsingMessages.getString("LexicalSortingAction.description")); //$NON-NLS-1$
- boolean checked= CUIPlugin.getDefault().getPreferenceStore().getBoolean(fPreferenceKey); //$NON-NLS-1$
- valueChanged(checked, false);
- WorkbenchHelp.setHelp(this, ICHelpContextIds.LEXICAL_SORTING_BROWSING_ACTION);
- }
-
- public void run() {
- valueChanged(isChecked(), true);
- }
-
- private void valueChanged(final boolean on, boolean store) {
- setChecked(on);
- BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- if (on)
- fViewer.setSorter(fSorter);
- else
- fViewer.setSorter(null);
- }
- });
-
- if (store)
- CUIPlugin.getDefault().getPreferenceStore().setValue(fPreferenceKey, on);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
deleted file mode 100644
index 733d61bea49..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.INamespace;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.part.IShowInTargetList;
-
-public class MembersView extends CBrowsingPart implements IPropertyChangeListener {
-
-// private MemberFilterActionGroup fMemberFilterActionGroup;
-
-
- public MembersView() {
- setHasWorkingSetFilter(false);
- setHasCustomSetFilter(true);
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- /**
- * Creates and returns the label provider for this part.
- *
- * @return the label provider
- * @see org.eclipse.jface.viewers.ILabelProvider
- */
- protected LabelProvider createLabelProvider() {
- return new CBrowsingLabelProvider();
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return ICHelpContextIds.MEMBERS_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_MEMBERS_TO_EDITOR;
- }
-
- /**
- * Creates the the viewer of this part.
- *
- * @param parent the parent for the viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- ElementTreeViewer viewer= new ElementTreeViewer(parent, SWT.MULTI);
-// fMemberFilterActionGroup= new MemberFilterActionGroup(viewer, JavaUI.ID_MEMBERS_VIEW);
- return viewer;
- }
-
- protected ViewerSorter createViewerSorter() {
- return new CBrowsingViewerSorter();
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(new CBrowsingElementFilter());
- }
-
- protected void fillToolBar(IToolBarManager tbm) {
- tbm.add(new LexicalSortingAction(getViewer(), CUIPlugin.ID_MEMBERS_VIEW));
-// fMemberFilterActionGroup.contributeToToolBar(tbm);
- super.fillToolBar(tbm);
- }
-
- /**
- * Answers if the given element
is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return element
is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return element
is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return element
is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return OpenProjectAction
. The action requires
- * that the selection provided by the site's selection provider is of type
- * org.eclipse.jface.viewers.IStructuredSelection
.
- *
- * @param site the site providing context information for this action
- */
- public OpenProjectAction(IWorkbenchSite site) {
- super(site);
- fWorkbenchAction= new OpenResourceAction(site.getShell());
- setText(fWorkbenchAction.getText());
- setToolTipText(fWorkbenchAction.getToolTipText());
- setEnabled(hasCloseProjects());
- WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_PROJECT_ACTION);
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- fWorkbenchAction.resourceChanged(event);
- switch (fMode) {
- case ELEMENT_SELECTION:
- setEnabled(fWorkbenchAction.isEnabled());
- break;
- case EMPTY_SELECTION:
- internalResourceChanged(event);
- break;
- }
- }
-
- private void internalResourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- if (delta != null) {
- IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED);
- for (int i = 0; i < projDeltas.length; ++i) {
- IResourceDelta projDelta = projDeltas[i];
- if ((projDelta.getFlags() & IResourceDelta.OPEN) != 0) {
- setEnabled(hasCloseProjects());
- return;
- }
- }
- }
- }
-
- //---- normal selection -------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(ISelection selection) {
- setEnabled(hasCloseProjects());
- fMode= EMPTY_SELECTION;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.viewers.ISelection)
- */
- public void run(ISelection selection) {
- internalRun();
- }
-
- //---- structured selection ---------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- setEnabled(hasCloseProjects());
- fMode= EMPTY_SELECTION;
- return;
- }
- fWorkbenchAction.selectionChanged(selection);
- setEnabled(fWorkbenchAction.isEnabled());
- fMode= ELEMENT_SELECTION;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- internalRun();
- return;
- }
- fWorkbenchAction.run();
- }
-
- private void internalRun() {
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new CElementLabelProvider());
- dialog.setTitle(ActionMessages.getString("OpenProjectAction.dialog.title")); //$NON-NLS-1$
- dialog.setMessage(ActionMessages.getString("OpenProjectAction.dialog.message")); //$NON-NLS-1$
- dialog.setElements(getClosedProjects());
- dialog.setMultipleSelection(true);
- int result= dialog.open();
- if (result != Window.OK)
- return;
- final Object[] projects= dialog.getResult();
- IWorkspaceRunnable runnable= createRunnable(projects);
- try {
- PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable));
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(),
- ActionMessages.getString("OpenProjectAction.dialog.title"), //$NON-NLS-1$
- ActionMessages.getString("OpenProjectAction.error.message")); //$NON-NLS-1$
- } catch (InterruptedException e) {
- }
- }
-
- private IWorkspaceRunnable createRunnable(final Object[] projects) {
- return new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", projects.length); //$NON-NLS-1$
- MultiStatus errorStatus= null;
- for (int i = 0; i < projects.length; i++) {
- IProject project= (IProject)projects[i];
- try {
- project.open(new SubProgressMonitor(monitor, 1));
- } catch (CoreException e) {
- if (errorStatus == null)
- errorStatus = new MultiStatus(CUIPlugin.getPluginId(), IStatus.ERROR, ActionMessages.getString("OpenProjectAction.error.message"), e); //$NON-NLS-1$
- errorStatus.merge(e.getStatus());
- }
- }
- monitor.done();
- if (errorStatus != null)
- throw new CoreException(errorStatus);
- }
- };
- }
-
- private Object[] getClosedProjects() {
- IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- List result= new ArrayList(5);
- for (int i = 0; i < projects.length; i++) {
- IProject project= projects[i];
- if (!project.isOpen())
- result.add(project);
- }
- return result.toArray();
- }
-
- private boolean hasCloseProjects() {
- IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- if (!projects[i].isOpen())
- return true;
- }
- return false;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectActionGroup.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectActionGroup.java
deleted file mode 100644
index cf8b467a607..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectActionGroup.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.CloseResourceAction;
-import org.eclipse.ui.ide.IDEActionFactory;
-
-/**
- * Adds actions to open and close a project to the global menu bar.
- *
- * ProjectActionGroup
. The group requires
- * that the selection provided by the site's selection provider is of type
- * org.eclipse.jface.viewers.IStructuredSelection
.
- *
- * @param part the view part that owns this action group
- */
- public ProjectActionGroup(IViewPart part) {
- fSite = part.getSite();
- Shell shell= fSite.getShell();
- ISelectionProvider provider= fSite.getSelectionProvider();
- ISelection selection= provider.getSelection();
-
- fCloseAction= new CloseResourceAction(shell);
- fCloseAction.setActionDefinitionId("org.eclipse.ui.project.closeProject"); //$NON-NLS-1$
- fOpenAction= new OpenProjectAction(fSite);
- fOpenAction.setActionDefinitionId("org.eclipse.ui.project.openProject"); //$NON-NLS-1$
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection s= (IStructuredSelection)selection;
- fOpenAction.selectionChanged(s);
- fCloseAction.selectionChanged(s);
- }
- provider.addSelectionChangedListener(fOpenAction);
- provider.addSelectionChangedListener(fCloseAction);
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- workspace.addResourceChangeListener(fOpenAction);
- workspace.addResourceChangeListener(fCloseAction);
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), fCloseAction);
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), fOpenAction);
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- if (fOpenAction.isEnabled())
- menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fOpenAction);
- if (fCloseAction.isEnabled())
- menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fCloseAction);
- }
-
-
- /*
- * @see ActionGroup#dispose()
- */
- public void dispose() {
- ISelectionProvider provider= fSite.getSelectionProvider();
- provider.removeSelectionChangedListener(fOpenAction);
- provider.removeSelectionChangedListener(fCloseAction);
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.removeResourceChangeListener(fOpenAction);
- workspace.removeResourceChangeListener(fCloseAction);
- super.dispose();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
deleted file mode 100644
index 455d09b934a..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IEnumeration;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.ITypeDef;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.part.IShowInTargetList;
-
-public class ProjectsView extends CBrowsingPart {
-
-// private FilterUpdater fFilterUpdater;
-
- /**
- * Creates the the viewer of this part.
- *
- * @param parent the parent for the viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- ElementTreeViewer result= new ElementTreeViewer(parent, SWT.MULTI);
-// fFilterUpdater= new FilterUpdater(result);
-// ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
- return result;
- }
-
- protected LabelProvider createLabelProvider() {
- return new CBrowsingLabelProvider();
- }
-
- protected ViewerSorter createViewerSorter() {
- return new CBrowsingViewerSorter();
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(new CBrowsingElementFilter());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#dispose()
- */
- public void dispose() {
-// if (fFilterUpdater != null)
-// ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater);
- super.dispose();
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
-
- /**
- * Creates the the content provider of this part.
- */
- protected IContentProvider createContentProvider() {
- return new ProjectsViewContentProvider(this);
- }
-
- /**
- * Returns the context ID for the Help system.
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return ICHelpContextIds.PROJECTS_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_PROJECTS_TO_EDITOR;
- }
-
-
- /**
- * Adds additional listeners to this view.
- */
- protected void hookViewerListeners() {
- super.hookViewerListeners();
- getViewer().addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- TreeViewer viewer= (TreeViewer)getViewer();
- Object element= ((IStructuredSelection)event.getSelection()).getFirstElement();
- if (viewer.isExpandable(element))
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- });
- }
-
- protected void setInitialInput() {
- ICElement root= CoreModel.create(CUIPlugin.getWorkspace().getRoot());
- getViewer().setInput(root);
- updateTitle();
- }
-
- /**
- * Answers if the given element
is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return element
is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return element
is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return element
is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return OpenTypeDialog
.
- * @param parent the parent shell.
- */
- public FocusOnTypeDialog(Shell parent) {
- super(parent);
- setTitle(TypeHierarchyMessages.getString("FocusOnTypeAction.dialog.title")); //$NON-NLS-1$
- setMessage(TypeHierarchyMessages.getString("FocusOnTypeAction.dialog.message")); //$NON-NLS-1$
- setVisibleTypes(VISIBLE_TYPES);
- setDialogSettings(DIALOG_SETTINGS);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java
deleted file mode 100644
index 541e5476376..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
-import org.eclipse.cdt.ui.CElementImageDescriptor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Label provider for the hierarchy viewers. Types in the hierarchy that are not belonging to the
- * input scope are rendered differntly.
- */
-public class HierarchyLabelProvider extends StandardCElementLabelProvider // AppearanceAwareLabelProvider {
-{
- private static class FocusDescriptor extends CompositeImageDescriptor {
- private ImageDescriptor fBase;
- public FocusDescriptor(ImageDescriptor base) {
- fBase= base;
- }
- protected void drawCompositeImage(int width, int height) {
- drawImage(getImageData(fBase), 0, 0);
- drawImage(getImageData(CPluginImages.DESC_OVR_FOCUS), 0, 0);
- }
-
- private ImageData getImageData(ImageDescriptor descriptor) {
- ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
- if (data == null) {
- data= DEFAULT_IMAGE_DATA;
- CUIPlugin.getDefault().logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
- }
- return data;
- }
-
- protected Point getSize() {
- return CElementImageProvider.BIG_SIZE;
- }
- public int hashCode() {
- return fBase.hashCode();
- }
- public boolean equals(Object object) {
- return object != null && FocusDescriptor.class.equals(object.getClass()) && ((FocusDescriptor)object).fBase.equals(fBase);
- }
- }
-
- private Color fGrayedColor;
- private Color fSpecialColor;
-
- private ViewerFilter fFilter;
-
- private TypeHierarchyLifeCycle fHierarchy;
-
- public HierarchyLabelProvider(TypeHierarchyLifeCycle lifeCycle) {
-// super(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS);
- super();
- fHierarchy= lifeCycle;
- fFilter= null;
- }
-
-
- /**
- * @return Returns the filter.
- */
- public ViewerFilter getFilter() {
- return fFilter;
- }
-
- /**
- * @param filter The filter to set.
- */
- public void setFilter(ViewerFilter filter) {
- fFilter= filter;
- }
-
- protected boolean isDifferentScope(ICElement type) {
- if (fFilter != null && !fFilter.select(null, null, type)) {
- return true;
- }
-
- ICElement input= fHierarchy.getInputElement();
- if (input == null || TypeUtil.isClassOrStruct(input)) {
- return false;
- }
-
- ICElement parent= type.getAncestor(input.getElementType());
- if (input.getElementType() == ICElement.C_CCONTAINER) {
- if (parent == null || parent.getElementName().equals(input.getElementName())) {
- return false;
- }
- } else if (input.equals(parent)) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see ILabelProvider#getImage
- */
- public Image getImage(Object element) {
- Image result= null;
- if (element instanceof ICElement) {
- ImageDescriptor desc= getTypeImageDescriptor((ICElement) element);
- if (desc != null) {
- if (element.equals(fHierarchy.getInputElement())) {
- desc= new FocusDescriptor(desc);
- }
- result= CUIPlugin.getImageDescriptorRegistry().get(desc);
- }
- } else {
- result= fImageLabelProvider.getImageLabel(element, getImageFlags());
- }
- return result;
- }
-
- private ImageDescriptor getTypeImageDescriptor(ICElement type) {
- ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
- if (hierarchy == null) {
- return new CElementImageDescriptor(CPluginImages.DESC_OBJS_CLASS, 0, CElementImageProvider.BIG_SIZE);
- }
-
- ImageDescriptor desc;
- if (isDifferentScope(type)) {
- desc = CElementImageProvider.getClassImageDescriptor();
- } else {
- desc= fImageLabelProvider.getBaseImageDescriptor(type, 0);
- }
-
- int adornmentFlags= 0;
- if (type instanceof IMethodDeclaration) {
- IMethodDeclaration method = (IMethodDeclaration) type;
- try {
- if (method.isStatic())
- adornmentFlags |= CElementImageDescriptor.STATIC;
-// if (method.isVirtual())
-// adornmentFlags |= CElementImageDescriptor.VIRTUAL;
- } catch (CModelException e) {
- }
- }
-
- if (type instanceof IStructure) {
-// hierarchy.getSupertypes(type);
-// TypeCacheManager.getInstance().getCache(type.getCProject().getProject()).getSupertypeAccess();
- }
-
- return new CElementImageDescriptor(desc, adornmentFlags, CElementImageProvider.BIG_SIZE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- if (element instanceof IMethod) {
- if (fSpecialColor == null) {
- fSpecialColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
- }
- return fSpecialColor;
- } else if (element instanceof ICElement && isDifferentScope((ICElement) element)) {
- if (fGrayedColor == null) {
- fGrayedColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
- }
- return fGrayedColor;
- }
- return null;
- }
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java
deleted file mode 100644
index 77d35d1c18b..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.ui.CElementSorter;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-/**
- */
-public class HierarchyViewerSorter extends ViewerSorter {
-
- private static final int OTHER= 0;
- private static final int CLASS= 1;
- private static final int FIELD= 2;
- private static final int METHOD= 3;
-
- private TypeHierarchyLifeCycle fHierarchy;
- private boolean fSortByDefiningType;
- private CElementSorter fNormalSorter;
-
- public HierarchyViewerSorter(TypeHierarchyLifeCycle cycle) {
- fHierarchy= cycle;
- fNormalSorter= new CElementSorter();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
- */
-// public int category(Object element) {
-// if (element instanceof ICElement) {
-// ICElement type= (ICElement) element;
-// ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
-// if (hierarchy != null) {
-// return CLASS;
-// }
-// }
-// return OTHER;
-// }
-
-// public boolean isSorterProperty(Object element, Object property) {
-// return true;
-// }
-
- public int category(Object obj) {
- if (obj instanceof ICElement) {
- ICElement elem= (ICElement)obj;
- switch (elem.getElementType()) {
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- return CLASS;
-// case ICElement.C_UNION:
-// return 3;
- case ICElement.C_FIELD:
- return FIELD;
-
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- return METHOD;
-// {
-// IMethodDeclaration method = (IMethodDeclaration) elem;
-// try {
-// // sort constructor and destructor first
-// if (method.isConstructor() || method.isDestructor())
-// return 10;
-// } catch (CModelException e) {
-// }
-// return 20;
-// }
- }
-
- }
- return OTHER;
- }
-
- public boolean isSortByDefiningType() {
- return fSortByDefiningType;
- }
-
- public void setSortByDefiningType(boolean sortByDefiningType) {
- fSortByDefiningType= sortByDefiningType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerSorter#compare(null, null, null)
- */
- public int compare(Viewer viewer, Object e1, Object e2) {
- int cat1= category(e1);
- int cat2= category(e2);
-
- if (cat1 != cat2)
- return cat1 - cat2;
-
- ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
- if (hierarchy == null) {
- return fNormalSorter.compare(viewer, e1, e2);
- }
-
- if (cat1 == FIELD || cat1 == METHOD) { // method or field
- if (fSortByDefiningType) {
- try {
- ICElement def1= (e1 instanceof IMethodDeclaration) ? getDefiningType(hierarchy, (IMethodDeclaration) e1) : null;
- ICElement def2= (e2 instanceof IMethodDeclaration) ? getDefiningType(hierarchy, (IMethodDeclaration) e2) : null;
- if (def1 != null) {
- if (def2 != null) {
- if (!def2.equals(def1)) {
- return compareInHierarchy(hierarchy, def1, def2);
- }
- } else {
- return -1;
- }
- } else {
- if (def2 != null) {
- return 1;
- }
- }
- } catch (CModelException e) {
- // ignore, default to normal comparison
- }
- }
- return fNormalSorter.compare(viewer, e1, e2); // use appearance pref page settings
- }
- String name1= ((ICElement) e1).getElementName(); //$NON-NLS-1$
- String name2= ((ICElement) e2).getElementName(); //$NON-NLS-1$
- return getCollator().compare(name1, name2);
- }
-
- private ICElement getDefiningType(ITypeHierarchy hierarchy, IMethodDeclaration method) throws CModelException {
- ICElement declaringType= TypeUtil.getDeclaringClass(method);
- if ((method.getVisibility() == ASTAccessVisibility.PRIVATE) || method.isStatic() || method.isConstructor() || method.isDestructor()) {
- return null;
- }
-
- ICElement res= TypeUtil.findMethodDeclarationInHierarchy(hierarchy, declaringType, method.getElementName(), method.getParameterTypes(), false, false);
- if (res == null || method.equals(res)) {
- return null;
- }
- return TypeUtil.getDeclaringClass(res);
- }
-
-
- private int compareInHierarchy(ITypeHierarchy hierarchy, ICElement def1, ICElement def2) {
- if (isSuperType(hierarchy, def1, def2)) {
- return 1;
- } else if (isSuperType(hierarchy, def2, def1)) {
- return -1;
- }
- String name1= def1.getElementName();
- String name2= def2.getElementName();
-
- return getCollator().compare(name1, name2);
- }
-
- private boolean isSuperType(ITypeHierarchy hierarchy, ICElement def1, ICElement def2) {
- ICElement[] superTypes= hierarchy.getSupertypes(def1);
- if (superTypes != null) {
- for (int i = 0; i < superTypes.length; ++i) {
- if (superTypes[i].equals(def2) || isSuperType(hierarchy, superTypes[i], def2)) {
- return true;
- }
- }
- }
- return false;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java
deleted file mode 100644
index 6bed875b8c4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action used for the type hierarchy forward / backward buttons
- */
-public class HistoryAction extends Action {
-
- private TypeHierarchyViewPart fViewPart;
- private ICElement fElement;
-
- public HistoryAction(TypeHierarchyViewPart viewPart, ICElement element) {
- super();
- fViewPart= viewPart;
- fElement= element;
-
- String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED | CElementLabels.M_PARAMETER_TYPES);
- setText(elementName);
- setImageDescriptor(getImageDescriptor(element));
-
- setDescription(TypeHierarchyMessages.getFormattedString("HistoryAction.description", elementName)); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getFormattedString("HistoryAction.tooltip", elementName)); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.HISTORY_ACTION);
- }
-
- private ImageDescriptor getImageDescriptor(ICElement elem) {
- CElementImageProvider imageProvider= new CElementImageProvider();
- ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
- imageProvider.dispose();
- return desc;
- }
-
- /*
- * @see Action#run()
- */
- public void run() {
- fViewPart.gotoHistoryEntry(fElement);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java
deleted file mode 100644
index 63d83f90fc9..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class HistoryDropDownAction extends Action implements IMenuCreator {
-
-
- public static final int RESULTS_IN_DROP_DOWN= 10;
-
- private TypeHierarchyViewPart fHierarchyView;
- private Menu fMenu;
-
- public HistoryDropDownAction(TypeHierarchyViewPart view) {
- fHierarchyView= view;
- fMenu= null;
- setToolTipText(TypeHierarchyMessages.getString("HistoryDropDownAction.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.TYPEHIERARCHY_HISTORY_ACTION);
- setMenuCreator(this);
- }
-
- public void dispose() {
- // action is reused, can be called several times.
- if (fMenu != null) {
- fMenu.dispose();
- fMenu= null;
- }
- }
-
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- public Menu getMenu(Control parent) {
- if (fMenu != null) {
- fMenu.dispose();
- }
- fMenu= new Menu(parent);
- ICElement[] elements= fHierarchyView.getHistoryEntries();
- boolean checked= addEntries(fMenu, elements);
- if (elements.length > RESULTS_IN_DROP_DOWN) {
- new MenuItem(fMenu, SWT.SEPARATOR);
- Action others= new HistoryListAction(fHierarchyView);
- others.setChecked(checked);
- addActionToMenu(fMenu, others);
- }
- return fMenu;
- }
-
- private boolean addEntries(Menu menu, ICElement[] elements) {
- boolean checked= false;
-
- int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
- for (int i= 0; i < min; i++) {
- HistoryAction action= new HistoryAction(fHierarchyView, elements[i]);
- action.setChecked(elements[i].equals(fHierarchyView.getInputElement()));
- checked= checked || action.isChecked();
- addActionToMenu(menu, action);
- }
- return checked;
- }
-
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- public void run() {
- (new HistoryListAction(fHierarchyView)).run();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java
deleted file mode 100644
index 30e30614575..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class HistoryListAction extends Action {
-
- private class HistoryListDialog extends StatusDialog {
-
- private ListDialogField fHistoryList;
- private IStatus fHistoryStatus;
- private ICElement fResult;
-
- private HistoryListDialog(Shell shell, ICElement[] elements) {
- super(shell);
- setTitle(TypeHierarchyMessages.getString("HistoryListDialog.title")); //$NON-NLS-1$
-
- String[] buttonLabels= new String[] {
- /* 0 */ TypeHierarchyMessages.getString("HistoryListDialog.remove.button"), //$NON-NLS-1$
- };
-
- IListAdapter adapter= new IListAdapter() {
- public void customButtonPressed(ListDialogField field, int index) {
- doCustomButtonPressed();
- }
- public void selectionChanged(ListDialogField field) {
- doSelectionChanged();
- }
-
- public void doubleClicked(ListDialogField field) {
- doDoubleClicked();
- }
- };
-
- CElementLabelProvider labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_QUALIFIED /*| CElementLabelProvider.SHOW_ROOT*/);
-
- fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
- fHistoryList.setLabelText(TypeHierarchyMessages.getString("HistoryListDialog.label")); //$NON-NLS-1$
- fHistoryList.setElements(Arrays.asList(elements));
-
- ISelection sel;
- if (elements.length > 0) {
- sel= new StructuredSelection(elements[0]);
- } else {
- sel= new StructuredSelection();
- }
-
- fHistoryList.selectElements(sel);
- }
-
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
- LayoutUtil.setHeigthHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
- LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null));
-
- applyDialogFont(composite);
- return composite;
- }
-
- /**
- * Method doCustomButtonPressed.
- */
- void doCustomButtonPressed() {
- fHistoryList.removeElements(fHistoryList.getSelectedElements());
- }
-
- void doDoubleClicked() {
- if (fHistoryStatus.isOK()) {
- okPressed();
- }
- }
-
-
- void doSelectionChanged() {
- StatusInfo status= new StatusInfo();
- List selected= fHistoryList.getSelectedElements();
- if (selected.size() != 1) {
- status.setError(""); //$NON-NLS-1$
- fResult= null;
- } else {
- fResult= (ICElement) selected.get(0);
- }
- fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
- fHistoryStatus= status;
- updateStatus(status);
- }
-
- public ICElement getResult() {
- return fResult;
- }
-
- public ICElement[] getRemaining() {
- List elems= fHistoryList.getElements();
- return (ICElement[]) elems.toArray(new ICElement[elems.size()]);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- WorkbenchHelp.setHelp(newShell, ICHelpContextIds.HISTORY_LIST_DIALOG);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#create()
- */
- public void create() {
- setShellStyle(getShellStyle() | SWT.RESIZE);
- super.create();
- }
-
- }
-
- private TypeHierarchyViewPart fView;
-
- public HistoryListAction(TypeHierarchyViewPart view) {
- fView= view;
- setText(TypeHierarchyMessages.getString("HistoryListAction.label")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.HISTORY_LIST_ACTION);
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- ICElement[] historyEntries= fView.getHistoryEntries();
- HistoryListDialog dialog= new HistoryListDialog(CUIPlugin.getActiveWorkbenchShell(), historyEntries);
- if (dialog.open() == Window.OK) {
- fView.setHistoryEntries(dialog.getRemaining());
- fView.setInputElement(dialog.getResult());
- }
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java
deleted file mode 100644
index c21589314d8..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-/**
- * Used by the TypeHierarchyLifeCycle to inform listeners about a change in the
- * type hierarchy
- */
-public interface ITypeHierarchyLifeCycleListener {
-
- /**
- * A Java element changed.
- */
- void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchyProvider, ICElement[] changedTypes);
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java
deleted file mode 100644
index 04a93e376f4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.ui.IViewPart;
-
-/**
- * The standard type hierarchy view presents a type hierarchy for a given input class
- * or interface. Visually, this view consists of a pair of viewers, one showing the type
- * hierarchy, the other showing the members of the type selected in the first.
- * null
- * to clear any input element
- * @deprecated use setInputElement instead
- */
- public void setInput(ICElement type);
-
- /**
- * Sets the input element of this type hierarchy view. The following input types are possible
- * IMember
(types, methods, fields..), IPackageFragment
, IPackageFragmentRoot
- * and IJavaProject
.
- *
- * @param element the input element of this type hierarchy view, or null
- * to clear any input
- *
- * @since 2.0
- */
- public void setInputElement(ICElement element);
-
- /**
- * Returns the input element of this type hierarchy view.
- *
- * @return the input element, or null
if no input element is set
- * @see #setInput(IType)
- * @deprecated use getInputElement instead
- */
- public ICElement getInput();
-
-
- /**
- * Returns the input element of this type hierarchy view.
- *
- * @return the input element, or null
if no input element is set
- * @see #setInputElement(IJavaElement)
- *
- * @since 2.0
- */
- public ICElement getInputElement();
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java
deleted file mode 100644
index 1370a46d5ee..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.CElementContentProvider;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Content provider used for the method view.
- * Allows also seeing methods inherited from base classes.
- */
-public class MethodsContentProvider extends CElementContentProvider //implements IStructuredContentProvider //, IWorkingCopyProvider
-{
- private static final Object[] NO_ELEMENTS = new Object[0];
-
- private boolean fShowInheritedMethods;
- private TypeHierarchyLifeCycle fHierarchyLifeCycle;
- private TableViewer fViewer;
-
- public MethodsContentProvider(TypeHierarchyLifeCycle lifecycle) {
- fHierarchyLifeCycle= lifecycle;
- fShowInheritedMethods= false;
- fViewer= null;
- }
-
- /**
- * Turn on / off showing of inherited methods
- */
- public void showInheritedMethods(boolean show) {
- if (show != fShowInheritedMethods) {
- fShowInheritedMethods= show;
- if (fViewer != null) {
- fViewer.refresh();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see IStructuredContentProvider#providesWorkingCopies()
- */
- public boolean providesWorkingCopies() {
- return true;
- }
-
- /**
- * Returns true if inherited methods are shown
- */
- public boolean isShowInheritedMethods() {
- return fShowInheritedMethods;
- }
-
-
- private void addAll(Object[] arr, List res) {
- if (arr != null) {
- for (int j= 0; j < arr.length; j++) {
- res.add(arr[j]);
- }
- }
- }
-
- /*
- * @see IStructuredContentProvider#getElements
- */
- public Object[] getElements(Object element) {
- if (element instanceof ICElement) {
- ICElement type= (ICElement)element;
-
- List res= new ArrayList();
-// try {
- ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
- if (fShowInheritedMethods && hierarchy != null) {
- ICElement[] allSupertypes= hierarchy.getAllSupertypes(type);
- // sort in from last to first: elements with same name
- // will show up in hierarchy order
- for (int i= allSupertypes.length - 1; i >= 0; i--) {
- ICElement superType= allSupertypes[i];
- if (superType.exists()) {
- addAll(TypeUtil.getMethods(superType), res);
- //addAll(TypeUtil.getInitializers(superType), res);
- addAll(TypeUtil.getFields(superType), res);
- }
- }
- }
- if (type.exists()) {
- addAll(TypeUtil.getMethods(type), res);
- //addAll(TypeUtil.getInitializers(type), res);
- addAll(TypeUtil.getFields(type), res);
- }
-// } catch (CModelException e) {
-// CUIPlugin.getDefault().log(e);
-// }
- return res.toArray();
- }
- return NO_ELEMENTS;
- }
-
-
- /*
- * @see IContentProvider#inputChanged
- */
- public void inputChanged(Viewer input, Object oldInput, Object newInput) {
- Assert.isTrue(input instanceof TableViewer);
-
- fViewer= (TableViewer) input;
- }
-
- /*
- * @see IContentProvider#dispose
- */
- public void dispose() {
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java
deleted file mode 100644
index 9ee430af59a..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Label provider for the hierarchy method viewers.
- */
-public class MethodsLabelProvider extends StandardCElementLabelProvider //extends AppearanceAwareLabelProvider
-{
- private Color fResolvedBackground;
-
- private boolean fShowDefiningType;
- private TypeHierarchyLifeCycle fHierarchy;
- private MethodsViewer fMethodsViewer;
-
- public MethodsLabelProvider(TypeHierarchyLifeCycle lifeCycle, MethodsViewer methodsViewer) {
-// super(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS);
- super();
- fHierarchy= lifeCycle;
- fShowDefiningType= false;
- fMethodsViewer= methodsViewer;
- fResolvedBackground= null;
- }
-
- public void setShowDefiningType(boolean showDefiningType) {
- fShowDefiningType= showDefiningType;
- }
-
- public boolean isShowDefiningType() {
- return fShowDefiningType;
- }
-
-
- private ICElement getDefiningType(Object element) throws CModelException {
- if (!(element instanceof ICElement))
- return null;
-
- ICElement elem = (ICElement) element;
- int kind= elem.getElementType();
- if (kind != ICElement.C_METHOD_DECLARATION && kind != ICElement.C_FIELD) {
- return null;
- }
- ICElement declaringType= TypeUtil.getDeclaringClass(elem);
- if (kind != ICElement.C_METHOD_DECLARATION) {
- return declaringType;
- }
- ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
- if (hierarchy == null) {
- return declaringType;
- }
- IMethodDeclaration method= (IMethodDeclaration) element;
- if ((method.getVisibility() == ASTAccessVisibility.PRIVATE) || method.isStatic() || method.isConstructor() || method.isDestructor()) {
- return declaringType;
- }
- IMethodDeclaration res= TypeUtil.findMethodDeclarationInHierarchy(hierarchy, declaringType, method.getElementName(), method.getParameterTypes(), false, false);
- if (res == null || method.equals(res)) {
- return declaringType;
- }
- return TypeUtil.getDeclaringClass(res);
- }
-
- /* (non-Javadoc)
- * @see ILabelProvider#getText
- */
- public String getText(Object element) {
- String text= super.getText(element);
- if ((getTextFlags() & CElementLabels.M_POST_QUALIFIED) != 0) {
- if (element instanceof ICElement) {
- ICElement parent = ((ICElement)element).getParent();
- if (parent != null) {
- StringBuffer name = new StringBuffer();
- name.append(text);
- name.append(CElementLabels.CONCAT_STRING);
- name.append(TypeUtil.getFullyQualifiedName(parent).toString());
- text = name.toString();
- }
- }
- }
-
- if (fShowDefiningType) {
- try {
- ICElement type= getDefiningType(element);
- if (type != null) {
- StringBuffer buf= new StringBuffer(super.getText(type));
- buf.append(CElementLabels.CONCAT_STRING);
- buf.append(text);
- return buf.toString();
- }
- } catch (CModelException e) {
- }
- }
- return text;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- if (fMethodsViewer.isShowInheritedMethods() && element instanceof IMethod) {
- IMethod curr= (IMethod) element;
- ICElement declaringType= TypeUtil.getDeclaringClass(curr);
-
- if (declaringType.equals(fMethodsViewer.getInput())) {
- if (fResolvedBackground == null) {
- Display display= Display.getCurrent();
- fResolvedBackground= display.getSystemColor(SWT.COLOR_DARK_BLUE);
- }
- return fResolvedBackground;
- }
- }
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java
deleted file mode 100644
index f1040498259..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
-import org.eclipse.cdt.internal.ui.util.SelectionUtil;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-/**
- * Method viewer shows a list of methods of a input type.
- * Offers filter actions.
- * No dependency to the type hierarchy view
- */
-public class MethodsViewer extends ProblemTableViewer {
-
- private static final String TAG_SHOWINHERITED= "showinherited"; //$NON-NLS-1$
- private static final String TAG_SORTBYDEFININGTYPE= "sortbydefiningtype"; //$NON-NLS-1$
- private static final String TAG_VERTICAL_SCROLL= "mv_vertical_scroll"; //$NON-NLS-1$
-
- private MethodsLabelProvider fLabelProvider;
-
- private MemberFilterActionGroup fMemberFilterActionGroup;
-
-// private OpenAction fOpen;
- private ShowInheritedMembersAction fShowInheritedMembersAction;
- private SortByDefiningTypeAction fSortByDefiningTypeAction;
-
- public MethodsViewer(Composite parent, final TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(new Table(parent, SWT.MULTI));
-
- fLabelProvider= new MethodsLabelProvider(lifeCycle, this);
-
-// setLabelProvider(new DecoratingCLabelProvider(fLabelProvider, true));
- setLabelProvider(fLabelProvider);
- setContentProvider(new MethodsContentProvider(lifeCycle));
-
- HierarchyViewerSorter sorter= new HierarchyViewerSorter(lifeCycle);
- sorter.setSortByDefiningType(false);
- setSorter(sorter);
-
-// fOpen= new OpenAction(part.getSite());
-// addOpenListener(new IOpenListener() {
-// public void open(OpenEvent event) {
-// fOpen.run();
-// }
-// });
-
- fMemberFilterActionGroup= new MemberFilterActionGroup(this, "HierarchyMethodView", false, MemberFilterActionGroup.ALL_FILTERS & ~MemberFilterActionGroup.FILTER_LOCALTYPES); //$NON-NLS-1$
-
- fShowInheritedMembersAction= new ShowInheritedMembersAction(this, false);
- fSortByDefiningTypeAction= new SortByDefiningTypeAction(this, false);
-
- showInheritedMethodsNoRedraw(false);
- sortByDefiningTypeNoRedraw(false);
-
-// CUIHelp.setHelp(this, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
- }
-
- private void showInheritedMethodsNoRedraw(boolean on) {
- MethodsContentProvider cprovider= (MethodsContentProvider) getContentProvider();
- cprovider.showInheritedMethods(on);
- fShowInheritedMembersAction.setChecked(on);
- if (on) {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() | CElementLabels.T_POST_QUALIFIED);
- } else {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() & ~CElementLabels.T_POST_QUALIFIED);
- }
- if (on) {
- sortByDefiningTypeNoRedraw(false);
- }
- fSortByDefiningTypeAction.setEnabled(!on);
-
- }
-
- /**
- * Show inherited methods
- */
- public void showInheritedMethods(boolean on) {
- if (on == isShowInheritedMethods()) {
- return;
- }
- try {
- getTable().setRedraw(false);
- showInheritedMethodsNoRedraw(on);
- refresh();
- } finally {
- getTable().setRedraw(true);
- }
- }
-
- private void sortByDefiningTypeNoRedraw(boolean on) {
- fSortByDefiningTypeAction.setChecked(on);
- fLabelProvider.setShowDefiningType(on);
- ((HierarchyViewerSorter) getSorter()).setSortByDefiningType(on);
- }
-
- /**
- * Show the name of the defining type
- */
- public void sortByDefiningType(boolean on) {
- if (on == isShowDefiningTypes()) {
- return;
- }
- try {
- getTable().setRedraw(false);
- sortByDefiningTypeNoRedraw(on);
- refresh();
- } finally {
- getTable().setRedraw(true);
- }
- }
-
- /*
- * @see Viewer#inputChanged(Object, Object)
- */
- protected void inputChanged(Object input, Object oldInput) {
- super.inputChanged(input, oldInput);
- }
-
- /**
- * Returns true
if inherited methods are shown.
- */
- public boolean isShowInheritedMethods() {
- return ((MethodsContentProvider) getContentProvider()).isShowInheritedMethods();
- }
-
- /**
- * Returns true
if defining types are shown.
- */
- public boolean isShowDefiningTypes() {
- return fLabelProvider.isShowDefiningType();
- }
-
- /**
- * Saves the state of the filter actions
- */
- public void saveState(IMemento memento) {
- fMemberFilterActionGroup.saveState(memento);
-
- memento.putString(TAG_SHOWINHERITED, String.valueOf(isShowInheritedMethods()));
- memento.putString(TAG_SORTBYDEFININGTYPE, String.valueOf(isShowDefiningTypes()));
-
- ScrollBar bar= getTable().getVerticalBar();
- int position= bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_VERTICAL_SCROLL, String.valueOf(position));
- }
-
- /**
- * Restores the state of the filter actions
- */
- public void restoreState(IMemento memento) {
- fMemberFilterActionGroup.restoreState(memento);
- getControl().setRedraw(false);
- refresh();
- getControl().setRedraw(true);
-
- boolean showInherited= Boolean.valueOf(memento.getString(TAG_SHOWINHERITED)).booleanValue();
- showInheritedMethods(showInherited);
-
- boolean showDefiningTypes= Boolean.valueOf(memento.getString(TAG_SORTBYDEFININGTYPE)).booleanValue();
- sortByDefiningType(showDefiningTypes);
-
- ScrollBar bar= getTable().getVerticalBar();
- if (bar != null) {
- Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
- if (vScroll != null) {
- bar.setSelection(vScroll.intValue());
- }
- }
- }
-
- /**
- * Attaches a contextmenu listener to the table
- */
- public void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) {
- MenuManager menuMgr= new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(menuListener);
- Menu menu= menuMgr.createContextMenu(getTable());
- getTable().setMenu(menu);
- viewSite.registerContextMenu(popupId, menuMgr, this);
- }
-
-
- /**
- * Fills up the context menu with items for the method viewer
- * Should be called by the creator of the context menu
- */
- public void contributeToContextMenu(IMenuManager menu) {
- }
-
- /**
- * Fills up the tool bar with items for the method viewer
- * Should be called by the creator of the tool bar
- */
- public void contributeToToolBar(ToolBarManager tbm) {
- tbm.add(fShowInheritedMembersAction);
- tbm.add(fSortByDefiningTypeAction);
- tbm.add(new Separator());
- fMemberFilterActionGroup.contributeToToolBar(tbm);
- }
-
- public void dispose() {
- if (fMemberFilterActionGroup != null) {
- fMemberFilterActionGroup.dispose();
- fMemberFilterActionGroup= null;
- }
- }
-
- /*
- * @see StructuredViewer#handleInvalidSelection(ISelection, ISelection)
- */
- protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
- // on change of input, try to keep selected methods stable by selecting a method with the same
- // signature: See #5466
- List oldSelections= SelectionUtil.toList(invalidSelection);
- List newSelections= SelectionUtil.toList(newSelection);
- if (!oldSelections.isEmpty()) {
- ArrayList newSelectionElements= new ArrayList(newSelections);
- try {
- Object[] currElements= getFilteredChildren(getInput());
- for (int i= 0; i < oldSelections.size(); i++) {
- Object curr= oldSelections.get(i);
- if (curr instanceof IMethodDeclaration && !newSelections.contains(curr)) {
- IMethodDeclaration method= (IMethodDeclaration) curr;
- if (method.exists()) {
- IMethodDeclaration similar= findSimilarMethod(method, currElements);
- if (similar != null) {
- newSelectionElements.add(similar);
- }
- }
- }
- }
- if (!newSelectionElements.isEmpty()) {
- newSelection= new StructuredSelection(newSelectionElements);
- } else if (currElements.length > 0) {
- newSelection= new StructuredSelection(currElements[0]);
- }
- } catch (CModelException e) {
- CUIPlugin.getDefault().log(e);
- }
- }
- setSelection(newSelection);
- updateSelection(newSelection);
- }
-
- private IMethodDeclaration findSimilarMethod(IMethodDeclaration meth, Object[] elements) throws CModelException {
- String name= meth.getElementName();
- String[] paramTypes= meth.getParameterTypes();
- boolean isConstructor= meth.isConstructor();
- boolean isDestructor= meth.isDestructor();
-
- for (int i= 0; i < elements.length; i++) {
- Object curr= elements[i];
- if (curr instanceof IMethodDeclaration && TypeUtil.isSameMethodSignature(name, paramTypes, isConstructor, isDestructor, (IMethodDeclaration) curr)) {
- return (IMethodDeclaration) curr;
- }
- }
- return null;
- }
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java
deleted file mode 100644
index 4df1fadc382..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.ICStatusConstants;
-import org.eclipse.cdt.internal.ui.actions.ActionMessages;
-import org.eclipse.cdt.internal.ui.actions.ActionUtil;
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * This action opens a type hierarchy on the selected type.
- * IType
.
- *
- * OpenTypeHierarchyAction
. The action requires
- * that the selection provided by the site's selection provider is of type
- * org.eclipse.jface.viewers.IStructuredSelection
.
- *
- * @param site the site providing context information for this action
- */
- public OpenTypeHierarchyAction(IWorkbenchSite site) {
- super(site);
- setText(ActionMessages.getString("OpenTypeHierarchyAction.label")); //$NON-NLS-1$
- setToolTipText(ActionMessages.getString("OpenTypeHierarchyAction.tooltip")); //$NON-NLS-1$
- setDescription(ActionMessages.getString("OpenTypeHierarchyAction.description")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_TYPE_HIERARCHY_ACTION);
- }
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- */
- public OpenTypeHierarchyAction(CEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(ITextSelection selection) {
-/* boolean enable = true;
- ICElement selectedElement = null;
- try {
- ICElement[] elements = SelectionConverter.getElementsAtOffset(fEditor);
- if (elements == null || elements.length == 0) {
- setEnabled(false);
- return;
- }
- // find class or struct
- for (int i = 0; i < elements.length; ++i) {
- if (TypeUtil.isClassOrStruct(elements[i])) {
- selectedElement = elements[i];
- break;
- }
- }
-
- if (selectedElement == null) {
- setEnabled(false);
- return;
- }
- } catch (CModelException e) {
- setEnabled(false);
- return;
- }
-
- ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
-
- if (textSelection == null) {
- setEnabled(false);
- return;
- }
-
- if( (((CElement)selectedElement).getIdStartPos() != textSelection.getOffset())
- || (((CElement)selectedElement).getIdLength() != textSelection.getLength())) {
- enable = false;
- }
- setEnabled(enable);
-*/ }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(isEnabled(selection));
- }
-
- private boolean isEnabled(IStructuredSelection selection) {
- if (selection.size() != 1)
- return false;
- Object input= selection.getFirstElement();
- if (input instanceof ICElement) {
- ICElement elem = (ICElement)input;
- return TypeUtil.isClassOrStruct(elem);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(ITextSelection selection) {
- ICElement input= SelectionConverter.getInput(fEditor);
- if (!ActionUtil.isProcessable(getShell(), input))
- return;
-
- ICElement[] elements= SelectionConverter.codeResolveOrInputHandled(fEditor, getShell(), getDialogTitle());
- if (elements == null)
- return;
- List candidates= new ArrayList(elements.length);
- for (int i= 0; i < elements.length; i++) {
- ICElement elem = elements[i];
- if (elem instanceof ITranslationUnit) {
- ICElement[] realElems = findTypeDeclarations(selection.getText(), (ITranslationUnit)elem, selection.getOffset(), selection.getLength(), new NullProgressMonitor());
- if (realElems != null) {
- for (int j = 0; j < realElems.length; ++j) {
- ICElement[] resolvedElements= OpenTypeHierarchyUtil.getCandidates(realElems[j]);
- if (resolvedElements != null)
- candidates.addAll(Arrays.asList(resolvedElements));
- }
- }
- } else {
- ICElement[] resolvedElements= OpenTypeHierarchyUtil.getCandidates(elem);
- if (resolvedElements != null)
- candidates.addAll(Arrays.asList(resolvedElements));
- }
- }
- run((ICElement[])candidates.toArray(new ICElement[candidates.size()]));
- }
-
- private ICElement[] findTypeDeclarations(String name, ITranslationUnit unit, int offset, int length, IProgressMonitor monitor) {
- final ITypeSearchScope wsScope = new TypeSearchScope(true);
- if (!AllTypesCache.isCacheUpToDate(wsScope)) {
- AllTypesCache.updateCache(wsScope, monitor);
- }
- ITypeSearchScope projectScope = new TypeSearchScope();
- projectScope.add(unit.getCProject());
- int[] kinds = {ICElement.C_CLASS, ICElement.C_STRUCT};
- ITypeInfo[] types = AllTypesCache.getTypes(projectScope, new QualifiedTypeName(name), kinds, true);
- if (types != null) {
- List elements = new ArrayList(types.length);
- for (int i = 0; i < types.length; ++i) {
- ICElement e = AllTypesCache.getElementForType(types[i], true, true, monitor);
- if (e != null && !elements.contains(e))
- elements.add(e);
- }
- if (!elements.isEmpty())
- return (ICElement[])elements.toArray(new ICElement[elements.size()]);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(IStructuredSelection selection) {
- if (selection.size() != 1)
- return;
- Object input= selection.getFirstElement();
-
- if (!(input instanceof ICElement)) {
- IStatus status= createStatus(ActionMessages.getString("OpenTypeHierarchyAction.messages.no_c_element")); //$NON-NLS-1$
- ErrorDialog.openError(getShell(), getDialogTitle(), ActionMessages.getString("OpenTypeHierarchyAction.messages.title"), status); //$NON-NLS-1$
- return;
- }
- ICElement element= (ICElement) input;
- if (!ActionUtil.isProcessable(getShell(), element))
- return;
-
- List result= new ArrayList(1);
- IStatus status= compileCandidates(result, element);
- if (status.isOK()) {
- run((ICElement[]) result.toArray(new ICElement[result.size()]));
- } else {
- ErrorDialog.openError(getShell(), getDialogTitle(), ActionMessages.getString("OpenTypeHierarchyAction.messages.title"), status); //$NON-NLS-1$
- }
- }
-
- public void run(ICElement[] elements) {
- if (elements.length == 0) {
- getShell().getDisplay().beep();
- return;
- }
- OpenTypeHierarchyUtil.open(elements, getSite().getWorkbenchWindow());
- }
-
- private static String getDialogTitle() {
- return ActionMessages.getString("OpenTypeHierarchyAction.dialog.title"); //$NON-NLS-1$
- }
-
- private static IStatus compileCandidates(List result, ICElement elem) {
- IStatus ok = new Status(IStatus.OK, CUIPlugin.getPluginId(), 0, "", null); //$NON-NLS-1$
- switch (elem.getElementType()) {
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_PROJECT:
- result.add(elem);
- return ok;
- }
- return createStatus(ActionMessages.getString("OpenTypeHierarchyAction.messages.no_valid_c_element")); //$NON-NLS-1$
- }
-
- private static IStatus createStatus(String message) {
- return new Status(IStatus.INFO, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR, message, null);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
deleted file mode 100644
index 196b49258b7..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.WorkbenchException;
-
-public class OpenTypeHierarchyUtil {
-
- private OpenTypeHierarchyUtil() {
- }
-
- public static TypeHierarchyViewPart open(ICElement element, IWorkbenchWindow window) {
- ICElement[] candidates= getCandidates(element);
- if (candidates != null) {
- return open(candidates, window);
- }
- return null;
- }
-
- public static TypeHierarchyViewPart open(ICElement[] candidates, IWorkbenchWindow window) {
- Assert.isTrue(candidates != null && candidates.length != 0);
-
- ICElement input= null;
- if (candidates.length > 1) {
- String title= CUIMessages.getString("OpenTypeHierarchyUtil.selectionDialog.title"); //$NON-NLS-1$
- String message= CUIMessages.getString("OpenTypeHierarchyUtil.selectionDialog.message"); //$NON-NLS-1$
- input= OpenActionUtil.selectCElement(candidates, window.getShell(), title, message);
- } else {
- input= candidates[0];
- }
- if (input == null)
- return null;
-
- try {
- if (PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE.equals(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.OPEN_TYPE_HIERARCHY))) {
- return openInPerspective(window, input);
- }
- return openInViewPart(window, input);
-
- } catch (WorkbenchException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CUIMessages.getString("OpenTypeHierarchyUtil.error.open_perspective"), //$NON-NLS-1$
- e.getMessage());
- } catch (CModelException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CUIMessages.getString("OpenTypeHierarchyUtil.error.open_editor"), //$NON-NLS-1$
- e.getMessage());
- }
- return null;
- }
-
- private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, ICElement input) {
- IWorkbenchPage page= window.getActivePage();
- try {
- TypeHierarchyViewPart result= (TypeHierarchyViewPart) page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
- if (result != null) {
- result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
- }
- result= (TypeHierarchyViewPart) page.showView(CUIPlugin.ID_TYPE_HIERARCHY);
- result.setInputElement(input);
-
- if (input instanceof IMember) {
- result.selectMember(input);
- }
- return result;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CUIMessages.getString("OpenTypeHierarchyUtil.error.open_view"), e.getMessage()); //$NON-NLS-1$
- }
- return null;
- }
-
- private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, ICElement input) throws WorkbenchException, CModelException {
- IWorkbench workbench= CUIPlugin.getDefault().getWorkbench();
- // The problem is that the input element can be a working copy. So we first convert it to the original element if
- // it exists.
- ICElement perspectiveInput= input;
-
- if (input instanceof IMember) {
-// if (input.getElementType() != ITypeElement.TYPE) {
- if (TypeUtil.isClassOrStruct(input)) {
-// perspectiveInput= ((IMember)input).getDeclaringType();
- perspectiveInput= TypeUtil.getDeclaringClass(input);
- } else {
- perspectiveInput= input;
- }
- }
- IWorkbenchPage page= workbench.showPerspective(CUIPlugin.ID_CHIERARCHY_PERSPECTIVE, window, perspectiveInput);
-
- TypeHierarchyViewPart part= (TypeHierarchyViewPart) page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
- if (part != null) {
- part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
- }
- part= (TypeHierarchyViewPart) page.showView(CUIPlugin.ID_TYPE_HIERARCHY);
- part.setInputElement(perspectiveInput);
- if (input instanceof IMember) {
- part.selectMember(input);
-
- if (page.getEditorReferences().length == 0) {
- openEditor(input, false); // only open when the perspecive has been created
- }
- }
- return part;
- }
-
- private static void openEditor(Object input, boolean activate) throws PartInitException, CModelException {
- IEditorPart part= EditorUtility.openInEditor(input, activate);
- if (input instanceof ICElement)
- EditorUtility.revealInEditor(part, (ICElement) input);
- }
-
- /**
- * Converts the input to a possible input candidates
- */
- public static ICElement[] getCandidates(Object input) {
- if (!(input instanceof ICElement)) {
- return null;
- }
- try {
- ICElement elem= (ICElement) input;
- switch (elem.getElementType()) {
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_FIELD:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF:
- return new ICElement[] { TypeUtil.getDeclaringClass(elem) };
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- return new ICElement[] { elem };
- case ICElement.C_NAMESPACE:
- return TypeUtil.getTypes(elem);
- case ICElement.C_UNIT: {
- ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
- if (cu != null) {
- return TypeUtil.getTypes(cu);
- }
- break;
- }
- case ICElement.C_PROJECT:
- default:
- }
- } catch (CModelException e) {
- CUIPlugin.getDefault().log(e);
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java
deleted file mode 100644
index d24e9017f45..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
-
-public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate {
-
- private IWorkbenchWindow fWindow;
-
- public OpenTypeInHierarchyAction() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- final ITypeSearchScope fScope = new TypeSearchScope(true);
- if (!AllTypesCache.isCacheUpToDate(fScope)) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.updateCache(fScope, monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- return;
- }
- }
-
- ITypeInfo[] elements = AllTypesCache.getAllTypes();
- if (elements.length == 0) {
- String title = OpenTypeMessages.getString("OpenTypeAction.notypes.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.notypes.message"); //$NON-NLS-1$
- MessageDialog.openInformation(getShell(), title, message);
- return;
- }
-
- OpenTypeInHierarchyDialog dialog = new OpenTypeInHierarchyDialog(getShell());
- dialog.setElements(elements);
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
- if (info == null)
- return;
-
- ICElement celem = AllTypesCache.getElementForType(info, false, true, null);
- if (celem != null) {
- OpenTypeHierarchyUtil.open(new ICElement[] { celem }, fWindow);
- }
- }
-
- protected Shell getShell() {
- return CUIPlugin.getActiveWorkbenchShell();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- fWindow= null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyDialog.java
deleted file mode 100644
index 2ca3d200f54..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyDialog.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- * QNX Software Systems - adapted for use in CDT
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A dialog to select a type from a list of types. The selected type will be
- * opened in the editor.
- */
-public class OpenTypeInHierarchyDialog extends TypeSelectionDialog {
-
- private static final String DIALOG_SETTINGS= OpenTypeInHierarchyDialog.class.getName();
- private final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
-
- /**
- * Constructs an instance of OpenTypeDialog
.
- * @param parent the parent shell.
- */
- public OpenTypeInHierarchyDialog(Shell parent) {
- super(parent);
- setTitle(TypeHierarchyMessages.getString("OpenTypeInHierarchyDialog.title")); //$NON-NLS-1$
- setMessage(TypeHierarchyMessages.getString("OpenTypeInHierarchyDialog.message")); //$NON-NLS-1$
- setVisibleTypes(VISIBLE_TYPES);
- setDialogSettings(DIALOG_SETTINGS);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java
deleted file mode 100644
index 634e95db028..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-
-/**
- * A selection provider for viewparts with more that one viewer.
- * Tracks the focus of the viewers to provide the correct selection.
- */
-public class SelectionProviderMediator implements IPostSelectionProvider {
-
- private class InternalListener implements ISelectionChangedListener, FocusListener {
- /*
- * @see ISelectionChangedListener#selectionChanged
- */
- public void selectionChanged(SelectionChangedEvent event) {
- doSelectionChanged(event);
- }
-
- /*
- * @see FocusListener#focusGained
- */
- public void focusGained(FocusEvent e) {
- doFocusChanged(e.widget);
- }
-
- /*
- * @see FocusListener#focusLost
- */
- public void focusLost(FocusEvent e) {
- // do not reset due to focus behaviour on GTK
- //fViewerInFocus= null;
- }
- }
-
- private class InternalPostSelectionListener implements ISelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent event) {
- doPostSelectionChanged(event);
- }
-
- }
-
- private StructuredViewer[] fViewers;
-
- private StructuredViewer fViewerInFocus;
- private ListenerList fSelectionChangedListeners;
- private ListenerList fPostSelectionChangedListeners;
-
- /**
- * @param viewers All viewers that can provide a selection
- */
- public SelectionProviderMediator(StructuredViewer[] viewers) {
- Assert.isNotNull(viewers);
- fViewers= viewers;
- InternalListener listener= new InternalListener();
- fSelectionChangedListeners= new ListenerList(4);
- fPostSelectionChangedListeners= new ListenerList(4);
- fViewerInFocus= null;
-
- for (int i= 0; i < fViewers.length; i++) {
- StructuredViewer viewer= fViewers[i];
- viewer.addSelectionChangedListener(listener);
- viewer.addPostSelectionChangedListener(new InternalPostSelectionListener());
- Control control= viewer.getControl();
- control.addFocusListener(listener);
- }
- }
-
- void doFocusChanged(Widget control) {
- for (int i= 0; i < fViewers.length; i++) {
- if (fViewers[i].getControl() == control) {
- propagateFocusChanged(fViewers[i]);
- return;
- }
- }
- }
-
- final void doPostSelectionChanged(SelectionChangedEvent event) {
- ISelectionProvider provider= event.getSelectionProvider();
- if (provider == fViewerInFocus) {
- firePostSelectionChanged();
- }
- }
-
- final void doSelectionChanged(SelectionChangedEvent event) {
- ISelectionProvider provider= event.getSelectionProvider();
- if (provider == fViewerInFocus) {
- fireSelectionChanged();
- }
- }
-
- final void propagateFocusChanged(StructuredViewer viewer) {
- if (viewer != fViewerInFocus) { // Ok to compare by idendity
- fViewerInFocus= viewer;
- fireSelectionChanged();
- firePostSelectionChanged();
- }
- }
-
- private void fireSelectionChanged() {
- if (fSelectionChangedListeners != null) {
- SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
-
- Object[] listeners= fSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
- listener.selectionChanged(event);
- }
- }
- }
-
- private void firePostSelectionChanged() {
- if (fPostSelectionChangedListeners != null) {
- SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
-
- Object[] listeners= fPostSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
- listener.selectionChanged(event);
- }
- }
- }
-
- /*
- * @see ISelectionProvider#addSelectionChangedListener
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- fSelectionChangedListeners.add(listener);
- }
-
- /*
- * @see ISelectionProvider#removeSelectionChangedListener
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- fSelectionChangedListeners.remove(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- fPostSelectionChangedListeners.add(listener);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- fPostSelectionChangedListeners.remove(listener);
- }
-
- /*
- * @see ISelectionProvider#getSelection
- */
- public ISelection getSelection() {
- if (fViewerInFocus != null) {
- return fViewerInFocus.getSelection();
- }
- return StructuredSelection.EMPTY;
- }
-
- /*
- * @see ISelectionProvider#setSelection
- */
- public void setSelection(ISelection selection) {
- if (fViewerInFocus != null) {
- fViewerInFocus.setSelection(selection);
- }
- }
-
- /**
- * Returns the viewer in focus or null if no viewer has the focus
- */
- public StructuredViewer getViewerInFocus() {
- return fViewerInFocus;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java
deleted file mode 100644
index 9d3aa85a8e4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to show / hide inherited members in the method view
- * Depending in the action state a different label provider is installed in the viewer
- */
-public class ShowInheritedMembersAction extends Action {
-
- MethodsViewer fMethodsViewer;
-
- /**
- * Creates the action.
- */
- public ShowInheritedMembersAction(MethodsViewer viewer, boolean initValue) {
- super(TypeHierarchyMessages.getString("ShowInheritedMembersAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ShowInheritedMembersAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ShowInheritedMembersAction.tooltip")); //$NON-NLS-1$
-
-// CPluginImages.setLocalImageDescriptors(this, "inher_co.gif"); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "inher_co.gif"); //$NON-NLS-1$
-
- fMethodsViewer= viewer;
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.SHOW_INHERITED_ACTION);
-
- setChecked(initValue);
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- BusyIndicator.showWhile(fMethodsViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- fMethodsViewer.showInheritedMethods(isChecked());
- }
- });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java
deleted file mode 100644
index 45dcd935e8c..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-
-/**
- * Action enable / disable showing qualified type names
- */
-public class ShowQualifiedTypeNamesAction extends Action {
-
- TypeHierarchyViewPart fView;
-
- public ShowQualifiedTypeNamesAction(TypeHierarchyViewPart v, boolean initValue) {
- super(TypeHierarchyMessages.getString("ShowQualifiedTypeNamesAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ShowQualifiedTypeNamesAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ShowQualifiedTypeNamesAction.tooltip")); //$NON-NLS-1$
-
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_showqualified.gif"); //$NON-NLS-1$
-
- fView= v;
- setChecked(initValue);
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.SHOW_QUALIFIED_NAMES_ACTION);
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- BusyIndicator.showWhile(fView.getSite().getShell().getDisplay(), new Runnable() {
- public void run() {
- fView.showQualifiedTypeNames(isChecked());
- }
- });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java
deleted file mode 100644
index bd4bd21d6d3..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to let the label provider show the defining type of the method
- */
-public class SortByDefiningTypeAction extends Action {
-
- MethodsViewer fMethodsViewer;
-
- /**
- * Creates the action.
- */
- public SortByDefiningTypeAction(MethodsViewer viewer, boolean initValue) {
- super(TypeHierarchyMessages.getString("SortByDefiningTypeAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("SortByDefiningTypeAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("SortByDefiningTypeAction.tooltip")); //$NON-NLS-1$
-
-// CPluginImages.setLocalImageDescriptors(this, "definingtype_sort_co.gif"); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "definingtype_sort_co.gif"); //$NON-NLS-1$
-
- fMethodsViewer= viewer;
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.SORT_BY_DEFINING_TYPE_ACTION);
-
- setChecked(initValue);
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- BusyIndicator.showWhile(fMethodsViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- fMethodsViewer.sortByDefiningType(isChecked());
- }
- });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java
deleted file mode 100644
index 947dcc37db6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * A viewer including the content provider for the subtype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
- */
-public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
-
- public SubTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle, part);
- }
-
- /*
- * @see TypeHierarchyViewer#getTitle
- */
- public String getTitle() {
- if (isMethodFiltering()) {
- return TypeHierarchyMessages.getString("SubTypeHierarchyViewer.filtered.title"); //$NON-NLS-1$
- }
- return TypeHierarchyMessages.getString("SubTypeHierarchyViewer.title"); //$NON-NLS-1$
- }
-
- /*
- * @see TypeHierarchyViewer#updateContent
- */
- public void updateContent(boolean expand) {
- getTree().setRedraw(false);
- refresh();
-
- if (expand) {
- int expandLevel= 2;
- if (isMethodFiltering()) {
- expandLevel++;
- }
- expandToLevel(expandLevel);
- }
- getTree().setRedraw(true);
- }
-
- /**
- * Content provider for the subtype hierarchy
- */
- public static class SubTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SubTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
- super(lifeCycle);
- }
-
- protected final void getTypesInHierarchy(ICElement type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- ICElement[] types= hierarchy.getSubtypes(type);
- if (types != null) {
- for (int i= 0; i < types.length; i++) {
- res.add(types[i]);
- }
- }
- }
-
- }
-
- protected ICElement[] getParentTypes(ICElement type) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- return hierarchy.getSupertypes(type);
- // dont handle interfaces
- }
- return null;
- }
-
-}
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java
deleted file mode 100644
index 30ceb991caa..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * A viewer including the content provider for the supertype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
- */
-public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
-
- public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle, part);
- }
-
- /*
- * @see TypeHierarchyViewer#getTitle
- */
- public String getTitle() {
- if (isMethodFiltering()) {
- return TypeHierarchyMessages.getString("SuperTypeHierarchyViewer.filtered.title"); //$NON-NLS-1$
- }
- return TypeHierarchyMessages.getString("SuperTypeHierarchyViewer.title"); //$NON-NLS-1$
- }
-
- /*
- * @see TypeHierarchyViewer#updateContent
- */
- public void updateContent(boolean expand) {
- getTree().setRedraw(false);
- refresh();
- if (expand) {
- expandAll();
- }
- getTree().setRedraw(true);
- }
-
- /*
- * Content provider for the supertype hierarchy
- */
- public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
- super(lifeCycle);
- }
-
- protected final void getTypesInHierarchy(ICElement type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- ICElement[] types= hierarchy.getSupertypes(type);
- for (int i= 0; i < types.length; i++) {
- res.add(types[i]);
- }
- }
- }
-
- protected ICElement[] getParentTypes(ICElement type) {
- // cant handle
- return null;
- }
-
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java
deleted file mode 100644
index e3d2f4ca1c6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
-
-
-/**
- * This action toggles whether the type hierarchy links its selection to the active
- * editor.
- *
- * @since 3.0
- */
-public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- TypeHierarchyViewPart fHierarchyViewPart;
-
- /**
- * Constructs a new action.
- */
- public ToggleLinkingAction(TypeHierarchyViewPart part) {
- setChecked(part.isLinkingEnabled());
- fHierarchyViewPart= part;
- }
-
- /**
- * Runs the action.
- */
- public void run() {
- fHierarchyViewPart.setLinkingEnabled(isChecked());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java
deleted file mode 100644
index fbfabb3bba6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Toggles the orientationof the layout of the type hierarchy
- */
-public class ToggleOrientationAction extends Action {
-
- private TypeHierarchyViewPart fView;
- private int fActionOrientation;
-
- public ToggleOrientationAction(TypeHierarchyViewPart v, int orientation) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.horizontal.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.horizontal.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.horizontal.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_horizontal.gif"); //$NON-NLS-1$
- } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_VERTICAL) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.vertical.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.vertical.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.vertical.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_vertical.gif"); //$NON-NLS-1$
- } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.automatic.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.automatic.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.automatic.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_automatic.gif"); //$NON-NLS-1$
- } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_SINGLE) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.single.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.single.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.single.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_single.gif"); //$NON-NLS-1$
- } else {
- Assert.isTrue(false);
- }
- fView= v;
- fActionOrientation= orientation;
- WorkbenchHelp.setHelp(this, ICHelpContextIds.TOGGLE_ORIENTATION_ACTION);
- }
-
- public int getOrientation() {
- return fActionOrientation;
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- if (isChecked()) {
- fView.fOrientation= fActionOrientation;
- fView.computeOrientation();
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java
deleted file mode 100644
index 1fe64cd02f3..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to switch between the different hierarchy views.
- */
-public class ToggleViewAction extends Action {
-
- private TypeHierarchyViewPart fViewPart;
- private int fViewerIndex;
-
- public ToggleViewAction(TypeHierarchyViewPart v, int viewerIndex) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- String contextHelpId= null;
- if (viewerIndex == TypeHierarchyViewPart.VIEW_ID_SUPER) {
- setText(TypeHierarchyMessages.getString("ToggleViewAction.supertypes.label")); //$NON-NLS-1$
- contextHelpId= ICHelpContextIds.SHOW_SUPERTYPES;
- setDescription(TypeHierarchyMessages.getString("ToggleViewAction.supertypes.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleViewAction.supertypes.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "super_co.gif"); //$NON-NLS-1$
- } else if (viewerIndex == TypeHierarchyViewPart.VIEW_ID_SUB) {
- setText(TypeHierarchyMessages.getString("ToggleViewAction.subtypes.label")); //$NON-NLS-1$
- contextHelpId= ICHelpContextIds.SHOW_SUBTYPES;
- setDescription(TypeHierarchyMessages.getString("ToggleViewAction.subtypes.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleViewAction.subtypes.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "sub_co.gif"); //$NON-NLS-1$
- } else {
- Assert.isTrue(false);
- }
-
- fViewPart= v;
- fViewerIndex= viewerIndex;
-
- WorkbenchHelp.setHelp(this, contextHelpId);
- }
-
- public int getViewerIndex() {
- return fViewerIndex;
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- fViewPart.setView(fViewerIndex);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java
deleted file mode 100644
index 72e11994653..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-/**
- * Base class for content providers for type hierarchy viewers.
- * Implementors must override 'getTypesInHierarchy'.
- * Java delta processing is also performed by the content provider
- */
-public abstract class TypeHierarchyContentProvider implements ITreeContentProvider //, IWorkingCopyProvider {
-{
- protected static final Object[] NO_ELEMENTS= new Object[0];
-
- protected TypeHierarchyLifeCycle fTypeHierarchy;
- protected IMember[] fMemberFilter;
-
- protected TreeViewer fViewer;
-
- private ViewerFilter fWorkingSetFilter;
-
- public TypeHierarchyContentProvider(TypeHierarchyLifeCycle lifecycle) {
- fTypeHierarchy= lifecycle;
- fMemberFilter= null;
- fWorkingSetFilter= null;
- }
-
- /**
- * Sets members to filter the hierarchy for. Set to null
to disable member filtering.
- * When member filtering is enabled, the hierarchy contains only types that contain
- * an implementation of one of the filter members and the members themself.
- * The hierarchy can be empty as well.
- */
- public final void setMemberFilter(IMember[] memberFilter) {
- fMemberFilter= memberFilter;
- }
-
- /**
- * The members to filter or null
if member filtering is disabled.
- */
- public IMember[] getMemberFilter() {
- return fMemberFilter;
- }
-
- /**
- * Sets a filter representing a working set or null
if working sets are disabled.
- */
- public void setWorkingSetFilter(ViewerFilter filter) {
- fWorkingSetFilter= filter;
- }
-
-
- protected final ITypeHierarchy getHierarchy() {
- return fTypeHierarchy.getHierarchy();
- }
-
-
- /* (non-Javadoc)
- * @see IReconciled#providesWorkingCopies()
- */
- public boolean providesWorkingCopies() {
- return true;
- }
-
-
- /*
- * Called for the root element
- * @see IStructuredContentProvider#getElements
- */
- public Object[] getElements(Object parent) {
- ArrayList types= new ArrayList();
- getRootTypes(types);
- for (int i= types.size() - 1; i >= 0; i--) {
- ICElement curr= (ICElement) types.get(i);
- try {
- if (!isInTree(curr)) {
- types.remove(i);
- }
- } catch (CModelException e) {
- // ignore
- }
- }
- return types.toArray();
- }
-
- protected void getRootTypes(List res) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- ICElement input= hierarchy.getType();
- if (input != null) {
- res.add(input);
- }
- // opened on a region: dont show
- }
- }
-
- /**
- * Hook to overwrite. Filter will be applied on the returned types
- */
- protected abstract void getTypesInHierarchy(ICElement type, List res);
-
- /**
- * Hook to overwrite. Return null if parent is ambiguous.
- */
- protected abstract ICElement[] getParentTypes(ICElement type);
-
-
- private boolean isInScope(ICElement type) {
- if (fWorkingSetFilter != null && !fWorkingSetFilter.select(null, null, type)) {
- return false;
- }
-
-// ICElement input= fTypeHierarchy.getInputElement();
-// int inputType= input.getElementType();
-// if (inputType == ICElement.TYPE) {
-// return true;
-// }
-//
-// ICElement parent= type.getAncestor(input.getElementType());
-// if (inputType == ICElement.PACKAGE_FRAGMENT) {
-// if (parent == null || parent.getElementName().equals(input.getElementName())) {
-// return true;
-// }
-// } else if (input.equals(parent)) {
-// return true;
-// }
- return true;
- }
-
- /*
- * Called for the tree children.
- * @see ITreeContentProvider#getChildren
- */
- public Object[] getChildren(Object element) {
- if (element instanceof ICElement) {
- try {
- ICElement type= (ICElement)element;
-
- List children= new ArrayList();
- if (fMemberFilter != null) {
- addFilteredMemberChildren(type, children);
- }
-
- addTypeChildren(type, children);
-
- return children.toArray();
- } catch (CModelException e) {
- // ignore
- }
- }
- return NO_ELEMENTS;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren
- */
- public boolean hasChildren(Object element) {
- if (element instanceof ICElement) {
- try {
- ICElement type= (ICElement) element;
- return hasTypeChildren(type) || (fMemberFilter != null && hasMemberFilterChildren(type));
- } catch (CModelException e) {
- return false;
- }
- }
- return false;
- }
-
- private void addFilteredMemberChildren(ICElement parent, List children) throws CModelException {
- IMethodDeclaration[] methods= TypeUtil.getMethods(parent);
- if (methods != null && methods.length > 0) {
- for (int i= 0; i < fMemberFilter.length; i++) {
- IMember member= fMemberFilter[i];
- if (parent.equals(TypeUtil.getDeclaringClass(member))) {
- if (!children.contains(member)) {
- children.add(member);
- }
- } else if (member instanceof IMethodDeclaration) {
- IMethodDeclaration curr= (IMethodDeclaration)member;
- IMethodDeclaration meth= TypeUtil.findMethod(curr.getElementName(), curr.getParameterTypes(), curr.isConstructor(), curr.isDestructor(), methods);
- if (meth != null && !children.contains(meth)) {
- children.add(meth);
- }
- }
- }
- }
- }
-
- private void addTypeChildren(ICElement type, List children) throws CModelException {
- ArrayList types= new ArrayList();
- getTypesInHierarchy(type, types);
- int len= types.size();
- for (int i= 0; i < len; i++) {
- ICElement curr= (ICElement) types.get(i);
- if (isInTree(curr)) {
- children.add(curr);
- }
- }
- }
-
- protected final boolean isInTree(ICElement type) throws CModelException {
- if (isInScope(type)) {
- if (fMemberFilter != null) {
- return hasMemberFilterChildren(type) || hasTypeChildren(type);
- }
- return true;
- }
- return hasTypeChildren(type);
- }
-
- private boolean hasMemberFilterChildren(ICElement type) throws CModelException {
- IMethodDeclaration[] methods= TypeUtil.getMethods(type);
- if (methods != null && methods.length > 0) {
- for (int i= 0; i < fMemberFilter.length; i++) {
- IMember member= fMemberFilter[i];
- if (type.equals(TypeUtil.getDeclaringClass(member))) {
- return true;
- } else if (member instanceof IMethodDeclaration) {
- IMethodDeclaration curr= (IMethodDeclaration)member;
- IMethodDeclaration meth= TypeUtil.findMethod(curr.getElementName(), curr.getParameterTypes(), curr.isConstructor(), curr.isDestructor(), methods);
- if (meth != null) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
-
- private boolean hasTypeChildren(ICElement type) throws CModelException {
- ArrayList types= new ArrayList();
- getTypesInHierarchy(type, types);
- int len= types.size();
- for (int i= 0; i < len; i++) {
- ICElement curr= (ICElement) types.get(i);
- if (isInTree(curr)) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see IContentProvider#inputChanged
- */
- public void inputChanged(Viewer part, Object oldInput, Object newInput) {
- Assert.isTrue(part instanceof TreeViewer);
- fViewer= (TreeViewer)part;
- }
-
- /*
- * @see IContentProvider#dispose
- */
- public void dispose() {
- }
-
- /*
- * @see ITreeContentProvider#getParent
- */
- public Object getParent(Object element) {
- if (element instanceof IMember) {
- IMember member= (IMember) element;
-// if (member.getElementType() == ICElement.TYPE) {
- if (TypeUtil.isClassOrStruct(member)) {
- ICElement[] parents= getParentTypes(member);
- if (parents != null && parents.length == 1)
- return parents[0];
- }
- return TypeUtil.getDeclaringClass(member);
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java
deleted file mode 100644
index 98a4bb97fe9..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchyChangedListener;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ElementChangedEvent;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-/**
- * Manages a type hierarchy, to keep it refreshed, and to allow it to be shared.
- */
-public class TypeHierarchyLifeCycle implements ITypeHierarchyChangedListener, IElementChangedListener {
-
- private boolean fHierarchyRefreshNeeded;
- private ITypeHierarchy fHierarchy;
- private ICElement fInputElement;
-
- private List fChangeListeners;
-
- public TypeHierarchyLifeCycle() {
- this(true);
- }
-
- public TypeHierarchyLifeCycle(boolean isSuperTypesOnly) {
- fHierarchy= null;
- fInputElement= null;
- fChangeListeners= new ArrayList(2);
- }
-
- public ITypeHierarchy getHierarchy() {
- return fHierarchy;
- }
-
- public ICElement getInputElement() {
- return fInputElement;
- }
-
-
- public void freeHierarchy() {
- if (fHierarchy != null) {
- fHierarchy.removeTypeHierarchyChangedListener(this);
- CoreModel.getDefault().removeElementChangedListener(this);
- fHierarchy= null;
- fInputElement= null;
- }
- }
-
- public void removeChangedListener(ITypeHierarchyLifeCycleListener listener) {
- fChangeListeners.remove(listener);
- }
-
- public void addChangedListener(ITypeHierarchyLifeCycleListener listener) {
- if (!fChangeListeners.contains(listener)) {
- fChangeListeners.add(listener);
- }
- }
-
- private void fireChange(ICElement[] changedTypes) {
- for (int i= fChangeListeners.size()-1; i>=0; i--) {
- ITypeHierarchyLifeCycleListener curr= (ITypeHierarchyLifeCycleListener) fChangeListeners.get(i);
- curr.typeHierarchyChanged(this, changedTypes);
- }
- }
-
- public void ensureRefreshedTypeHierarchy(final ICElement element, IRunnableContext context) throws InvocationTargetException, InterruptedException {
- if (element == null || !element.exists()) {
- freeHierarchy();
- return;
- }
- boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
-
- if (hierachyCreationNeeded || fHierarchyRefreshNeeded) {
-
- IRunnableWithProgress op= new IRunnableWithProgress() {
- public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
- try {
- doHierarchyRefresh(element, pm);
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- } catch (OperationCanceledException e) {
- throw new InterruptedException();
- }
- }
- };
- fHierarchyRefreshNeeded= true;
- context.run(true, true, op);
- fHierarchyRefreshNeeded= false;
- }
- }
-
- private ITypeHierarchy createTypeHierarchy(ICElement element, IProgressMonitor pm) throws CModelException {
- if (element.getElementType() == ICElement.C_CLASS
- || element.getElementType() == ICElement.C_STRUCT) {
- return AllTypesCache.createTypeHierarchy(element, pm);
- } else {
-// IRegion region= JavaCore.newRegion();
-// if (element.getElementType() == ICElement.JAVA_PROJECT) {
-// // for projects only add the contained source folders
-// IPackageFragmentRoot[] roots= ((IJavaProject) element).getPackageFragmentRoots();
-// for (int i= 0; i < roots.length; i++) {
-// if (!roots[i].isExternal()) {
-// region.add(roots[i]);
-// }
-// }
-// } else if (element.getElementType() == ICElement.PACKAGE_FRAGMENT) {
-// IPackageFragmentRoot[] roots= element.getJavaProject().getPackageFragmentRoots();
-// String name= element.getElementName();
-// for (int i= 0; i < roots.length; i++) {
-// IPackageFragment pack= roots[i].getPackageFragment(name);
-// if (pack.exists()) {
-// region.add(pack);
-// }
-// }
-// } else {
-// region.add(element);
-// }
-// ICProject jproject= element.getCProject();
-// return jproject.newTypeHierarchy(region, pm);
- return null;
- }
- }
-
-
- public synchronized void doHierarchyRefresh(ICElement element, IProgressMonitor pm) throws CModelException {
- boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
- // to ensure the order of the two listeners always remove / add listeners on operations
- // on type hierarchies
- if (fHierarchy != null) {
- fHierarchy.removeTypeHierarchyChangedListener(this);
- CoreModel.getDefault().removeElementChangedListener(this);
- }
- if (hierachyCreationNeeded) {
- fHierarchy= createTypeHierarchy(element, pm);
- if (pm != null && pm.isCanceled()) {
- throw new OperationCanceledException();
- }
- fInputElement= element;
- } else if (fHierarchy != null) {
- fHierarchy.refresh(pm);
- }
- if (fHierarchy != null) {
- fHierarchy.addTypeHierarchyChangedListener(this);
- }
- CoreModel.getDefault().addElementChangedListener(this);
- fHierarchyRefreshNeeded= false;
- }
-
- /*
- * @see ITypeHierarchyChangedListener#typeHierarchyChanged
- */
- public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {
- fHierarchyRefreshNeeded= true;
- fireChange(null);
- }
-
- /*
- * @see IElementChangedListener#elementChanged(ElementChangedEvent)
- */
- public void elementChanged(ElementChangedEvent event) {
- if (fChangeListeners.isEmpty()) {
- return;
- }
-
- if (fHierarchyRefreshNeeded) {
- return;
- }
- ArrayList changedTypes= new ArrayList();
- processDelta(event.getDelta(), changedTypes);
- if (changedTypes.size() > 0) {
- fireChange((ICElement[]) changedTypes.toArray(new ICElement[changedTypes.size()]));
- }
- }
-
- /*
- * Assume that the hierarchy is intact (no refresh needed)
- */
- private void processDelta(ICElementDelta delta, ArrayList changedTypes) {
- ICElement element= delta.getElement();
- switch (element.getElementType()) {
-// case ICElement.TYPE:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- processTypeDelta(element, changedTypes);
- processChildrenDelta(delta, changedTypes); // (inner types)
- break;
- case ICElement.C_MODEL:
- case ICElement.C_PROJECT:
-// case ICElement.PACKAGE_FRAGMENT_ROOT:
-// case ICElement.PACKAGE_FRAGMENT:
- processChildrenDelta(delta, changedTypes);
- break;
- case ICElement.C_UNIT:
- ITranslationUnit cu= (ITranslationUnit)element;
-// if (!CModelUtil.isPrimary(cu)) {
-// return;
-// }
-
- if (delta.getKind() == ICElementDelta.CHANGED && isPossibleStructuralChange(delta.getFlags())) {
-// try {
- if (cu.exists()) {
-// IType[] types= cu.getAllTypes();
- ICElement[] types= getAllTypesForTranslationUnit(cu); for (int i= 0; i < types.length; i++) {
- processTypeDelta(types[i], changedTypes);
- }
- }
-// } catch (CModelException e) {
-// CUIPlugin.getDefault().log(e);
-// }
- } else {
- processChildrenDelta(delta, changedTypes);
- }
- break;
-// case ICElement.CLASS_FILE:
-// if (delta.getKind() == ICElementDelta.CHANGED) {
-// try {
-// IType type= ((IClassFile) element).getType();
-// processTypeDelta(type, changedTypes);
-// } catch (CModelException e) {
-// CUIPlugin.getDefault().log(e);
-// }
-// } else {
-// processChildrenDelta(delta, changedTypes);
-// }
-// break;
- }
- }
-
- private boolean isPossibleStructuralChange(int flags) {
- return (flags & (ICElementDelta.F_CONTENT | ICElementDelta.F_FINE_GRAINED)) == ICElementDelta.F_CONTENT;
- }
-
- private void processTypeDelta(ICElement type, ArrayList changedTypes) {
- if (getHierarchy().contains(type)) {
- changedTypes.add(type);
- }
- }
-
- private void processChildrenDelta(ICElementDelta delta, ArrayList changedTypes) {
- ICElementDelta[] children= delta.getAffectedChildren();
- for (int i= 0; i < children.length; i++) {
- processDelta(children[i], changedTypes); // recursive
- }
- }
-
- private static ICElement[] getAllTypesForTranslationUnit(ITranslationUnit unit) {
- return null;
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java
deleted file mode 100644
index d86960efd2f..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class TypeHierarchyMessages {
-
- private static final String RESOURCE_BUNDLE= TypeHierarchyMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TypeHierarchyMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties
deleted file mode 100644
index fd87439f7a6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties
+++ /dev/null
@@ -1,105 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2005 IBM Corporation and others.
-# All rights reserved. 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:
-# IBM Corporation - initial API and implementation
-# QNX Software Systems - adapted for use in CDT
-###############################################################################
-
-EnableMemberFilterAction.label=Members in Hierarchy
-EnableMemberFilterAction.tooltip=Lock View and Show Members in Hierarchy
-EnableMemberFilterAction.description=Lock view and show members in hierarchy
-
-ToggleOrientationAction.horizontal.label=Horizontal View Orientation
-ToggleOrientationAction.horizontal.tooltip=Horizontal View Orientation
-ToggleOrientationAction.horizontal.description=Horizontal View Orientation
-
-ToggleOrientationAction.vertical.label=Vertical View Orientation
-ToggleOrientationAction.vertical.tooltip=Vertical View Orientation
-ToggleOrientationAction.vertical.description=Vertical View Orientation
-
-ToggleOrientationAction.automatic.label=Automatic View Orientation
-ToggleOrientationAction.automatic.tooltip=Automatic View Orientation
-ToggleOrientationAction.automatic.description=Automatic View Orientation
-
-ToggleOrientationAction.single.label=Hierarchy View Only
-ToggleOrientationAction.single.tooltip=Hierarchy View Only
-ToggleOrientationAction.single.description=Hierarchy View Only
-
-FocusOnSelectionAction.label=Fo&cus On ''{0}''
-FocusOnSelectionAction.tooltip=Focus the Type Hierarchy on the Selected Element
-FocusOnSelectionAction.description=Focus the Type Hierarchy on the selected element
-
-FocusOnTypeAction.label=&Focus On...
-FocusOnTypeAction.tooltip=Focus the Type Hierarchy on a New Type
-FocusOnTypeAction.description=Focus the Type Hierarchy on a new type
-FocusOnTypeAction.dialog.title=Focus On Type
-FocusOnTypeAction.dialog.message=&Select the type to be shown in the Type Hierarchy view:
-
-HistoryDropDownAction.tooltip=Previous Type Hierarchies
-
-HistoryAction.description=Open ''{0}'' in Hierarchy
-HistoryAction.tooltip=Open ''{0}'' in Hierarchy
-
-HistoryListDialog.title=Type Hierarchy History
-HistoryListDialog.label=&Select the element to open in the type hierarchy:
-HistoryListDialog.remove.button=&Remove
-
-HistoryListAction.label=More...
-
-ShowInheritedMembersAction.label=All Inherited Members
-ShowInheritedMembersAction.tooltip=Show All Inherited Members
-ShowInheritedMembersAction.description=Show all inherited members
-
-ShowQualifiedTypeNamesAction.label=Show Qualified Type Names
-ShowQualifiedTypeNamesAction.tooltip=Show Qualified Type Names
-ShowQualifiedTypeNamesAction.description=Show qualified type names
-
-SortByDefiningTypeAction.label=Sort by the Defining Type
-SortByDefiningTypeAction.tooltip=Sort Methods by the Defining Type
-SortByDefiningTypeAction.description=Sort methods by the defining type
-
-SubTypeHierarchyViewer.title=Hierarchy
-SubTypeHierarchyViewer.filtered.title=Hierarchy
-
-SuperTypeHierarchyViewer.title=Hierarchy
-SuperTypeHierarchyViewer.filtered.title=Hierarchy
-
-TraditionalHierarchyViewer.title=Hierarchy
-TraditionalHierarchyViewer.filtered.title=Hierarchy
-
-TypeHierarchyViewPart.error.title=Open Type Hierarchy
-TypeHierarchyViewPart.error.message=The selected element only exists in the editor. To perform this operation you have to save the editor first.
-TypeHierarchyViewPart.empty=To display the type hierarchy, select a structure or class (for example in the outline view or in the editor), and select the \'Open Type Hierarchy\' menu option.
-TypeHierarchyViewPart.nodecl=No declarations of selected members\nin the chosen hierarchy of ''{0}''
-TypeHierarchyViewPart.exception.title=Type Hierarchy
-TypeHierarchyViewPart.exception.message=Creating hierarchy failed. Check log for details.
-
-TypeHierarchyViewPart.title={0} : {1}
-TypeHierarchyViewPart.tooltip={0} of ''{1}''
-
-TypeHierarchyViewPart.layout.submenu=&Layout
-
-OpenTypeInHierarchyDialog.title=Open Type In Hierarchy
-OpenTypeInHierarchyDialog.message=&Choose a type (? = any character, * = any string):
-
-ToggleViewAction.subtypes.label=Subtype Hierarchy
-ToggleViewAction.subtypes.tooltip=Show the Subtype Hierarchy
-ToggleViewAction.subtypes.description=Show the subtype hierarchy
-
-ToggleViewAction.supertypes.label=Supertype Hierarchy
-ToggleViewAction.supertypes.tooltip=Show the Supertype Hierarchy
-ToggleViewAction.supertypes.description=Show the supertype hierarchy
-
-ToggleViewAction.vajhierarchy.label=Type Hierarchy
-ToggleViewAction.vajhierarchy.tooltip=Show the Type Hierarchy
-ToggleViewAction.vajhierarchy.description=Show the type hierarchy
-
-HierarchyInformationControl.methodhierarchy.label=Types implementing or defining ''{0}.{1}''
-HierarchyInformationControl.hierarchy.label=Type hierarchy of ''{0}'':
-HierarchyInformationControl.toggle.traditionalhierarchy.label=Press ''{0}'' to see the Subtype hierarchy
-HierarchyInformationControl.toggle.superhierarchy.label=Press ''{0}'' to see the Supertype hierarchy
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
deleted file mode 100644
index 29f3ad55098..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
+++ /dev/null
@@ -1,1570 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.cdt.internal.ui.actions.SelectAllAction;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * view showing the super types/sub types of its input.
- */
-public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart, IViewPartInputProvider {
-
- public static final int VIEW_ID_SUPER= 0;
- public static final int VIEW_ID_SUB= 1;
-
- public static final int VIEW_ORIENTATION_VERTICAL= 0;
- public static final int VIEW_ORIENTATION_HORIZONTAL= 1;
- public static final int VIEW_ORIENTATION_SINGLE= 2;
- public static final int VIEW_ORIENTATION_AUTOMATIC= 3;
-
- private static final String DIALOGSTORE_HIERARCHYVIEW= "TypeHierarchyViewPart.hierarchyview"; //$NON-NLS-1$
- private static final String DIALOGSTORE_VIEWORIENTATION= "TypeHierarchyViewPart.orientation"; //$NON-NLS-1$
-
- //private static final String TAG_INPUT= "input"; //$NON-NLS-1$
- private static final String TAG_VIEW= "view"; //$NON-NLS-1$
- private static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
- private static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
- //private static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
- private static final String TAG_VERTICAL_SCROLL= "vertical_scroll"; //$NON-NLS-1$
-
- private static final String GROUP_FOCUS= "group.focus"; //$NON-NLS-1$
-
-
- // the selected type in the hierarchy view
- private ICElement fSelectedType;
- // input element or null
- private ICElement fInputElement;
-
- // history of input elements. No duplicates
- private ArrayList fInputHistory;
-
- private IMemento fMemento;
- private IDialogSettings fDialogSettings;
-
- protected TypeHierarchyLifeCycle fHierarchyLifeCycle;
- private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;
-
- private IPropertyChangeListener fPropertyChangeListener;
-
- private SelectionProviderMediator fSelectionProviderMediator;
- private ISelectionChangedListener fSelectionChangedListener;
- private IPartListener2 fPartListener;
-
- private int fCurrentOrientation;
- int fOrientation= VIEW_ORIENTATION_AUTOMATIC;
- boolean fInComputeOrientation= false;
-
- private boolean fLinkingEnabled;
- private boolean fSelectInEditor;
-
- private boolean fIsVisible;
- private boolean fNeedRefresh;
- private boolean fIsEnableMemberFilter;
- protected boolean fIsRefreshRunnablePosted;
-
- private int fCurrentViewerIndex;
- private TypeHierarchyViewer[] fAllViewers;
-
- protected MethodsViewer fMethodsViewer;
-
- private SashForm fTypeMethodsSplitter;
- private PageBook fViewerbook;
- protected PageBook fPagebook;
-
- private Label fNoHierarchyShownLabel;
- private Label fEmptyTypesViewer;
-
- private ViewForm fTypeViewerViewForm;
- private ViewForm fMethodViewerViewForm;
-
- private CLabel fMethodViewerPaneLabel;
- private CUILabelProvider fPaneLabelProvider;
- private Composite fParent;
-
- private ToggleViewAction[] fViewActions;
- private ToggleLinkingAction fToggleLinkingAction;
- private HistoryDropDownAction fHistoryDropDownAction;
- private ToggleOrientationAction[] fToggleOrientationActions;
- private EnableMemberFilterAction fEnableMemberFilterAction;
- private ShowQualifiedTypeNamesAction fShowQualifiedTypeNamesAction;
-// private AddMethodStubAction fAddStubAction;
- private FocusOnTypeAction fFocusOnTypeAction;
- private FocusOnSelectionAction fFocusOnSelectionAction;
- private CompositeActionGroup fActionGroups;
- protected SelectAllAction fSelectAllAction;
-
- private WorkingSetFilterActionGroup fWorkingSetActionGroup;
- private Job fRestoreStateJob;
-
- public TypeHierarchyViewPart() {
- fSelectedType= null;
- fInputElement= null;
- fIsVisible= false;
- fIsRefreshRunnablePosted= false;
- fSelectInEditor= true;
- fRestoreStateJob= null;
-
- fHierarchyLifeCycle= new TypeHierarchyLifeCycle();
- fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
- public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, ICElement[] changedTypes) {
- doTypeHierarchyChanged(typeHierarchy, changedTypes);
- }
- };
- fHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener);
-
- fPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doPropertyChange(event);
- }
- };
- PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
-
- fIsEnableMemberFilter= false;
-
- fInputHistory= new ArrayList();
- fAllViewers= null;
-
- fViewActions= new ToggleViewAction[] {
- new ToggleViewAction(this, VIEW_ID_SUPER),
- new ToggleViewAction(this, VIEW_ID_SUB)
- };
-
- fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
-
- fHistoryDropDownAction= new HistoryDropDownAction(this);
- fHistoryDropDownAction.setEnabled(false);
-
- fToggleOrientationActions= new ToggleOrientationAction[] {
- new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE)
- };
-
- fEnableMemberFilterAction= new EnableMemberFilterAction(this, false);
- fShowQualifiedTypeNamesAction= new ShowQualifiedTypeNamesAction(this, false);
-
- fFocusOnTypeAction= new FocusOnTypeAction(this);
-
- fPaneLabelProvider= new CUILabelProvider();
-//
-// fAddStubAction= new AddMethodStubAction();
- fFocusOnSelectionAction= new FocusOnSelectionAction(this);
-
- fPartListener= new IPartListener2() {
- public void partVisible(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part == TypeHierarchyViewPart.this) {
- visibilityChanged(true);
- }
- }
-
- public void partHidden(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part == TypeHierarchyViewPart.this) {
- visibilityChanged(false);
- }
- }
-
- public void partActivated(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part instanceof IEditorPart)
- editorActivated((IEditorPart) part);
- }
-
- public void partInputChanged(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part instanceof IEditorPart)
- editorActivated((IEditorPart) part);
- }
-
- public void partBroughtToTop(IWorkbenchPartReference ref) {}
- public void partClosed(IWorkbenchPartReference ref) {}
- public void partDeactivated(IWorkbenchPartReference ref) {}
- public void partOpened(IWorkbenchPartReference ref) {}
- };
-
- fSelectionChangedListener= new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- doSelectionChanged(event);
- }
- };
-
- fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR);
- }
-
- /**
- * Method doPropertyChange.
- * @param event
- */
- protected void doPropertyChange(PropertyChangeEvent event) {
- String property= event.getProperty();
- if (fMethodsViewer != null) {
-// if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
-// fMethodsViewer.refresh();
-// }
- }
- if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- updateHierarchyViewer(true);
- }
- }
-
- /**
- * Adds the entry if new. Inserted at the beginning of the history entries list.
- */
- private void addHistoryEntry(ICElement entry) {
- if (fInputHistory.contains(entry)) {
- fInputHistory.remove(entry);
- }
- fInputHistory.add(0, entry);
- fHistoryDropDownAction.setEnabled(true);
- }
-
- private void updateHistoryEntries() {
- for (int i= fInputHistory.size() - 1; i >= 0; i--) {
- ICElement type= (ICElement) fInputHistory.get(i);
- if (!type.exists()) {
- fInputHistory.remove(i);
- }
- }
- fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
- }
-
- /**
- * Goes to the selected entry, without updating the order of history entries.
- */
- public void gotoHistoryEntry(ICElement entry) {
- if (fInputHistory.contains(entry)) {
- updateInput(entry);
- }
- }
-
- /**
- * Gets all history entries.
- */
- public ICElement[] getHistoryEntries() {
- if (fInputHistory.size() > 0) {
- updateHistoryEntries();
- }
- return (ICElement[]) fInputHistory.toArray(new ICElement[fInputHistory.size()]);
- }
-
- /**
- * Sets the history entries
- */
- public void setHistoryEntries(ICElement[] elems) {
- fInputHistory.clear();
- for (int i= 0; i < elems.length; i++) {
- fInputHistory.add(elems[i]);
- }
- updateHistoryEntries();
- }
-
- /**
- * Selects an member in the methods list or in the current hierarchy.
- */
- public void selectMember(ICElement member) {
- fSelectInEditor= false;
- if (!TypeUtil.isClassOrStruct(member)) {
- Control methodControl= fMethodsViewer.getControl();
- if (methodControl != null && !methodControl.isDisposed()) {
- methodControl.setFocus();
- }
-
- fMethodsViewer.setSelection(new StructuredSelection(member), true);
- } else {
- Control viewerControl= getCurrentViewer().getControl();
- if (viewerControl != null && !viewerControl.isDisposed()) {
- viewerControl.setFocus();
- }
-
- if (!member.equals(fSelectedType)) {
- getCurrentViewer().setSelection(new StructuredSelection(member), true);
- }
- }
- fSelectInEditor= true;
- }
-
- /**
- * @deprecated
- */
- public ICElement getInput() {
- return fInputElement;
- }
-
- /**
- * Sets the input to a new type
- * @deprecated
- */
- public void setInput(ICElement type) {
- setInputElement(type);
- }
-
- /**
- * Returns the input element of the type hierarchy.
- * Can be of type ICElement
or IPackageFragment
- */
- public ICElement getInputElement() {
- return fInputElement;
- }
-
-
- /**
- * Sets the input to a new element.
- */
- public void setInputElement(ICElement element) {
- if (element != null) {
- if (!(element instanceof IStructure)) {
- element = TypeUtil.getDeclaringClass(element);
- }
- if (element == null || !element.exists()) {
- MessageDialog.openError(getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.message")); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
- } else {
- CUIPlugin.getDefault().logErrorMessage("Invalid type hierarchy input type.");//$NON-NLS-1$
- }
- if (element != null && !element.equals(fInputElement)) {
- addHistoryEntry(element);
- }
-
- updateInput(element);
- }
-
- /**
- * Changes the input to a new type
- */
- private void updateInput(ICElement inputElement) {
- ICElement prevInput= fInputElement;
-
- synchronized (this) {
- if (fRestoreStateJob != null) {
- fRestoreStateJob.cancel();
- try {
- fRestoreStateJob.join();
- } catch (InterruptedException e) {
- // ignore
- } finally {
- fRestoreStateJob= null;
- }
- }
- }
-
- // Make sure the UI got repainted before we execute a long running
- // operation. This can be removed if we refresh the hierarchy in a
- // separate thread.
- // Work-araound for http://dev.eclipse.org/bugs/show_bug.cgi?id=30881
- processOutstandingEvents();
- if (inputElement == null) {
- clearInput();
- } else {
- fInputElement= inputElement;
- try {
- fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(inputElement, CUIPlugin.getActiveWorkbenchWindow());
- // fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(inputElement, getSite().getWorkbenchWindow());
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.message")); //$NON-NLS-1$ //$NON-NLS-2$
- clearInput();
- return;
- } catch (InterruptedException e) {
- return;
- }
-
- if (!TypeUtil.isClassOrStruct(inputElement)) {
- setView(VIEW_ID_SUPER);
- }
- // turn off member filtering
- fSelectInEditor= false;
- setMemberFilter(null);
- internalSelectType(null, false); // clear selection
- fIsEnableMemberFilter= false;
- if (!inputElement.equals(prevInput)) {
- updateHierarchyViewer(true);
- }
- ICElement root= getSelectableType(inputElement);
- internalSelectType(root, true);
- updateMethodViewer(root);
- updateToolbarButtons();
- updateTitle();
- enableMemberFilter(false);
- fPagebook.showPage(fTypeMethodsSplitter);
- fSelectInEditor= true;
- }
- }
-
- private void processOutstandingEvents() {
- Display display= getDisplay();
- if (display != null && !display.isDisposed())
- display.update();
- }
-
- private void clearInput() {
- fInputElement= null;
- fHierarchyLifeCycle.freeHierarchy();
-
- updateHierarchyViewer(false);
- updateToolbarButtons();
- }
-
- /*
- * @see IWorbenchPart#setFocus
- */
- public void setFocus() {
- fPagebook.setFocus();
- }
-
- /*
- * @see IWorkbenchPart#dispose
- */
- public void dispose() {
- fHierarchyLifeCycle.freeHierarchy();
- fHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener);
- fPaneLabelProvider.dispose();
-
- if (fMethodsViewer != null) {
- fMethodsViewer.dispose();
- }
-
- if (fPropertyChangeListener != null) {
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- fPropertyChangeListener= null;
- }
-
- getSite().getPage().removePartListener(fPartListener);
-
- if (fActionGroups != null)
- fActionGroups.dispose();
-
- if (fWorkingSetActionGroup != null) {
- fWorkingSetActionGroup.dispose();
- }
-
- super.dispose();
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInSource.class) {
- return getShowInSource();
- }
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- private Control createTypeViewerControl(Composite parent) {
- fViewerbook= new PageBook(parent, SWT.NULL);
-
- KeyListener keyListener= createKeyListener();
-
- // Create the viewers
- TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
- initializeTypesViewer(superTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);
-
- TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
- initializeTypesViewer(subTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);
-
- fAllViewers= new TypeHierarchyViewer[2];
- fAllViewers[VIEW_ID_SUPER]= superTypesViewer;
- fAllViewers[VIEW_ID_SUB]= subTypesViewer;
-
- int currViewerIndex;
- try {
- currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
- if (currViewerIndex < 0 || currViewerIndex > 2) {
- currViewerIndex= VIEW_ID_SUPER;
- }
- } catch (NumberFormatException e) {
- currViewerIndex= VIEW_ID_SUPER;
- }
-
- fEmptyTypesViewer= new Label(fViewerbook, SWT.LEFT);
-
- for (int i= 0; i < fAllViewers.length; i++) {
- fAllViewers[i].setInput(fAllViewers[i]);
- }
-
- // force the update
- fCurrentViewerIndex= -1;
- setView(currViewerIndex);
-
- return fViewerbook;
- }
-
- private KeyListener createKeyListener() {
- return new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- if (event.stateMask == 0) {
- if (event.keyCode == SWT.F5) {
- ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
- if (hierarchy != null) {
- fHierarchyLifeCycle.typeHierarchyChanged(hierarchy);
- doTypeHierarchyChangedOnViewers(null);
- }
- updateHierarchyViewer(false);
- return;
- }
- }
- }
- };
- }
-
-
- private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, KeyListener keyListener, String cotextHelpId) {
- typesViewer.getControl().setVisible(false);
- typesViewer.getControl().addKeyListener(keyListener);
- typesViewer.initContextMenu(new IMenuListener() {
- public void menuAboutToShow(IMenuManager menu) {
- fillTypesViewerContextMenu(typesViewer, menu);
- }
- }, cotextHelpId, getSite());
- typesViewer.addPostSelectionChangedListener(fSelectionChangedListener);
- typesViewer.setQualifiedTypeName(isShowQualifiedTypeNames());
- typesViewer.setWorkingSetFilter(fWorkingSetActionGroup.getWorkingSetFilter());
- }
-
- private Control createMethodViewerControl(Composite parent) {
- fMethodsViewer= new MethodsViewer(parent, fHierarchyLifeCycle, this);
- fMethodsViewer.initContextMenu(new IMenuListener() {
- public void menuAboutToShow(IMenuManager menu) {
- fillMethodsViewerContextMenu(menu);
- }
- }, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite());
- fMethodsViewer.addPostSelectionChangedListener(fSelectionChangedListener);
-
- Control control= fMethodsViewer.getTable();
- control.addKeyListener(createKeyListener());
- control.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- fSelectAllAction.setEnabled(true);
- }
-
- public void focusLost(FocusEvent e) {
- fSelectAllAction.setEnabled(false);
- }
- });
-
- return control;
- }
-
- private void initDragAndDrop() {
-// Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
-// int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
-//
-// for (int i= 0; i < fAllViewers.length; i++) {
-// addDragAdapters(fAllViewers[i], ops, transfers);
-// addDropAdapters(fAllViewers[i], ops | DND.DROP_DEFAULT, transfers);
-// }
-// addDragAdapters(fMethodsViewer, ops, transfers);
-//
-// //DND on empty hierarchy
-// DropTarget dropTarget = new DropTarget(fNoHierarchyShownLabel, ops | DND.DROP_DEFAULT);
-// dropTarget.setTransfer(transfers);
-// dropTarget.addDropListener(new TypeHierarchyTransferDropAdapter(this, fAllViewers[0]));
- }
-
-// private void addDropAdapters(AbstractTreeViewer viewer, int ops, Transfer[] transfers){
-// TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
-// new TypeHierarchyTransferDropAdapter(this, viewer)
-// };
-// viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
-// }
-
-// private void addDragAdapters(StructuredViewer viewer, int ops, Transfer[] transfers) {
-// TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
-// new SelectionTransferDragAdapter(viewer)
-// };
-// viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners));
-// }
-
- /**
- * Returns the inner component in a workbench part.
- * @see IWorkbenchPart#createPartControl(Composite)
- */
- public void createPartControl(Composite container) {
- fParent= container;
- addResizeListener(container);
-
- fPagebook= new PageBook(container, SWT.NONE);
- fWorkingSetActionGroup= new WorkingSetFilterActionGroup(CUIPlugin.ID_TYPE_HIERARCHY, container.getShell(), fPropertyChangeListener);
-
- // page 1 of page book (no hierarchy label)
-
- fNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
- fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$
-
- // page 2 of page book (viewers)
-
- fTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL);
- fTypeMethodsSplitter.setVisible(false);
-
- fTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
-
- Control typeViewerControl= createTypeViewerControl(fTypeViewerViewForm);
- fTypeViewerViewForm.setContent(typeViewerControl);
-
- fMethodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
- fTypeMethodsSplitter.setWeights(new int[] {35, 65});
-
- Control methodViewerPart= createMethodViewerControl(fMethodViewerViewForm);
- fMethodViewerViewForm.setContent(methodViewerPart);
-
- fMethodViewerPaneLabel= new CLabel(fMethodViewerViewForm, SWT.NONE);
- fMethodViewerViewForm.setTopLeft(fMethodViewerPaneLabel);
-
- ToolBar methodViewerToolBar= new ToolBar(fMethodViewerViewForm, SWT.FLAT | SWT.WRAP);
- fMethodViewerViewForm.setTopCenter(methodViewerToolBar);
-
- initDragAndDrop();
-
- MenuManager menu= new MenuManager();
- menu.add(fFocusOnTypeAction);
- fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
-
- fPagebook.showPage(fNoHierarchyShownLabel);
-
- try {
- fOrientation= fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION);
- if (fOrientation < 0 || fOrientation > 3) {
- fOrientation= VIEW_ORIENTATION_VERTICAL;
- }
- } catch (NumberFormatException e) {
- fOrientation= VIEW_ORIENTATION_AUTOMATIC;
- }
-
- // force the update
- fCurrentOrientation= -1;
- // will fill the main tool bar
- setOrientation(fOrientation);
-
- if (fMemento != null) { // restore state before creating action
- restoreLinkingEnabled(fMemento);
- }
- fToggleLinkingAction= new ToggleLinkingAction(this);
-
- // set the filter menu items
- IActionBars actionBars= getViewSite().getActionBars();
- IMenuManager viewMenu= actionBars.getMenuManager();
- for (int i= 0; i < fViewActions.length; i++) {
- ToggleViewAction action= fViewActions[i];
- viewMenu.add(action);
- action.setEnabled(false);
- }
- viewMenu.add(new Separator());
-
- fWorkingSetActionGroup.contributeToMenu(viewMenu);
-
- viewMenu.add(new Separator());
-
- IMenuManager layoutSubMenu= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.layout.submenu")); //$NON-NLS-1$
- viewMenu.add(layoutSubMenu);
- for (int i= 0; i < fToggleOrientationActions.length; i++) {
- layoutSubMenu.add(fToggleOrientationActions[i]);
- }
- viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- viewMenu.add(fShowQualifiedTypeNamesAction);
- viewMenu.add(fToggleLinkingAction);
-
-
- // fill the method viewer tool bar
- ToolBarManager lowertbmanager= new ToolBarManager(methodViewerToolBar);
- lowertbmanager.add(fEnableMemberFilterAction);
- lowertbmanager.add(new Separator());
- fMethodsViewer.contributeToToolBar(lowertbmanager);
- lowertbmanager.update(true);
-
- // selection provider
- int nHierarchyViewers= fAllViewers.length;
- StructuredViewer[] trackedViewers= new StructuredViewer[nHierarchyViewers + 1];
- for (int i= 0; i < nHierarchyViewers; i++) {
- trackedViewers[i]= fAllViewers[i];
- }
- trackedViewers[nHierarchyViewers]= fMethodsViewer;
- fSelectionProviderMediator= new SelectionProviderMediator(trackedViewers);
- IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
- fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
-
- getSite().setSelectionProvider(fSelectionProviderMediator);
- getSite().getPage().addPartListener(fPartListener);
-
- // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33657
- ICElement input= null; //determineInputElement();
- if (fMemento != null) {
- restoreState(fMemento, input);
- } else if (input != null) {
- setInputElement(input);
- } else {
- setViewerVisibility(false);
- }
-
- WorkbenchHelp.setHelp(fPagebook, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
-
-
- fActionGroups= new CompositeActionGroup(new ActionGroup[] {
-// new NewWizardsActionGroup(this.getSite()),
-// new OpenEditorActionGroup(this),
- new OpenViewActionGroup(this),
-// new CCPActionGroup(this),
-// new GenerateActionGroup(this),
-// new RefactorActionGroup(this),
-// new CSearchActionGroup(this)
- });
-
- fActionGroups.fillActionBars(actionBars);
- fSelectAllAction= new SelectAllAction(fMethodsViewer);
-
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
- }
-
- private void addResizeListener(Composite parent) {
- parent.addControlListener(new ControlListener() {
- public void controlMoved(ControlEvent e) {
- }
- public void controlResized(ControlEvent e) {
- computeOrientation();
- }
- });
- }
-
- void computeOrientation() {
- // fix for bug: 63268 error while activating view
- // avoid recursive calls of compute orientation
- if (fInComputeOrientation) {
- return;
- }
- fInComputeOrientation= true;
- try {
- if (fOrientation != VIEW_ORIENTATION_AUTOMATIC) {
- setOrientation(fOrientation);
- }
- else {
- if (fOrientation == VIEW_ORIENTATION_SINGLE)
- return;
- Point size= fParent.getSize();
- if (size.x != 0 && size.y != 0) {
- if (size.x > size.y)
- setOrientation(VIEW_ORIENTATION_HORIZONTAL);
- else
- setOrientation(VIEW_ORIENTATION_VERTICAL);
- }
- }
- } finally {
- fInComputeOrientation= false;
- }
- }
-
- /**
- * called from ToggleOrientationAction.
- * @param orientation VIEW_ORIENTATION_SINGLE, VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
- */
- public void setOrientation(int orientation) {
- if (fCurrentOrientation != orientation) {
- boolean methodViewerNeedsUpdate= false;
-
- if (fMethodViewerViewForm != null && !fMethodViewerViewForm.isDisposed()
- && fTypeMethodsSplitter != null && !fTypeMethodsSplitter.isDisposed()) {
- if (orientation == VIEW_ORIENTATION_SINGLE) {
- fMethodViewerViewForm.setVisible(false);
- enableMemberFilter(false);
- updateMethodViewer(null);
- } else {
- if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) {
- fMethodViewerViewForm.setVisible(true);
- methodViewerNeedsUpdate= true;
- }
- boolean horizontal= orientation == VIEW_ORIENTATION_HORIZONTAL;
- fTypeMethodsSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
- }
- updateMainToolbar(orientation);
- fTypeMethodsSplitter.layout();
- }
- updateCheckedState();
- if (methodViewerNeedsUpdate) {
- updateMethodViewer(fSelectedType);
- }
- fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation);
- fCurrentOrientation= orientation;
- }
- }
-
-
- private void updateCheckedState() {
- for (int i= 0; i < fToggleOrientationActions.length; i++) {
- fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
- }
- }
-
- private void updateMainToolbar(int orientation) {
- IActionBars actionBars= getViewSite().getActionBars();
- IToolBarManager tbmanager= actionBars.getToolBarManager();
-
- if (orientation == VIEW_ORIENTATION_HORIZONTAL) {
- clearMainToolBar(tbmanager);
- ToolBar typeViewerToolBar= new ToolBar(fTypeViewerViewForm, SWT.FLAT | SWT.WRAP);
- fillMainToolBar(new ToolBarManager(typeViewerToolBar));
- fTypeViewerViewForm.setTopLeft(typeViewerToolBar);
- } else {
- fTypeViewerViewForm.setTopLeft(null);
- fillMainToolBar(tbmanager);
- }
- }
-
- private void fillMainToolBar(IToolBarManager tbmanager) {
- tbmanager.removeAll();
- for (int i= 0; i < fViewActions.length; i++) {
- tbmanager.add(fViewActions[i]);
- }
- tbmanager.add(fHistoryDropDownAction);
- tbmanager.update(false);
- }
-
- private void clearMainToolBar(IToolBarManager tbmanager) {
- tbmanager.removeAll();
- tbmanager.update(false);
- }
-
-
- /**
- * Creates the context menu for the hierarchy viewers
- */
- protected void fillTypesViewerContextMenu(TypeHierarchyViewer viewer, IMenuManager menu) {
- CUIPlugin.createStandardGroups(menu);
-
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS));
- // viewer entries
- viewer.contributeToContextMenu(menu);
-
- if (fFocusOnSelectionAction.canActionBeAdded())
- menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction);
- menu.appendToGroup(GROUP_FOCUS, fFocusOnTypeAction);
-
- fActionGroups.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
- fActionGroups.fillContextMenu(menu);
- fActionGroups.setContext(null);
- }
-
- /**
- * Creates the context menu for the method viewer
- */
- protected void fillMethodsViewerContextMenu(IMenuManager menu) {
- CUIPlugin.createStandardGroups(menu);
- // viewer entries
- fMethodsViewer.contributeToContextMenu(menu);
- fActionGroups.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
- fActionGroups.fillContextMenu(menu);
- fActionGroups.setContext(null);
-// if (fSelectedType != null && fAddStubAction.init(fSelectedType, fMethodsViewer.getSelection())) {
-// IMenuManager source= menu.findMenuUsingPath(GenerateActionGroup.MENU_ID);
-// if (source != null)
-// source.appendToGroup(GenerateActionGroup.GROUP_GENERATE, fAddStubAction);
-// }
- }
-
- /**
- * Toggles between the empty viewer page and the hierarchy
- */
- private void setViewerVisibility(boolean showHierarchy) {
- if (showHierarchy) {
- fViewerbook.showPage(getCurrentViewer().getControl());
- } else {
- fViewerbook.showPage(fEmptyTypesViewer);
- }
- }
-
- /**
- * Sets the member filter. null
disables member filtering.
- */
- private void setMemberFilter(IMember[] memberFilter) {
- Assert.isNotNull(fAllViewers);
- for (int i= 0; i < fAllViewers.length; i++) {
- fAllViewers[i].setMemberFilter(memberFilter);
- }
- }
-
- private ICElement getSelectableType(ICElement elem) {
- if (!TypeUtil.isClassOrStruct(elem)) {
- return getCurrentViewer().getTreeRootType();
- }
- return elem;
- }
-
- private void internalSelectType(ICElement elem, boolean reveal) {
- TypeHierarchyViewer viewer= getCurrentViewer();
- if (viewer != null) {
- viewer.removePostSelectionChangedListener(fSelectionChangedListener);
- viewer.setSelection(elem != null ? new StructuredSelection(elem) : StructuredSelection.EMPTY, reveal);
- viewer.addPostSelectionChangedListener(fSelectionChangedListener);
- }
- }
-
- /**
- * When the input changed or the hierarchy pane becomes visible,
- * updateHierarchyViewer
brings up the correct view and refreshes
- * the current tree
- */
- protected void updateHierarchyViewer(final boolean doExpand) {
- if (fInputElement == null) {
- fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$
- fPagebook.showPage(fNoHierarchyShownLabel);
- } else {
- final TypeHierarchyViewer viewer = getCurrentViewer();
- if (viewer != null && viewer.containsElements() != null) {
- Runnable runnable= new Runnable() {
- public void run() {
- viewer.updateContent(doExpand); // refresh
- }
- };
- BusyIndicator.showWhile(getDisplay(), runnable);
- if (!isChildVisible(fViewerbook, viewer.getControl())) {
- setViewerVisibility(true);
- }
- } else {
- fEmptyTypesViewer.setText(TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.nodecl", fInputElement.getElementName())); //$NON-NLS-1$
- setViewerVisibility(false);
- }
- }
- }
-
- private void updateMethodViewer(final ICElement input) {
- if (!fIsEnableMemberFilter && fCurrentOrientation != VIEW_ORIENTATION_SINGLE) {
- if (input == fMethodsViewer.getInput()) {
- if (input != null) {
- Runnable runnable= new Runnable() {
- public void run() {
- fMethodsViewer.refresh(); // refresh
- }
- };
- BusyIndicator.showWhile(getDisplay(), runnable);
- }
- } else {
- if (input != null) {
- fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(input));
- fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(input));
- } else {
- fMethodViewerPaneLabel.setText(""); //$NON-NLS-1$
- fMethodViewerPaneLabel.setImage(null);
- }
- Runnable runnable= new Runnable() {
- public void run() {
- fMethodsViewer.setInput(input); // refresh
- }
- };
- BusyIndicator.showWhile(getDisplay(), runnable);
- }
- }
- }
-
- protected void doSelectionChanged(SelectionChangedEvent e) {
- if (e.getSelectionProvider() == fMethodsViewer) {
- methodSelectionChanged(e.getSelection());
- } else {
- typeSelectionChanged(e.getSelection());
- }
- }
-
-
-
- private void methodSelectionChanged(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- List selected= ((IStructuredSelection)sel).toList();
- int nSelected= selected.size();
- if (fIsEnableMemberFilter) {
- IMember[] memberFilter= null;
- if (nSelected > 0) {
- memberFilter= new IMember[nSelected];
- selected.toArray(memberFilter);
- }
- setMemberFilter(memberFilter);
- updateHierarchyViewer(true);
- updateTitle();
- internalSelectType(fSelectedType, true);
- }
- if (nSelected == 1 && fSelectInEditor) {
- revealElementInEditor(selected.get(0), fMethodsViewer);
- }
- }
- }
-
- private void typeSelectionChanged(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- List selected= ((IStructuredSelection)sel).toList();
- int nSelected= selected.size();
- if (nSelected != 0) {
- List types= new ArrayList(nSelected);
- for (int i= nSelected-1; i >= 0; i--) {
- Object elem= selected.get(i);
- if (elem instanceof ICElement && !types.contains(elem)) {
- types.add(elem);
- }
- }
- if (types.size() == 1) {
- fSelectedType= (ICElement) types.get(0);
- updateMethodViewer(fSelectedType);
- } else if (types.size() == 0) {
- // method selected, no change
- }
- if (nSelected == 1 && fSelectInEditor) {
- revealElementInEditor(selected.get(0), getCurrentViewer());
- }
- } else {
- fSelectedType= null;
- updateMethodViewer(null);
- }
- }
- }
-
- private void revealElementInEditor(Object elem, StructuredViewer originViewer) {
- // only allow revealing when the type hierarchy is the active page
- // no revealing after selection events due to model changes
-
- if (getSite().getPage().getActivePart() != this) {
- return;
- }
-
- if (fSelectionProviderMediator.getViewerInFocus() != originViewer) {
- return;
- }
-
- IEditorPart editorPart= EditorUtility.isOpenInEditor(elem);
- if (editorPart != null && (elem instanceof ICElement)) {
- getSite().getPage().removePartListener(fPartListener);
- getSite().getPage().bringToTop(editorPart);
- EditorUtility.revealInEditor(editorPart, (ICElement) elem);
- getSite().getPage().addPartListener(fPartListener);
- }
- }
-
- private Display getDisplay() {
- if (fPagebook != null && !fPagebook.isDisposed()) {
- return fPagebook.getDisplay();
- }
- return null;
- }
-
- private boolean isChildVisible(Composite pb, Control child) {
- Control[] children= pb.getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i] == child && children[i].isVisible())
- return true;
- }
- return false;
- }
-
- private void updateTitle() {
- String tooltip;
- String title;
- String viewerTitle;
- TypeHierarchyViewer viewer = getCurrentViewer();
- if (viewer != null) {
- viewerTitle= viewer.getTitle();
- } else {
- viewerTitle = TypeHierarchyMessages.getString("TraditionalHierarchyViewer.title"); //$NON-NLS-1$
- }
-
- if (fInputElement != null) {
- String[] args= new String[] { viewerTitle, CElementLabels.getElementLabel(fInputElement, CElementLabels.ALL_DEFAULT) };
- title= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.title", args); //$NON-NLS-1$
- tooltip= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.tooltip", args); //$NON-NLS-1$
- } else {
- title= viewerTitle;
- tooltip= viewerTitle;
- }
- setPartName(title);
- setContentDescription(""); //$NON-NLS-1$
- setTitleToolTip(tooltip);
- }
-
- private void updateToolbarButtons() {
- for (int i= 0; i < fViewActions.length; i++) {
- ToggleViewAction action= fViewActions[i];
- action.setEnabled(true);
- }
- }
-
- /**
- * Sets the current view (see view id)
- * called from ToggleViewAction. Must be called after creation of the view part.
- */
- public void setView(int viewerIndex) {
- Assert.isNotNull(fAllViewers);
- if (viewerIndex < fAllViewers.length && fCurrentViewerIndex != viewerIndex) {
- fCurrentViewerIndex= viewerIndex;
-
- updateHierarchyViewer(true);
- if (fInputElement != null) {
- ISelection currSelection= getCurrentViewer().getSelection();
- if (currSelection == null || currSelection.isEmpty()) {
- internalSelectType(getSelectableType(fInputElement), false);
- currSelection= getCurrentViewer().getSelection();
- }
- if (!fIsEnableMemberFilter) {
- typeSelectionChanged(currSelection);
- }
- }
- updateTitle();
-
- fDialogSettings.put(DIALOGSTORE_HIERARCHYVIEW, viewerIndex);
- getCurrentViewer().getTree().setFocus();
- }
- for (int i= 0; i < fViewActions.length; i++) {
- ToggleViewAction action= fViewActions[i];
- action.setChecked(fCurrentViewerIndex == action.getViewerIndex());
- }
- }
-
- /**
- * Gets the current active view index.
- */
- public int getViewIndex() {
- return fCurrentViewerIndex;
- }
-
- private TypeHierarchyViewer getCurrentViewer() {
- if (fCurrentViewerIndex != -1)
- return fAllViewers[fCurrentViewerIndex];
- return null;
- }
-
- /**
- * called from EnableMemberFilterAction.
- * Must be called after creation of the view part.
- */
- public void enableMemberFilter(boolean on) {
- if (on != fIsEnableMemberFilter) {
- fIsEnableMemberFilter= on;
- if (!on) {
- ICElement methodViewerInput= (ICElement) fMethodsViewer.getInput();
- setMemberFilter(null);
- updateHierarchyViewer(true);
- updateTitle();
-
- if (methodViewerInput != null && getCurrentViewer().isElementShown(methodViewerInput)) {
- // avoid that the method view changes content by selecting the previous input
- internalSelectType(methodViewerInput, true);
- } else if (fSelectedType != null) {
- // choose a input that exists
- internalSelectType(fSelectedType, true);
- updateMethodViewer(fSelectedType);
- }
- } else {
- methodSelectionChanged(fMethodsViewer.getSelection());
- }
- }
- fEnableMemberFilterAction.setChecked(on);
- }
-
- /**
- * called from ShowQualifiedTypeNamesAction. Must be called after creation
- * of the view part.
- */
- public void showQualifiedTypeNames(boolean on) {
- if (fAllViewers == null) {
- return;
- }
- for (int i= 0; i < fAllViewers.length; i++) {
- fAllViewers[i].setQualifiedTypeName(on);
- }
- }
-
- private boolean isShowQualifiedTypeNames() {
- return fShowQualifiedTypeNamesAction.isChecked();
- }
-
- /**
- * Called from ITypeHierarchyLifeCycleListener.
- * Can be called from any thread
- */
- protected void doTypeHierarchyChanged(final TypeHierarchyLifeCycle typeHierarchy, final ICElement[] changedTypes) {
- if (!fIsVisible) {
- fNeedRefresh= true;
- return;
- }
- if (fIsRefreshRunnablePosted) {
- return;
- }
-
- Display display= getDisplay();
- if (display != null) {
- fIsRefreshRunnablePosted= true;
- display.asyncExec(new Runnable() {
- public void run() {
- try {
- if (fPagebook != null && !fPagebook.isDisposed()) {
- doTypeHierarchyChangedOnViewers(changedTypes);
- }
- } finally {
- fIsRefreshRunnablePosted= false;
- }
- }
- });
- }
- }
-
- protected void doTypeHierarchyChangedOnViewers(ICElement[] changedTypes) {
- if (fHierarchyLifeCycle.getHierarchy() == null || !fHierarchyLifeCycle.getHierarchy().exists()) {
- clearInput();
- } else {
- if (changedTypes == null) {
- // hierarchy change
- try {
- fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement, getSite().getWorkbenchWindow());
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.message")); //$NON-NLS-1$ //$NON-NLS-2$
- clearInput();
- return;
- } catch (InterruptedException e) {
- return;
- }
- fMethodsViewer.refresh();
- updateHierarchyViewer(false);
- } else {
- // elements in hierarchy modified
- Object methodViewerInput= fMethodsViewer.getInput();
- fMethodsViewer.refresh();
- fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(methodViewerInput));
- fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(methodViewerInput));
- if (getCurrentViewer().isMethodFiltering()) {
- if (changedTypes.length == 1) {
- getCurrentViewer().refresh(changedTypes[0]);
- } else {
- updateHierarchyViewer(false);
- }
- } else {
- getCurrentViewer().update(changedTypes, new String[] { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE } );
- }
- }
- }
- }
-
- /*
- * @see IViewPart#init
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- fMemento= memento;
- }
-
- /*
- * @see ViewPart#saveState(IMemento)
- */
- public void saveState(IMemento memento) {
- if (fPagebook == null) {
- // part has not been created
- if (fMemento != null) { //Keep the old state;
- memento.putMemento(fMemento);
- }
- return;
- }
-// if (fInputElement != null) {
-// String handleIndentifier= fInputElement.getHandleIdentifier();
-// memento.putString(TAG_INPUT, handleIndentifier);
-// }
- memento.putInteger(TAG_VIEW, getViewIndex());
- memento.putInteger(TAG_ORIENTATION, fOrientation);
- int weigths[]= fTypeMethodsSplitter.getWeights();
- int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
- memento.putInteger(TAG_RATIO, ratio);
-
- ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
- int position= bar != null ? bar.getSelection() : 0;
- memento.putInteger(TAG_VERTICAL_SCROLL, position);
-
-// ICElement selection= (ICElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement();
-// if (selection != null) {
-// memento.putString(TAG_SELECTION, selection.getHandleIdentifier());
-// }
-
- fWorkingSetActionGroup.saveState(memento);
-
- fMethodsViewer.saveState(memento);
-
- saveLinkingEnabled(memento);
- }
-
- private void saveLinkingEnabled(IMemento memento) {
- memento.putInteger(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR, fLinkingEnabled ? 1 : 0);
- }
-
- /**
- * Restores the type hierarchy settings from a memento.
- */
- private void restoreState(final IMemento memento, ICElement defaultInput) {
- ICElement input= defaultInput;
-// String elementId= memento.getString(TAG_INPUT);
-// if (elementId != null) {
-// input= CoreModel.create(elementId);
-// if (input != null && !input.exists()) {
-// input= null;
-// }
-// }
- if (input == null) {
- doRestoreState(memento, input);
- } else {
- final ICElement hierarchyInput= input;
-
- synchronized (this) {
- String label= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.restoreinput", hierarchyInput.getElementName()); //$NON-NLS-1$
- fNoHierarchyShownLabel.setText(label);
-
- fRestoreStateJob= new Job(label) {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- doRestoreInBackground(memento, hierarchyInput, monitor);
- } catch (CModelException e) {
- return e.getStatus();
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- }
- };
- fRestoreStateJob.schedule();
- }
- }
- }
-
- protected void doRestoreInBackground(final IMemento memento, final ICElement hierarchyInput, IProgressMonitor monitor) throws CModelException {
- fHierarchyLifeCycle.doHierarchyRefresh(hierarchyInput, monitor);
- if (!monitor.isCanceled()) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- // running async: check first if view still exists
- if (fPagebook != null && !fPagebook.isDisposed()) {
- doRestoreState(memento, hierarchyInput);
- }
- }
- });
- }
- }
-
-
- final void doRestoreState(IMemento memento, ICElement input) {
- synchronized (this) {
- if (fRestoreStateJob == null) {
- return;
- }
- fRestoreStateJob= null;
- }
-
- fWorkingSetActionGroup.restoreState(memento);
- setInputElement(input);
-
- Integer viewerIndex= memento.getInteger(TAG_VIEW);
- if (viewerIndex != null) {
- setView(viewerIndex.intValue());
- }
- Integer orientation= memento.getInteger(TAG_ORIENTATION);
- if (orientation != null) {
- fOrientation= orientation.intValue();
- }
- computeOrientation();
- updateCheckedState();
-
- Integer ratio= memento.getInteger(TAG_RATIO);
- if (ratio != null) {
- fTypeMethodsSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() });
- }
- ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
- if (bar != null) {
- Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
- if (vScroll != null) {
- bar.setSelection(vScroll.intValue());
- }
- }
- fMethodsViewer.restoreState(memento);
- }
-
- private void restoreLinkingEnabled(IMemento memento) {
- Integer val= memento.getInteger(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR);
- if (val != null) {
- fLinkingEnabled= val.intValue() != 0;
- }
- }
-
-
- /**
- * view part becomes visible
- */
- protected void visibilityChanged(boolean isVisible) {
- fIsVisible= isVisible;
- if (isVisible && fNeedRefresh) {
- doTypeHierarchyChangedOnViewers(null);
- }
- fNeedRefresh= false;
- }
-
-
- /**
- * Link selection to active editor.
- */
- protected void editorActivated(IEditorPart editor) {
- if (!isLinkingEnabled()) {
- return;
- }
- if (fInputElement == null) {
- // no type hierarchy shown
- return;
- }
-
- ICElement elem= (ICElement)editor.getEditorInput().getAdapter(ICElement.class);
- TypeHierarchyViewer currentViewer= getCurrentViewer();
- if (elem instanceof ITranslationUnit) {
- try {
- ICElement[] allTypes= TypeUtil.getAllTypes((ITranslationUnit)elem);
- for (int i= 0; i < allTypes.length; i++) {
- if (currentViewer.isElementShown(allTypes[i])) {
- internalSelectType(allTypes[i], true);
- updateMethodViewer(allTypes[i]);
- return;
- }
- }
- } catch (CModelException e) {
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- return fInputElement;
- }
-
-
- /**
- * Returns the
IShowInSource
for this view.
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(
- null,
- getSite().getSelectionProvider().getSelection());
- }
- };
- }
-
- boolean isLinkingEnabled() {
- return fLinkingEnabled;
- }
-
- public void setLinkingEnabled(boolean enabled) {
- fLinkingEnabled= enabled;
- PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR, enabled);
-
- if (enabled) {
- IEditorPart editor = getSite().getPage().getActiveEditor();
- if (editor != null) {
- editorActivated(editor);
- }
- }
- }
-
- public void clearNeededRefresh() {
- fNeedRefresh= false;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java
deleted file mode 100644
index 5a114f47f92..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-public abstract class TypeHierarchyViewer extends ProblemTreeViewer {
-
-// private OpenAction fOpen;
- private HierarchyLabelProvider fLabelProvider;
-
- public TypeHierarchyViewer(Composite parent, IContentProvider contentProvider, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(new Tree(parent, SWT.SINGLE));
-
- fLabelProvider= new HierarchyLabelProvider(lifeCycle);
-
-// setLabelProvider(new DecoratingCLabelProvider(fLabelProvider, true));
- setLabelProvider(fLabelProvider);
- setUseHashlookup(true);
-
- setContentProvider(contentProvider);
- setSorter(new HierarchyViewerSorter(lifeCycle));
-
-// fOpen= new OpenAction(part.getSite());
-// addOpenListener(new IOpenListener() {
-// public void open(OpenEvent event) {
-// fOpen.run();
-// }
-// });
-
-// CUIHelp.setHelp(this, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
- }
-
- public void setQualifiedTypeName(boolean on) {
- if (on) {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() | CElementLabels.T_POST_QUALIFIED);
- } else {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() & ~CElementLabels.T_POST_QUALIFIED);
- }
- refresh();
- }
-
- /**
- * Attaches a contextmenu listener to the tree
- */
- public void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) {
- MenuManager menuMgr= new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(menuListener);
- Menu menu= menuMgr.createContextMenu(getTree());
- getTree().setMenu(menu);
- viewSite.registerContextMenu(popupId, menuMgr, this);
- }
-
- /**
- * Fills up the context menu with items for the hierarchy viewer
- * Should be called by the creator of the context menu
- */
- public void contributeToContextMenu(IMenuManager menu) {
- }
-
- /**
- * Set the member filter
- */
- public void setMemberFilter(IMember[] memberFilter) {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- contentProvider.setMemberFilter(memberFilter);
- }
- }
-
- /**
- * Returns if method filtering is enabled.
- */
- public boolean isMethodFiltering() {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- return contentProvider.getMemberFilter() != null;
- }
- return false;
- }
-
- public void setWorkingSetFilter(ViewerFilter filter) {
- fLabelProvider.setFilter(filter);
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- contentProvider.setWorkingSetFilter(filter);
- }
- }
-
- /**
- * Returns true if the hierarchy contains elements. Returns one of them
- * With member filtering it is possible that no elements are visible
- */
- public Object containsElements() {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- Object[] elements= contentProvider.getElements(null);
- if (elements.length > 0) {
- return elements[0];
- }
- }
- return null;
- }
-
- /**
- * Returns true if the hierarchy contains elements. Returns one of them
- * With member filtering it is possible that no elements are visible
- */
- public ICElement getTreeRootType() {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- Object[] elements= contentProvider.getElements(null);
- if (elements.length > 0 && elements[0] instanceof ICElement) {
- return (ICElement) elements[0];
- }
- }
- return null;
- }
-
- /**
- * Returns true if the hierarchy contains element the element.
- */
- public boolean isElementShown(Object element) {
- return findItem(element) != null;
- }
-
- /**
- * Updates the content of this viewer: refresh and expanding the tree in the way wanted.
- */
- public abstract void updateContent(boolean doExpand);
-
- /**
- * Returns the title for the current view
- */
- public abstract String getTitle();
-
- /*
- * @see StructuredViewer#setContentProvider
- * Content provider must be of type TypeHierarchyContentProvider
- */
- public void setContentProvider(IContentProvider cp) {
- Assert.isTrue(cp instanceof TypeHierarchyContentProvider);
- super.setContentProvider(cp);
- }
-
- protected TypeHierarchyContentProvider getHierarchyContentProvider() {
- return (TypeHierarchyContentProvider)getContentProvider();
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java
deleted file mode 100644
index 6a6e1564cd4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- * QNX Software Systems - adapted for use in CDT
- *******************************************************************************/
-package org.eclipse.cdt.ui.browser.typeinfo;
-
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class TypeInfoLabelProvider extends LabelProvider {
-
- public static final int SHOW_TYPE_ONLY= 0x01;
- public static final int SHOW_ENCLOSING_TYPE_ONLY= 0x02;
- public static final int SHOW_FULLY_QUALIFIED= 0x04;
- public static final int SHOW_PATH= 0x08;
-
- private static final Image HEADER_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT_HEADER);
- private static final Image SOURCE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT);
- private static final Image NAMESPACE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_NAMESPACE);
- private static final Image TEMPLATE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TEMPLATE);
- private static final Image CLASS_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_CLASS);
- private static final Image STRUCT_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_STRUCT);
- private static final Image TYPEDEF_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TYPEDEF);
- private static final Image UNION_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_UNION);
- private static final Image ENUM_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_ENUMERATION);
- private static final Image UNKNOWN_TYPE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_UNKNOWN_TYPE);
-
- private int fFlags;
-
- public TypeInfoLabelProvider(int flags) {
- fFlags= flags;
- }
-
- private boolean isSet(int flag) {
- return (fFlags & flag) != 0;
- }
-
- /* non java-doc
- * @see ILabelProvider#getText
- */
- public String getText(Object element) {
- if (! (element instanceof ITypeInfo))
- return super.getText(element);
-
- ITypeInfo typeRef= (ITypeInfo) element;
- IQualifiedTypeName qualifiedName = typeRef.getQualifiedTypeName();
-
- StringBuffer buf= new StringBuffer();
- if (isSet(SHOW_TYPE_ONLY)) {
- String name= typeRef.getName();
- if (name != null && name.length() > 0)
- buf.append(name);
- } else if (isSet(SHOW_ENCLOSING_TYPE_ONLY)) {
- IQualifiedTypeName parentName= qualifiedName.getEnclosingTypeName();
- if (parentName != null) {
- buf.append(parentName.getFullyQualifiedName());
- } else {
- buf.append(TypeInfoMessages.getString("TypeInfoLabelProvider.globalScope")); //$NON-NLS-1$
- }
- } else if (isSet(SHOW_FULLY_QUALIFIED)) {
- buf.append(qualifiedName.getFullyQualifiedName());
- }
-
- if (isSet(SHOW_PATH)) {
- IPath path = null;
- ITypeReference ref = typeRef.getResolvedReference();
- if (ref != null) {
- path = ref.getPath();
- } else {
- IProject project = typeRef.getEnclosingProject();
- if (project != null) {
- path = project.getFullPath();
- }
- }
- if (path != null) {
- buf.append(TypeInfoMessages.getString("TypeInfoLabelProvider.dash"));//$NON-NLS-1$
- buf.append(path.toString());
- }
- }
- return buf.toString();
- }
-
- /* non java-doc
- * @see ILabelProvider#getImage
- */
- public Image getImage(Object element) {
- if (!(element instanceof ITypeInfo))
- return super.getImage(element);
-
- ITypeInfo typeRef= (ITypeInfo) element;
- if (isSet(SHOW_ENCLOSING_TYPE_ONLY)) {
- ITypeInfo parentInfo = typeRef.getEnclosingType();
- if (parentInfo != null) {
- return getTypeIcon(parentInfo.getCElementType());
- }
- IPath path = null;
- ITypeReference ref = typeRef.getResolvedReference();
- if (ref != null) {
- path = ref.getPath();
- if (CoreModel.isValidHeaderUnitName(typeRef.getEnclosingProject(), path.lastSegment())) {
- return HEADER_ICON;
- }
- }
- return SOURCE_ICON;
- }
-
- return getTypeIcon(typeRef.getCElementType());
- }
-
- public static Image getTypeIcon(int type)
- {
- switch (type)
- {
- case ICElement.C_NAMESPACE:
- return NAMESPACE_ICON;
-
- case ICElement.C_TEMPLATE_CLASS:
- return TEMPLATE_ICON;
-
- case ICElement.C_CLASS:
- return CLASS_ICON;
-
- case ICElement.C_STRUCT:
- return STRUCT_ICON;
-
- case ICElement.C_UNION:
- return UNION_ICON;
-
- case ICElement.C_ENUMERATION:
- return ENUM_ICON;
-
- case ICElement.C_TYPEDEF:
- return TYPEDEF_ICON;
-
- default:
- return UNKNOWN_TYPE_ICON;
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
index d2ce05a9276..8b7982576b1 100644
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
@@ -11,17 +11,13 @@
*******************************************************************************/
package org.eclipse.cdt.ui.browser.typeinfo;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.util.QualifiedTypeName;
import org.eclipse.cdt.internal.ui.util.StringMatcher;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -121,46 +117,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
* @see FilteredList.FilterMatcher#match(Object)
*/
public boolean match(Object element) {
- if (!(element instanceof ITypeInfo))
- return false;
-
- ITypeInfo info = (ITypeInfo) element;
- IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
-
- if (fVisibleTypes != null && !fVisibleTypes.contains(new Integer(info.getCElementType())))
- return false;
-
- if (!fShowLowLevelTypes && qualifiedName.isLowLevel())
- return false;
-
- if (fSegmentMatchers.length == 1 && !fMatchGlobalNamespace)
- return fNameMatcher.match(qualifiedName.getName());
-
- return matchQualifiedName(info);
- }
-
- private boolean matchQualifiedName(ITypeInfo info) {
- IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
- if (fSegmentMatchers.length != qualifiedName.segmentCount())
- return false;
-
- if (fMatchGlobalNamespace) {
- // must match global namespace (eg ::foo)
- if (info.getRootNamespace(false) != null)
- return false;
- }
-
- boolean matchFound = true;
- int max = Math.min(fSegmentMatchers.length, qualifiedName.segmentCount());
- for (int i = 0; i < max; ++i) {
- StringMatcher matcher = fSegmentMatchers[i];
- String name = qualifiedName.segment(i);
- if (name == null || !matcher.match(name)) {
- matchFound = false;
- break;
- }
- }
- return matchFound;
+ return false;
}
private static String adjustPattern(String pattern) {
@@ -203,9 +160,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
private static final String SETTINGS_SHOW_UNIONS = "show_unions"; //$NON-NLS-1$
private static final String SETTINGS_SHOW_LOWLEVEL = "show_lowlevel"; //$NON-NLS-1$
- private static final TypeInfoLabelProvider fElementRenderer = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY);
- private static final TypeInfoLabelProvider fQualifierRenderer = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_ENCLOSING_TYPE_ONLY + TypeInfoLabelProvider.SHOW_PATH);
-
static final TypeFilterMatcher fFilterMatcher = new TypeFilterMatcher();
private static final StringComparator fStringComparator = new StringComparator();
@@ -226,7 +180,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
* @param parent the parent shell.
*/
public TypeSelectionDialog(Shell parent) {
- super(parent, fElementRenderer, fQualifierRenderer);
+ super(parent, null, null);//fElementRenderer, fQualifierRenderer);
setMatchEmptyString(false);
setUpperListLabel(TypeInfoMessages.getString("TypeSelectionDialog.upperLabel")); //$NON-NLS-1$
setLowerListLabel(TypeInfoMessages.getString("TypeSelectionDialog.lowerLabel")); //$NON-NLS-1$
@@ -341,7 +295,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
default:
return;
}
- Image icon = TypeInfoLabelProvider.getTypeIcon(type);
+ Image icon = null; //TypeInfoLabelProvider.getTypeIcon(type);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout(2, false);
@@ -570,12 +524,5 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
* @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
*/
protected void computeResult() {
- ITypeInfo selection = (ITypeInfo) getLowerSelectedElement();
- if (selection == null)
- return;
-
- List result = new ArrayList(1);
- result.add(selection);
- setResult(result);
}
}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/Checks.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/Checks.java
deleted file mode 100644
index c44dff6a24b..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/Checks.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CConventions;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModelMarker;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.internal.ui.util.Resources;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * This class defines a set of reusable static checks methods.
- */
-public class Checks {
-
- /*
- * no instances
- */
- private Checks(){
- }
-
- /* Constants returned by checkExpressionIsRValue */
- public static final int IS_RVALUE= 0;
- public static final int NOT_RVALUE_MISC= 1;
- public static final int NOT_RVALUE_VOID= 2;
-
- /**
- * Checks if the given name is a valid C field name.
- *
- * @param the java field name.
- * @return a refactoring status containing the error message if the
- * name is not a valid java field name.
- */
- public static RefactoringStatus checkFieldName(String name) {
- return checkName(name, CConventions.validateFieldName(name));
- }
-
- /**
- * Checks if the given name is a valid C identifier.
- *
- * @param the java identifier.
- * @return a refactoring status containing the error message if the
- * name is not a valid java identifier.
- */
- public static RefactoringStatus checkIdentifier(String name) {
- return checkName(name, CConventions.validateIdentifier(name));
- }
-
- /**
- * Checks if the given name is a valid C method name.
- *
- * @param the java method name.
- * @return a refactoring status containing the error message if the
- * name is not a valid java method name.
- */
- public static RefactoringStatus checkMethodName(String name) {
- RefactoringStatus status= checkName(name, CConventions.validateMethodName(name));
- if (status.isOK() && startsWithUpperCase(name))
- return RefactoringStatus.createWarningStatus(RefactoringCoreMessages.getString("Checks.method_names_lowercase")); //$NON-NLS-1$
- else
- return status;
- }
-
- /**
- * Checks if the given name is a valid C type name.
- *
- * @param the java method name.
- * @return a refactoring status containing the error message if the
- * name is not a valid java type name.
- */
- public static RefactoringStatus checkClassName(String name) {
- //fix for: 1GF5Z0Z: ITPJUI:WINNT - assertion failed after renameType refactoring
- if (name.indexOf(".") != -1) //$NON-NLS-1$
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("Checks.no_dot"));//$NON-NLS-1$
- else {
- RefactoringStatus status = checkName(name, CConventions.validateClassName(name));
- if (status.hasFatalError()){
- String msg = RefactoringCoreMessages.getFormattedString(
- "Checks.error.InvalidClassName",//$NON-NLS-1$
- status.getFirstMessage(RefactoringStatus.FATAL));
- return RefactoringStatus.createFatalErrorStatus(msg);
- }
- else if (status.hasError()){
- String msg = RefactoringCoreMessages.getFormattedString(
- "Checks.error.InvalidClassName",//$NON-NLS-1$
- status.getFirstMessage(RefactoringStatus.ERROR));
- return RefactoringStatus.createErrorStatus(msg);
- }
- else if (status.hasWarning()){
- String msg = RefactoringCoreMessages.getFormattedString(
- "Checks.warning.ClassNameDiscouraged",//$NON-NLS-1$
- status.getFirstMessage(RefactoringStatus.INFO));
- return RefactoringStatus.createWarningStatus(msg);
- }else{
- return status;
- }
- }
- }
-
-
- private static boolean startsWithUpperCase(String s) {
- if (s == null)
- return false;
- else if ("".equals(s)) //$NON-NLS-1$
- return false;
- else
- //workaround for JDK bug (see 26529)
- return s.charAt(0) == Character.toUpperCase(s.charAt(0));
- }
-
- public static boolean startsWithLowerCase(String s){
- if (s == null)
- return false;
- else if ("".equals(s)) //$NON-NLS-1$
- return false;
- else
- //workaround for JDK bug (see 26529)
- return s.charAt(0) == Character.toLowerCase(s.charAt(0));
- }
-
- public static boolean resourceExists(IPath resourcePath){
- return ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath) != null;
- }
-
-
- public static boolean isAlreadyNamed(ICElement element, String name){
- return name.equals(element.getElementName());
- }
-
- //---- Private helpers ----------------------------------------------------------------------
-
- private static RefactoringStatus checkName(String name, IStatus status) {
- RefactoringStatus result= new RefactoringStatus();
- if ("".equals(name)) //$NON-NLS-1$
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("Checks.Choose_name")); //$NON-NLS-1$
-
- if (status.isOK())
- return result;
-
- switch (status.getSeverity()){
- case IStatus.ERROR:
- return RefactoringStatus.createFatalErrorStatus(status.getMessage());
- case IStatus.WARNING:
- return RefactoringStatus.createWarningStatus(status.getMessage());
- case IStatus.INFO:
- return RefactoringStatus.createInfoStatus(status.getMessage());
- default: //no nothing
- return new RefactoringStatus();
- }
- }
-
- public static RefactoringStatus checkIfTuBroken(ICElement element) throws CModelException{
- ITranslationUnit tu= (ITranslationUnit)CoreModel.getDefault().create(element.getUnderlyingResource());
- if (tu == null)
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("Checks.cu_not_created")); //$NON-NLS-1$
- else if (! tu.isStructureKnown())
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("Checks.cu_not_parsed")); //$NON-NLS-1$
- return new RefactoringStatus();
- }
- //-------- validateEdit checks ----
-
- public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify) {
- RefactoringStatus result= new RefactoringStatus();
- IStatus status= Resources.checkInSync(filesToModify);
- if (!status.isOK())
- result.merge(RefactoringStatus.create(status));
- status= Resources.makeCommittable(filesToModify, null);
- if (!status.isOK())
- result.merge(RefactoringStatus.create(status));
- return result;
- }
-
- public static boolean isAvailable(ICElement cElement) throws CModelException {
- if (cElement == null)
- return false;
- if (! cElement.exists())
- return false;
- if (cElement.isReadOnly())
- return false;
- return true;
- }
-
- /**
- * From SearchResultGroup[] passed as the parameter
- * this method removes all those that correspond to a non-parsable ITranslationUnit
- * and returns it as a result.
- * Status object collect the result of checking.
- */
- public static SearchResultGroup[] excludeTranslationUnits(SearchResultGroup[] grouped, RefactoringStatus status) throws CModelException{
- List result= new ArrayList();
- boolean wasEmpty= grouped.length == 0;
- for (int i= 0; i < grouped.length; i++){
- IResource resource= grouped[i].getResource();
- ICElement element= CoreModel.getDefault().create(resource);
- if (! (element instanceof ITranslationUnit))
- continue;
- //XXX this is a workaround for a jcore feature that shows errors in cus only when you get the original element
- ITranslationUnit cu= (ITranslationUnit)CoreModel.getDefault().create(resource);
- if (! cu.isStructureKnown()){
- String path= cu.getResource().getFullPath().toOSString();
- status.addError(RefactoringCoreMessages.getFormattedString("Checks.cannot_be_parsed", path)); //$NON-NLS-1$
- continue; //removed, go to the next one
- }
- result.add(grouped[i]);
- }
-
- if ((!wasEmpty) && result.isEmpty())
- status.addFatalError(RefactoringCoreMessages.getString("Checks.all_excluded")); //$NON-NLS-1$
- else if (result.isEmpty()){
- status.addFatalError(RefactoringCoreMessages.getString("Checks.no_files")); //$NON-NLS-1$
- }
-
- return (SearchResultGroup[])result.toArray(new SearchResultGroup[result.size()]);
- }
-
- public static RefactoringStatus checkCompileErrorsInAffectedFiles(SearchResultGroup[] grouped) throws CModelException {
- RefactoringStatus result= new RefactoringStatus();
- for (int i= 0; i < grouped.length; i++){
- IResource resource= grouped[i].getResource();
- if (hasCompileErrors(resource))
- result.addFatalError(RefactoringCoreMessages.getFormattedString("Checks.cu_has_compile_errors", resource.getFullPath().makeRelative())); //$NON-NLS-1$
- }
- return result;
- }
-
- private static boolean hasCompileErrors(IResource resource) throws CModelException {
- try {
- IMarker[] problemMarkers= resource.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- for (int i= 0; i < problemMarkers.length; i++) {
- if (problemMarkers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR)
- return true;
- }
- return false;
- } catch (CModelException e){
- throw e;
- } catch (CoreException e){
- throw new CModelException(e);
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/CompositeChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/CompositeChange.java
deleted file mode 100644
index 978c87b8b23..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/CompositeChange.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.internal.corext.refactoring.base.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-
-/**
- * Represents a composite change.
- */
-public class CompositeChange extends Change implements ICompositeChange {
-
- private List fChanges;
- private IChange fUndoChange;
- private String fName;
-
- public CompositeChange() {
- this(RefactoringCoreMessages.getString("CompositeChange.CompositeChange")); //$NON-NLS-1$
- }
-
- public CompositeChange(String name, IChange[] changes) {
- this(name, new ArrayList(changes.length));
- addAll(changes);
- }
-
- public CompositeChange(String name) {
- this(name, new ArrayList(5));
- }
-
- public CompositeChange(String name, int initialCapacity) {
- this(name, new ArrayList(initialCapacity));
- }
-
- private CompositeChange(String name, List changes) {
- fChanges= changes;
- fName= name;
- }
-
- /* (Non-Javadoc)
- * Method declared in IChange.
- */
- public final RefactoringStatus aboutToPerform(ChangeContext context, IProgressMonitor pm) {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- RefactoringStatus result= new RefactoringStatus();
- pm.beginTask("", fChanges.size() + 1); //$NON-NLS-1$
- result.merge(super.aboutToPerform(context, new SubProgressMonitor(pm,1)));
- for (Iterator iter= fChanges.iterator(); iter.hasNext(); ) {
- result.merge(((IChange)iter.next()).aboutToPerform(context, new SubProgressMonitor(pm,1)));
- }
- return result;
- }
-
- /* (Non-Javadoc)
- * Method declared in IChange.
- */
- public final void performed() {
- for (Iterator iter= fChanges.iterator(); iter.hasNext(); ) {
- ((IChange)iter.next()).performed();
- }
- }
-
- /* non java-doc
- * @see IChange#getUndoChange
- */
- public final IChange getUndoChange() {
- return fUndoChange;
- }
-
- public void addAll(IChange[] changes) {
- for (int i= 0; i < changes.length; i++) {
- add(changes[i]);
- }
- }
-
- public void add(IChange change) {
- if (change != null)
- fChanges.add(change);
- }
-
- public IChange[] getChildren() {
- if (fChanges == null)
- return null;
- return (IChange[])fChanges.toArray(new IChange[fChanges.size()]);
- }
-
- final List getChanges() {
- return fChanges;
- }
-
- /**
- * to reverse a composite means reversing all changes in reverse order
- */
- private List createUndoList(ChangeContext context, IProgressMonitor pm) throws CModelException {
- List undoList= null;
- try {
- undoList= new ArrayList(fChanges.size());
- pm.beginTask("", fChanges.size()); //$NON-NLS-1$
- for (Iterator iter= fChanges.iterator(); iter.hasNext();) {
- try {
- IChange each= (IChange)iter.next();
- each.perform(context, new SubProgressMonitor(pm, 1));
- undoList.add(each.getUndoChange());
- context.addPerformedChange(each);
- } catch (Exception e) {
- handleException(context, e);
- }
- }
- pm.done();
- Collections.reverse(undoList);
- return undoList;
- } catch (Exception e) {
- handleException(context, e);
- }
- if (undoList == null)
- undoList= new ArrayList(0);
- return undoList;
- }
-
- /* non java-doc
- * @see IChange#perform
- */
- public final void perform(ChangeContext context, IProgressMonitor pm) throws CModelException {
- pm.beginTask("", 1); //$NON-NLS-1$
- pm.setTaskName(RefactoringCoreMessages.getString("CompositeChange.performingChangesTask.name")); //$NON-NLS-1$
- if (!isActive()) {
- fUndoChange= new NullChange();
- } else {
- fUndoChange= new CompositeChange(fName, createUndoList(context, new SubProgressMonitor(pm, 1)));
- }
- pm.done();
- }
-
- /* non java-doc
- * for debugging only
- */
- public String toString() {
- StringBuffer buff= new StringBuffer();
- buff.append("CompositeChange\n"); //$NON-NLS-1$
- for (Iterator iter= fChanges.iterator(); iter.hasNext();) {
- buff.append("<").append(iter.next().toString()).append("/>\n"); //$NON-NLS-2$ //$NON-NLS-1$
- }
- return buff.toString();
- }
-
- /* non java-doc
- * @see IChange#getName()
- */
- public String getName() {
- return fName;
- }
-
- /* non java-doc
- * @see IChange#getModifiedLanguageElement()
- */
- public Object getModifiedLanguageElement() {
- return null;
- }
-
- /* non java-doc
- * @see IChange#setActive
- * This method activates/disactivates all subchanges of this change. The
- * change itself is always active to ensure that sub changes are always
- * considered if they are active.
- */
- public void setActive(boolean active) {
- for (Iterator iter= fChanges.iterator(); iter.hasNext(); ) {
- ((IChange)iter.next()).setActive(active);
- }
- }
-
- /*non java-doc
- * @see IChange#isUndoable()
- * Composite can be undone iff all its sub-changes can be undone.
- */
- public boolean isUndoable() {
- for (Iterator iter= fChanges.iterator(); iter.hasNext(); ) {
- IChange each= (IChange)iter.next();
- if (! each.isUndoable())
- return false;
- }
- return true;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IProcessorBasedRefactoring.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IProcessorBasedRefactoring.java
deleted file mode 100644
index 61e4188db1d..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IProcessorBasedRefactoring.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * A tagging interface for refactorings that are implemented using
- * the processor/participant architecture
- */
-public interface IProcessorBasedRefactoring extends IAdaptable {
-
- /**
- * Returns the refactoring's processor
- *
- * @return the refactoring's processor
- */
- public IRefactoringProcessor getProcessor();
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IQualifiedNameUpdatingRefactoring.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IQualifiedNameUpdatingRefactoring.java
deleted file mode 100644
index a4e3265c705..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IQualifiedNameUpdatingRefactoring.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-public interface IQualifiedNameUpdatingRefactoring {
-
- /**
- * Performs a dynamic check whether this refactoring object is capable of
- * updating qualified names in non C files. The return value of this
- * method may change according to the state of the refactoring.
- */
- public boolean canEnableQualifiedNameUpdating();
-
- /**
- * If canEnableQualifiedNameUpdating
returns true
,
- * then this method is used to ask the refactoring object whether references
- * in non C files should be updated. This call can be ignored if
- * canEnableQualifiedNameUpdating
returns false
.
- */
- public boolean getUpdateQualifiedNames();
-
- /**
- * If canEnableQualifiedNameUpdating
returns true
,
- * then this method is used to inform the refactoring object whether
- * references in non C files should be updated. This call can be ignored
- * if canEnableQualifiedNameUpdating
returns false
.
- */
- public void setUpdateQualifiedNames(boolean update);
-
- public String getFilePatterns();
-
- public void setFilePatterns(String patterns);
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRefactoringProcessor.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRefactoringProcessor.java
deleted file mode 100644
index 7b6b9fa7b52..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRefactoringProcessor.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-public interface IRefactoringProcessor extends IAdaptable {
-
- public void initialize(Object[] elements) throws CoreException;
-
- public boolean isAvailable() throws CoreException;
-
- public String getProcessorName();
-
- public int getStyle();
-
-// public IProject[] getAffectedProjects() throws CoreException;
-
- public Object[] getElements();
-
- public Object[] getDerivedElements() throws CoreException;
-
-// public IResourceModifications getResourceModifications() throws CoreException;
-
- public RefactoringStatus checkActivation() throws CoreException;
-
- public RefactoringStatus checkInput(IProgressMonitor pm) throws CoreException;
-
- public IChange createChange(IProgressMonitor pm) throws CoreException;
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IReferenceUpdating.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IReferenceUpdating.java
deleted file mode 100644
index f5fd60d8d16..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IReferenceUpdating.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-public interface IReferenceUpdating {
-
- /**
- * Checks if this refactoring object is capable of updating references to the renamed element.
- */
- public boolean canEnableUpdateReferences();
-
- /**
- * If canUpdateReferences
returns true
, then this method is used to
- * inform the refactoring object whether references should be updated.
- * This call can be ignored if canUpdateReferences
returns false
.
- */
- public void setUpdateReferences(boolean update);
-
- /**
- * If canUpdateReferences
returns true
, then this method is used to
- * ask the refactoring object whether references should be updated.
- * This call can be ignored if canUpdateReferences
returns false
.
- */
- public boolean getUpdateReferences();
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRenameProcessor.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRenameProcessor.java
deleted file mode 100644
index 14370acb016..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRenameProcessor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.*;
-
-
-public interface IRenameProcessor extends IRefactoringProcessor {
-
- public String getCurrentElementName();
-
- public RefactoringStatus checkNewElementName(String newName) throws CoreException;
-
- public void setNewElementName(String newName);
-
- public String getNewElementName();
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRenameRefactoring.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRenameRefactoring.java
deleted file mode 100644
index 4ab3177af75..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IRenameRefactoring.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.internal.corext.refactoring.base.*;
-
-/**
- * Represents a refactoring that renames an ICElement
.
- */
-public interface IRenameRefactoring extends IRefactoring {
-
- /**
- * Sets new name for the entity that this refactoring is working on.
- */
- public void setNewName(String newName);
-
- /**
- * Get the name for the entity that this refactoring is working on.
- */
- public String getNewName();
-
- /**
- * Gets the current name of the entity that this refactoring is working on.
- */
- public String getCurrentName();
-
- /**
- * Checks if the new name is valid for the entity that this refactoring renames.
- */
- public RefactoringStatus checkNewName(String newName) throws CModelException;
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IResourceModifications.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IResourceModifications.java
deleted file mode 100644
index f7159075cc8..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/IResourceModifications.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-
-/**
- * A data structure describing the resource modification resulting from
- * applying a certain refactoring.
- *
- * @since 3.0
- */
-public interface IResourceModifications {
-
- /**
- * Returns the list of resources to be created.
- *
- * @return the list of resources to be created
- */
- public List getCreate();
-
- /**
- * Returns the list of resources to be deleted.
- *
- * @return the list of resources to be deleted
- */
- public List getDelete();
-
- /**
- * Returns the list of resources to be copied.
- *
- * @return the list of resources to be copied
- */
- public List getCopy();
-
- /**
- * Returns the copy target.
- *
- * @return the copy target
- */
- public IContainer getCopyTarget();
-
- /**
- * Returns the list of resources to be moved.
- *
- * @return the list of resources to be moved
- */
- public List getMove();
-
- /**
- * Returns the move target
- *
- * @return the move target
- */
- public IContainer getMoveTarget();
-
- /**
- * Returns the resource to be renamed
- *
- * @return the resourcr to be renamed
- */
- public IResource getRename();
-
- /**
- * Returns the new name of the resource to be renamed
- *
- * @return the new resource name
- */
- public String getNewName();
-
- /**
- * Returns an array of participants that want to participate
- * in the resource modifications described by this data
- * structure.
- *
- * @param processor the main processor of the overall refactoring
- * @return an array of participants
- */
-// public IRefactoringParticipant[] getParticipants(IRefactoringProcessor processor, SharableParticipants shared) throws CoreException;
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ITextUpdating.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ITextUpdating.java
deleted file mode 100644
index 2531887d4a4..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ITextUpdating.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-
-
-public interface ITextUpdating {
-
- /**
- * Performs a dynamic check whether this refactoring object is capable of updating references to the renamed element.
- */
- public boolean canEnableTextUpdating();
-
- /**
- * If canEnableTextUpdating
returns true
, then this method is used to
- * ask the refactoring object whether references in JavaDoc comments should be updated.
- * This call can be ignored if canEnableTextUpdating
returns false
.
- */
- public boolean getUpdateJavaDoc();
-
- /**
- * If canEnableTextUpdating
returns true
, then this method is used to
- * ask the refactoring object whether references in regular (non JavaDoc) comments should be updated.
- * This call can be ignored if canEnableTextUpdating
returns false
.
- */
- public boolean getUpdateComments();
-
- /**
- * If canEnableTextUpdating
returns true
, then this method is used to
- * ask the refactoring object whether references in string literals should be updated.
- * This call can be ignored if canEnableTextUpdating
returns false
.
- */
- public boolean getUpdateStrings();
-
- /**
- * If canEnableTextUpdating
returns true
, then this method is used to
- * inform the refactoring object whether references in JavaDoc comments should be updated.
- * This call can be ignored if canEnableTextUpdating
returns false
.
- */
- public void setUpdateJavaDoc(boolean update);
-
- /**
- * If canEnableTextUpdating
returns true
, then this method is used to
- * inform the refactoring object whether references in regular (non JavaDoc) comments should be updated.
- * This call can be ignored if canEnableTextUpdating
returns false
.
- */
- public void setUpdateComments(boolean update);
-
- /**
- * If canEnableTextUpdating
returns true
, then this method is used to
- * inform the refactoring object whether references in string literals should be updated.
- * This call can be ignored if canEnableTextUpdating
returns false
.
- */
- public void setUpdateStrings(boolean update);
-
- /**
- * Returns the current name of the element to be renamed.
- *
- * @return the current name of the element to be renamed
- */
- public String getCurrentElementName();
-
- /**
- * Returns the new name of the element
- *
- * @return the new element name
- */
- public String getNewElementName();
-}
-
-
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ListenerList.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ListenerList.java
deleted file mode 100644
index ba32e3d4432..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ListenerList.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import org.eclipse.cdt.internal.corext.Assert;
-
-/**
- * Local copy of org.eclipse.jface.ListenerList
- */
-public class ListenerList {
-
- static {
- //XXX: 1GCQD0A: ITPVCM:WIN2000 - ListenerList should be part of a core project
- }
-
- /**
- * The initial capacity of the list. Always >= 1.
- */
- private int capacity;
-
- /**
- * The current number of listeners.
- * Maintains invariant: 0 <= size <= listeners.length.
- */
- private int size;
-
- /**
- * The list of listeners. Initially null
but initialized
- * to an array of size capacity the first time a listener is added.
- * Maintains invariant: listeners != null IFF size != 0
- */
- private Object[] listeners= null;
-
- /**
- * The empty array singleton instance, returned by getListeners()
- * when size == 0.
- */
- private static final Object[] EmptyArray= new Object[0];
-
- /**
- * Creates a listener list with an initial capacity of 3.
- */
- public ListenerList() {
- this(3);
- }
-
- /**
- * Creates a listener list with the given initial capacity.
- *
- * @param capacity the number of listeners which this list can initially accept
- * without growing its internal representation; must be at least 1
- */
- public ListenerList(int capacity) {
- Assert.isTrue(capacity >= 1);
- this.capacity= capacity;
- }
-
- /**
- * Adds the given listener to this list. Has no effect if an identical listener
- * is already registered.
- *
- * @param listener the listener
- */
- public void add(Object listener) {
- Assert.isNotNull(listener);
- if (size == 0) {
- listeners= new Object[capacity];
- } else {
- // check for duplicates using identity
- for (int i= 0; i < size; ++i) {
- if (listeners[i] == listener) {
- return;
- }
- }
- // grow array if necessary
- if (size == listeners.length) {
- System.arraycopy(listeners, 0, listeners= new Object[size * 2 + 1], 0, size);
- }
- }
- listeners[size++]= listener;
- }
-
- /**
- * Returns an array containing all the registered listeners.
- * The resulting array is unaffected by subsequent adds or removes.
- * If there are no listeners registered, the result is an empty array
- * singleton instance (no garbage is created).
- * Use this method when notifying listeners, so that any modifications
- * to the listener list during the notification will have no effect on the
- * notification itself.
- *
- * @return the list of registered listeners
- */
- public Object[] getListeners() {
- if (size == 0)
- return EmptyArray;
- Object[] result= new Object[size];
- System.arraycopy(listeners, 0, result, 0, size);
- return result;
- }
-
- /**
- * Returns whether this listener list is empty.
- *
- * @return true
if there are no registered listeners, and
- * false
otherwise
- */
- public boolean isEmpty() {
- return size == 0;
- }
-
- /**
- * Removes the given listener from this list. Has no effect if an identical
- * listener was not already registered.
- *
- * @param listener the listener
- */
- public void remove(Object listener) {
- Assert.isNotNull(listener);
- for (int i= 0; i < size; ++i) {
- if (listeners[i] == listener) {
- if (--size == 0) {
- listeners= new Object[1];
- } else {
- if (i < size) {
- listeners[i]= listeners[size];
- }
- listeners[size]= null;
- }
- return;
- }
- }
- }
-
- /**
- * Returns the number of registered listeners.
- *
- * @return the number of registered listeners
- */
- public int size() {
- return size;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/NullChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/NullChange.java
deleted file mode 100644
index 66d26b0522e..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/NullChange.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-public class NullChange extends Change {
-
- private String fName;
-
- public NullChange(String name){
- fName= name;
- }
-
- public NullChange(){
- this(null);
- }
-
- public void perform(ChangeContext context, IProgressMonitor pm) {
- }
-
- public IChange getUndoChange() {
- return new NullChange(fName);
- }
-
- public String getName(){
- return "NullChange (" + fName + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public Object getModifiedLanguageElement(){
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringCoreMessages.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringCoreMessages.java
deleted file mode 100644
index e2fe901ca18..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringCoreMessages.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class RefactoringCoreMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.corext.refactoring.refactoring";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private RefactoringCoreMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String getFormattedString(String key, String arg) {
- try{
- return MessageFormat.format(fgResourceBundle.getString(key), new String[] { arg });
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String getFormattedString(String key, Object arg) {
- try{
- return MessageFormat.format(fgResourceBundle.getString(key), new Object[] { arg });
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String getFormattedString(String key, String[] args) {
- try{
- return MessageFormat.format(fgResourceBundle.getString(key), args);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String getFormattedString(String key, Object[] args) {
- try{
- return MessageFormat.format(fgResourceBundle.getString(key), args);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringSearchEngine.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringSearchEngine.java
deleted file mode 100644
index 360a07d251a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringSearchEngine.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.cdt.core.search.BasicSearchResultCollector;
-import org.eclipse.cdt.core.search.ICSearchPattern;
-import org.eclipse.cdt.core.search.ICSearchResultCollector;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.util.CModelUtil;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-/**
- * Convenience wrapper for SearchEngine
- performs searching and sorts the results.
- */
-public class RefactoringSearchEngine {
-
- //no instances
- private RefactoringSearchEngine(){
- }
-
- public static ITranslationUnit[] findAffectedTranslationUnits(final IProgressMonitor pm, ICSearchScope scope, ICSearchPattern pattern) throws CModelException {
- final Set matches= new HashSet(5);
- ICSearchResultCollector collector = new BasicSearchResultCollector();
- try {
- new SearchEngine().search(ResourcesPlugin.getWorkspace(), pattern, scope, collector, false);
- } catch (InterruptedException e){
-
- }
-
- List result= new ArrayList(matches.size());
- for (Iterator iter= matches.iterator(); iter.hasNext(); ) {
- IResource resource= (IResource)iter.next();
- ICElement element= CoreModel.getDefault().create(resource);
- if (element instanceof ITranslationUnit) {
- ITranslationUnit original= (ITranslationUnit)element;
- result.add(CModelUtil.toWorkingCopy(original)); // take working copy is there is one
- }
- }
- return (ITranslationUnit[])result.toArray(new ITranslationUnit[result.size()]);
- }
-
- /**
- * Performs searching for a given SearchPattern
.
- * Returns SearchResultGroup[]
- * In each of SearchResultGroups all SearchResults are
- * sorted backwards by SearchResult#getStart()
- * @see SearchResult
- */
- public static SearchResultGroup[] search(IProgressMonitor pm, ICSearchScope scope, ICSearchPattern pattern) throws CModelException {
- return search(scope, pattern, new BasicSearchResultCollector(pm));
- }
-
- public static SearchResultGroup[] search(ICSearchScope scope, ICSearchPattern pattern, BasicSearchResultCollector collector) throws CModelException {
- return search(scope, pattern, collector, null);
- }
-
- public static SearchResultGroup[] search(IProgressMonitor pm, ICSearchScope scope, ICSearchPattern pattern, ITranslationUnit[] workingCopies) throws CModelException {
- return search(scope, pattern, new BasicSearchResultCollector(pm), workingCopies);
- }
-
- public static SearchResultGroup[] search(ICSearchScope scope, ICSearchPattern pattern, BasicSearchResultCollector collector, ITranslationUnit[] workingCopies) throws CModelException {
- internalSearch(scope, pattern, collector, workingCopies);
- Set results = collector.getSearchResults();
- List resultList = new ArrayList(results);
- return groupByResource(createSearchResultArray(resultList));
- }
-
- public static SearchResultGroup[] groupByResource(BasicSearchMatch[] results){
- Map grouped= groupByResource(Arrays.asList(results));
-
- SearchResultGroup[] result= new SearchResultGroup[grouped.keySet().size()];
- int i= 0;
- for (Iterator iter= grouped.keySet().iterator(); iter.hasNext();) {
- IResource resource= (IResource)iter.next();
- List searchResults= (List)grouped.get(resource);
- result[i]= new SearchResultGroup(resource, createSearchResultArray(searchResults));
- i++;
- }
- return result;
- }
-
- private static BasicSearchMatch[] createSearchResultArray(List searchResults){
- return (BasicSearchMatch[])searchResults.toArray(new BasicSearchMatch[searchResults.size()]);
- }
-
- private static Map groupByResource(List searchResults){
- Map grouped= new HashMap(); //IResource -> List of SearchResults
- for (Iterator iter= searchResults.iterator(); iter.hasNext();) {
- BasicSearchMatch searchResult= (BasicSearchMatch) iter.next();
- if (! grouped.containsKey(searchResult.getResource()))
- grouped.put(searchResult.getResource(), new ArrayList(1));
- ((List)grouped.get(searchResult.getResource())).add(searchResult);
- }
- return grouped;
- }
-
- private static void internalSearch(ICSearchScope scope, ICSearchPattern pattern, ICSearchResultCollector collector, ITranslationUnit[] workingCopies) throws CModelException {
- if (pattern == null)
- return;
- Assert.isNotNull(scope, "scope"); //$NON-NLS-1$
- try {
- createSearchEngine(workingCopies).search(ResourcesPlugin.getWorkspace(), pattern, scope, collector, false);
- }catch (InterruptedException e){
-
- }
- }
-
- private static SearchEngine createSearchEngine(ITranslationUnit[] workingCopies){
-// if (workingCopies == null)
- return new SearchEngine();
-// else
-// return new SearchEngine(workingCopies);
- }
-
-// public static ICSearchPattern createSearchPattern(ICElement[] elements, int limitTo) {
-// if (elements == null || elements.length == 0)
-// return null;
-// Set set= new HashSet(Arrays.asList(elements));
-// Iterator iter= set.iterator();
-// ICElement first= (ICElement)iter.next();
-// ICSearchPattern pattern= createSearchPattern(first, limitTo);
-// while(iter.hasNext()){
-// ICElement each= (ICElement)iter.next();
-// pattern= SearchEngine.createOrSearchPattern(pattern, createSearchPattern(each, limitTo));
-// }
-// return pattern;
-// }
-
-// private static ICSearchPattern createSearchPattern(ICElement element, int limitTo) {
-// return SearchEngine.createSearchPattern(element, limitTo, true);
-// }
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringStyles.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringStyles.java
deleted file mode 100644
index e20bb24f12e..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RefactoringStyles.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-
-public final class RefactoringStyles {
-
- public static final int NONE= 0;
- public static final int NEEDS_PREVIEW= 1 << 0;
- public static final int FORCE_PREVIEW= 1 << 1;
- public static final int NEEDS_PROGRESS= 1 << 2;
-
- private RefactoringStyles() {
- // no instance
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RenameProcessor.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RenameProcessor.java
deleted file mode 100644
index b1043b8adc6..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RenameProcessor.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.core.runtime.CoreException;
-
-public abstract class RenameProcessor implements IRenameProcessor {
-
- private int fStyle;
- protected String fNewElementName;
-
- public int getStyle() {
- return fStyle;
- }
-
- protected RenameProcessor() {
- fStyle= RefactoringStyles.NEEDS_PREVIEW;
- }
-
- protected RenameProcessor(int style) {
- fStyle= style;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.participants.IRenameProcessor#setNewElementName(java.lang.String)
- */
- public void setNewElementName(String newName) {
- Assert.isNotNull(newName);
- fNewElementName= newName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.participants.IRenameProcessor#getNewElementName()
- */
- public String getNewElementName() {
- return fNewElementName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.participants.IRefactoringProcessor#getDerivedElements()
- */
- public Object[] getDerivedElements() throws CoreException {
- return new Object[0];
- }
-
-// public void propagateDataTo(IRenameParticipant participant) throws CoreException {
-// participant.setNewElementName(fNewElementName);
-// if (this instanceof IReferenceUpdating) {
-// participant.setUpdateReferences(((IReferenceUpdating)this).getUpdateReferences());
-// }
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class clazz) {
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RenameRefactoring.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RenameRefactoring.java
deleted file mode 100644
index d83634a6fee..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/RenameRefactoring.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.internal.corext.refactoring.rename.RenameElementProcessor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-public class RenameRefactoring extends Refactoring implements IProcessorBasedRefactoring, IRenameRefactoring {
-
- private Object fElement;
- private IRenameProcessor fProcessor;
-
- public RenameRefactoring(Object element) throws CoreException {
- Assert.isNotNull(element);
-
- fElement= element;
- fProcessor = new RenameElementProcessor();
- fProcessor.initialize(new Object[] {fElement});
- }
-
- public boolean isAvailable() {
- return fProcessor != null;
- }
-
- public Object getAdapter(Class clazz) {
- if (clazz.isInstance(fProcessor))
- return fProcessor;
- return super.getAdapter(clazz);
- }
-
- public IRefactoringProcessor getProcessor() {
- return fProcessor;
- }
-
- public int getStyle() {
- return fProcessor.getStyle();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.IRenameRefactoring#getNewName()
- */
- public String getNewName() {
- return fProcessor.getNewElementName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.IRenameRefactoring#setNewName(java.lang.String)
- */
- public void setNewName(String newName) {
- fProcessor.setNewElementName(newName);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.IRenameRefactoring#getCurrentName()
- */
- public String getCurrentName() {
- return fProcessor.getCurrentElementName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.IRenameRefactoring#checkNewName(java.lang.String)
- */
- public RefactoringStatus checkNewName(String newName) throws CModelException {
- RefactoringStatus result= new RefactoringStatus();
- try {
- result.merge(fProcessor.checkNewElementName(newName));
- } catch (CoreException e) {
- throw new CModelException(e);
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.base.IRefactoring#getName()
- */
- public String getName() {
- return fProcessor.getProcessorName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.base.Refactoring#checkActivation(org.eclipse.core.runtime.IProgressMonitor)
- */
- public RefactoringStatus checkActivation(IProgressMonitor pm) throws CModelException {
- RefactoringStatus result= new RefactoringStatus();
- try {
- result.merge(fProcessor.checkActivation());
- } catch (CoreException e) {
- throw new CModelException(e);
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.base.Refactoring#checkInput(org.eclipse.core.runtime.IProgressMonitor)
- */
- public RefactoringStatus checkInput(IProgressMonitor pm) throws CModelException {
- RefactoringStatus result= new RefactoringStatus();
- try {
- //initParticipants();
- pm.beginTask("", 2); //$NON-NLS-1$
-
- result.merge(fProcessor.checkInput(new SubProgressMonitor(pm, 1)));
- if (result.hasFatalError())
- return result;
-
- } catch (CModelException e) {
- throw e;
- } catch (CoreException e) {
- throw new CModelException(e);
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.base.IRefactoring#createChange(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IChange createChange(IProgressMonitor pm) throws CModelException {
- pm.beginTask("", 1); //$NON-NLS-1$
- CompositeChange result= new CompositeChange();
- try {
- result.add(fProcessor.createChange(new SubProgressMonitor(pm, 1)));
- } catch (CModelException e) {
- throw e;
- } catch (CoreException e) {
- throw new CModelException(e);
- }
- return result;
- }
-
- /* non java-doc
- * for debugging only
- */
- public String toString() {
- if (isAvailable())
- return getName();
- else
- return "No refactoring available to process: " + fElement; //$NON-NLS-1$
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ResourceUtil.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ResourceUtil.java
deleted file mode 100644
index d9b573e7eaa..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/ResourceUtil.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.IOpenable;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-
-public class ResourceUtil {
-
- private ResourceUtil(){
- }
-
- public static IFile[] getFiles(ITranslationUnit[] cus) {
- List files= new ArrayList(cus.length);
- for (int i= 0; i < cus.length; i++) {
- IResource resource= ResourceUtil.getResource(cus[i]);
- if (resource.getType() == IResource.FILE)
- files.add(resource);
- }
- return (IFile[]) files.toArray(new IFile[files.size()]);
- }
-
- public static IFile getFile(ITranslationUnit cu) {
- IResource resource= ResourceUtil.getResource(cu);
- if (resource.getType() == IResource.FILE)
- return (IFile)resource;
- else
- return null;
- }
-
- //----- other ------------------------------
-
- /**
- * Finds an IResource
for a given ITranslationUnit
.
- * If the parameter is a working copy then the IResource
for
- * the original element is returned.
- */
- public static IResource getResource(ITranslationUnit cu) {
- return cu.getResource();
- }
-
-
- /**
- * Returns the IResource
that the given IMember
is defined in.
- * @see #getResource
- */
- public static IResource getResource(IMember member) {
- //Assert.isTrue(!member.isBinary());
- return getResource(member.getTranslationUnit());
- }
-
- public static IResource getResource(Object o){
- if (o instanceof IResource)
- return (IResource)o;
- if (o instanceof ICElement)
- return getResource((ICElement)o);
- return null;
- }
-
- private static IResource getResource(ICElement element){
- if (element.getElementType() == ICElement.C_UNIT)
- return getResource((ITranslationUnit) element);
- else if (element instanceof IOpenable)
- return element.getResource();
- else
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/SearchResultGroup.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/SearchResultGroup.java
deleted file mode 100644
index fa2e4fdadd8..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/SearchResultGroup.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.core.resources.IResource;
-
-public class SearchResultGroup {
-
- private final IResource fResouce;
- private final List fSearchResults;
-
- public SearchResultGroup(IResource res, BasicSearchMatch[] results){
- Assert.isNotNull(results);
- fResouce= res;
- fSearchResults= new ArrayList(Arrays.asList(results));//have to is this way to allow adding
- }
-
- public void add(BasicSearchMatch result) {
- Assert.isNotNull(result);
- fSearchResults.add(result);
- }
-
- public IResource getResource() {
- return fResouce;
- }
-
- public BasicSearchMatch[] getSearchResults() {
- return (BasicSearchMatch[]) fSearchResults.toArray(new BasicSearchMatch[fSearchResults.size()]);
- }
-
- public static IResource[] getResources(SearchResultGroup[] searchResultGroups){
- Set resourceSet= new HashSet(searchResultGroups.length);
- for (int i= 0; i < searchResultGroups.length; i++) {
- resourceSet.add(searchResultGroups[i].getResource());
- }
- return (IResource[]) resourceSet.toArray(new IResource[resourceSet.size()]);
- }
-
- public IResource getResultGroupResource(){
- if (getSearchResults() == null || getSearchResults().length == 0)
- return null;
- return getSearchResults()[0].getResource();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/TextChangeManager.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/TextChangeManager.java
deleted file mode 100644
index 1ab68bc8b52..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/TextChangeManager.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-import org.eclipse.cdt.internal.corext.refactoring.changes.TranslationUnitChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange;
-
-/**
- * A TextChangeManager
manages associations between ITranslationUnit
- * or IFile
and TextChange
objects.
- */
-public class TextChangeManager {
-
- private Map fMap= new HashMap(10); // ITranslationUnit -> TextChange
-
- private final boolean fKeepExecutedTextEdits;
-
- public TextChangeManager() {
- this(false);
- }
-
- /**
- * @see TextChange.setKeepExecutedTextEdits
- */
- public TextChangeManager(boolean keepExecutedTextEdits) {
- fKeepExecutedTextEdits= keepExecutedTextEdits;
- }
-
- /**
- * Adds an association between the given Translation unit and the passed
- * change to this manager.
- *
- * @param cu the Translation unit (key)
- * @param change the change associated with the Translation unit
- */
- public void manage(ITranslationUnit cu, TextChange change) {
- fMap.put(cu, change);
- }
-
- /**
- * Returns the TextChange
associated with the given Translation unit.
- * If the manager does not already manage an association it creates a one.
- *
- * @param cu the Translation unit for which the text buffer change is requested
- * @return the text change associated with the given Translation unit.
- */
- public TextChange get(ITranslationUnit cu) throws CoreException {
- TextChange result= (TextChange)fMap.get(cu);
- if (result == null) {
- result= new TranslationUnitChange(cu.getElementName(), cu);
- result.setKeepExecutedTextEdits(fKeepExecutedTextEdits);
- fMap.put(cu, result);
- }
- return result;
- }
-
- /**
- * Removes the TextChange managed under the given key
- * unit
.
- *
- * @param unit the key determining the TextChange to be removed.
- * @return the removed TextChange.
- */
- public TextChange remove(ITranslationUnit unit) {
- return (TextChange)fMap.remove(unit);
- }
-
- /**
- * Returns all text changes managed by this instance.
- *
- * @return all text changes managed by this instance
- */
- public TextChange[] getAllChanges(){
- return (TextChange[])fMap.values().toArray(new TextChange[fMap.values().size()]);
- }
-
- /**
- * Returns all Translation units managed by this instance.
- *
- * @return all Translation units managed by this instance
- */
- public ITranslationUnit[] getAllTranslationUnits(){
- return (ITranslationUnit[]) fMap.keySet().toArray(new ITranslationUnit[fMap.keySet().size()]);
- }
-
- /**
- * Clears all associations between resources and text changes.
- */
- public void clear() {
- fMap.clear();
- }
-
- /**
- * Returns if any text changes are managed for the specified Translation unit.
- *
- * @return
true
if any text changes are managed for the specified Translation unit and false
otherwise.
- */
- public boolean containsChangesIn(ITranslationUnit cu){
- return fMap.containsKey(cu);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/UndoManager.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/UndoManager.java
deleted file mode 100644
index 9deb3116ca0..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/UndoManager.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.corext.refactoring;
-
-import java.util.Stack;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ElementChangedEvent;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
-import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManagerListener;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-/**
- * Default implementation of IUndoManager.
- */
-public class UndoManager implements IUndoManager {
-
- private class FlushListener implements IElementChangedListener {
- public void elementChanged(ElementChangedEvent event)
- {
- // If we don't have anything to undo or redo don't examine the tree.
- if (fUndoChanges.isEmpty() && fRedoChanges.isEmpty())
- return;
-
- processDelta(event.getDelta());
- }
-
- private boolean processDelta(ICElementDelta delta)
- {
- int kind= delta.getKind();
- int details= delta.getFlags();
- int type= delta.getElement().getElementType();
- ICElementDelta[] affectedChildren= delta.getAffectedChildren();
- if (affectedChildren == null)
- return true;
-
- switch (type) {
- // Consider containers for class files.
- case ICElement.C_MODEL:
- case ICElement.C_PROJECT:
- case ICElement.C_CCONTAINER:
- // If we did something different than changing a child we flush the the undo / redo stack.
- if (kind != ICElementDelta.CHANGED
- && ((details & ICElementDelta.F_CHILDREN) == 0)) {
- flush();
- return false;
- }
- break;
- case ICElement.C_UNIT:
- // if we have changed a primary working copy (e.g created, removed, ...)
- // then we do nothing.
- ITranslationUnit unit= (ITranslationUnit)delta.getElement();
- // If we change a working copy we do nothing
- if (unit.isWorkingCopy()) {
- // Don't examine children of a working copy but keep processing siblings.
- return true;
- } else {
- flush();
- return false;
- }
- }
- for (int i= 0; i < affectedChildren.length; i++) {
- if (!processDelta(affectedChildren[i]))
- return false;
- }
- return true;
- }
- }
-
- private class SaveListener implements IResourceChangeListener {
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDeltaVisitor visitor= new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource= delta.getResource();
- if (resource.getType() == IResource.FILE && delta.getKind() == IResourceDelta.CHANGED &&
- (delta.getFlags() & IResourceDelta.CONTENT) != 0) {
- if(CoreModel.isValidTranslationUnitName(resource.getProject(), resource.getName())) {
- ITranslationUnit unit= (ITranslationUnit)CoreModel.getDefault().create((IFile)resource);
- if (unit != null && unit.exists()) {
- flush();
- return false;
- }
- }
- }
- return true;
- }
- };
- try {
- IResourceDelta delta= event.getDelta();
- if (delta != null)
- delta.accept(visitor);
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- }
- }
- }
-
- private Stack fUndoChanges;
- private Stack fRedoChanges;
- private Stack fUndoNames;
- private Stack fRedoNames;
- private ListenerList fListeners;
- private FlushListener fFlushListener;
- private SaveListener fSaveListener;
-
- /**
- * Creates a new undo manager with an empty undo and redo stack.
- */
- public UndoManager() {
- flush();
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public void addListener(IUndoManagerListener listener) {
- if (fListeners == null)
- fListeners= new ListenerList();
- fListeners.add(listener);
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public void removeListener(IUndoManagerListener listener) {
- if (fListeners == null)
- return;
- fListeners.remove(listener);
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public void aboutToPerformRefactoring() {
- // Remove the resource change listener since we are changing code.
- if (fFlushListener != null)
- CoreModel.getDefault().removeElementChangedListener(fFlushListener);
- if (fSaveListener != null)
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(fSaveListener);
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public void refactoringPerformed(boolean success) {
- if (success) {
- if (fFlushListener != null)
- CoreModel.getDefault().addElementChangedListener(fFlushListener);
- if (fSaveListener != null)
- ResourcesPlugin.getWorkspace().addResourceChangeListener(fSaveListener);
- } else {
- flush();
- }
- }
-
- /* (non-Javadoc)
- * @see IUndoManager#shutdown()
- */
- public void shutdown() {
- if (fFlushListener != null)
- CoreModel.getDefault().removeElementChangedListener(fFlushListener);
- if (fSaveListener != null)
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(fSaveListener);
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public void flush() {
- flushUndo();
- flushRedo();
- if (fFlushListener != null)
- CoreModel.getDefault().removeElementChangedListener(fFlushListener);
- if (fSaveListener != null)
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(fSaveListener);
-
- fFlushListener= null;
- fSaveListener= null;
- }
-
- private void flushUndo(){
- fUndoChanges= new Stack();
- fUndoNames= new Stack();
- fireUndoStackChanged();
- }
-
- private void flushRedo(){
- fRedoChanges= new Stack();
- fRedoNames= new Stack();
- fireRedoStackChanged();
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public void addUndo(String refactoringName, IChange change){
- Assert.isNotNull(refactoringName, "refactoring"); //$NON-NLS-1$
- Assert.isNotNull(change, "change"); //$NON-NLS-1$
- fUndoNames.push(refactoringName);
- fUndoChanges.push(change);
- flushRedo();
- if (fFlushListener == null) {
- fFlushListener= new FlushListener();
- CoreModel.getDefault().addElementChangedListener(fFlushListener);
- }
- if (fSaveListener == null) {
- fSaveListener= new SaveListener();
- ResourcesPlugin.getWorkspace().addResourceChangeListener(fSaveListener);
- }
- fireUndoStackChanged();
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public RefactoringStatus performUndo(ChangeContext context, IProgressMonitor pm) throws CModelException{
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- RefactoringStatus result= new RefactoringStatus();
-
- if (fUndoChanges.empty())
- return result;
-
- IChange change= (IChange)fUndoChanges.peek();
-
- executeChange(result, context, change, pm);
-
- if (!result.hasError()) {
- fUndoChanges.pop();
- fRedoNames.push(fUndoNames.pop());
- fRedoChanges.push(change.getUndoChange());
- fireUndoStackChanged();
- fireRedoStackChanged();
- }
- return result;
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public RefactoringStatus performRedo(ChangeContext context, IProgressMonitor pm) throws CModelException{
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- RefactoringStatus result= new RefactoringStatus();
-
- if (fRedoChanges.empty())
- return result;
-
- IChange change= (IChange)fRedoChanges.peek();
-
-
- executeChange(result, context, change, pm);
-
- if (!result.hasError()) {
- fRedoChanges.pop();
- fUndoNames.push(fRedoNames.pop());
- fUndoChanges.push(change.getUndoChange());
- fireRedoStackChanged();
- fireUndoStackChanged();
- }
-
- return result;
- }
-
- private void executeChange(RefactoringStatus status, final ChangeContext context, final IChange change, IProgressMonitor pm) throws CModelException {
- if (fFlushListener != null)
- CoreModel.getDefault().removeElementChangedListener(fFlushListener);
- if (fSaveListener != null)
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(fSaveListener);
- try {
- pm.beginTask("", 10); //$NON-NLS-1$
- status.merge(change.aboutToPerform(context, new SubProgressMonitor(pm, 2)));
- if (status.hasError())
- return;
-
- CoreModel.run(
- new IWorkspaceRunnable() {
- public void run(IProgressMonitor innerPM) throws CoreException {
- change.perform(context, innerPM);
- }
- },
- new SubProgressMonitor(pm, 8));
- } catch (CModelException e){
- throw e;
- } catch (CoreException e) {
- throw new CModelException(e);
- } finally {
- change.performed();
- if (fFlushListener != null)
- CoreModel.getDefault().addElementChangedListener(fFlushListener);
- if (fSaveListener != null)
- ResourcesPlugin.getWorkspace().addResourceChangeListener(fSaveListener);
- pm.done();
- }
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public boolean anythingToRedo(){
- return !fRedoChanges.empty();
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public boolean anythingToUndo(){
- return !fUndoChanges.empty();
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public String peekUndoName() {
- if (fUndoNames.size() > 0)
- return (String)fUndoNames.peek();
- return null;
- }
-
- /* (Non-Javadoc)
- * Method declared in IUndoManager.
- */
- public String peekRedoName() {
- if (fRedoNames.size() > 0)
- return (String)fRedoNames.peek();
- return null;
- }
-
- private void fireUndoStackChanged() {
- if (fListeners == null)
- return;
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ((IUndoManagerListener)listeners[i]).undoStackChanged(this);
- }
- }
-
- private void fireRedoStackChanged() {
- if (fListeners == null)
- return;
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ((IUndoManagerListener)listeners[i]).redoStackChanged(this);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Change.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Change.java
deleted file mode 100644
index ba4f8f4b333..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Change.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.corext.refactoring.RefactoringCoreMessages;
-import org.eclipse.cdt.internal.corext.util.CModelUtil;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-/**
- * An abstract default implementation for a change object - suitable for subclassing. This class manages
- * the change's active status.
- * IChangeExceptionHandler
provided by
- * the given change context. If the execution of the change is to be aborted than
- * this method throws a corresponding CModelException
. The exception
- * is either the given exception if it is an instance of CModelException
or
- * a new one created by calling new CModelException(exception, code)
.
- *
- * @param context the change context used to retrieve the exception handler
- * @param exception the exception caugth during change execution
- * @exception ChangeAbortException
if the execution is to be aborted
- */
- protected void handleException(ChangeContext context, Exception exception) throws ChangeAbortException {
- if (exception instanceof ChangeAbortException)
- throw (ChangeAbortException)exception;
- if (exception instanceof OperationCanceledException)
- throw (OperationCanceledException)exception;
- context.getExceptionHandler().handle(context, this, exception);
- }
-
- protected static void checkIfModifiable(Object element, RefactoringStatus status, ChangeContext context) {
- IResource resource= getResource(element);
- if (resource != null)
- checkIfModifiable(resource, status, context);
- }
-
- protected static void checkIfModifiable(IResource resource, RefactoringStatus status, ChangeContext context) {
- if (resource.isReadOnly()) {
- status.addFatalError(RefactoringCoreMessages.getFormattedString("Change.is_read_only", resource.getFullPath().toString())); //$NON-NLS-1$
- }
- if (resource instanceof IFile)
- context.checkUnsavedFile(status, (IFile)resource);
- }
-
-
- private static IResource getResource(Object element) {
- if (element instanceof IResource) {
- return (IResource)element;
- }
- if (element instanceof ITranslationUnit) {
- return CModelUtil.toOriginal((ITranslationUnit)element).getResource();
- }
- if (element instanceof ICElement) {
- return ((ICElement)element).getUnderlyingResource();
- }
- if (element instanceof IAdaptable) {
- return (IResource) ((IAdaptable)element).getAdapter(IResource.class);
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ChangeAbortException.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ChangeAbortException.java
deleted file mode 100644
index 7bde4421364..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ChangeAbortException.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.refactoring.RefactoringCoreMessages;
-
-
-/**
- * This exception is thrown if an unexpected errors occurs during execution
- * of a change object.
- */
-public class ChangeAbortException extends RuntimeException {
-
- private Throwable fThrowable;
-
-
- /**
- * Creates a new ChangeAbortException
for the given throwable.
- *
- * @param t the unexpected throwable caught while performing the change
- * @param context the change context used to process the change
- */
- public ChangeAbortException(Throwable t) {
- fThrowable= t;
- Assert.isNotNull(fThrowable);
- }
-
- /**
- * Returns the Throwable
that has caused the change to fail.
- *
- * @return the throwable that has caused the change to fail
- */
- public Throwable getThrowable() {
- return fThrowable;
- }
-
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- */
- public void printStackTrace(PrintStream output) {
- synchronized (output) {
- output.print("ChangeAbortException: "); //$NON-NLS-1$
- super.printStackTrace(output);
-
- if (fThrowable != null) {
- output.print(RefactoringCoreMessages.getFormattedString("ChangeAbortException.wrapped", "ChangeAbortException: ")); //$NON-NLS-2$ //$NON-NLS-1$
- fThrowable.printStackTrace(output);
- }
- }
- }
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- */
- public void printStackTrace(PrintWriter output) {
- synchronized (output) {
- output.print("ChangeAbortException: "); //$NON-NLS-1$
- super.printStackTrace(output);
-
- if (fThrowable != null) {
- output.print(RefactoringCoreMessages.getFormattedString("ChangeAbortException.wrapped", "ChangeAbortException: ")); //$NON-NLS-2$ //$NON-NLS-1$
- fThrowable.printStackTrace(output);
- }
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ChangeContext.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ChangeContext.java
deleted file mode 100644
index 85f7cec3f67..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ChangeContext.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.refactoring.RefactoringCoreMessages;
-
-/**
- * A change context is used to give an IChange
object access to several workspace
- * resource independend from whether the change is executed head less or not.
- * null
- */
- public ChangeContext(IChangeExceptionHandler handler) {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- this(handler, new IFile[] {});
- }
-
- /**
- * Creates a new change context with the given exception handler.
- *
- * @param handler object to handle exceptions caught during performing
- * a change. Must not be null
- */
- public ChangeContext(IChangeExceptionHandler handler, IFile[] unsavedFiles) {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- fExceptionHandler= handler;
- Assert.isNotNull(fExceptionHandler);
- fUnsavedFiles= unsavedFiles;
- Assert.isNotNull(fUnsavedFiles);
- fHandledUnsavedFiles= new ArrayList(fUnsavedFiles.length);
- }
-
- /**
- * Returns the list of unsaved resources.
- *
- * @return the list of unsaved resources
- */
- public IFile[] getUnsavedFiles() {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- return fUnsavedFiles;
- }
-
- public void checkUnsavedFile(RefactoringStatus status, IFile file) {
- if (fHandledUnsavedFiles.contains(file))
- return;
-
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- for (int i= 0; i < fUnsavedFiles.length; i++) {
- if (fUnsavedFiles[i].equals(file)) {
- status.addFatalError(RefactoringCoreMessages.getFormattedString("Change.is_unsaved", file.getFullPath().toString())); //$NON-NLS-1$
- fHandledUnsavedFiles.add(file);
- return;
- }
- }
- }
-
- /**
- * Returns the exception handler used to report exception back to the client.
- *
- * @return the exception handler to report exceptions
- */
- public IChangeExceptionHandler getExceptionHandler() {
- return fExceptionHandler;
- }
-
- /**
- * Sets the change that caused an exception to the given value.
- *
- * @param change the change that caused an exception
- */
- public void setFailedChange(IChange change) {
- fFailedChange= change;
- }
-
- /**
- * Returns the change that caused an exception.
- *
- * @return the change that caused an exception
- */
- public IChange getFailedChange() {
- return fFailedChange;
- }
-
- /**
- * An unexpected error has occurred during execution of a change. Communicate
- * to the outer operation that the successfully performed changes collected by
- * this change context are supposed to be undone.
- *
- * @see ChangeContext#addPerformedChange(IChange)
- */
- public void setTryToUndo() {
- fTryToUndo= true;
- }
-
- /**
- * Returns true
if an exception has been caught during execution of
- * the change and the outer operation should try to undo all successfully performed
- * changes. Otherwise false
is returned.
- *
- * @return if the outer operation should try to undo all successfully performed
- * changes
- */
- public boolean getTryToUndo() {
- return fTryToUndo;
- }
-
- /**
- * Adds the given change to the list of successfully performed changes.
- *
- * @param the change executed successfully.
- */
- public void addPerformedChange(IChange change) {
-// if (change instanceof ICompositeChange)
-// return;
-
- fPerformedChanges.add(change);
- }
-
- /**
- * Returns all changes that have been performed successfully
- *
- * @return the successfully performed changes.
- */
- public IChange[] getPerformedChanges() {
- return (IChange[])fPerformedChanges.toArray(new IChange[fPerformedChanges.size()]);
- }
-
- /**
- * Removes all performed changes from this context.
- */
- public void clearPerformedChanges() {
- fPerformedChanges= new ArrayList(1);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Context.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Context.java
deleted file mode 100644
index e162644dbb3..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Context.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * A Context
can be used to annotate a
RefactoringStatusEntry
with
- * additional information presentable in the UI.
- */
-public class Context {
- public IAdaptable getCorrespondingElement() {
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IChange.java
deleted file mode 100644
index 999b8f7e26a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IChange.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.cdt.core.model.CModelException;
-
-
-/**
- * Represents a generic change to the workbench. An IChange
object is typically
- * created by calling IRefactoring::createChange
.
- * perform
performs the actual change to the workbench. Clients then call
- * getUndoChange
. It is the implementors responsbility to make sure that the
- * IChange
object returned by getUndoChange
really represents a reverse change.
- *
- * Clients can implement this interface.
- * perform
on this change. The client of this
- * change must ensure that the method is called outside a runnable that modifies the
- * workbench. Typically aboutToPerform
, perform
and
- * performed
are used as follows:
- *
- * try {
- * change.aboutToPerform(context);
- * workbench.run(new IWorkspaceRunnable() {
- * public void run(IProgressMonitor pm) throws CoreException {
- * change.perform(context, pm);
- * }
- * }, progressMonitor);
- * } finally {
- * change.performed();
- * }
- *
- * @see #performed()
- */
- public RefactoringStatus aboutToPerform(ChangeContext context, IProgressMonitor pm);
-
- /**
- * Performs this change. It is critical that you call perform
- * before you call getUndoChange
. In general, IChange
- * objects do not know what the reverse will be before they are performed.
- */
- public void perform(ChangeContext context, IProgressMonitor pm) throws CModelException, ChangeAbortException;
-
- /**
- * The change has been performed. Clients must ensure that this method is called after all
- * resource deltas emitted by calling perform
are processed. This method must
- * be called even if the perform has thrown a runtime exception.
- * @see #aboutToPerform(ChangeContext, IProgressMonitor)
- */
- public void performed();
-
- /**
- * Returns the change that, when performed, will undo the receiver. IChange
- * objects can assume that perform
has been called on them before. It is the
- * caller's responsiblity to make sure that this is true. As mentioned in the class comment,
- * it is the responsiblity of the implementors to make sure that this method does create a
- * reverse change.
- *
- * @return the reverse change of this change
- */
- public IChange getUndoChange();
-
- /**
- * Sets the activation status for this IChange
. When a change is not active,
- * then executing it is expected to do nothing.
- *
- * @param active the activation status for this change.
- */
- public void setActive(boolean active);
-
- /**
- * Returns the activation status of this IChange
. This method doesn't
- * consider the activation status of possible children.
- *
- * @return the change's activation status.
- * @see #setActive(boolean)
- */
- public boolean isActive();
-
- /**
- * Returns the name of this change. The main purpose of the change's name is to
- * render it in the UI.
- *
- * @return the change's name.
- */
- public String getName();
-
- /**
- * Returns the language element modified by this IChange
. The method
- * may return null
if the change isn't related to a language element.
- *
- * @return the language element modified by this change
- */
- public Object getModifiedLanguageElement();
-
- /**
- * Returns whether the change can be undone.
- * If false
is returned, then the result
- * of getUndoChange
will be ignored.
- */
- public boolean isUndoable();
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IChangeExceptionHandler.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IChangeExceptionHandler.java
deleted file mode 100644
index e58bf7a9146..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IChangeExceptionHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-
-/**
- * An ChangeExceptionHandler
is informed about any exception that occurrs during
- * performing a change. Implementors of this interface can control if the change is supposed to
- * be continued or if it is to be aborted.
- * IChange.perform
- * @param change the change that caused the exception
- * @param exception the exception cought during executing the change
- * @exception ChangeAbortException if the change is to be aborted
- */
- public void handle(ChangeContext context, IChange change, Exception exception) throws ChangeAbortException;
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ICompositeChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ICompositeChange.java
deleted file mode 100644
index aa41d58c15b..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/ICompositeChange.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-
-/**
- * A composite change consisting of a list of changes. Performing a composite
- * change peforms all managed changes. Managed changes can be either primitive
- * or composite changes.
- * Clients can implement this interface if they want their IChange
to be treated as composites.
- * null
is returned.
- * @return an array of changes this composite change consists of
- */
- public IChange[] getChildren();
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IRefactoring.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IRefactoring.java
deleted file mode 100644
index 0df0f85add8..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IRefactoring.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-/**
- * Represents a refactoring.
- * IStatus
has severity IStatus.ERROR
,
- * than createChange
will not be called on the receiver.
- * Must not return null
.
- * Implementors can assume the progress monitor to be not initialized.
- * @see RefactoringStatus
- * @see RefactoringStatus#OK
- * @see RefactoringStatus#ERROR
- */
- public RefactoringStatus checkPreconditions(IProgressMonitor pm) throws CModelException;
-
- /**
- * Creates an IChange
object that performs the actual refactoring.
- * This is guaranteed not to be called before checkPreconditions
or
- * if checkPreconditions
returns an RefactoringStatus
- * object with severity RefactoringStatus.ERROR
.
- * Implementors can assume the progress monitor to be not initialized.
- */
- public IChange createChange(IProgressMonitor pm) throws CModelException;
-
-
- /**
- * Returns the name of this refactoring.
- *
- * @return the refactoring's name. Mainly used in the UI.
- */
- public String getName();
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IUndoManager.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IUndoManager.java
deleted file mode 100644
index be741ae0609..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IUndoManager.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.cdt.core.model.CModelException;
-
-/**
- * An undo manager keeps track of changes performed by refactorings. Use performUndo
- * and performRedo
to undo and redo changes.
- * true
if the refactoring has been executed successful.
- * Otherwise false
- * @return a change that can undo this change
- */
- protected abstract IChange createReverseChange(UndoEdit edits , int changeKind);
-
- /**
- * Returns .
- */
- public void refactoringPerformed(boolean success);
-
- /**
- * Adds a new undo change to this undo manager.
- *
- * @param name the name of the refactoring the change was created
- * for. The name must not be
REDO_CHANGEnull
- * @param change the undo change. The change must not be null
- */
- public void addUndo(String name, IChange change);
-
- /**
- * Returns true
if there is anything to undo, otherwise
- * false
.
- *
- * @return true
if there is anything to undo, otherwise
- * false
- */
- public boolean anythingToUndo();
-
- /**
- * Returns the name of the top most undo.
- *
- * @return the top most undo name. The main purpose of the name is to
- * render it in the UI. Returns null
if there aren't any changes to undo
- */
- public String peekUndoName();
-
- /**
- * Undo the top most undo change.
- *
- * @param pm a progress monitor to report progress during performing
- * the undo change. The progress monitor must not be null
- * @return a status indicating if the undo preflight produced any error
- */
- public RefactoringStatus performUndo(ChangeContext context, IProgressMonitor pm) throws CModelException;
-
- /**
- * Returns true
if there is anything to redo, otherwise
- * false
.
- *
- * @return true
if there is anything to redo, otherwise
- * false
- */
- public boolean anythingToRedo();
-
- /**
- * Returns the name of the top most redo.
- *
- * @return the top most redo name. The main purpose of the name is to
- * render it in the UI. Returns null
if there are no any changes to redo.
- */
- public String peekRedoName();
-
- /**
- * Redo the top most redo change.
- *
- * @param pm a progress monitor to report progress during performing
- * the redo change. The progress monitor must not be null
- * @return a status indicating if the undo preflight produced any error
- */
- public RefactoringStatus performRedo(ChangeContext context, IProgressMonitor pm) throws CModelException;
-
- /**
- * Flushes the undo manager's undo and redo stacks.
- */
- public void flush();
-
- /**
- * Shut down the undo manager.
- */
- public void shutdown();
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IUndoManagerListener.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IUndoManagerListener.java
deleted file mode 100644
index fcb168ad36a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/IUndoManagerListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-/**
- * Listener to monitor changes made to an UndoManager
- */
-public interface IUndoManagerListener {
-
- /**
- * This method is called by the undo manager if an undo change has been
- * added to it.
- */
- public void undoStackChanged(IUndoManager manager);
-
- /**
- * This method is called by the undo manager if a redo change has been
- * added to it.
- */
- public void redoStackChanged(IUndoManager manager);
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Refactoring.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Refactoring.java
deleted file mode 100644
index 97209d7c94f..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/Refactoring.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.cdt.internal.corext.refactoring.UndoManager;
-
-/**
- * Superclass for all refactorings.
- * null
.
- */
- public abstract RefactoringStatus checkActivation(IProgressMonitor pm) throws CModelException;
-
- /**
- * After checkActivation
has been performed and the user has provided all input
- * necessary to perform the refactoring this method is called to check the remaining preconditions.
- * Typically, this is used in the ui after the user has pressed 'next' on the last user input page.
- * This method is always called after checkActivation
and only if the status returned by
- * checkActivation
isOK
.
- * Must not return null
.
- * @see #checkActivation
- * @see RefactoringStatus#isOK
- */
- public abstract RefactoringStatus checkInput(IProgressMonitor pm) throws CModelException;
-
- /**
- * @see IRefactoring#checkPreconditions
- * This implementation performs checkActivation
- * and checkInput
and merges the results.
- *
- * @see #checkActivation
- * @see #checkInput
- * @see RefactoringStatus#merge
- */
- public RefactoringStatus checkPreconditions(IProgressMonitor pm) throws CModelException{
- pm.beginTask("", 11); //$NON-NLS-1$
- RefactoringStatus result= new RefactoringStatus();
- result.merge(checkActivation(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)));
- if (!result.hasFatalError())
- result.merge(checkInput(new SubProgressMonitor(pm, 10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)));
- pm.done();
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (adapter.isInstance(this))
- return this;
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatus.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatus.java
deleted file mode 100644
index fdb78f81e79..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatus.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.core.runtime.IStatus;
-
-
-/**
- * A RefactoringStatus
object represents the outcome of a precondition checking
- * operation.
- * It keeps a list of RefactoringStatusEntries
.
- * Clients can instantiate.
- * This class is not intented to be subclassed.
- * RefactorngStatus
with one INFO entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createInfoStatus(String msg){
- return createStatus(INFO, msg);
- }
-
- /**
- * Creates a RefactorngStatus
with one INFO entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createInfoStatus(String msg, Context context){
- return createStatus(INFO, msg, context);
- }
-
- /**
- * Creates a RefactorngStatus
with one WARNING entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createWarningStatus(String msg){
- return createStatus(WARNING, msg);
- }
-
- /**
- * Creates a RefactorngStatus
with one WARNING entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createWarningStatus(String msg, Context context){
- return createStatus(WARNING, msg, context);
- }
-
- /**
- * Creates a RefactorngStatus
with one ERROR entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createErrorStatus(String msg){
- return createStatus(ERROR, msg);
- }
-
- /**
- * Creates a RefactorngStatus
with one ERROR entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createErrorStatus(String msg, Context context){
- return createStatus(ERROR, msg, context);
- }
-
- /**
- * Creates a RefactorngStatus
with one FATAL entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createFatalErrorStatus(String msg){
- return createStatus(FATAL, msg);
- }
-
- /**
- * Creates a RefactorngStatus
with one FATAL entry.
- * This is a convenience method.
- */
- public static RefactoringStatus createFatalErrorStatus(String msg, Context context){
- return createStatus(FATAL, msg, context);
- }
-
- /**
- * Creates a RefactorngStatus
from the given IStatus
- */
- public static RefactoringStatus create(IStatus status){
- if (status.isOK())
- return new RefactoringStatus();
-
- if (! status.isMultiStatus()){
- switch (status.getSeverity()){
- case IStatus.INFO:
- return RefactoringStatus.createWarningStatus(status.getMessage());
- case IStatus.WARNING:
- return RefactoringStatus.createErrorStatus(status.getMessage());
- case IStatus.ERROR:
- return RefactoringStatus.createFatalErrorStatus(status.getMessage());
- default:
- return new RefactoringStatus();
- }
- } else {
- IStatus[] children= status.getChildren();
- RefactoringStatus result= new RefactoringStatus();
- for (int i= 0; i < children.length; i++) {
- result.merge(RefactoringStatus.create(children[i]));
- }
- return result;
- }
- }
-
- /*
- * @see RefactoringStatusCodes
- */
- public static RefactoringStatus createStatus(int severity, String msg, Context context, Object data, int code) {
- RefactoringStatus result= new RefactoringStatus();
- result.fEntries.add(new RefactoringStatusEntry(msg, severity, context, data, code));
- result.fSeverity= severity;
- return result;
- }
-
- public static RefactoringStatus createStatus(int severity, String msg, Context context) {
- return createStatus(severity, msg, context, null, RefactoringStatusCodes.NONE);
- }
-
- public static RefactoringStatus createStatus(int severity, String msg){
- return createStatus(severity, msg, null);
- }
-
- /**
- * Adds an info to this status.
- * If the current severity was OK
it will be changed to INFO
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- */
- public void addInfo(String msg){
- addInfo(msg, null);
- }
-
- /**
- * Adds an info to this status.
- * If the current severity was OK
it will be changed to INFO
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- */
- public void addInfo(String msg, Context context){
- fEntries.add(RefactoringStatusEntry.createInfo(msg, context));
- fSeverity= Math.max(fSeverity, INFO);
- }
-
- /**
- * Adds a warning to this status.
- * If the current severity was OK
or INFO
it will be changed to WARNING
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- * @see #WARNING
- */
- public void addWarning(String msg){
- addWarning(msg, null);
- }
-
- /**
- * Adds a warning to this status.
- * If the current severity was OK
or INFO
it will be changed to WARNING
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- * @see #WARNING
- */
- public void addWarning(String msg, Context context){
- fEntries.add(RefactoringStatusEntry.createWarning(msg, context));
- fSeverity= Math.max(fSeverity, WARNING);
- }
-
-
- /**
- * Adds an error to this status.
- * If the current severity was OK
, INFO
or WARNING
- * it will be changed to ERROR
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- * @see #WARNING
- * @see #ERROR
- */
- public void addError(String msg){
- addError(msg, null);
- }
-
- /**
- * Adds an error to this status.
- * If the current severity was OK
, INFO
or WARNING
- * it will be changed to ERROR
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- * @see #WARNING
- * @see #ERROR
- */
- public void addError(String msg, Context context){
- fEntries.add(RefactoringStatusEntry.createError(msg, context));
- fSeverity= Math.max(fSeverity, ERROR);
- }
-
-
- /**
- * Adds a fatal error to this status.
- * If the current severity was OK
, INFO
, WARNING
- * or ERROR
it will be changed to FATAL
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- * @see #WARNING
- * @see #ERROR
- * @see #FATAL
- */
- public void addFatalError(String msg){
- addFatalError(msg, null);
- }
-
- /**
- * Adds a fatal error to this status.
- * If the current severity was OK
, INFO
, WARNING
- * or ERROR
it will be changed to FATAL
.
- * It will remain unchanged otherwise.
- * @see #OK
- * @see #INFO
- * @see #WARNING
- * @see #ERROR
- * @see #FATAL
- */
- public void addFatalError(String msg, Context context){
- fEntries.add(RefactoringStatusEntry.createFatal(msg, context));
- fSeverity= Math.max(fSeverity, FATAL);
- }
-
- /**
- * Adds an RefactoringStatusEntry
.
- *
- * @param entry the RefactoringStatusEntry
to be added
- */
- public void addEntry(RefactoringStatusEntry entry) {
- Assert.isNotNull(entry);
- fEntries.add(entry);
- fSeverity= Math.max(fSeverity, entry.getSeverity());
- }
-
- /**
- * Returns true
iff there were no errors, warings or infos added.
- * @see #OK
- * @see #INFO
- * @see #WARNING
- * @see #ERROR
- */
- public boolean isOK(){
- return fSeverity == OK;
- }
-
- /**
- * Returns true
if the current severity is FATAL
.
- * @see #FATAL
- */
- public boolean hasFatalError() {
- return fSeverity == FATAL;
- }
-
- /**
- * Returns true
if the current severity is FATAL
or
- * ERROR
.
- * @see #FATAL
- * @see #ERROR
- */
- public boolean hasError() {
- return fSeverity == FATAL || fSeverity == ERROR;
- }
-
- /**
- * Returns true
if the current severity is FATAL
,
- * ERROR
or WARNING
.
- * @see #FATAL
- * @see #ERROR
- * @see #WARNING
- */
- public boolean hasWarning() {
- return fSeverity == FATAL || fSeverity == ERROR || fSeverity == WARNING;
- }
-
- /**
- * Returns true
if the status has an entry with the given code.
- * Otherwise false
is returned.
- *
- * @param code the code of the RefactoringStatusEntry.
- * @return true
if the status has an entry with the given code.
- * Otherwise false
is returned.
- */
- public boolean hasEntryWithCode(int code) {
- for (Iterator iter= fEntries.iterator(); iter.hasNext();) {
- RefactoringStatusEntry entry= (RefactoringStatusEntry) iter.next();
- if (entry.getCode() == code)
- return true;
- }
- return false;
- }
-
- /**
- * Merges the receiver and the parameter statuses.
- * The resulting list of entries in the receiver will contain entries from both.
- * The resuling severity in the reciver will be the more severe of its current severity
- * and the parameter's severity.
- * Merging with null
is allowed - it has no effect.
- * @see #getSeverity
- */
- public void merge(RefactoringStatus that){
- if (that == null)
- return;
- fEntries.addAll(that.getEntries());
- fSeverity= Math.max(fSeverity, that.getSeverity());
- }
-
-
- /**
- * Returns the current severity.
- * Severities are ordered as follows: OK < INFO < WARNING < ERROR
- */
- public int getSeverity(){
- return fSeverity;
- }
-
- /**
- * Returns all entries.
- * Returns a List of RefactoringStatusEntries
.
- * This list is empty if there are no entries.
- */
- public List getEntries(){
- return fEntries;
- }
-
- /**
- * Returns the RefactoringStatusEntry at the specified index.
- *
- * @param index of entry to return
- * @return the enrty at the specified index
- *
- * @throws IndexOutOfBoundsException if the index is out of range
- */
- public RefactoringStatusEntry getEntry(int index) {
- return (RefactoringStatusEntry)fEntries.get(index);
- }
-
- /**
- * Returns the first entry which severity is equal or greater than the given
- * severity. Returns null
if no element exists with
- * the given severity.
- * @param severity must be one of FATAL
, ERROR
,
- * WARNING
or INFO
.
- */
- public RefactoringStatusEntry getFirstEntry(int severity) {
- Assert.isTrue(severity >= OK && severity <= FATAL);
- if (severity > fSeverity)
- return null;
- Iterator iter= fEntries.iterator();
- while(iter.hasNext()) {
- RefactoringStatusEntry entry= (RefactoringStatusEntry)iter.next();
- if (entry.getSeverity() >= severity)
- return entry;
- }
- return null;
- }
-
-
- /**
- * Returns the first message which severity is equal or greater than the given
- * severity. Returns null
if no element exists with
- * the given severity.
- * @param severity must me one of FATAL
, ERROR
,
- * WARNING
or INFO
.
- */
- public String getFirstMessage(int severity) {
- RefactoringStatusEntry entry= getFirstEntry(severity);
- if (entry == null)
- return null;
- return entry.getMessage();
- }
-
-
- /* non java-doc
- * for debugging only
- * not for nls
- */
- /*package*/ static String getSeverityString(int severity){
- Assert.isTrue(severity >= OK && severity <= FATAL);
- if (severity == RefactoringStatus.OK) return "OK"; //$NON-NLS-1$
- if (severity == RefactoringStatus.INFO) return "INFO"; //$NON-NLS-1$
- if (severity == RefactoringStatus.WARNING) return "WARNING"; //$NON-NLS-1$
- if (severity == RefactoringStatus.ERROR) return "ERROR"; //$NON-NLS-1$
- if (severity == RefactoringStatus.FATAL) return "FATALERROR"; //$NON-NLS-1$
- return null;
- }
-
- /* non java-doc
- * for debugging only
- */
- public String toString(){
- StringBuffer buff= new StringBuffer();
- buff.append("<") //$NON-NLS-1$
- .append(getSeverityString(fSeverity))
- .append("\n"); //$NON-NLS-1$
- if (!isOK()){
- for (Iterator iter= fEntries.iterator(); iter.hasNext();){
- buff.append("\t") //$NON-NLS-1$
- .append(iter.next())
- .append("\n"); //$NON-NLS-1$
- }
- }
- buff.append(">"); //$NON-NLS-1$
- return buff.toString();
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatusCodes.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatusCodes.java
deleted file mode 100644
index 396c09b9455..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatusCodes.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-
-public class RefactoringStatusCodes {
-
- private RefactoringStatusCodes() {
- }
-
- public static final int NONE= 0;
-
- public static final int OVERRIDES_ANOTHER_METHOD= 1;
- public static final int METHOD_DECLARED_IN_INTERFACE= 2;
-
- public static final int EXPRESSION_NOT_RVALUE= 64;
- public static final int EXPRESSION_NOT_RVALUE_VOID= 65;
- public static final int EXTRANEOUS_TEXT= 66;
-
- public static final int NOT_STATIC_FINAL_SELECTED= 128;
- public static final int SYNTAX_ERRORS= 129;
- public static final int DECLARED_IN_CLASSFILE= 130;
- public static final int CANNOT_INLINE_BLANK_FINAL= 131;
- public static final int LOCAL_AND_ANONYMOUS_NOT_SUPPORTED= 132;
- public static final int REFERENCE_IN_CLASSFILE= 133;
- public static final int WILL_NOT_REMOVE_DECLARATION= 134;
-
- public static int CANNOT_MOVE_STATIC= 192;
- public static int SELECT_METHOD_IMPLEMENTATION= 193;
- public static int CANNOT_MOVE_NATIVE= 194;
- public static int CANNOT_MOVE_SYNCHRONIZED= 195;
- public static int CANNOT_MOVE_CONSTRUCTOR= 196;
- public static int SUPER_REFERENCES_NOT_ALLOWED= 197;
- public static int ENCLOSING_INSTANCE_REFERENCES_NOT_ALLOWED= 198;
- public static int CANNOT_MOVE_RECURSIVE= 199;
- public static int CANNOT_MOVE_TO_SAME_CU= 200;
- public static int CANNOT_MOVE_TO_LOCAL= 201;
- public static int METHOD_NOT_SELECTED= 202;
- public static int NO_NEW_RECEIVERS= 203;
- public static int PARAM_NAME_ALREADY_USED= 204;
-
- // inline method error codes
- public static final int INLINE_METHOD_FIELD_INITIALIZER= 256;
- public static final int INLINE_METHOD_LOCAL_INITIALIZER= 257;
- public static final int INLINE_METHOD_NULL_BINDING= 258;
- public static final int INLINE_METHOD_ONLY_SIMPLE_FUNCTIONS= 259;
- public static final int INLINE_METHOD_EXECUTION_FLOW= 260;
- public static final int INLINE_METHOD_INITIALIZER_IN_FRAGEMENT= 261;
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatusEntry.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatusEntry.java
deleted file mode 100644
index ae2d187d38a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/base/RefactoringStatusEntry.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.base;
-
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-/**
- * An immutable tuple (message, severity) representing an entry in the list in
- * RefactoringStatus
.
- * null
.
- * @param severity severity
- * @param msg message
- */
- public RefactoringStatusEntry(String msg, int severity) {
- this(msg, severity, null);
- }
-
- /**
- * Creates an entry with RefactoringStatus.INFO
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createInfo(String msg) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.INFO);
- }
-
- /**
- * Creates an entry with RefactoringStatus.INFO
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createInfo(String msg, Context context) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.INFO, context);
- }
-
- /**
- * Creates an entry with RefactoringStatus.WARNING
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createWarning(String msg) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.WARNING);
- }
-
- /**
- * Creates an entry with RefactoringStatus.WARNING
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createWarning(String msg, Context context) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.WARNING, context);
- }
-
- /**
- * Creates an entry with RefactoringStatus.ERROR
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createError(String msg) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.ERROR);
- }
-
- /**
- * Creates an entry with RefactoringStatus.ERROR
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createError(String msg, Context context) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.ERROR, context);
- }
-
- /**
- * Creates an entry with RefactoringStatus.FATAL
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createFatal(String msg) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.FATAL);
- }
-
- /**
- * Creates an entry with RefactoringStatus.FATAL
status.
- * @param msg message
- */
- public static RefactoringStatusEntry createFatal(String msg, Context context) {
- return new RefactoringStatusEntry(msg, RefactoringStatus.FATAL, context);
- }
-
- /**
- * @return true
iff (severity == RefactoringStatus.FATAL
).
- */
- public boolean isFatalError() {
- return fSeverity == RefactoringStatus.FATAL;
- }
-
- /**
- * @return true
iff (severity == RefactoringStatus.ERROR
).
- */
- public boolean isError() {
- return fSeverity == RefactoringStatus.ERROR;
- }
-
- /**
- * @return true
iff (severity == RefactoringStatus.WARNING
).
- */
- public boolean isWarning() {
- return fSeverity == RefactoringStatus.WARNING;
- }
-
- /**
- * @return true
iff (severity == RefactoringStatus.INFO
).
- */
- public boolean isInfo() {
- return fSeverity == RefactoringStatus.INFO;
- }
-
- /**
- * @return message.
- */
- public String getMessage() {
- return fMessage;
- }
-
- /**
- * @return severity level.
- * @see RefactoringStatus#INFO
- * @see RefactoringStatus#WARNING
- * @see RefactoringStatus#ERROR
- * @see RefactoringStatus#FATAL
- */
- public int getSeverity() {
- return fSeverity;
- }
-
- /**
- * Returns the context which can be used to show more detailed information
- * regarding this status entry in the UI. The method may return null
- *
indicating that no context is available.
- *
- * @return the status entry's context
- */
- public Context getContext() {
- return fContext;
- }
-
- public Object getData() {
- return fData;
- }
-
- public int getCode() {
- return fCode;
- }
-
- /**
- * Converts this RefactoringStatusEntry into an IStatus.
- * The mapping is done as follows:
- *
- *
- * @return IStatus
- */
- public IStatus asStatus () {
- int statusSeverity= IStatus.ERROR;
- switch (fSeverity) {
- case RefactoringStatus.OK:
- statusSeverity= IStatus.OK;
- break;
- case RefactoringStatus.INFO:
- statusSeverity= IStatus.INFO;
- break;
- case RefactoringStatus.WARNING:
- case RefactoringStatus.ERROR:
- statusSeverity= IStatus.WARNING;
- break;
- }
- return new Status(statusSeverity, CUIPlugin.getPluginId(), fCode, fMessage, null);
- }
-
- /* non java-doc
- * for debugging only
- */
- public String toString() {
- String contextString= fContext == null ? "IStatus.ERROR
.
- * IStatus.WARNING
.
- * IStatus.INFO
.IUndoManagerListener
.
- */
-public class UndoManagerAdapter implements IUndoManagerListener {
-
- /* (non-Javadoc)
- * Method declared in IUndoManagerListener
- */
- public void undoStackChanged(IUndoManager manager) {
- }
-
- /* (non-Javadoc)
- * Method declared in IUndoManagerListener
- */
- public void redoStackChanged(IUndoManager manager) {
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/AbstractTextChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/AbstractTextChange.java
deleted file mode 100644
index 150fc809478..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/AbstractTextChange.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.changes;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.cdt.core.model.CModelException;
-
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.text.edits.UndoEdit;
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.refactoring.NullChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.Change;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBuffer;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextBufferEditor;
-
-public abstract class AbstractTextChange extends Change {
-
- private String fName;
- private int fChangeKind;
- private IChange fUndoChange;
-
- protected final static int ORIGINAL_CHANGE= 0;
- protected final static int UNDO_CHANGE= 1;
- protected final static int REDO_CHANGE= 2;
-
- protected static class LocalTextEditProcessor extends TextBufferEditor {
- public static final int EXCLUDE= 1;
- public static final int INCLUDE= 2;
-
- private TextEdit[] fExcludes;
- private TextEdit[] fIncludes;
-
- public LocalTextEditProcessor(TextBuffer buffer) {
- super(buffer);
- }
- public void setIncludes(TextEdit[] includes) {
- Assert.isNotNull(includes);
- Assert.isTrue(fExcludes == null);
- fIncludes= flatten(includes);
- }
- public void setExcludes(TextEdit[] excludes) {
- Assert.isNotNull(excludes);
- Assert.isTrue(fIncludes == null);
- fExcludes= excludes;
- }
- protected boolean considerEdit(TextEdit edit) {
- if (fExcludes != null) {
- for (int i= 0; i < fExcludes.length; i++) {
- if (edit.equals(fExcludes[i]))
- return false;
- }
- return true;
- }
- if (fIncludes != null) {
- for (int i= 0; i < fIncludes.length; i++) {
- if (edit.equals(fIncludes[i]))
- return true;
- }
- return false;
- }
- return true;
- }
- private TextEdit[] flatten(TextEdit[] edits) {
- List result= new ArrayList(5);
- for (int i= 0; i < edits.length; i++) {
- flatten(result, edits[i]);
- }
- return (TextEdit[])result.toArray(new TextEdit[result.size()]);
- }
- private void flatten(List result, TextEdit edit) {
- result.add(edit);
- TextEdit[] children= edit.getChildren();
- for (int i= 0; i < children.length; i++) {
- flatten(result, children[i]);
- }
- }
- }
-
- /**
- * Creates a new TextChange
with the given name.
- *
- * @param name the change's name mainly used to render the change in the UI.
- * @param changeKind a flag indicating if the change is a ORIGINAL_CHANGE
,
- * a UNDO_CHANGE
or a REDO_CHANGE
- */
- protected AbstractTextChange(String name, int changeKind) {
- fName= name;
- Assert.isNotNull(fName);
- fChangeKind= changeKind;
- Assert.isTrue(0 <= fChangeKind && fChangeKind <= 2);
- }
-
- /**
- * Acquires a new text buffer to perform the changes managed by this
- * text buffer change. Two subsequent calls to this method must
- * return the identical ITextBuffer
object.
- *
- * @return the acquired text buffer
- */
- protected abstract TextBuffer acquireTextBuffer() throws CoreException;
-
- /**
- * Releases the given text buffer. The given text buffer is not usable
- * anymore after calling this method.
- *
- * @param textBuffer the text buffer to be released
- */
- protected abstract void releaseTextBuffer(TextBuffer textBuffer);
-
- /**
- * Create a new TextBuffer
. Any call to this method
- * must create a new TextBuffer
instance.
- *
- * @return the created text buffer
- */
- protected abstract TextBuffer createTextBuffer() throws CoreException;
-
- /**
- * Adds the TextEdits
managed by this change to the given
- * text buffer editor.
- *
- * @param editor the text buffer edit
- * @param copy if true
the edits are copied before adding.
- * Otherwise the original edits are added.
- */
- protected abstract void addTextEdits(LocalTextEditProcessor editor) throws CoreException;
-
- /**
- * Creates a IChange
that can undo this change.
- *
- * @param edits the text edits that can undo the edits performed by this change
- * @param changeKind the change kind of the reverse change. Either
- * UNDO_CHANGE
or true
if this change is a reverse change. This is the case for an undo
- * or a redo change. Returns false
if the change is an original
- * change.
- *
- * @return whether or not this change is a reverse change
- */
- public boolean isReverseChange() {
- return fChangeKind != ORIGINAL_CHANGE;
- }
-
- protected int getReverseKind() {
- if (fChangeKind == ORIGINAL_CHANGE || fChangeKind == REDO_CHANGE)
- return UNDO_CHANGE;
- else
- return REDO_CHANGE;
- }
-
- /* (Non-Javadoc)
- * Method declared in IChange.
- */
- public String getName(){
- return fName;
- }
-
- /* Non-Javadoc
- * Method declared in IChange
- */
- public IChange getUndoChange() {
- return fUndoChange;
- }
-
- /* Non-Javadoc
- * Method declared in IChange
- */
- public void perform(ChangeContext context, IProgressMonitor pm) throws CModelException, ChangeAbortException {
- if (!isActive()) {
- fUndoChange= new NullChange();
- return;
- }
- LocalTextEditProcessor editor= null;
- try {
- fUndoChange= null;
- editor= new LocalTextEditProcessor(acquireTextBuffer());
- addTextEdits(editor);
- fUndoChange= createReverseChange(editor.performEdits(pm), getReverseKind());
- } catch (Exception e) {
- handleException(context, e);
- } finally {
- if (editor != null) {
- releaseTextBuffer(editor.getTextBuffer());
- }
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TextBufferEditor.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TextBufferEditor.java
deleted file mode 100644
index d6355c25838..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TextBufferEditor.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.changes;
-
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBuffer;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.text.edits.TextEditProcessor;
-import org.eclipse.text.edits.UndoEdit;
-
-public class TextBufferEditor extends TextEditProcessor {
-
- private TextBuffer fBuffer;
- private TextEditProcessor fUndoProcessor;
-
- /**
- * Creates a new TextBufferEditor
for the given
- * TextBuffer
.
- *
- * @param the text buffer this editor is working on.
- */
- public TextBufferEditor(TextBuffer buffer) {
- super(buffer.getDocument(), new MultiTextEdit(0, buffer.getDocument().getLength()),
- TextEdit.CREATE_UNDO | TextEdit.UPDATE_REGIONS);
- fBuffer= buffer;
- }
-
- /**
- * Returns the text buffer this editor is working on.
- *
- * @return the text buffer this editor is working on
- */
- public TextBuffer getTextBuffer() {
- return fBuffer;
- }
-
- /**
- * Adds an Edit
to this edit processor. Adding an edit
- * to an edit processor transfers ownership of the edit to the
- * processor. So after an edit has been added to a processor the
- * creator of the edit must not continue modifying the edit.
- *
- * @param edit the edit to add
- * @exception MalformedTreeException if the text edit can not be
- * added to this edit processor.
- *
- * @see TextEdit#addChild(TextEdit)
- */
- public void add(TextEdit edit) throws MalformedTreeException {
- getRoot().addChild(edit);
- }
-
- /**
- * Adds an undo memento to this edit processor. Adding an undo memento
- * transfers ownership of the memento to the processor. So after a memento
- * has been added the creator of that memento must not continue
- * modifying it.
- *
- * @param undo the undo memento to add
- * @exception EditException if the undo memento can not be added
- * to this processor
- */
- public void add(UndoEdit undo) {
- Assert.isTrue(!getRoot().hasChildren());
- fUndoProcessor= new TextEditProcessor(getDocument(), undo, TextEdit.CREATE_UNDO | TextEdit.UPDATE_REGIONS);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.text.edits.TextEditProcessor#canPerformEdits()
- */
- public boolean canPerformEdits() {
- if (fUndoProcessor != null)
- return fUndoProcessor.canPerformEdits();
- return super.canPerformEdits();
- }
-
- /**
- * Executes the text edits added to this text buffer editor and clears all added
- * text edits.
- *
- * @param pm a progress monitor to report progress or null
if
- * no progress is desired.
- * @return an object representing the undo of the executed TextEdit
s
- * @exception CoreException if the edits cannot be executed
- */
- public UndoEdit performEdits(IProgressMonitor pm) throws CoreException {
- try {
- if (fUndoProcessor != null) {
- return fUndoProcessor.performEdits();
- } else {
- return super.performEdits();
- }
- } catch (BadLocationException e) {
- String message= (e != null ? e.getMessage() : ""); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
- IStatus.ERROR, message, e));
- } catch (MalformedTreeException e) {
- String message= (e != null ? e.getMessage() : ""); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
- IStatus.ERROR, message, e));
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TextChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TextChange.java
deleted file mode 100644
index fd59c0f94ce..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TextChange.java
+++ /dev/null
@@ -1,572 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.changes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.textmanipulation.GroupDescription;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextBuffer;
-import org.eclipse.cdt.internal.corext.textmanipulation.TextRegion;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.text.edits.TextEditCopier;
-
-public abstract class TextChange extends AbstractTextChange {
-
- public static class EditChange {
- private boolean fIsActive;
- private TextChange fTextChange;
- private GroupDescription fDescription;
-
- /* package */ EditChange(GroupDescription description, TextChange change) {
- fTextChange= change;
- fIsActive= true;
- fDescription= description;
- }
- public String getName() {
- return fDescription.getName();
- }
- public void setActive(boolean active) {
- fIsActive= active;
- }
- public boolean isActive() {
- return fIsActive;
- }
- public TextChange getTextChange() {
- return fTextChange;
- }
- public IRegion getTextRange() {
- return fDescription.getTextRange();
- }
- public boolean isEmpty() {
- return fDescription.hasTextEdits();
- }
- /* package */ GroupDescription getGroupDescription() {
- return fDescription;
- }
- public boolean coveredBy(IRegion sourceRegion) {
- int sLength= sourceRegion.getLength();
- if (sLength == 0)
- return false;
- int sOffset= sourceRegion.getOffset();
- int sEnd= sOffset + sLength - 1;
- TextEdit[] edits= fDescription.getTextEdits();
- for (int i= 0; i < edits.length; i++) {
- TextEdit edit= edits[i];
- if (edit.isDeleted())
- return false;
- int rOffset= edit.getOffset();
- int rLength= edit.getLength();
- int rEnd= rOffset + rLength - 1;
- if (rLength == 0) {
- if (!(sOffset < rOffset && rOffset <= sEnd))
- return false;
- } else {
- if (!(sOffset <= rOffset && rEnd <= sEnd))
- return false;
- }
- }
- return true;
- }
- }
-
- private List fTextEditChanges;
- private TextEditCopier fCopier;
- private TextEdit fEdit;
- private boolean fKeepExecutedTextEdits;
- private boolean fAutoMode;
- private String fTextType;
-
- /**
- * Creates a new TextChange
with the given name.
- *
- * @param name the change's name mainly used to render the change in the UI.
- */
- protected TextChange(String name) {
- super(name, ORIGINAL_CHANGE);
- fTextEditChanges= new ArrayList(5);
- fTextType= "txt"; //$NON-NLS-1$
- }
-
- /**
- * Sets the text type. Text types are defined by the extension
- * point >>TODO<<.
- *
- * @param type the text type. If null
is passed the
- * text type is resetted to the default text type "text".
- */
- protected void setTextType(String type) {
- if (type == null)
- fTextType= "txt"; //$NON-NLS-1$
- fTextType= type;
- }
-
- /**
- * Returns the text change's text type.
- *
- * @return the text change's text type
- */
- public String getTextType() {
- return fTextType;
- }
-
- /**
- * Adds a text edit object to this text buffer change.
- *
- * @param name the name of the given text edit. The name is used to render this
- * change in the UI.
- * @param edit the text edit to add
- */
- public void addTextEdit(String name, TextEdit edit) {
- addTextEdit(name, new TextEdit[] {edit});
- }
-
- /**
- * Adds an array of text edit objects to this text buffer change.
- *
- * @param name the name of the given text edit. The name is used to render this
- * change in the UI.
- * @param edite the array of text edits to add
- */
- public void addTextEdit(String name, TextEdit[] edits) {
- Assert.isNotNull(name);
- Assert.isNotNull(edits);
- GroupDescription description= new GroupDescription(name, edits);
- fTextEditChanges.add(new EditChange(description, this));
- if (fEdit == null) {
- fEdit= new MultiTextEdit();
- fAutoMode= true;
- } else {
- Assert.isTrue(fAutoMode, "Can only add edits when in auto organizing mode"); //$NON-NLS-1$
- }
- for (int i= 0; i < edits.length; i++) {
- insert(fEdit, edits[i]);
- }
- }
-
- /**
- * Sets the root text edit.
- *
- * @param edit the root text edit
- */
- public void setEdit(TextEdit edit) {
- Assert.isTrue(fEdit == null, "Root edit can only be set once"); //$NON-NLS-1$
- Assert.isTrue(edit != null);
- fEdit= edit;
- fTextEditChanges= new ArrayList(5);
- fAutoMode= false;
- }
-
- /**
- * Gets the root text edit.
- *
- * @return Returns the root text edit
- */
- public TextEdit getEdit() {
- return fEdit;
- }
-
- /**
- * Adds a group description.
- *
- * @param description the group description to be added
- */
- public void addGroupDescription(GroupDescription description) {
- Assert.isTrue(fEdit != null, "Can only add a description if a root edit exists"); //$NON-NLS-1$
- Assert.isTrue(!fAutoMode, "Group descriptions are only supported if root edit has been set by setEdit"); //$NON-NLS-1$
- Assert.isTrue(description != null);
- fTextEditChanges.add(new EditChange(description, this));
- }
-
- /**
- * Adds a set of group descriptions.
- *
- * @param descriptios the group descriptions to be added
- */
- public void addGroupDescriptions(GroupDescription[] descriptions) {
- for (int i= 0; i < descriptions.length; i++) {
- addGroupDescription(descriptions[i]);
- }
- }
-
- /**
- * Returns the group descriptions that have been added to this change
- * @return GroupDescription[]
- */
- public GroupDescription[] getGroupDescriptions() {
- GroupDescription[] res= new GroupDescription[fTextEditChanges.size()];
- for (int i= 0; i < res.length; i++) {
- EditChange elem= (EditChange) fTextEditChanges.get(i);
- res[i]= elem.getGroupDescription();
- }
- return res;
- }
-
- /**
- * Returns the group description with the given name or null
if no such
- * GroupDescription exists.
- */
- public GroupDescription getGroupDescription(String name) {
- for (int i= 0; i < fTextEditChanges.size(); i++) {
- EditChange elem= (EditChange) fTextEditChanges.get(i);
- GroupDescription description= elem.getGroupDescription();
- if (name.equals(description.getName())) {
- return description;
- }
- }
- return null;
- }
-
-
- /**
- * Returns the text edit changes managed by this text change.
- *
- * @return the text edit changes
- */
- public EditChange[] getTextEditChanges() {
- return (EditChange[])fTextEditChanges.toArray(new EditChange[fTextEditChanges.size()]);
- }
-
- /**
- * Returns the text this change is working on.
- *
- * @return the original text.
- * @exception CModelException if text cannot be accessed
- */
- public String getCurrentContent() throws CModelException {
- TextBuffer buffer= null;
- try {
- buffer= acquireTextBuffer();
- return buffer.getContent();
- } catch (CModelException e){
- throw e;
- } catch (CoreException e) {
- throw new CModelException(e);
- } finally {
- if (buffer != null)
- releaseTextBuffer(buffer);
- }
- }
-
- /**
- * Returns a preview of the change without actually modifying the underlying text.
- *
- * @return the change's preview
- * @exception CModelException if the preview could not be created
- */
- public String getPreviewContent() throws CModelException {
- return getPreviewTextBuffer().getContent();
- }
-
- /**
- * Note: API is under construction
- */
- public TextBuffer getPreviewTextBuffer() throws CModelException {
- try {
- LocalTextEditProcessor editor= new LocalTextEditProcessor(createTextBuffer());
- addTextEdits(editor);
- editor.performEdits(new NullProgressMonitor());
- return editor.getTextBuffer();
- } catch (CModelException e){
- throw e;
- } catch (CoreException e) {
- throw new CModelException(e);
- }
- }
-
- /**
- * Returns the current content to be modified by the given text edit change. The
- * text edit change must have been added to this TextChange
- * by calling
addTextEdit()
- *
- * @param change the text edit change for which the content is requested
- * @param surroundingLines the number of surrounding lines added at top and bottom
- * of the content
- * @return the current content to be modified by the given text edit change
- */
- public String getCurrentContent(EditChange change, int surroundingLines) throws CoreException {
- return getContent(change, surroundingLines, false);
- }
-
- /**
- * Returns the preview of the given text edit change. The text edit change must
- * have been added to this TextChange
by calling
which
- * always aborts an change if an exception is caught.
- */
-public class AbortChangeExceptionHandler implements IChangeExceptionHandler {
-
- public void handle(ChangeContext context, IChange change, Exception e) {
- CUIPlugin.getDefault().log(e);
- throw new ChangeAbortException(e);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElement.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElement.java
deleted file mode 100644
index a5bdaec9234..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElement.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Instances of addTextEdit()
- *
- *
- * @param change the text edit change for which the preview is requested
- * @param surroundingLines the number of surrounding lines added at top and bottom
- * of the preview
- * @return the preview of the given text edit change
- */
- public String getPreviewContent(EditChange change, int surroundingLines) throws CoreException {
- return getContent(change, surroundingLines, true);
- }
-
- /**
- * Returns the current content denoted by the given range
.
- *
- * @param range the range describing the content to be returned
- * @return the current content denoted by the given range
- */
- public String getCurrentContent(IRegion range) throws CoreException {
- TextBuffer buffer= null;
- try {
- buffer= acquireTextBuffer();
- int offset= buffer.getLineInformationOfOffset(range.getOffset()).getOffset();
- int length= range.getLength() + range.getOffset() - offset;
- return buffer.getContent(offset, length);
- } finally {
- if (buffer != null)
- releaseTextBuffer(buffer);
- }
- }
-
- /**
- * Returns a preview denoted by the given range
. First the changes
- * passed in argument changes
are applied and then a string denoted
- * by range
is extracted from the result.
- *
- * @param changes the changes to apply
- * @param range the range denoting the resulting string.
- * @return the computed preview
- */
- public String getPreviewContent(EditChange[] changes, IRegion range) throws CoreException {
- TextBuffer buffer= createTextBuffer();
- LocalTextEditProcessor editor= new LocalTextEditProcessor(buffer);
- addTextEdits(editor, changes);
- int oldLength= buffer.getLength();
- editor.performEdits(new NullProgressMonitor());
- int delta= buffer.getLength() - oldLength;
- int offset= buffer.getLineInformationOfOffset(range.getOffset()).getOffset();
- int length= range.getLength() + range.getOffset() - offset + delta;
- if (length > 0) {
- return buffer.getContent(offset, length);
- } else {
- // range got removed
- return ""; //$NON-NLS-1$
- }
- }
-
- /**
- * Controls whether the text change should keep executed edits. If set to true
- * a call to getExecutedTextEdit(TextEdit original)
will return the executed edit
- * associated with the original edit.
- *
- * @param keep if true
executed edits are kept
- */
- public void setKeepExecutedTextEdits(boolean keep) {
- fKeepExecutedTextEdits= keep;
- if (!fKeepExecutedTextEdits)
- fCopier= null;
- }
-
- /**
- * Returns the edit that got copied and executed instead of the orignial.
- *
- * @return the executed edit
- */
- private TextEdit getExecutedTextEdit(TextEdit original) {
- if (!fKeepExecutedTextEdits || fCopier == null)
- return null;
- return fCopier.getCopy(original);
- }
-
- /**
- * Returns the text range of the given text edit. If the change doesn't
- * manage the given text edit or if setTrackPositionChanges
- * is set to false
null
is returned.
- *
- * setTrackPositionChanges
- * is set to false
null
is returned.
- *
- * null
- if (fAcquiredTextBuffer != null) {
- try {
- TextBuffer.changed(fAcquiredTextBuffer);
- } catch (CoreException e) {
- Assert.isTrue(false, "Should not happen since the buffer is acquired through a text buffer manager"); //$NON-NLS-1$
- } finally {
- releaseTextBuffer(fAcquiredTextBuffer);
- }
- }
- super.performed();
- }
- }
-
- private IFile fFile;
- private TextBuffer fAcquiredTextBuffer;
- private int fAcquireCounter;
- private boolean fSave= true;
-
- /**
- * Creates a new TextFileChange
for the given file.
- *
- * @param name the change's name mainly used to render the change in the UI
- * @param file the file this text change operates on
- */
- public TextFileChange(String name, IFile file) {
- super(name);
- fFile= file;
- Assert.isNotNull(fFile);
- }
-
- /**
- * Sets the save state. If set to true
the change will save the
- * content of the file back to disk.
- *
- * @param save whether or not the changes should be saved to disk
- */
- public void setSave(boolean save) {
- fSave= save;
- }
-
- /**
- * Returns the IFile
this change is working on.
- *
- * @return the file this change is working on
- */
- public IFile getFile() {
- return fFile;
- }
-
- /* non java-doc
- * Method declared in TextChange
- */
- protected TextBuffer acquireTextBuffer() throws CoreException {
- TextBuffer result= TextBuffer.acquire(fFile);
- if (fAcquiredTextBuffer == null || result == fAcquiredTextBuffer) {
- fAcquiredTextBuffer= result;
- fAcquireCounter++;
- }
- return result;
- }
-
- /* non java-doc
- * Method declared in TextChange
- */
- protected void releaseTextBuffer(TextBuffer textBuffer) {
- TextBuffer.release(textBuffer);
- if (textBuffer == fAcquiredTextBuffer) {
- if (--fAcquireCounter == 0)
- fAcquiredTextBuffer= null;
- }
- }
-
- /* non java-doc
- * Method declared in TextChange
- */
- protected TextBuffer createTextBuffer() throws CoreException {
- return TextBuffer.create(fFile);
- }
-
- /* non java-doc
- * Method declared in TextChange
- */
- protected IChange createReverseChange(UndoEdit undo, int changeKind) {
- return new UndoTextFileChange(getName(), fFile, changeKind, undo);
- }
-
- /* non java-doc
- * Method declared in IChange.
- */
- public Object getModifiedLanguageElement(){
- return fFile;
- }
-
- /* non java-doc
- * Method declared in TextChange
- */
- public RefactoringStatus aboutToPerform(ChangeContext context, IProgressMonitor pm) {
- if (fSave) {
- return Checks.validateModifiesFiles(new IFile[] {fFile});
- }
- return new RefactoringStatus();
- }
-
- /* non java-doc
- * Method declared in TextChange
- */
- public void perform(ChangeContext context, IProgressMonitor pm) throws CModelException, ChangeAbortException {
- if (pm == null)
- pm= new NullProgressMonitor();
- if (!isActive()) {
- super.perform(context, pm);
- return;
- }
- try{
- acquireTextBuffer();
- pm.beginTask("", 10); //$NON-NLS-1$
- super.perform(context, new SubProgressMonitor(pm, 8));
- if (fSave) {
- TextBuffer.aboutToChange(fAcquiredTextBuffer);
- TextBuffer.save(fAcquiredTextBuffer, new SubProgressMonitor(pm, 2));
- }
- } catch (Exception e) {
- handleException(context, e);
- } finally {
- pm.done();
- }
- }
-
- /* non java-doc
- * Method declared in TextChange
- */
- public void performed() {
- // During acquiring of text buffer an exception has occured. In this case
- // the pointer is null
- if (fAcquiredTextBuffer != null) {
- try {
- if (fSave)
- TextBuffer.changed(fAcquiredTextBuffer);
- } catch (CoreException e) {
- Assert.isTrue(false, "Should not happen since the buffer is acquired through a text buffer manager"); //$NON-NLS-1$
- } finally {
- releaseTextBuffer(fAcquiredTextBuffer);
- }
- }
- super.performed();
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TranslationUnitChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TranslationUnitChange.java
deleted file mode 100644
index 532f3e72d20..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/TranslationUnitChange.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.changes;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-import org.eclipse.cdt.internal.corext.Assert;
-
-public class TranslationUnitChange extends TextFileChange {
-
- private ITranslationUnit fCUnit;
-
- /**
- * Creates a new TranslationUnitChange
.
- *
- * @param name the change's name mainly used to render the change in the UI
- * @param cunit the Translation unit this text change works on
- */
- public TranslationUnitChange(String name, ITranslationUnit cunit) throws CoreException {
- super(name, getFile(cunit));
- Assert.isNotNull(cunit);
- fCUnit= cunit;
- setTextType("java"); //$NON-NLS-1$
- }
-
- private static IFile getFile(ITranslationUnit cunit) throws CoreException {
- return (IFile) cunit.getResource();
- }
-
- /* non java-doc
- * Method declared in IChange.
- */
- public Object getModifiedLanguageElement(){
- return fCUnit;
- }
-
- /**
- * Returns the Translation unit this change works on.
- *
- * @return the Translation unit this change works on
- */
- public ITranslationUnit getTranslationUnit() {
- return fCUnit;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/UndoTextChange.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/UndoTextChange.java
deleted file mode 100644
index 207a1930923..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/changes/UndoTextChange.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.corext.refactoring.changes;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.text.edits.UndoEdit;
-
-abstract class UndoTextChange extends AbstractTextChange {
-
- private UndoEdit fUndos;
-
- public UndoTextChange(String name, int changeKind, UndoEdit undos) {
- super(name, changeKind);
- fUndos= undos;
- }
-
- protected void addTextEdits(LocalTextEditProcessor editor) throws CoreException {
- editor.add(fUndos);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/refactoring.properties b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/refactoring.properties
deleted file mode 100644
index 5429404c8bf..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/corext/refactoring/refactoring.properties
+++ /dev/null
@@ -1,793 +0,0 @@
-###############################################################################
-# Copyright (c) 2004 IBM Corporation and others.
-# All rights reserved. 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:
-# IBM Rational Software - Initial API and implementation
-###############################################################################
-# NLS properties for the Refactoring Core
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring
-
-Assert.assertion_failed=assertion failed;
-Assert.null_argument=null argument;
-
-Checks.Choose_name=Choose a name
-Checks.all_excluded=All resources have been excluded from refactoring. Cannot proceed
-Checks.cannot_be_parsed=''{0}'' has syntax errors. Content of that file will not be updated.
-Checks.cu_not_created=Translation unit could not be created for this element.
-Checks.cu_not_parsed=This refactoring cannot be performed correctly due to syntax errors in the translation unit. To perform this operation you will need to fix the errors.
-Checks.cu_has_compile_errors=Code modification may not be accurate as affected resource ''{0}'' has compile errors.
-Checks.no_dot=Class name cannot contain a dot (.)
-Checks.cu_name_used=translation unit ''{0}.java'' already exists
-Checks.method_native=Method {0}::{1} is native. Running the modified program will cause {2}.
-Checks.methodName.constructor=New method name has constructor name
-Checks.methodName.exists=Method ''{0}'' already exists in type ''{1}''
-Checks.methodName.overrides=New method ''{0}'' overrides existing method in type ''{1}''
-Checks.methodName.returnTypeClash=New method ''{0}'' overrides a method declared in type ''{1}'' that uses a different return type.
-Checks.has_main=Type {0} contains a main method - some applications (such as scripts) may not work after refactoring
-Checks.constructor_name= If you proceed, the method {0} in ''{1}'' will have a constructor name.
-Checks.method_names_lowercase=This name is discouraged. According to convention, names of methods should start with lowercase letters
-Checks.error.InvalidClassName=Class name is not valid. {0}
-Checks.warning.ClassNameDiscouraged=Class name is discouraged. {0}
-Checks.no_files=No files are found.
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.base
-#######################################
-
-Change.checking_for=Checking change for: {0}
-Change.internal_Error=Internal Error
-Change.is_unsaved={0} is unsaved
-Change.is_read_only={0} is read only
-Change.unexpected_exception=Unexpected exception while executing a change. See log for details.
-Change.javaChanges= C changes
-
-
-ChangeAbortException.wrapped=Exception wrapped by {0}
-
-Refactoring.binary={0} is binary
-Refactoring.not_in_model={0} does not exist in the model
-Refactoring.read_only={0} is read only
-Refactoring.unknown_structure={0} - unknown structure
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.changes
-#######################################
-AbstractRenameChange.Renaming=Renaming...
-
-RenameResourceChange.rename_resource=rename resource
-RenameResourceChange.name=Rename ''{0}'' to: ''{1}''
-
-CompositeChange.CompositeChange=CompositeChange>
-
-DeleteFromClassPathChange.remove=Remove entry from classpath of C project:
-
-MovePackageChange.move=Move package ''{0}'' to ''{1}''
-MoveResourceChange.move=Move resource ''{0}'' to ''{1}''
-
-RenameCProjectChange.rename=Rename C Project ''{0}'' to ''{1}''
-RenameCProjectChange.update=Updating classpaths
-
-RenameSourceFolderChange.rename=Rename Source Folder ''{0}'' to ''{1}''
-
-AbstractCElementRenameChange.checking_change=Checking change for:
-
-AbstractDeleteChange.deleting=deleting
-
-CreatePackageChange.Creating_package=Creating package
-CreatePackageChange.Create_package=Create package
-
-AddToClasspathChange.add=Add entry to classpath of C project:
-
-CopyCompilationUnitChange.copy=Copy ''{0}'' to ''{1}''
-
-CopyPackageChange.copy=Copy package ''{0}'' to ''{1}''
-
-RenamePackageChange.checking_change=Checking change for: {0}
-RenamePackageChange.name=Rename package ''{0}'' to ''{1}''
-
-MoveCompilationUnitChange.default_package=(default package)
-MoveCompilationUnitChange.name=Move Translation Unit ''{0}'' to ''{1}''
-
-RenameCompilationUnitChange.name=Rename translation unit ''{0}'' to ''{1}''
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.code
-#######################################
-
-#-- Extract Method -------------------------------------------
-LocalTypeAnalyzer.local_type_from_outside=Selected block references a local type declared outside the selection.
-LocalTypeAnalyzer.local_type_referenced_outside=A local type declared in the selected block is referenced outside the selection.
-
-FlowAnalyzer.execution_flow=Selected statements contain a return statement but not all possible execution flows end in a return.
-
-ExtractMethodAnalyzer.assignments_to_local=Ambiguous return value: selected block contains more than one assignment to local variable.
-ExtractMethodAnalyzer.only_method_body=Cannot extract new method from selection. Only statements from a method body can be extracted.
-ExtractMethodAnalyzer.after_do_keyword=Selection may not start immediately after the \'do\' keyword.
-ExtractMethodAnalyzer.super_or_this=Cannot extract super or this call from constructor.
-ExtractMethodAnalyzer.cannot_determine_return_type=Cannot determine expression's return type. Using void instead.
-ExtractMethodAnalyzer.branch_mismatch=Selection contains branch statement but corresponding branch target is not selected.
-ExtractMethodAnalyzer.parent_mismatch=Not all selected statements are enclosed by the same parent statement.
-ExtractMethodAnalyzer.cannot_extract_anonymous_type=Cannot extract the body of a anonymous type declaration. Select whole declaration.
-ExtractMethodAnalyzer.cannot_extract_variable_declaration_fragment=Cannot extract a variable declaration fragment. Select whole declaration statement.
-ExtractMethodAnalyzer.cannot_extract_for_initializer=Cannot extract initialization part of a for statement.
-ExtractMethodAnalyzer.cannot_extract_for_updater=Cannot extract increment part of a for statement.
-ExtractMethodAnalyzer.cannot_extract_variable_declaration=Cannot extract parts of a variable declaration. Select whole declaration.
-ExtractMethodAnalyzer.cannot_extract_type_reference=Cannot extract a single type reference.
-ExtractMethodAnalyzer.cannot_extract_name_in_declaration=Cannot extract the name part of a declaration.
-ExtractMethodAnalyzer.ambiguous_return_value=Ambiguous return value: expression, access to local or return statement extracted.
-ExtractMethodAnalyzer.compile_errors=The method''s body cannot be analyzed because of compilation errors in method ''{0}''. To perform the operation you will need to fix the errors.
-ExtractMethodAnalyzer.leftHandSideOfAssignment=Cannot extract the left hand side of an assignment.
-ExtractMethodAnalyzer.single_expression_or_set=Can only extract a single expression or a set of statements.
-ExtractMethodAnalyzer.cannot_extract_null_type=Cannot extract null expression.
-
-ExtractMethodRefactoring.name=Extract Method {0} in {1}
-ExtractMethodRefactoring.add_method=add new method {0}
-ExtractMethodRefactoring.checking_new_name=Checking new method name
-ExtractMethodRefactoring.checking_selection=Checking text selection
-ExtractMethodRefactoring.no_set_of_statements=Selection does not mark a set of statements. Only statements from a method body can be extracted.
-ExtractMethodRefactoring.substitute_with_call=substitute statement(s) with call to {0}
-ExtractMethodRefactoring.change_name=extract method {0} from method {1}
-ExtractMethodRefactoring.organize_imports=Organize Imports
-ExtractMethodRefactoring.duplicates.single=replace duplicate code fragment with call to {0}
-ExtractMethodRefactoring.duplicates.multi=replace duplicate code fragments with call to {0}
-ExtractMethodRefactoring.error.nameInUse=''{0}'' is already used as a name in the selected code
-ExtractMethodRefactoring.error.sameParameter=A parameter ''{0}'' already exists
-
-#-- Inline Method ------------------------------------------------------
-InlineMethodRefactoring.name= Inline Method Refactoring
-InlineMethodRefactoring.searching= Searching for references...
-InlineMethodRefactoring.processing= Processing {0}
-InlineMethodRefactoring.edit.inline= Inline invocation
-InlineMethodRefactoring.edit.delete= Delete method declaration
-InlineMethodRefactoring.edit.inlineCall= Inline Call
-InlineMethodRefactoring.edit.import= Update import statements
-InlineMethodRefactoring.error.classFile= Can\'t inline method since it is declared in a class file
-InlineMethodRefactoring.error.noMethodDeclaration= Unable to resolve corresponding method declaration.
-InlineMethodRefactoring.checking.overridden= Checking for overridden methods...
-# The there keys below are referenced indirectly by passing a string to a helper
-# method. So don't remove them even if they are marked as unused.
-InlineMethodRefactoring.checking.overridden.error= Type {0} overrides method to be inlined.
-InlineMethodRefactoring.checking.overrides.error= Method to be inlined overrides method from class {0}.
-InlineMethodRefactoring.checking.implements.error= Method to be inlined implements method from interface {0}.
-
-InlineMethodRefactoring.SourceAnalyzer.recursive_call=Method declaration contains recursive call.
-InlineMethodRefactoring.SourceAnalyzer.declaration_has_errors=The method declaration contains compile errors. To perform the operation you will need to fix the errors.
-
-InlineMethodRefactoring.SourceAnalyzer.qualified_this_expressions=Cannot inline a method that uses qualified this expressions.
-InlineMethodRefactoring.SourceAnalyzer.syntax_errors=The translation unit containing this method declaration has syntax errors. To perform the operation you will need to fix the errors.
-InlineMethodRefactoring.SourceAnalyzer.abstract_methods=Cannot inline abstract methods.
-
-CallInliner.receiver_type=Can\'t determine receiver\'s type.
-CallInliner.execution_flow=Can\'t inline method. Return statement in method declaration interrupts execution flow.
-CallInliner.multiDeclaration=Can\'t inline method used as an initializer in a multi fragment variable declaration.
-CallInliner.simple_functions=Inlining is only possible on simple functions (consisting of a single return statement), or functions used in an assignment.
-CallInliner.field_initializer_simple=In field initializers inlining is only supported for simple functions (e.g. functions consisting of a single return statement).
-CallInliner.field_initialize_new_local=Can\'t inline field initializer because new local variable is required.
-CallInliner.field_initialize_write_parameter=Can\'t inline field initializer because one of the method parameters is used as an assignment target and will require new local variable.
-CallInliner.field_initialize_self_reference=Can\'t inline method. Method references the field to be initialized.
-CallInliner.constructors=Can\'t inline a constructor invocation that is used as a class instance creation.
-
-#-- SEF ------------------------------------------------------
-SelfEncapsulateField.AccessAnalyzer.encapsulate_read_access=Encapsulate read access
-SelfEncapsulateField.AccessAnalyzer.encapsulate_write_access=Encapsulate write access
-SelfEncapsulateField.AccessAnalyzer.encapsulate_prefix_access=Encapsulate prefix access
-SelfEncapsulateField.AccessAnalyzer.encapsulate_postfix_access=Encapsulate postfix access
-SelfEncapsulateField.AccessAnalyzer.cannot_convert_postfix_expression=Cannot convert postfix expression. It is used inside another expression.
-
-SelfEncapsulateField.name=Self Encapsulate Field
-SelfEncapsulateField.method_exists=A method ''{0}'' already exists in type ''{1}''.
-SelfEncapsulateField.compiler_errors_field=Cannot analyze field ''{0}'' due to the following compiler error: {1}
-SelfEncapsulateField.compiler_errors_update={0} contains compiler errors. This may affect field access update.
-SelfEncapsulateField.type_not_resolveable=The type of the selected field cannot be resolved. An import statement may be missing.
-SelfEncapsulateField.cannot_analyze_selected_field=Cannot analyze selected field ''{0}''
-SelfEncapsulateField.checking_preconditions=Checking preconditions..
-SelfEncapsulateField.searching_for_cunits=Searching for affected translation units...
-SelfEncapsulateField.analyzing=Analyzing...
-SelfEncapsulateField.create_changes=Create changes
-SelfEncapsulateField.change_visibility=Change visibility to private
-SelfEncapsulateField.add_setter=Add Setter method
-SelfEncapsulateField.add_getter=Add Getter method
-
-#-- inline temp ------------------------------------------------------
-InlineTempRefactoring.name=Inline local variable
-InlineTempRefactoring.syntax_errors=This translation unit contains syntax errors. To perform the operation you will need to fix the errors.
-InlineTempRefactoring.select_temp=A local variable declaration or reference must be selected to activate this refactoring.
-InlineTempRefactoring.method_parameter=Cannot inline method parameters.
-InlineTempRefactoring.exceptions_declared=Cannot inline exceptions declared in \'catch\' clauses.
-InlineTempRefactoring.not_initialized=Local variable ''{0}'' is not initialized at declaration.
-InlineTempRefactoring.assigned_more_once=Local variable ''{0}'' is assigned more than once.
-InlineTempRefactoring.preview=Creating preview
-InlineTempRefactoring.inline=Inline local variable
-InlineTempRefactoring.inline_edit_name=Inline local variable:
-InlineTempRefactoring.remove_edit_name=Remove local variable:
-InlineTempRefactoring.Array_vars_initialized=Array variables initialized with constants cannot be inlined.
-InlineTempRefactoring.for_initializers=Cannot inline variables declared in the initializer list of a \'for\' statement.
-
-#-- extract temp ------------------------------------------------------
-ExtractTempRefactoring.name=Extract Local Variable
-ExtractTempRefactoring.select_expression=An expression must be selected to activate this refactoring.
-ExtractTempRefactoring.syntax_error=This file contains syntax errors. To perform this operation you will need to fix the errors.
-ExtractTempRefactoring.explicit_constructor=Code from explicit constructor calls cannot be extracted to a variable.
-ExtractTempRefactoring.expression_in_method=An expression used in a method must be selected to activate this refactoring.
-ExtractTempRefactoring.no_void=Cannot extract an expression of type \'void\'.
-ExtractTempRefactoring.null_literals=Cannot extract single null literals.
-ExtractTempRefactoring.array_initializer=Operation not applicable to an array initializer.
-ExtractTempRefactoring.assignment=Cannot extract assignment that is part of another expression.
-ExtractTempRefactoring.single_conditional_expression=Currently no support to extract a single conditional expression.
-ExtractTempRefactoring.convention=This name is discouraged. According to convention, names of local variables should start with lowercase letters.
-ExtractTempRefactoring.checking_preconditions=Checking preconditions...
-ExtractTempRefactoring.preview=Preparing preview
-ExtractTempRefactoring.extract_temp=Extract Temp
-ExtractTempRefactoring.update_imports=Update imports
-ExtractTempRefactoring.declare_local_variable=Declare local variable
-ExtractTempRefactoring.replace=Replace expression with a local variable reference
-ExtractTempRefactoring.name_in_new=Cannot extract this name - try selecting the whole instance creation expression.
-ExtractTempRefactoring.names_in_declarations=An expression has to be selected to activate this refactoring. Names used in declarations are not expressions.
-ExtractTempRefactoring.assigned_to=The selected expression is assigned. Extracting may change the program\'s semantics.
-ExtractTempRefactoring.refers_to_for_variable=Cannot extract expression, since it refers to a variable declared in the initializer of the enclosing \'for\' statement.
-ExtractTempRefactoring.for_initializer_updater=Cannot extract \'for\' initializer or updater.
-
-#-- extract constant --------------------------------------------------
-ExtractConstantRefactoring.name=Extract Constant
-ExtractConstantRefactoring.select_expression=An expression must be selected to activate this refactoring.
-ExtractConstantRefactoring.syntax_error=This file contains syntax errors. To perform this operation you will need to fix the errors.
-ExtractConstantRefactoring.declare_constant=Declare constant
-ExtractConstantRefactoring.update_imports=Update imports
-ExtractConstantRefactoring.replace=Replace expression with a constant reference
-ExtractConstantRefactoring.preview=Preparing preview
-ExtractConstantRefactoring.field_exists=Field ''{0}'' already exists.
-ExtractConstantRefactoring.no_void=Cannot extract an expression of type \'void\'.
-ExtractConstantRefactoring.null_literals=Cannot extract single null literals.
-ExtractConstantRefactoring.not_load_time_constant=Cannot extract this expression - it is not a valid static constant.
-ExtractConstantRefactoring.extract_constant=Extract Constant
-ExtractConstantRefactoring.convention=This name is discouraged. According to convention, names of class constants do not contain lowercase letters.
-ExtractConstantRefactoring.checking_preconditions=Checking preconditions...
-ExtractConstantRefactoring.rename=Rename Constant
-
-#-- introduce parameter --------------------------------------------------
-IntroduceParameterRefactoring.name=Introduce Parameter
-IntroduceParameterRefactoring.introduce_parameter=Introduce Parameter
-IntroduceParameterRefactoring.syntax_error=This translation unit contains syntax errors. To perform the operation you will need to fix the errors.
-IntroduceParameterRefactoring.select=An expression must be selected to activate this refactoring.
-IntroduceParameterRefactoring.expression_in_method=An expression used in a method must be selected to activate this refactoring.
-IntroduceParameterRefactoring.no_void=Cannot introduce a parameter from an expression of type \'void\'.
-IntroduceParameterRefactoring.duplicate_name=A parameter or local variable with this name already exists.
-IntroduceParameterRefactoring.preview=Preparing preview
-
-IntroduceParameterRefactoring.add_parameter=Add parameter
-IntroduceParameterRefactoring.replace=Replace expression with a parameter reference
-IntroduceParameterRefactoring.add_argument=Add actual argument expression
-
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.rename
-#######################################
-RenameCompilationUnitRefactoring.name=Rename ''{0}'' to ''{1}''
-RenameCompilationUnitRefactoring.not_parsed={0} has syntax errors. No references will be updated if you proceed
-RenameCompilationUnitRefactoring.not_parsed_1={0} has syntax errors.
-RenameCompilationUnitRefactoring.same_name=The same name chosen
-
-RenameFieldRefactoring.name=Rename field ''{0}'' to ''{1}''
-RenameFieldRefactoring.hiding=After renaming, the field ''{0}'' will be hidden in the scope of the field ''{1}'' declared in type ''{2}''
-RenameFieldRefactoring.hiding2=After renaming, the field named ''{0}'' declared in type ''{1}'' will be hidden in the scope of the field ''{2}''
-RenameFieldRefactoring.another_name=Choose another name.
-RenameFieldRefactoring.checking=Checking preconditions...
-RenameFieldRefactoring.field_already_defined=Field with this name is already defined.
-RenameFieldRefactoring.searching=Searching for references...
-RenameFieldRefactoring.deleted=The selected field has been deleted from ''{0}''
-RenameFieldRefactoring.already_exists=Method ''{0}'' already exists in ''{1}''
-RenameFieldRefactoring.overridden=Method ''{0}'' is overridden or overrides another method
-RenameFieldRefactoring.overridden_or_overrides=Method ''{0}'' is overridden or overrides another method
-RenameFieldRefactoring.Update_getter_occurrence=Update getter occurrence
-RenameFieldRefactoring.Update_setter_occurrence=Update setter occurrence
-RenameFieldRefactoring.searching_for_text_matches=searching for text matches
-RenameFieldRefactoring.Update_field_declaration=Update field declaration
-RenameFieldRefactoring.Update_field_reference=Update field reference
-RenameFieldRefactoring.should_start_lowercase=This name is discouraged. According to convention, C instance field names should start with lowercase letters
-RenameFieldRefactoring.declared_in_supertype=Cannot be renamed because it is declared in a supertype
-
-RenamePackageRefactoring.another_name=Choose another name.
-RenamePackageRefactoring.checking=Checking preconditions...
-RenamePackageRefactoring.creating_change=Preparing preview...
-RenamePackageRefactoring.package_exists=Package already exists
-RenamePackageRefactoring.searching=Searching for references...
-RenamePackageRefactoring.update_reference=update package reference
-RenamePackageRefactoring.name=Rename package ''{0}'' to ''{1}''
-RenamePackageRefactoring.aleady_exists=Package ''{0}'' already exists in this project in folder ''{1}''
-
-RenameMethodInInterfaceRefactoring.already_defined=A related type declares a method with the new name (and same number of parameters)
-RenameMethodInInterfaceRefactoring.special_case=Cannot rename this method because it is a special case (see the language specification section 9.2 for details)
-
-RenameMethodRefactoring.name=Rename method ''{0}'' to ''{1}''
-RenameMethodRefactoring.no_binary=Related method ''{0}'' (declared in ''{1}'') is binary. Refactoring cannot be performed.
-RenameMethodRefactoring.no_native=Renaming native methods will cause an unsatisfied link error on runtime.
-RenameMethodRefactoring.no_native_1=Related method ''{0}'' (declared in ''{1}'') is native. Renaming will cause an UnsatisfiedLinkError on runtime.
-RenameMethodRefactoring.no_read_only=Related method ''{0}'' (declared in ''{1}'') is read-only. Refactoring cannot be performed.
-RenameMethodRefactoring.not_in_model=Related method ''{0}'' (declared in ''{1}'') does not exist in the model.
-RenameMethodRefactoring.same_name=This name already exists.
-
-RenamePrivateMethodRefactoring.hierarchy_defines=''{0}'' or a type in its hierarchy defines a method ''{1}'' with the same number of parameters and same parameter type names.
-RenamePrivateMethodRefactoring.hierarchy_defines2=''{0}'' or a type in its hierarchy defines a method ''{1}'' with the same number of parameters, but different parameter type names.
-RenamePrivateMethodRefactoring.update=Update method reference
-
-RenameVirtualMethodRefactoring.requieres_renaming_native=Renaming ''{0}'' requires renaming a native method. Renaming will cause {1} on runtime.
-RenameVirtualMethodRefactoring.hierarchy_declares1=Hierarchy declares a method ''{0}'' with the same number of parameters, but different parameter type names.
-RenameVirtualMethodRefactoring.hierarchy_declares2=Hierarchy declares a method ''{0}'' with the same number of parameters and same parameter type names.
-
-RenameMethodRefactoring.update_occurrence=Update method occurrence
-RenameMethodRefactoring.update_declaration=Update method declaration
-RenameMethodRefactoring.deleted=The selected method has been deleted from ''{0}''
-
-RenameTypeRefactoring.checking=Checking preconditions...
-RenameTypeRefactoring.choose_another_name=Please choose another name.
-RenameTypeRefactoring.creating_change=Preparing preview...
-RenameTypeRefactoring.rename_constructor=rename constructor
-RenameTypeRefactoring.searching=Searching for references...
-RenameTypeRefactoring.update_reference=update element reference
-RenameTypeRefactoring.name=Rename ''{0}'' to ''{1}''
-RenameTypeRefactoring.enclosed=Element ''{0}'' is enclosed in a type named ''{1}''
-RenameTypeRefactoring.encloses=Element ''{0}'' encloses a type named ''{1}''
-RenameTypeRefactoring.exists=Type named ''{0}'' already exists in package ''{1}''
-RenameTypeRefactoring.imported=Type named ''{0}'' is imported (single-type-import) in ''{1}'' (a translation unit must not import and declare a type with the same name)
-RenameTypeRefactoring.member_type_exists=Another element named ''{0}'' already exists in ''{1}''
-RenameTypeRefactoring.global_member_type_exists=Another element named ''{0}'' already exists in the same element domain. This change might result in compilation errors.
-RenameTypeRefactoring.enclosed_type_native=An element enclosed in type ''{0}'' declares a native method. Renaming will cause an unsatisfied link error on runtime.
-RenameTypeRefactoring.name_conflict1=Name conflict with element ''{0}'' in ''{1}''
-RenameTypeRefactoring.searching_text=searching for text matches
-RenameTypeRefactoring.update=Type declaration update
-RenameTypeRefactoring.does_not_exist=Element ''{0}'' does not exist in the saved version of ''{1}''
-RenameTypeRefactoring.will_not_rename=Translation unit will not be renamed
-RenameTypeRefactoring.local_type=Local Type declared inside ''{0}'' is named {1}
-RenameTypeRefactoring.member_type=Member Type declared inside ''{0}'' is named {1}
-RenameTypeRefactoring.another_type=Another type named ''{0} is referenced in ''{1}''
-RenameTypeRefactoring.wrong_element=Rename refactoring does not handle this type of element.
-RenameTypeRefactoring.virtual_method=Renaming a virtual method. Consider renaming the base and derived class methods (if any).
-
-
-
-TextMatchFinder.comment=text reference update in a comment
-TextMatchFinder.string=text reference update in a string literal
-TextMatchFinder.searching=searching for text matches in:
-
-RippleMethodFinder.analizing_hierarchy=analyzing hierarchy
-
-RefactoringAnalyzeUtil.name_collision=Name collision with name ''{0}''
-
-RenameTempRefactoring.must_select_local=A local variable declaration or reference must be selected to activate this refactoring
-RenameTempRefactoring.only_in_methods_and_initializers=Only local variables declared in methods and initializers can be renamed
-RenameTempRefactoring.lowercase=This name is discouraged. According to convention, local variable names should start with lowercase letters.
-RenameTempRefactoring.rename=Rename Local Variable
-RenameTempRefactoring.changeName=Rename local variable:''{0}'' to: ''{1}''
-
-MethodChecks.overrides=The selected method overrides method ''{0}'' declared in type ''{1}''.
-MethodChecks.implements=The selected method is an implementation of method ''{0}'' declared in type ''{1}''
-
-RenameCProjectRefactoring.rename=Rename C project ''{0}'' to:''{1}''
-RenameCProjectRefactoring.already_exists=A project with that name already exists
-RenameCProjectRefactoring.read_only=Project ''{0}'' is marked as read-only
-
-RenamePackageRefactoring.searching_text=searching for text matches
-RenamePackageRefactoring.Packagered_only=Package ''{0}'' is read-only.
-RenamePackageRefactoring.resource_read_only=Resource corresponding to package ''{0}'' is read only. Click ''Continue'' if still you want to rename it.
-RenamePackageRefactoring.contains_type=Package ''{0}'' already contains a type named ''{1}''
-
-RenameResourceRefactoring.Internal_Error=Internal Error
-RenameResourceRefactoring.alread_exists=A file or folder with this name already exists
-RenameResourceRefactoring.invalidName=This is an invalid name for a file or folder
-
-RenameSourceFolderRefactoring.blank=Name must not start or end with a blank
-RenameSourceFolderRefactoring.invalid_name=This is an invalid name for a file or folder
-RenameSourceFolderRefactoring.already_exists=An element with this name already exists
-RenameSourceFolderRefactoring.alread_exists=An element with this name already exists
-RenameSourceFolderRefactoring.rename=Rename Source Folder ''{0}'' to ''{1}''
-
-################ Rename Processors #########################################
-
-RenameResourceProcessor.name=Rename resource ''{0}'' to ''{1}''
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.reorg
-#######################################
-MoveRefactoring.reorganize_elements=Reorganize elements
-
-DeleteRefactoring.delete_package_fragment_root= Deleting a package fragment root
-
-MoveCuUpdateCreator.update_imports=update imports
-MoveCuUpdateCreator.searching=Searching for references to types in ''{0}''
-MoveCuUpdateCreator.update_references=update references
-
-CopyRefactoring.cu.copyOf1=CopyOf{0}
-CopyRefactoring.cu.copyOfMore=Copy_{0}_of_{1}
-CopyRefactoring.resource.copyOf1=Copy of {0}
-CopyRefactoring.resource.copyOfMore=Copy ({0}) of {1}
-CopyRefactoring.package.copyOf1={0}.copy
-CopyRefactoring.package.copyOfMore={1}.copy{0}
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.structure
-#######################################
-PullUpRefactoring.Pull_Up=Pull Up
-PullUpRefactoring.no_interface_members=Pull up is not allowed on interface members
-PullUpRefactoring.no_java.lang.Object=Pull up is not allowed on elements declared in java.lang.Object
-PullUpRefactoring.no_binary_types=Pull up is not allowed on elements declared in binary types
-PullUpRefactoring.no_read_only_types=Pull up is not allowed on elements declared in read-only types
-PullUpRefactoring.not_this_type=Pull up is not allowed on elements declared in this type
-PullUpRefactoring.final_fields=Pulling up final fields will result in compilation errors if they are not initialized on creation or in constructors
-PullUpRefactoring.checking_referenced_elements=Checking referenced elements
-PullUpRefactoring.does_not_exist=Element {0} does not exist in the saved version of the file
-PullUpRefactoring.type_not_accessible=Type ''{0}'' referenced in one of the pulled elements is not accessible from type ''{1}''
-PullUpRefactoring.field_not_accessible=Field ''{0}'' referenced in one of the pulled elements is not accessible from type ''{1}''
-PullUpRefactoring.method_not_accessible=Method ''{0}'' referenced in one of the pulled elements is not accessible from type ''{1}''
-PullUpRefactoring.different_method_return_type=Method ''{0}'' declared in type''{1}'' has a different return type than its pulled up counterpart, which will result in compile errors if you proceed
-PullUpRefactoring.different_field_type=Field ''{0}'' declared in type ''{1}'' has a different type than its pulled up counterpart
-PullUpRefactoring.static_method=Method ''{0}'' declared in type ''{1}'' is \'static\', which will result in compile errors if you proceed
-PullUpRefactoring.lower_visibility=Method ''{0}'' declared in type ''{1}'' has visibility lower than \'protected\', which will result in compile errors if you proceed
-PullUpRefactoring.preview=Preparing preview
-PullUpRefactoring.calculating_required=Calculating required members
-PullUpRefactoring.gets_instantiated=Class ''{0}'' cannot be made abstract because it gets instantiated
-PullUpRefactoring.Field_declared_in_class=Field ''{0}'' is declared in class ''{1}''. Pulling it up may result in changed program semantics.
-PullUpRefactoring.methodis_declared_in_class=Method ''{0}'' is declared in class ''{1}''. Pulling it up may result in changed program semantics.
-PullUpRefactoring.field_cannot_be_accessed=Field ''{0}'' cannot be accessed from ''{1}''
-PullUpRefactoring.method_cannot_be_accessed=Method ''{0}'' cannot be accessed from ''{1}''
-PullUpRefactoring.Type_declared_in_class=Type ''{0}'' is declared in class ''{1}''. Pulling it up may result in changed program semantics.
-
-MemberCheckUtil.signature_exists=Method ''{0}'' (with the same signature) already exists in type ''{1}'', which will result in compile errors if you proceed
-MemberCheckUtil.same_param_count=Method ''{0}'' (with the same number of parameters) already exists in type ''{1}''
-MemberCheckUtil.field_exists=Field ''{0}'' already exists in type ''{1}'', which will result in compile errors if you proceed
-MemberCheckUtil.type_name_conflict0=Nested type ''{0}'' already exists in type ''{1}'', which will result in compile errors if you proceed
-MemberCheckUtil.type_name_conflict1=Destination type has the same simple name as ''{0}'', which will result in compile errors if you proceed
-MemberCheckUtil.type_name_conflict2=Destination type is enclosed in a type that has same simple name as ''{0}'', which will result in compile errors if you proceed
-MemberCheckUtil.type_name_conflict3=Destination type has the same simple name as ''{0}'' (enclosed in ''{1}''), which will result in compile errors if you proceed
-MemberCheckUtil.type_name_conflict4=Destination type is enclosed in a type that has same simple name as ''{0}'' (enclosed in ''{1}''), which will result in compile errors if you proceed
-
-ChangeSignatureRefactoring.modify_Parameters=Change Method Signature
-ChangeSignatureRefactoring.restructure_parameters=Restructure parameters
-ChangeSignatureRefactoring.checking_preconditions=Checking preconditions...
-ChangeSignatureRefactoring.method_deleted=The selected method has been deleted from ''{0}''
-ChangeSignatureRefactoring.native=Method ''{0}'' declared in type ''{1}'' is native. Reordering parameters will cause UnsatisfiedLinkError on runtime if you do not update your native libraries
-ChangeSignatureRefactoring.duplicate_name=Duplicate parameter name: {0}
-
-MoveMembersRefactoring.Move_Members=Move Members
-MoveMembersRefactoring.compile_errors=Operation can't be performed due to compile errors in ''{0}''. Please fix errors first.
-MoveMembersRefactoring.deleteMembers= delete members
-MoveMembersRefactoring.addMembers= add members
-MoveMembersRefactoring.referenceUpdate= update reference to moved member
-MoveMembersRefactoring.Checking_preconditions=Checking preconditions...
-MoveMembersRefactoring.static_declaration=Static members can be declared only in top level or static types.
-MoveMembersRefactoring.multi_var_fields=Currently, only field declarations with single variable declaration fragments can be moved.
-MoveMembersRefactoring.only_public_static_final=Only ''public static final'' fields with variable initializers can be moved to an interface.
-MoveMembersRefactoring.Object=Move is not allowed on members declared in 'java.lang.Object'.
-MoveMembersRefactoring.binary=Pull up is not allowed on members of binary types.
-MoveMembersRefactoring.read_only=Pull up is not allowed on members of read-only types.
-MoveMembersRefactoring.move_members=Move members
-MoveMembersRefactoring.not_found=Destination type ''{0}'' not be found
-MoveMembersRefactoring.same=Destination and source types are the same (''{0}'')
-MoveMembersRefactoring.inside=Destination type ''{1}'' is inside moved member''{0}''.
-MoveMembersRefactoring.not_exist=Destination type ''{0}'' does not exist
-MoveMembersRefactoring.dest_binary=Destination type ''{0}'' is binary
-MoveMembersRefactoring.native=Moved method ''{0}'' is native. You will need to update native libraries.
-MoveMembersRefactoring.moved_field=In ''{2}'', moved field ''{0}'' will not be visible from ''{1}''
-MoveMembersRefactoring.accessed_field=Accessed field ''{0}'' will not be visible from ''{1}''
-MoveMembersRefactoring.moved_method=In ''{2}'', moved method ''{0}'' will not be visible from ''{2}''
-MoveMembersRefactoring.accessed_method=Accessed method ''{0}'' will not be visible from ''{1}''
-MoveMembersRefactoring.moved_type=In ''{2}'', moved type ''{0}'' will not be visible from ''{2}''
-MoveMembersRefactoring.accessed_type=Accessed type ''{0}'' will not be visible from ''{1}''
-
-MoveRefactoring.scanning_qualified_names=Scanning for qualified names in non C files...
-
-QualifiedNameFinder.update_name=Update fully qualified name
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.surround
-#######################################
-
-SurroundWithTryCatchRefactoring.name=Surround with try/catch Block
-SurroundWithTryCatchAnalyzer.doesNotCover=Selection does not cover a set of statements. Extend selection to a valid range using the "Expand Selection With" actions from the Edit menu.
-SurroundWithTryCatchAnalyzer.doesNotContain=Selection does not contain statements from a method body or static initializer.
-SurroundWithTryCatchAnalyzer.noUncaughtExceptions=No uncaught exceptions are thrown by the selected code.
-SurroundWithTryCatchAnalyzer.onlyStatements=Only statements can be surrounded with try/catch blocks.
-SurroundWithTryCatchAnalyzer.cannotHandleSuper=Cannot surround a super constructor call.
-SurroundWithTryCatchAnalyzer.cannotHandleThis=Cannot surround a constructor invocation.
-SurroundWithTryCatchAnalyzer.compile_errors=The selected code cannot be analyzed because of compilation errors. To perform this operation you will need to fix the errors.
-
-#######################################
-# org.eclipse.jdt.internal.core.refactoring.util
-#######################################
-
-CommentAnalyzer.internal_error=Internal error during precondition checking.
-CommentAnalyzer.ends_inside_comment=Selection ends inside a comment.
-CommentAnalyzer.starts_inside_comment=Selection starts inside a comment.
-
-StatementAnalyzer.doesNotCover= The selection does not cover a set of statements or an expression. Extend selection to a valid range using the "Expand Selection With" actions from the Edit menu.
-StatementAnalyzer.beginning_of_selection=The beginning of the selection contains characters that do not belong to a statement.
-StatementAnalyzer.end_of_selection=The end of the selection contains characters that do not belong to a statement.
-StatementAnalyzer.do_body_expression=Operation not applicable to a do statement's body and expression.
-StatementAnalyzer.for_initializer_expression=Operation not applicable to a for statement's initializer and expression part.
-StatementAnalyzer.for_expression_updater=Operation not applicable to a for statement's expression and updater part.
-StatementAnalyzer.for_updater_body=Operation not applicable to a for statement's updater and body part.
-StatementAnalyzer.catch_argument=Operation is not applicable to a catch block's argument declaration.
-StatementAnalyzer.while_expression_body=Operation not applicable to a while statement's expression and body.
-StatementAnalyzer.try_statement=Selection must either cover whole try statement or parts of try, catch, or finally block.
-StatementAnalyzer.switch_statement=Selection must either cover whole switch statement or parts of a single case block.
-StatementAnalyzer.synchronized_statement=Selection must either cover whole synchronized statement or parts of the synchronized block.
-
-CodeAnalyzer.array_initializer=Operation not applicable to an array initializer.
-CElementUtil.initializer=initializer
-
-#######################################
-# other
-#######################################
-CopyResourceString.copy=Copy resource ''{0}'' to ''{1}''
-
-RenameAnalyzeUtil.shadows=Problem in ''{0}''. Another name shadows access to the renamed element
-CopyRefactoring.update_ref=Update Type Reference
-CopyRefactoring.searching=Searching
-CompositeChange.performingChangesTask.name=Performing changes...
-CodeRefactoringUtil.error.message=The body of the method ''{0}'' cannot be analyzed because of compilation errors in that method. To perform the operation you will need to fix the errors.
-InlineTemRefactoring.error.message.nulLiteralsCannotBeInlined=Null literals cannot be inlined
-InlineTemRefactoring.error.message.fieldsCannotBeInlined=Cannot inline fields
-RenameMethodRefactoring.taskName.checkingPreconditions=Checking preconditions...
-RenameMethodRefactoring.taskName.searchingForReferences=Searching for references...
-
-PushDownRefactoring.name=Push Down
-PushDownRefactoring.no_subclasses=Class ''{0}'' does not have any modifiable non-anonymous subclasses to which members could be pushed down
-PushDownRefactoring.not_in_saved=One of the selected members does not exist in the saved version of the file
-PushDownRefactoring.interface_members=Pushing down interface members is not supported
-PushDownRefactoring.members_of_binary=Pushing down members declared in binary types is not supported
-PushDownRefactoring.members_of_read-only=Pushing down members declared in read-only types is not supported
-PushDownRefactoring.calculating=Calculating required members
-PushDownRefactoring.referenced=Pushed down member ''{0}'' is referenced by ''{1}''
-PushDownRefactoring.checking=Checking referenced elements
-PushDownRefactoring.type_not_accessible=Type ''{0}'' referenced in one of the pushed elements is not accessible from type ''{1}''
-PushDownRefactoring.field_not_accessible=Field ''{0}'' referenced in one of the pulled elements is not accessible from type ''{1}''
-PushDownRefactoring.method_not_accessible=Method ''{0}'' referenced in one of the pulled elements is not accessible from type ''{1}''
-PushDownRefactoring.gets_instantiated=Class ''{0}'' cannot be made abstract because it gets instantiated
-PushDownRefactoring.preview=Creating preview...
-PushDownRefactoring.initializer=initializer
-PushDownRefactoring.creating_preview=Creating preview...
-
-ChangeSignatureRefactoring.invalid_return_type=''{0}'' is not a valid return type name
-ChangeSignatureRefactoring.default_value=Enter the default value for parameter ''{0}''
-ChangeSignatureRefactoring.invalid_expression=''{0}'' is not a valid expression
-ChangeSignatureRefactoring.parameter_type=Enter the type for parameter ''{0}''
-ChangeSignatureRefactoring.invalid_type_name=''{0}'' is not a valid parameter type name
-ChangeSignatureRefactoring.unchanged=Method signature and return type are unchanged.
-ChangeSignatureRefactoring.parameter_used=Parameter ''{0}'' is used in method ''{1}'' declared in type ''{2}''
-ChangeSignatureRefactoring.anonymous_subclass=anonymous subclass of ''{0}''
-ChangeSignatureRefactoring.non-virtual=Changing visibility to \'private\' will make this method non-virtual, which may affect the program\'s behavior
-ChangeSignatureRefactoring.already_has=Method ''{0}'' already has a parameter named ''{1}''
-ChangeSignatureRefactoring.preview=Preparing preview
-ChangeSignatureRefactoring.modify_parameters=Modify parameters
-ChangeSignatureRefactoring.not_unique=Parameter type name ''{0}'' cannot be uniquely resolved or is not a valid type name.
-ChangeSignatureRefactoring.ambiguous=Parameter type name ''{0}'' is ambiguous. There are {1} types with that name.
-
-MoveInnerToTopRefactoring.names_start_lowercase=This name is discouraged. According to convention, names of instance fields and local variables start with lowercase letters.
-MoveInnerToTopRefactoring.already_declared=A field named ''{0}'' is already declared in type ''{1}''
-MoveInnerToTopRefactoring.deleted=The selected type has been deleted from ''{0}''
-MoveInnerToTopRefactoring.compilation_Unit_exists=Compilation Unit named ''{0}'' already exists in package ''{1}''
-MoveInnerToTopRefactoring.name_used=Name ''{0}'' is used as a parameter name in one of the constructors of type ''{1}''
-MoveInnerToTopRefactoring.name=Move Member Type to New File
-MoveInnerToTopRefactoring.creating_preview=Creating change
-MoveInnerToTopRefactoring.move_to_Top=Move Member Type to New File
-MoveInnerToTopRefactoring.type_exists=Type named ''{0}'' already exists in package ''{1}''
-
-InstanceMethodMover.move_method=Move instance method
-InstanceMethodMover.replace_with_delegation=Replace method body with delegation.
-InstanceMethodMover.create_in_receiver=Create method in new receiver\'s class.
-InstanceMethodMover.add_imports=Add needed imports for created method
-InstanceMethodMover.to_local_localunsupported=Moving to within local classes is currently unsupported.
-InstanceMethodMover.parameter_name_used=Parameter name ''{0}'' is already used
-InstanceMethodMover.no_static_methods=This refactoring cannot be used to move static methods.
-InstanceMethodMover.single_implementation=Select a single method implementation to move.
-InstanceMethodMover.no_native_methods=This refactoring cannot be used to move native methods.
-InstanceMethodMover.no_synchronized_methods=This refactoring cannot be used to move synchronized methods.
-InstanceMethodMover.no_constructors=This refactoring cannot be used to move a constructor.
-InstanceMethodMover.uses_super=The method cannot be moved, since it uses the \"super\" keyword.
-InstanceMethodMover.refers_enclosing_instances=The method cannot be moved, since it refers to enclosing instances (i.e. ChangeElement
are used to present
- * IChange
object as nodes in a tree.
- */
-abstract class ChangeElement {
-
- /** Flag indicating that the change element isn't active */
- public final static int INACTIVE= 0;
- /** Flag indicating that the change element is partly active (some children are inactive) */
- public final static int PARTLY_ACTIVE= 1;
- /** Flage indicating that the change element is active */
- public final static int ACTIVE= 2;
-
- protected final static int[][] ACTIVATION_TABLE= new int[][] {
- /*INACTIVE*/ /*PARTLY_ACTIVE */ /*ACTIVE */
- /* INACTIVE */ { INACTIVE, PARTLY_ACTIVE, PARTLY_ACTIVE },
- /* PARTLY_ACTIVE*/{ PARTLY_ACTIVE, PARTLY_ACTIVE, PARTLY_ACTIVE },
- /* ACTIVE */ { PARTLY_ACTIVE, PARTLY_ACTIVE, ACTIVE}
- };
-
- protected static final ChangeElement[] EMPTY_CHILDREN= new ChangeElement[0];
-
- private ChangeElement fParent;
-
- /**
- * Creates a new ChangeElement
with the
- * given parent
- *
- * @param parent the change element's parent or null
- *
if the change element doesn't have a parent
- */
- public ChangeElement(ChangeElement parent) {
- fParent= parent;
- }
-
- /**
- * Returns the change element's parent.
- *
- * @return the change element's parent
- */
- public ChangeElement getParent() {
- return fParent;
- }
-
- /**
- * Returns the viewer used to present a preview of this change element
- *
- * @return the viewer suitable to present a preview of this change or
- * null
if no previewer is configured.
- */
-// public abstract ChangePreviewViewerDescriptor getChangePreviewViewer() throws CoreException;
-
- public abstract void feedInput(IChangePreviewViewer viewer) throws CoreException;
-
- /**
- * Sets the activation status for this ChangeElement
. When a
- * change element is not active, then executing it is expected to do nothing.
- *
- * @param active the activation status for this change element
- */
- public abstract void setActive(boolean active);
-
- /**
- * Returns the activation status of this ChangeElement
.
- * Returns one of the following values: IChange.ACTIVE
- * if the node and all its children are active, IChange.INACTIVE
- * if all children and the node itself is inactive, and IChange.PARTLy_ACTIVE
- *
otherwise.
- *
- * @return the change element's activation status.
- */
- public abstract int getActive();
-
- /**
- * Returns the change element's children.
- *
- * @return the change element's children.
- */
- public abstract ChangeElement[] getChildren();
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementContentProvider.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementContentProvider.java
deleted file mode 100644
index 8ba5a44ea1b..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementContentProvider.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.ICompositeChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange.EditChange;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * A default content provider to present a hierarchy of IChange
- * objects in a tree viewer.
- */
-class ChangeElementContentProvider implements ITreeContentProvider {
-
- private static final ChangeElement[] EMPTY_CHILDREN= new ChangeElement[0];
-
- private static class OffsetComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- EditChange c1= (EditChange)o1;
- EditChange c2= (EditChange)o2;
- int p1= getOffset(c1);
- int p2= getOffset(c2);
- if (p1 < p2)
- return -1;
- if (p1 > p2)
- return 1;
- // same offset
- return 0;
- }
- private int getOffset(EditChange edit) {
- return edit.getTextRange().getOffset();
- }
- }
-
- /* non Java-doc
- * @see ITreeContentProvider#inputChanged
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // do nothing
- }
-
- /* non Java-doc
- * @see ITreeContentProvider#getChildren
- */
- public Object[] getChildren(Object o) {
- ChangeElement element= (ChangeElement)o;
- ChangeElement[] children= element.getChildren();
- if (children == null) {
- children= createChildren(element);
- }
- return children;
- }
-
- /* non Java-doc
- * @see ITreeContentProvider#getParent
- */
- public Object getParent(Object element){
- return ((ChangeElement)element).getParent();
- }
-
- /* non Java-doc
- * @see ITreeContentProvider#hasChildren
- */
- public boolean hasChildren(Object element){
- Object[] children= getChildren(element);
- return children != null && children.length > 0;
- }
-
- /* non Java-doc
- * @see ITreeContentProvider#dispose
- */
- public void dispose(){
- }
-
- /* non Java-doc
- * @see ITreeContentProvider#getElements
- */
- public Object[] getElements(Object element){
- return getChildren(element);
- }
-
- private ChangeElement[] createChildren(ChangeElement object) {
- ChangeElement[] result= EMPTY_CHILDREN;
- if (!(object instanceof DefaultChangeElement))
- return result;
-
- DefaultChangeElement changeElement= (DefaultChangeElement)object;
- IChange change= changeElement.getChange();
- if (change instanceof ICompositeChange) {
- IChange[] children= ((ICompositeChange)change).getChildren();
- result= new ChangeElement[children.length];
- for (int i= 0; i < children.length; i++) {
- result[i]= new DefaultChangeElement(changeElement, children[i]);
- }
- }
-////////////////
-// else if (change instanceof TranslationUnitChange) {
-// List children= new ArrayList(5);
-// TranslationUnitChange cunitChange= (TranslationUnitChange)change;
-// ITranslationUnit cunit= cunitChange.getTranslationUnit();
-// Map map= new HashMap(20);
-// EditChange[] changes=getSortedTextEditChanges(cunitChange);
-// for (int i= 0; i < changes.length; i++) {
-// EditChange tec= changes[i];
-// try {
-// ICElement element= getModifiedCElement(tec, cunit);
-// if (element.equals(cunit)) {
-// children.add(new TextEditChangeElement(changeElement, tec));
-// } else {
-// PseudoCChangeElement pjce= getChangeElement(map, element, children, changeElement);
-// pjce.addChild(new TextEditChangeElement(pjce, tec));
-// }
-// } catch (CModelException e) {
-// children.add(new TextEditChangeElement(changeElement, tec));
-// }
-// }
-// result= (ChangeElement[]) children.toArray(new ChangeElement[children.size()]);
-// }
-// else if (change instanceof TextChange) {
-// EditChange[] changes= getSortedTextEditChanges((TextChange)change);
-// result= new ChangeElement[changes.length];
-// for (int i= 0; i < changes.length; i++) {
-// result[i]= new TextEditChangeElement(changeElement, changes[i]);
-// }
-// }
-///////////
- changeElement.setChildren(result);
- return result;
- }
-
- private EditChange[] getSortedTextEditChanges(TextChange change) {
- EditChange[] edits= change.getTextEditChanges();
- List result= new ArrayList(edits.length);
- for (int i= 0; i < edits.length; i++) {
- if (!edits[i].isEmpty())
- result.add(edits[i]);
- }
- Comparator comparator= new OffsetComparator();
- Collections.sort(result, comparator);
- return (EditChange[])result.toArray(new EditChange[result.size()]);
- }
-
- private PseudoCChangeElement getChangeElement(Map map, ICElement element, List children, ChangeElement cunitChange) {
- PseudoCChangeElement result= (PseudoCChangeElement)map.get(element);
- if (result != null)
- return result;
- ICElement parent= element.getParent();
- if (parent instanceof ITranslationUnit) {
- result= new PseudoCChangeElement(cunitChange, element);
- children.add(result);
- map.put(element, result);
- } else {
- PseudoCChangeElement parentChange= getChangeElement(map, parent, children, cunitChange);
- result= new PseudoCChangeElement(parentChange, element);
- parentChange.addChild(result);
- map.put(element, result);
- }
- return result;
- }
-
- private ICElement getModifiedCElement(EditChange edit, ITranslationUnit cunit) throws CModelException {
- IRegion range= edit.getTextRange();
- if (range.getOffset() == 0 && range.getLength() == 0)
- return cunit;
- ICElement result= getElementAt(cunit, range.getOffset());
- if (result == null)
- return cunit;
-
- try {
- while(true) {
- ISourceReference ref= (ISourceReference)result;
- IRegion sRange= new Region(ref.getSourceRange().getStartPos(), ref.getSourceRange().getLength());
- if (result.getElementType() == ICElement.C_UNIT || result.getParent() == null || edit.coveredBy(sRange))
- break;
- result= result.getParent();
- }
- } catch(CModelException e) {
- // Do nothing, use old value.
- } catch(ClassCastException e) {
- // Do nothing, use old value.
- }
- return result;
- }
-
- protected ICElement getElementAt(IParent unit, int position) throws CModelException {
- if (unit instanceof ISourceReference) {
- ICElement[] children = unit.getChildren();
- for (int i = 0; i < children.length; i++) {
- ICElement aChild = children[i];
- if (aChild instanceof ISourceReference) {
- ISourceReference child = (ISourceReference) children[i];
- ISourceRange range = child.getSourceRange();
- if (position < range.getStartPos() + range.getLength() && position >= range.getStartPos()) {
- if (child instanceof IParent) {
- return getElementAt((IParent)child, position);
- } else {
- return ((ICElement)child);
- }
- }
- }
- }
- }
- return null;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementLabelProvider.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementLabelProvider.java
deleted file mode 100644
index c91ed6a16dc..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementLabelProvider.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.ICompositeChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextFileChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TranslationUnitChange;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.swt.graphics.Image;
-
-class ChangeElementLabelProvider extends LabelProvider {
-
- private int fCElementFlags;
- private CElementLabelProvider fCElementLabelProvider;
- private Map fDescriptorImageMap= new HashMap();
- private boolean fShowQualification= true;
-
- public ChangeElementLabelProvider(int CElementFlags) {
- fCElementFlags= CElementFlags;
- fCElementLabelProvider= new CElementLabelProvider(CElementFlags);
- }
-
- public void setShowQualification(boolean showQualification) {
- fShowQualification= showQualification;
- LabelProviderChangedEvent event= new LabelProviderChangedEvent(this, null);
- fireLabelProviderChanged(event);
- }
-
- public Image getImage(Object object) {
- if (object instanceof DefaultChangeElement) {
- Object element= ((DefaultChangeElement)object).getChange();
- return doGetImage(element);
- }
- else if (object instanceof TextEditChangeElement) {
- Object element= ((TextEditChangeElement)object).getTextEditChange();
- return doGetImage(element);
- }
- else if (object instanceof PseudoCChangeElement) {
- PseudoCChangeElement element= (PseudoCChangeElement)object;
- return fCElementLabelProvider.getImage(element.getCElement());
- }
- return super.getImage(object);
- }
-
- public String getText(Object object) {
- if (object instanceof DefaultChangeElement) {
- IChange change= ((DefaultChangeElement)object).getChange();
- if (!fShowQualification)
- return change.getName();
-
- if (change instanceof TextFileChange) {
- IFile file= ((TextFileChange)change).getFile();
- return RefactoringMessages.getFormattedString(
- "PreviewWizardPage.changeElementLabelProvider.textFormat", //$NON-NLS-1$
- new String[] {file.getName(), getPath(file)});
- } else {
- return change.getName();
- }
- }
- else if (object instanceof TextEditChangeElement) {
- TextEditChangeElement element= (TextEditChangeElement)object;
- String result= element.getTextEditChange().getName();
- if ((fCElementFlags & CElementLabelProvider.SHOW_POST_QUALIFIED) != 0) {
- ChangeElement parent= getParent(element);
- if (parent != null)
- result= RefactoringMessages.getFormattedString(
- "PreviewWizardPage.changeElementLabelProvider.textFormatEdit", //$NON-NLS-1$
- new String[] {getText(parent), result});
- }
- return result;
- }
- else if (object instanceof PseudoCChangeElement) {
- PseudoCChangeElement element= (PseudoCChangeElement)object;
- return fCElementLabelProvider.getText(element.getCElement());
- }
- return super.getText(object);
- }
-
- public void dispose() {
- for (Iterator iter= fDescriptorImageMap.values().iterator(); iter.hasNext(); ) {
- Image image= (Image)iter.next();
- image.dispose();
- }
- super.dispose();
- }
-
- private Image doGetImage(Object element) {
- ImageDescriptor descriptor= null;
- if (descriptor == null) {
- if (element instanceof ICompositeChange) {
- descriptor= CPluginImages.DESC_OBJS_COMPOSITE_CHANGE;
- }
- else if (element instanceof TextEditChangeElement) {
- descriptor= CPluginImages.DESC_OBJS_TEXT_EDIT;
- }
- else if (element instanceof TranslationUnitChange) {
- descriptor= CPluginImages.DESC_OBJS_CU_CHANGE;
- }
- else if (element instanceof TextFileChange) {
- descriptor= CPluginImages.DESC_OBJS_FILE_CHANGE;
- }
- else {
- descriptor= CPluginImages.DESC_OBJS_DEFAULT_CHANGE;
- }
- }
- Image image= (Image)fDescriptorImageMap.get(descriptor);
- if (image == null) {
- image= descriptor.createImage();
- fDescriptorImageMap.put(descriptor, image);
- }
- return image;
- }
-
- private String getPath(IFile file) {
- StringBuffer result= new StringBuffer(file.getProject().getName());
- String projectRelativePath= file.getParent().getProjectRelativePath().toString();
- if (projectRelativePath.length() > 0) {
- result.append('/');
- result.append(projectRelativePath);
- }
- return result.toString();
- }
-
- private ChangeElement getParent(TextEditChangeElement element) {
- ChangeElement parent= element.getParent();
- while (parent != null
- && !(parent instanceof PseudoCChangeElement)
- && !(parent instanceof DefaultChangeElement)) {
- parent= parent.getParent();
- }
- return parent;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementTreeViewer.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementTreeViewer.java
deleted file mode 100644
index c9ab85f8f0a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeElementTreeViewer.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-class ChangeElementTreeViewer extends CheckboxTreeViewer {
-
- public ChangeElementTreeViewer(Composite parentComposite) {
- super(parentComposite, SWT.NONE);
- addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event){
- ChangeElement element= (ChangeElement)event.getElement();
- boolean checked= event.getChecked();
-
- element.setActive(checked);
- setSubtreeChecked(element, checked);
- setSubtreeGrayed(element, false);
- ChangeElement parent= element.getParent();
- while(parent != null) {
- int active= parent.getActive();
- boolean grayed= (active == ChangeElement.PARTLY_ACTIVE);
- setChecked(parent, checked ? true : grayed);
- setGrayed(parent, grayed);
- parent= parent.getParent();
- }
- }
- });
- }
-
- protected void inputChanged(Object input, Object oldInput) {
- super.inputChanged(input, oldInput);
- // XXX workaround for http://bugs.eclipse.org/bugs/show_bug.cgi?id=9390
- initializeChildren((ChangeElement)input);
- }
-
- protected void doUpdateItem(Item item, Object element) {
- super.doUpdateItem(item, element);
- TreeItem treeItem= (TreeItem)item;
- ChangeElement ce= (ChangeElement)element;
- int state= ce.getActive();
- boolean checked= state == ChangeElement.INACTIVE ? false : true;
- treeItem.setChecked(checked);
- boolean grayed= state == ChangeElement.PARTLY_ACTIVE ? true : false;
- treeItem.setGrayed(grayed);
- }
-
- protected void revealNext() {
- revealElement(true);
- }
-
- protected void revealPrevious() {
- revealElement(false);
- }
-
- private void initializeChildren(ChangeElement element) {
- if (element == null)
- return;
- ChangeElement[] children= element.getChildren();
- if (children == null)
- return;
- for (int i= 0; i < children.length; i++) {
- ChangeElement child= children[i];
- int state= child.getActive();
- boolean checked= state == ChangeElement.INACTIVE ? false : true;
- if (checked)
- setChecked(child, checked);
- boolean grayed= state == ChangeElement.PARTLY_ACTIVE ? true : false;
- if (grayed)
- setGrayed(child, grayed);
- }
- }
-
- private void setSubtreeGrayed(Object element, boolean grayed) {
- Widget widget= findItem(element);
- if (widget instanceof TreeItem) {
- TreeItem item= (TreeItem)widget;
- if (item.getGrayed() != grayed) {
- item.setGrayed(grayed);
- grayChildren(getChildren(item), grayed);
- }
- }
- }
-
- private void grayChildren(Item[] items, boolean grayed) {
- for (int i= 0; i < items.length; i++) {
- Item element= items[i];
- if (element instanceof TreeItem) {
- TreeItem item= (TreeItem)element;
- if (item.getGrayed() != grayed) {
- item.setGrayed(grayed);
- grayChildren(getChildren(item), grayed);
- }
- }
- }
- }
-
- private void revealElement(boolean next) {
- ChangeElement current= (ChangeElement)getInput();
- IStructuredSelection selection= (IStructuredSelection)getSelection();
- if (!selection.isEmpty())
- current= (ChangeElement)selection.iterator().next();
-
- ChangeElement candidate= getLeaf(current, next);
- if (candidate == null) {
- candidate= getElement(current, next);
- if (candidate != null) {
- ChangeElement leaf= getLeaf(candidate, next);
- if (leaf != null)
- candidate= leaf;
- }
- }
- if (candidate != null)
- setSelection(new StructuredSelection(candidate), true);
- else
- getControl().getDisplay().beep();
- }
-
- private ChangeElement getLeaf(ChangeElement element, boolean first) {
- ChangeElement result= null;
- ChangeElement[] children= element.getChildren();
- while(children != null && children.length > 0) {
- result= children[first ? 0 : children.length - 1];
- children= result.getChildren();
- }
- return result;
- }
-
- private ChangeElement getElement(ChangeElement element, boolean next) {
- while(true) {
- ChangeElement parent= element.getParent();
- if (parent == null)
- return null;
- ChangeElement candidate= getSibling(parent.getChildren(), element, next);
- if (candidate != null)
- return candidate;
- element= parent;
- }
- }
-
- private ChangeElement getSibling(ChangeElement[] children, ChangeElement element, boolean next) {
- for (int i= 0; i < children.length; i++) {
- if (children[i] == element) {
- if (next)
- if (i < children.length - 1)
- return children[i + 1];
- else
- return null;
- else
- if (i > 0)
- return children[i - 1];
- else
- return null;
- }
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java
deleted file mode 100644
index 4d10ac4b458..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChangeExceptionHandler;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-
-/**
- * An implementation of IChangeExceptionHandler
which pops up a dialog
- * box asking the user if the refactoring is to be aborted without further actions or
- * if the refactoring engine should try to undo all successfully executed changes.
- */
-public class ChangeExceptionHandler implements IChangeExceptionHandler {
-
- private Shell fParent;
-
- private static class RefactorErrorDialog extends ErrorDialog {
- public RefactorErrorDialog(Shell parentShell, String dialogTitle, String message, IStatus status, int displayMask) {
- super(parentShell, dialogTitle, message, status, displayMask);
- }
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- Button ok= getButton(IDialogConstants.OK_ID);
- ok.setText( RefactoringMessages.getString("ChangeExceptionHandler.undo")); //$NON-NLS-1$
- Button abort= createButton(parent, IDialogConstants.CANCEL_ID, RefactoringMessages.getString("ChangeExceptionHandler.abort"), true); //$NON-NLS-1$
- abort.moveBelow(ok);
- abort.setFocus();
- }
- protected Control createMessageArea (Composite parent) {
- Control result= super.createMessageArea(parent);
- new Label(parent, SWT.NONE); // filler
- Label label= new Label(parent, SWT.NONE);
- label.setText(RefactoringMessages.getString("ChangeExceptionHandler.button_explanation")); //$NON-NLS-1$
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- applyDialogFont(result);
- return result;
- }
- }
-
- public ChangeExceptionHandler(Shell parent) {
- Assert.isNotNull(parent);
- fParent= parent;
- }
-
- public void handle(ChangeContext context, IChange change, Exception e) {
- CUIPlugin.getDefault().log(e);
- IStatus status= null;
- if (e instanceof CoreException) {
- status= ((CoreException)e).getStatus();
- } else {
- if (e.getMessage() == null)
- status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
- RefactoringMessages.getString("ChangeExceptionHandler.no_details"), e); //$NON-NLS-1$
- else
- status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, e.getMessage(), e);
- }
- final ErrorDialog dialog= new RefactorErrorDialog(fParent,
- RefactoringMessages.getString("ChangeExceptionHandler.refactoring"), //$NON-NLS-1$
- RefactoringMessages.getFormattedString("ChangeExceptionHandler.unexpected_exception", new String[] {change.getName()}), //$NON-NLS-1$
- status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
-
- final int[] result= new int[1];
- Runnable runnable= new Runnable() {
- public void run() {
- result[0]= dialog.open();
- }
- };
- fParent.getDisplay().syncExec(runnable);
- switch(result[0]) {
- case IDialogConstants.OK_ID:
- context.setTryToUndo();
- // Fall through
- case IDialogConstants.CANCEL_ID:
- throw new ChangeAbortException(e);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/CheckConditionsOperation.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/CheckConditionsOperation.java
deleted file mode 100644
index 48f9575e1e0..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/CheckConditionsOperation.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.cdt.core.model.CModelException;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-/**
- * Operation that, when run, check proceconditions of an Refactoring
passed
- * on creation.
- */
-public class CheckConditionsOperation implements IRunnableWithProgress {
- private Refactoring fRefactoring;
- private int fStyle;
- private RefactoringStatus fStatus;
-
- public final static int NONE= 0;
- public final static int ACTIVATION= 1 << 1;
- public final static int INPUT= 1 << 2;
- public final static int PRECONDITIONS= ACTIVATION | INPUT;
- final static int LAST= 1 << 3;
-
- /**
- * Creates a new CheckConditionsOperation
.
- *
- * @param refactoring the refactoring. Parameter must not be null
.
- * @param style style to define which conditions to check.
- */
- public CheckConditionsOperation(Refactoring refactoring, int style) {
- Assert.isNotNull(refactoring);
- fRefactoring= refactoring;
- fStyle= style;
- Assert.isTrue(checkStyle(fStyle));
- }
-
- /*
- * (Non-Javadoc)
- * Method defined int IRunnableWithProgress
- */
- public void run(IProgressMonitor pm) throws InvocationTargetException {
- try {
- fStatus= null;
- if ((fStyle & PRECONDITIONS) == PRECONDITIONS)
- fStatus= fRefactoring.checkPreconditions(pm);
- else if ((fStyle & ACTIVATION) == ACTIVATION)
- fStatus= fRefactoring.checkActivation(pm);
- else if ((fStyle & INPUT) == INPUT)
- fStatus= fRefactoring.checkInput(pm);
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- } finally {
- pm.done();
- }
- }
-
- /**
- * Returns the outcome of the operation or null
if an exception
- * has occured when performing the operation.
- *
- * @return the RefactoringStatus
returned from
- * IRefactoring.checkPreconditions
.
- * @see org.eclipse.jdt.internal.corext.refactoring.base.IRefactoring#checkPreconditions(IProgressMonitor)
- */
- public RefactoringStatus getStatus() {
- return fStatus;
- }
-
- private boolean checkStyle(int style) {
- return style < LAST;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/CreateChangeOperation.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/CreateChangeOperation.java
deleted file mode 100644
index 90feb2274fb..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/CreateChangeOperation.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.cdt.core.model.CModelException;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-/**
- * Operation that, when performed, creates an IChange
object for the refactoring
- * passed as a constructor parameter.
- */
-public class CreateChangeOperation implements IRunnableWithProgress {
-
- private Refactoring fRefactoring;
- private int fStyle;
- private int fCheckPassedSeverity;
- private IChange fChange;
- private RefactoringStatus fStatus;
-
- public static final int CHECK_NONE= CheckConditionsOperation.NONE;
- public static final int CHECK_ACTIVATION= CheckConditionsOperation.ACTIVATION;
- public static final int CHECK_INPUT= CheckConditionsOperation.INPUT;
- public static final int CHECK_PRECONDITION= CheckConditionsOperation.PRECONDITIONS;
- private static final int LAST= CheckConditionsOperation.LAST;
-
- /**
- * Creates a new instance with the given refactoring.
- *
- * @param refactoring the refactoring. Parameter must not be null
- * @param style style to define which conditions to check
- */
- public CreateChangeOperation(Refactoring refactoring, int style) {
- Assert.isNotNull(refactoring);
- fRefactoring= refactoring;
- fStyle= style;
- Assert.isTrue(checkStyle(fStyle));
- fCheckPassedSeverity= RefactoringStatus.ERROR;
- }
-
- /**
- * Creates a new instance with the given refactoring.
- *
- * @param refactoring the refactoring. Parameter must not be null
- * @param style style to define which conditions to check
- * @param checkPassedSeverity the severity below which the check is considered
- * to be passed
- * @see #setCheckPassedSeverity(int)
- */
- public CreateChangeOperation(Refactoring refactoring, int style, int checkPassedSeverity) {
- Assert.isNotNull(refactoring);
- fRefactoring= refactoring;
- fStyle= style;
- Assert.isTrue(checkStyle(fStyle));
- setCheckPassedSeverity(checkPassedSeverity);
- }
-
- /**
- * Sets the check passed severity value. This value is used to deceide whether the
- * condition check is interpreted as passed or not. The condition check is considered
- * to be passed if the refactoring status's severity is less or equal the given severity.
- * The given value must be smaller than RefactoringStatus.FATAL
.
- */
- public void setCheckPassedSeverity(int severity) {
- fCheckPassedSeverity= severity;
- Assert.isTrue (fCheckPassedSeverity < RefactoringStatus.FATAL);
- }
-
- /* (Non=Javadoc)
- * Method declared in IRunnableWithProgress
- */
- public void run(IProgressMonitor pm) throws InvocationTargetException {
- fChange= null;
- fStatus= null;
- try {
- fChange= null;
- if (fStyle != CHECK_NONE) {
- pm.beginTask("", 5); //$NON-NLS-1$
- pm.subTask(""); //$NON-NLS-1$
- CheckConditionsOperation op= new CheckConditionsOperation(fRefactoring, fStyle);
- op.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- fStatus= op.getStatus();
- if (fStatus != null && fStatus.getSeverity() <= fCheckPassedSeverity) {
- fChange= fRefactoring.createChange(
- new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- } else {
- pm.worked(1);
- }
- } else {
- fChange= fRefactoring.createChange(pm);
- }
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- } finally {
- pm.done();
- }
- }
-
- /**
- * Returns the outcome of the operation or null
if an exception
- * occured when performing the operation.
- *
- * @return the outcome of the operation
- */
- public IChange getChange() {
- return fChange;
- }
-
- /**
- * Returns the status of the condition cheking. Returns null
if an
- * exception occured when performing the operation.
- *
- * @return the condition checking's status
- */
- public RefactoringStatus getStatus() {
- return fStatus;
- }
-
- /**
- * Returns the checking style.
- *
- * @return the style used for precondition checking. Is one of NONE
,
- * ACTIVATION
, INPUT
, or PRECONDITION
.
- */
- public int getConditionCheckingStyle() {
- return fStyle;
- }
-
- public void setConditionCheckingStyle(int style) {
- Assert.isTrue(checkStyle(style));
- fStyle= style;
- }
-
- private boolean checkStyle(int style) {
- return style < LAST;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/DefaultChangeElement.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/DefaultChangeElement.java
deleted file mode 100644
index 7f974183a7a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/DefaultChangeElement.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.ICompositeChange;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.util.Assert;
-//import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange;
-//import org.eclipse.jdt.internal.corext.refactoring.changes.TextChange;
-
-class DefaultChangeElement extends ChangeElement {
-
- private IChange fChange;
- private ChangeElement[] fChildren;
-
- /**
- * Creates a new ChangeElement
for the given
- * change.
- *
- * @param parent the change element's parent or null
- *
if the change element doesn't have a parent
- * @param change the actual change. Argument must not be
- * null
- */
- public DefaultChangeElement(ChangeElement parent, IChange change) {
- super(parent);
- fChange= change;
- Assert.isNotNull(fChange);
- }
-
- /**
- * Returns the underlying IChange
object.
- *
- * @return the underlying change
- */
- public IChange getChange() {
- return fChange;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.ChangeElement#getChangePreviewViewer()
- */
-// public ChangePreviewViewerDescriptor getChangePreviewViewer() throws CoreException {
-// return ChangePreviewViewerDescriptor.get(fChange);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.ChangeElement#feedInput(org.eclipse.jdt.internal.ui.refactoring.IChangePreviewViewer)
- */
- public void feedInput(IChangePreviewViewer viewer) throws CoreException {
- viewer.setInput(fChange);
- }
-
- /* non Java-doc
- * @see ChangeElement#setActive
- */
- public void setActive(boolean active) {
- fChange.setActive(active);
- }
-
- /* non Java-doc
- * @see ChangeElement.getActive
- */
- public int getActive() {
- if (fChange instanceof ICompositeChange /*|| fChange instanceof CompilationUnitChange || fChange instanceof TextChange*/)
- return getCompositeChangeActive();
- else
- return getDefaultChangeActive();
- }
-
- /* non Java-doc
- * @see ChangeElement.getChildren
- */
- public ChangeElement[] getChildren() {
- return fChildren;
- }
-
- /**
- * Sets the children.
- *
- * @param the children of this node. Must not be null
- */
- public void setChildren(ChangeElement[] children) {
- Assert.isNotNull(children);
- fChildren= children;
- }
-
- private int getDefaultChangeActive() {
- int result= fChange.isActive() ? ACTIVE : INACTIVE;
- if (fChildren != null) {
- for (int i= 0; i < fChildren.length; i++) {
- result= ACTIVATION_TABLE[fChildren[i].getActive()][result];
- if (result == PARTLY_ACTIVE)
- break;
- }
- }
- return result;
- }
-
- private int getCompositeChangeActive() {
- if (fChildren != null && fChildren.length > 0) {
- int result= fChildren[0].getActive();
- for (int i= 1; i < fChildren.length; i++) {
- result= ACTIVATION_TABLE[fChildren[i].getActive()][result];
- if (result == PARTLY_ACTIVE)
- break;
- }
- return result;
- } else {
- return ACTIVE;
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ErrorWizardPage.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ErrorWizardPage.java
deleted file mode 100644
index b03290ba34f..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ErrorWizardPage.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.wizard.IWizardPage;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-/**
- * Presents the list of failed preconditions to the user
- */
-class ErrorWizardPage extends RefactoringWizardPage {
-
- public static final String PAGE_NAME= "ErrorPage"; //$NON-NLS-1$
-
- private RefactoringStatus fStatus;
- private RefactoringStatusViewer fViewer;
-
- public ErrorWizardPage() {
- super(PAGE_NAME);
- }
-
- /**
- * Sets the page's refactoring status to the given value.
- * @param status the refactoring status.
- */
- public void setStatus(RefactoringStatus status) {
- fStatus= status;
- if (fStatus != null) {
- setPageComplete(isRefactoringPossible());
- int severity= fStatus.getSeverity();
- if (severity >= RefactoringStatus.FATAL) {
- setDescription(RefactoringMessages.getString("ErrorWizardPage.cannot_proceed")); //$NON-NLS-1$
- } else if (severity >= RefactoringStatus.INFO) {
- setDescription(RefactoringMessages.getString("ErrorWizardPage.confirm")); //$NON-NLS-1$
- } else {
- setDescription(""); //$NON-NLS-1$
- }
- } else {
- setPageComplete(true);
- setDescription(""); //$NON-NLS-1$
- }
- }
-
- public RefactoringStatus getStatus() {
- return fStatus;
- }
-
- //---- UI creation ----------------------------------------------------------------------
-
- /* (non-Javadoc)
- * Method declared in IWizardPage.
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- setControl(fViewer= new RefactoringStatusViewer(parent, SWT.NONE));
- Dialog.applyDialogFont(fViewer);
- WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.REFACTORING_ERROR_WIZARD_PAGE);
- }
-
- //---- Reimplementation of WizardPage methods ------------------------------------------
-
- /* (non-Javadoc)
- * Method declared on IDialog.
- */
- public void setVisible(boolean visible) {
- if (visible) {
- fViewer.setStatus(fStatus);
- }
- super.setVisible(visible);
- }
-
- /* (non-Javadoc)
- * Method declared in IWizardPage.
- */
- public boolean canFlipToNextPage() {
- // We have to call super.getNextPage since computing the next
- // page is expensive. So we avoid it as long as possible.
- return fStatus != null && isRefactoringPossible() &&
- isPageComplete() && super.getNextPage() != null;
- }
-
- /* (non-Javadoc)
- * Method declared in IWizardPage.
- */
- public IWizardPage getNextPage() {
- RefactoringWizard wizard= getRefactoringWizard();
- IChange change= wizard.getChange();
- if (change == null) {
- change= wizard.createChange(CreateChangeOperation.CHECK_NONE, RefactoringStatus.ERROR, false);
- wizard.setChange(change);
- }
- if (change == null)
- return this;
-
- return super.getNextPage();
- }
-
- /* (non-JavaDoc)
- * Method defined in RefactoringWizardPage
- */
- protected boolean performFinish() {
- RefactoringWizard wizard= getRefactoringWizard();
- IChange change= wizard.getChange();
- PerformChangeOperation op= null;
- if (change != null) {
- op= new PerformChangeOperation(change);
- } else {
- CreateChangeOperation ccop= new CreateChangeOperation(getRefactoring(), CreateChangeOperation.CHECK_NONE);
- ccop.setCheckPassedSeverity(RefactoringStatus.ERROR);
-
- op= new PerformChangeOperation(ccop);
- op.setCheckPassedSeverity(RefactoringStatus.ERROR);
- }
- return wizard.performFinish(op);
- }
-
- //---- Helpers ----------------------------------------------------------------------------------------
-
- private boolean isRefactoringPossible() {
- return fStatus.getSeverity() < RefactoringStatus.FATAL;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IChangePreviewViewer.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IChangePreviewViewer.java
deleted file mode 100644
index ad3828ae3fe..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IChangePreviewViewer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Presents a preview of a ChangeElement
- */
-public interface IChangePreviewViewer {
-
- /**
- * Creates the preview viewer's widget hierarchy. This method
- * should only be called once. Method getControl()
- * should be use retrieve the widget hierarchy.
- *
- * @param parent the parent for the widget hierarchy
- *
- * @see #getControl()
- */
- public void createControl(Composite parent);
-
- /**
- * Returns the preview viewer's SWT control.
- *
- * @return the preview viewer's SWT control
- */
- public Control getControl();
-
- /**
- * Sets the preview viewer's input element.
- *
- * @param input the input element
- */
- public void setInput(Object input) throws CoreException;
-
- /**
- * Refreshes the preview viewer.
- */
- public void refresh();
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IPreviewWizardPage.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IPreviewWizardPage.java
deleted file mode 100644
index f3a864185e8..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IPreviewWizardPage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.jface.wizard.IWizardPage;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-
-public interface IPreviewWizardPage extends IWizardPage {
-
- /** The page's name */
- public static final String PAGE_NAME= "PreviewPage"; //$NON-NLS-1$
-
- /**
- * Sets that change for which the page is supposed to display a preview.
- *
- * @param change the new change.
- */
- public void setChange(IChange change);
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IStatusContextViewer.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IStatusContextViewer.java
deleted file mode 100644
index 18b3636316b..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/IStatusContextViewer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.Context;
-
-/**
- * A special viewer to present a context for a RefactoringStatusEntry
.
- */
-public interface IStatusContextViewer {
-
- /**
- * Creates the status viewer's widget hierarchy. This method
- * should only be called once. Method getControl()
- * should be used to retrieve the widget hierarchy.
- *
- * @param parent the parent for the widget hierarchy
- *
- * @see #getControl()
- */
- public void createControl(Composite parent);
-
- /**
- * Returns the status context viewer's SWT control.
- *
- * @return the status context viewer's SWT control
- */
- public Control getControl();
-
- /**
- * Sets the status context viewer's input element.
- *
- * @param input the input element
- */
- public void setInput(Context input);
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ListDialog.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ListDialog.java
deleted file mode 100644
index 65e13ac5e8a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/ListDialog.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-public class ListDialog extends SelectionDialog {
-
- private IStructuredContentProvider fContentProvider;
- private ILabelProvider fLabelProvider;
- private Object fInput;
- private TableViewer fTableViewer;
- private boolean fAddCancelButton;
-
- public ListDialog(Shell parent) {
- super(parent);
- fAddCancelButton= false;
- }
-
- public void setInput(Object input) {
- fInput= input;
- }
-
- public void setContentProvider(IStructuredContentProvider sp){
- fContentProvider= sp;
- }
-
- public void setLabelProvider(ILabelProvider lp){
- fLabelProvider= lp;
- }
-
- public void setAddCancelButton(boolean addCancelButton) {
- fAddCancelButton= addCancelButton;
- }
-
- public TableViewer getTableViewer(){
- return fTableViewer;
- }
-
- public boolean hasFilters(){
- return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0;
- }
-
- public void create() {
- setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
- super.create();
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- if (! fAddCancelButton)
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- else
- super.createButtonsForButtonBar(parent);
- }
-
- protected Control createDialogArea(Composite container) {
- Composite parent= (Composite) super.createDialogArea(container);
- createMessageArea(parent);
- fTableViewer= new TableViewer(parent, getTableStyle());
- fTableViewer.setContentProvider(fContentProvider);
- Table table= fTableViewer.getTable();
- fTableViewer.setLabelProvider(fLabelProvider);
- fTableViewer.setInput(fInput);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(15);
- gd.widthHint= convertWidthInCharsToPixels(55);
- table.setLayoutData(gd);
- applyDialogFont(parent);
- return parent;
- }
-
- protected int getTableStyle() {
- return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PerformChangeOperation.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PerformChangeOperation.java
deleted file mode 100644
index 25780316f93..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PerformChangeOperation.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-
-import org.eclipse.ui.IEditorPart;
-
-import org.eclipse.cdt.core.model.CoreModel;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-import org.eclipse.cdt.internal.ui.ICStatusConstants;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * Operation that, when performed, performes a change to the workbench.
- */
-public class PerformChangeOperation implements IRunnableWithProgress {
-
- private IChange fChange;
- private ChangeContext fChangeContext;
- private CreateChangeOperation fCreateChangeOperation;
- private int fCheckPassedSeverity;
- private boolean fChangeExecuted;
-
- /**
- * Creates a new perform change operation instance for the given change.
- *
- * @param change the change to be applied to the workbench
- */
- public PerformChangeOperation(IChange change) {
- fChange= change;
- Assert.isNotNull(fChange);
- }
-
- /**
- * Creates a new perform change operation for the given create change operation.
- * When executed, a new change is created using the passed instance.
- *
- * @param op the CreateChangeOperation
used to create a new
- * change object
- */
- public PerformChangeOperation(CreateChangeOperation op) {
- fCreateChangeOperation= op;
- Assert.isNotNull(fCreateChangeOperation);
- fCheckPassedSeverity= RefactoringStatus.INFO;
- }
-
- /**
- * Returns true
if the change has been executed. Otherwise false
- * is returned.
- *
- * @return true
if the change has been executed, otherwise
- * false
- */
- public boolean changeExecuted() {
- return fChangeExecuted;
- }
-
- /**
- * Returns the change used by this operation. This is either the change passed to
- * the constructor or the one create by the CreateChangeOperation
.
- * Method returns null
if the create operation did not create
- * the change.
- *
- * @return the change used by this operation or null
if no change
- * has been created
- */
- public IChange getChange() {
- return fChange;
- }
-
- public RefactoringStatus getStatus() {
- return fCreateChangeOperation != null ? fCreateChangeOperation.getStatus() : null;
- }
-
- /**
- * Sets the check passed severity value. This value is used to deceide whether the
- * condition check, executed if a change is to be created, is interpreted as passed
- * or not. The condition check is considered to be passed if the refactoring status's
- * severity is less or equal the given severity. The given value must be smaller
- * than RefactoringStatus.FATAL
.
- *
- * @param severity the severity value considered to be "ok".
- */
- public void setCheckPassedSeverity(int severity) {
- fCheckPassedSeverity= severity;
- Assert.isTrue (fCheckPassedSeverity < RefactoringStatus.FATAL);
- }
-
- /**
- * Sets the change context used to execute the change. The given context is passed
- * to the method IChange.perform
.
- *
- * @param context the change context to use
- * @see IChange#perform(ChangeContext, IProgressMonitor)
- */
- public void setChangeContext(ChangeContext context) {
- fChangeContext= context;
- Assert.isNotNull(fChangeContext);
- }
-
- /* (non-Javadoc)
- * Method declard in IRunnableWithProgress
- */
- public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
- try{
- fChangeExecuted= false;
- if (createChange()) {
- pm.beginTask("", 2); //$NON-NLS-1$
- fCreateChangeOperation.run(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- fChange= fCreateChangeOperation.getChange();
- RefactoringStatus status= fCreateChangeOperation.getStatus();
- int conditionCheckingStyle= fCreateChangeOperation.getConditionCheckingStyle();
- if (fChange != null &&
- (conditionCheckingStyle == CreateChangeOperation.CHECK_NONE ||
- status != null && status.getSeverity() <= fCheckPassedSeverity)) {
- executeChange(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- fChangeExecuted= true;
- } else {
- pm.worked(1);
- }
- } else {
- executeChange(pm);
- fChangeExecuted= true;
- }
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally{
- pm.done();
- }
- }
-
- private void executeChange(IProgressMonitor pm) throws CoreException {
- Assert.isNotNull(fChangeContext);
- IRewriteTarget[] targets= null;
- try {
- targets= getRewriteTargets();
- beginCompoundChange(targets);
- // Since we have done precondition checking this check should be fast. No PM.
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- fChange.aboutToPerform(fChangeContext, new NullProgressMonitor());
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- fChange.perform(fChangeContext, monitor);
- } catch (ChangeAbortException e) {
- throw new CoreException(
- new Status(
- IStatus.ERROR,
- CUIPlugin.getPluginId(), ICStatusConstants.CHANGE_ABORTED,
- RefactoringMessages.getString("PerformChangeOperation.unrecoverable_error"), e)); //$NON-NLS-1$
- }
- }
- };
- CoreModel.run(runnable, pm);
- } finally {
- fChange.performed();
- if (targets != null)
- endCompoundChange(targets);
- }
- }
-
- private boolean createChange() {
- return fCreateChangeOperation != null;
- }
-
- private static void beginCompoundChange(IRewriteTarget[] targets) {
- for (int i= 0; i < targets.length; i++) {
- targets[i].beginCompoundChange();
- }
- }
-
- private static void endCompoundChange(IRewriteTarget[] targets) {
- for (int i= 0; i < targets.length; i++) {
- targets[i].endCompoundChange();
- }
- }
-
- private static IRewriteTarget[] getRewriteTargets() {
- IEditorPart[] editors= CUIPlugin.getInstanciatedEditors();
- List result= new ArrayList(editors.length);
- for (int i= 0; i < editors.length; i++) {
- IRewriteTarget target= (IRewriteTarget)editors[i].getAdapter(IRewriteTarget.class);
- if (target != null) {
- result.add(target);
- }
- }
- return (IRewriteTarget[]) result.toArray(new IRewriteTarget[result.size()]);
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PerformRefactoringUtil.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PerformRefactoringUtil.java
deleted file mode 100644
index d56aec0ec22..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PerformRefactoringUtil.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-
-import org.eclipse.cdt.core.model.CoreModel;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-
-import org.eclipse.cdt.internal.ui.ICStatusConstants;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-
-public class PerformRefactoringUtil {
-
- //no instances
- private PerformRefactoringUtil(){
- }
-
- public static boolean performRefactoring(PerformChangeOperation op, Refactoring refactoring, IRunnableContext execContext, Shell parent) {
- ChangeContext context= new ChangeContext(new ChangeExceptionHandler(parent));
- boolean success= false;
- IUndoManager undoManager= Refactoring.getUndoManager();
- try{
- op.setChangeContext(context);
- undoManager.aboutToPerformRefactoring();
- execContext.run(false, false, op);
- if (op.changeExecuted()) {
- if (! op.getChange().isUndoable()){
- success= false;
- } else {
- undoManager.addUndo(refactoring.getName(), op.getChange().getUndoChange());
- success= true;
- }
- }
- } catch (InvocationTargetException e) {
- Throwable t= e.getTargetException();
- if (t instanceof CoreException) {
- IStatus status= ((CoreException)t).getStatus();
- if (status != null && status.getCode() == ICStatusConstants.CHANGE_ABORTED && status.getPlugin().equals(status.getPlugin())) {
- success= handleChangeAbortException(execContext, context);
- return true;
- }
- }
- handleUnexpectedException(e);
- return false;
- } catch (InterruptedException e) {
- return false;
- } finally {
- context.clearPerformedChanges();
- undoManager.refactoringPerformed(success);
- }
-
- return true;
- }
-
- private static boolean handleChangeAbortException(IRunnableContext execContext, final ChangeContext context) {
- if (!context.getTryToUndo())
- return false; // Return false since we handle an unexpected exception and we don't have any
- // idea in which state the workbench is.
-
- IRunnableWithProgress op= new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- CoreModel.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- ChangeContext undoContext= new ChangeContext(new AbortChangeExceptionHandler());
- IChange[] changes= context.getPerformedChanges();
- pm.beginTask(RefactoringMessages.getString("RefactoringWizard.undoing"), changes.length); //$NON-NLS-1$
- IProgressMonitor sub= new NullProgressMonitor();
- for (int i= changes.length - 1; i >= 0; i--) {
- IChange change= changes[i];
- pm.subTask(change.getName());
- change.getUndoChange().perform(undoContext, sub);
- pm.worked(1);
- }
- }
- }, monitor);
- } catch (ChangeAbortException e) {
- throw new InvocationTargetException(e.getThrowable());
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- };
-
- try {
- execContext.run(false, false, op);
- } catch (InvocationTargetException e) {
- handleUnexpectedException(e);
- return false;
- } catch (InterruptedException e) {
- // not possible. Operation not cancelable.
- }
-
- return true;
- }
-
- private static void handleUnexpectedException(InvocationTargetException e) {
- ExceptionHandler.handle(e, RefactoringMessages.getString("RefactoringWizard.refactoring"), RefactoringMessages.getString("RefactoringWizard.unexpected_exception_1")); //$NON-NLS-2$ //$NON-NLS-1$
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PreviewWizardPage.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PreviewWizardPage.java
deleted file mode 100644
index 40cc181d1da..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PreviewWizardPage.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.Change;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.ICompositeChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.util.ViewerPane;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.part.PageBook;
-
-/**
- * Presents the changes made by the refactoring.
- * Consists of a tree of changes and a compare viewer that shows the differences.
- */
-public class PreviewWizardPage extends RefactoringWizardPage implements IPreviewWizardPage {
- // Dummy root node if input element isn't a composite change.
- private static class DummyRootNode extends Change implements ICompositeChange {
- private IChange[] fChildren;
-
- public DummyRootNode(IChange change) {
- fChildren= new IChange[] { change };
- }
- public IChange[] getChildren() {
- return fChildren;
- }
- public String getName() {
- return null;
- }
- public Object getModifiedLanguageElement() {
- return null;
- }
- public IChange getUndoChange() {
- return null;
- }
- public void perform(ChangeContext context, IProgressMonitor pm) {
- }
- }
-
- private static class NullPreviewer implements IChangePreviewViewer {
- private Label fLabel;
- public void createControl(Composite parent) {
- fLabel= new Label(parent, SWT.CENTER | SWT.FLAT);
- fLabel.setText(RefactoringMessages.getString("PreviewWizardPage.no_preview")); //$NON-NLS-1$
- }
- public void refresh() {
- }
- public Control getControl() {
- return fLabel;
- }
- public void setInput(Object input) throws CoreException {
- }
- }
-
- private class NextChange extends Action {
- public NextChange() {
- setImageDescriptor(CompareUI.DESC_ETOOL_NEXT);
- setDisabledImageDescriptor(CompareUI.DESC_DTOOL_NEXT);
- setHoverImageDescriptor(CompareUI.DESC_CTOOL_NEXT);
- setToolTipText(RefactoringMessages.getString("PreviewWizardPage.next_Change")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.NEXT_CHANGE_ACTION);
- }
- public void run() {
- fTreeViewer.revealNext();
- }
- }
-
- private class PreviousChange extends Action {
- public PreviousChange() {
- setImageDescriptor(CompareUI.DESC_ETOOL_PREV);
- setDisabledImageDescriptor(CompareUI.DESC_DTOOL_PREV);
- setHoverImageDescriptor(CompareUI.DESC_CTOOL_PREV);
- setToolTipText(RefactoringMessages.getString("PreviewWizardPage.previous_Change")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.PREVIOUS_CHANGE_ACTION);
- }
- public void run() {
- fTreeViewer.revealPrevious();
- }
- }
-
- private IChange fChange;
- private ChangeElement fCurrentSelection;
- private PageBook fPageContainer;
- private Control fStandardPage;
- private Control fNullPage;
- private ChangeElementTreeViewer fTreeViewer;
-//////
-// private PageBook fPreviewContainer;
-// private ChangePreviewViewerDescriptor fCurrentDescriptor;
-// private IChangePreviewViewer fCurrentPreviewViewer;
-// private IChangePreviewViewer fNullPreviewer;
-//////
- public PreviewWizardPage() {
- super(PAGE_NAME);
- setDescription(RefactoringMessages.getString("PreviewWizardPage.description")); //$NON-NLS-1$
- }
-
- public void setChange(IChange change) {
- if (fChange == change)
- return;
-
- fChange= change;
- setTreeViewerInput();
- }
-
- protected ChangeElementTreeViewer createTreeViewer(Composite parent) {
- return new ChangeElementTreeViewer(parent);
- }
-
- protected ITreeContentProvider createTreeContentProvider() {
- return new ChangeElementContentProvider();
- }
-
- protected ILabelProvider createTreeLabelProvider() {
- return new ChangeElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT | CElementLabelProvider.SHOW_SMALL_ICONS);
- }
-
- protected boolean performFinish() {
- return getRefactoringWizard().performFinish(new PerformChangeOperation(fChange));
- }
-
- public boolean canFlipToNextPage() {
- return false;
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- fPageContainer= new PageBook(parent, SWT.NONE);
- fStandardPage= createStandardPreviewPage(fPageContainer);
- fNullPage= createNullPage(fPageContainer);
- setControl(fPageContainer);
- WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.REFACTORING_PREVIEW_WIZARD_PAGE);
- }
-
- private Composite createStandardPreviewPage(Composite parent) {
- // XXX The composite is needed to limit the width of the SashForm. See http://bugs.eclipse.org/bugs/show_bug.cgi?id=6854
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0; layout.marginWidth= 0;
- result.setLayout(layout);
-
- SashForm sashForm= new SashForm(result, SWT.HORIZONTAL);
-
- ViewerPane pane= new ViewerPane(sashForm, SWT.BORDER | SWT.FLAT);
- pane.setText(RefactoringMessages.getString("PreviewWizardPage.changes")); //$NON-NLS-1$
- ToolBarManager tbm= pane.getToolBarManager();
- tbm.add(new NextChange());
- tbm.add(new PreviousChange());
- tbm.update(true);
-
- fTreeViewer= createTreeViewer(pane);
- fTreeViewer.setContentProvider(createTreeContentProvider());
- fTreeViewer.setLabelProvider(createTreeLabelProvider());
- fTreeViewer.addSelectionChangedListener(createSelectionChangedListener());
- fTreeViewer.addCheckStateListener(createCheckStateListener());
- pane.setContent(fTreeViewer.getControl());
- setTreeViewerInput();
-////////
-// fPreviewContainer= new PageBook(sashForm, SWT.NONE);
-// fNullPreviewer= new NullPreviewer();
-// fNullPreviewer.createControl(fPreviewContainer);
-// fPreviewContainer.showPage(fNullPreviewer.getControl());
-// fCurrentPreviewViewer= fNullPreviewer;
-// fCurrentDescriptor= null;
-// sashForm.setWeights(new int[]{33, 67});
-////////
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= convertWidthInCharsToPixels(80);
- sashForm.setLayoutData(gd);
- Dialog.applyDialogFont(result);
- return result;
- }
-
- private Control createNullPage(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- result.setLayout(layout);
- Label label= new Label(result, SWT.CENTER);
- label.setText(RefactoringMessages.getString("PreviewWizardPage.no_source_code_change")); //$NON-NLS-1$
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Dialog.applyDialogFont(result);
- return result;
- }
-
- public void setVisible(boolean visible) {
- fCurrentSelection= null;
- if (hasChanges()) {
- fPageContainer.showPage(fStandardPage);
- ChangeElement treeViewerInput= (ChangeElement)fTreeViewer.getInput();
- if (visible && treeViewerInput != null) {
- IStructuredSelection selection= (IStructuredSelection)fTreeViewer.getSelection();
- if (selection.isEmpty()) {
- ITreeContentProvider provider= (ITreeContentProvider)fTreeViewer.getContentProvider();
- Object[] elements= provider.getElements(treeViewerInput);
- if (elements != null && elements.length > 0) {
- Object element= elements[0];
- if (getRefactoringWizard().getExpandFirstNode()) {
- Object[] subElements= provider.getElements(element);
- if (subElements != null && subElements.length > 0) {
- fTreeViewer.expandToLevel(element, 999);
- }
- }
- fTreeViewer.setSelection(new StructuredSelection(element));
- }
- }
- }
- super.setVisible(visible);
- fTreeViewer.getControl().setFocus();
- } else {
- fPageContainer.showPage(fNullPage);
- super.setVisible(visible);
- }
- getRefactoringWizard().setPreviewShown(visible);
- }
-
- private void setTreeViewerInput() {
- ChangeElement input;
- IChange change= computeChangeInput();
- if (change == null) {
- input= null;
- } else if (change instanceof ICompositeChange && !(change instanceof TextChange)) {
- input= new DefaultChangeElement(null, change);
- } else {
- input= new DefaultChangeElement(null, new DummyRootNode(change));
- }
- if (fTreeViewer != null) {
- fTreeViewer.setInput(input);
- }
- }
-
- private IChange computeChangeInput() {
- IChange result= fChange;
- if (result == null)
- return result;
- while (true) {
- if (result instanceof ICompositeChange) {
- IChange[] children= ((ICompositeChange)result).getChildren();
- if (children.length == 1) {
- result= children[0];
- } else {
- return result;
- }
- } else {
- return result;
- }
- }
- }
-
- private ICheckStateListener createCheckStateListener() {
- return new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event){
- ChangeElement element= (ChangeElement)event.getElement();
- if (isChild(fCurrentSelection, element) || isChild(element, fCurrentSelection)) {
- showPreview(fCurrentSelection);
- }
- }
- private boolean isChild(ChangeElement element, ChangeElement child) {
- while (child != null) {
- if (child == element)
- return true;
- child= child.getParent();
- }
- return false;
- }
- };
- }
-
- private ISelectionChangedListener createSelectionChangedListener() {
- return new ISelectionChangedListener(){
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel= (IStructuredSelection) event.getSelection();
- if (sel.size() == 1) {
- ChangeElement newSelection= (ChangeElement)sel.getFirstElement();
- if (newSelection != fCurrentSelection) {
- fCurrentSelection= newSelection;
- showPreview(newSelection);
- }
- } else {
- showPreview(null);
- }
- }
- };
- }
-
- private void showPreview(ChangeElement element) {
-/////////////
-// try {
-// if (element == null) {
- showNullPreviewer();
-// } else {
-// ChangePreviewViewerDescriptor descriptor= element.getChangePreviewViewer();
-// if (fCurrentDescriptor != descriptor) {
-// IChangePreviewViewer newViewer;
-// if (descriptor != null) {
-// newViewer= descriptor.createViewer();
-// newViewer.createControl(fPreviewContainer);
-// } else {
-// newViewer= fNullPreviewer;
-// }
-// fCurrentDescriptor= descriptor;
-// element.feedInput(newViewer);
-// if (fCurrentPreviewViewer != null && fCurrentPreviewViewer != fNullPreviewer)
-// fCurrentPreviewViewer.getControl().dispose();
-// fCurrentPreviewViewer= newViewer;
-// fPreviewContainer.showPage(fCurrentPreviewViewer.getControl());
-// } else {
-// element.feedInput(fCurrentPreviewViewer);
-// }
-// }
-// } catch (CoreException e) {
-// showNullPreviewer();
-// }
-///////////
- }
-
- private void showNullPreviewer() {
-/////////
-// fCurrentDescriptor= null;
-// fCurrentPreviewViewer= fNullPreviewer;
-// fPreviewContainer.showPage(fCurrentPreviewViewer.getControl());
-/////////
- }
-
- public boolean hasChanges() {
- if (fChange == null)
- return false;
- if (fChange instanceof ICompositeChange)
- return ((ICompositeChange)fChange).getChildren().length > 0;
- return true;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PseudoCChangeElement.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PseudoCChangeElement.java
deleted file mode 100644
index 4cb417cbf02..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/PseudoCChangeElement.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange.EditChange;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.Assert;
-
-/* package */ class PseudoCChangeElement extends ChangeElement {
-
- private ICElement fCElement;
- private List fChildren;
-
- public PseudoCChangeElement(ChangeElement parent, ICElement element) {
- super(parent);
- fCElement= element;
- Assert.isNotNull(fCElement);
- }
-
- /**
- * Returns the C element.
- *
- * @return the C element managed by this node
- */
- public ICElement getCElement() {
- return fCElement;
- }
-
- /* (non-Cdoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.ChangeElement#getChangePreviewViewer()
- */
-// public ChangePreviewViewerDescriptor getChangePreviewViewer() throws CoreException {
-// DefaultChangeElement element= getStandardChangeElement();
-// if (element == null)
-// return null;
-// return element.getChangePreviewViewer();
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.ChangeElement#feedInput(org.eclipse.jdt.internal.ui.refactoring.IChangePreviewViewer)
- */
- public void feedInput(IChangePreviewViewer viewer) throws CoreException {
- DefaultChangeElement element= getStandardChangeElement();
- if (element != null) {
- IChange change= element.getChange();
- if (change instanceof TextChange) {
- List edits= collectTextEditChanges();
- viewer.setInput(TextChangePreviewViewer.createInput(
- (EditChange[])edits.toArray(new EditChange[edits.size()]),
- getTextRange()));
- }
- } else {
- viewer.setInput(null);
- }
- }
-
- /* non Java-doc
- * @see ChangeElement#setActive
- */
- public void setActive(boolean active) {
- for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
- ChangeElement element= (ChangeElement)iter.next();
- element.setActive(active);
- }
- }
-
- /* non Java-doc
- * @see ChangeElement.getActive
- */
- public int getActive() {
- Assert.isTrue(fChildren.size() > 0);
- int result= ((ChangeElement)fChildren.get(0)).getActive();
- for (int i= 1; i < fChildren.size(); i++) {
- ChangeElement element= (ChangeElement)fChildren.get(i);
- result= ACTIVATION_TABLE[element.getActive()][result];
- if (result == PARTLY_ACTIVE)
- break;
- }
- return result;
- }
-
- /* non Java-doc
- * @see ChangeElement.getChildren
- */
- public ChangeElement[] getChildren() {
- if (fChildren == null)
- return EMPTY_CHILDREN;
- return (ChangeElement[]) fChildren.toArray(new ChangeElement[fChildren.size()]);
- }
-
- /**
- * Adds the given TextEditChangeElement
as a child to this
- *
PseudoCChangeElement
- *
- * @param child the child to be added
- */
- public void addChild(TextEditChangeElement child) {
- doAddChild(child);
- }
-
- /**
- * Adds the given PseudoCChangeElement
as a child to this
- *
PseudoCChangeElement
- *
- * @param child the child to be added
- */
- public void addChild(PseudoCChangeElement child) {
- doAddChild(child);
- }
-
- private void doAddChild(ChangeElement child) {
- if (fChildren == null)
- fChildren= new ArrayList(2);
- fChildren.add(child);
- }
-
- private DefaultChangeElement getStandardChangeElement() {
- ChangeElement element= getParent();
- while(!(element instanceof DefaultChangeElement) && element != null) {
- element= element.getParent();
- }
- return (DefaultChangeElement)element;
- }
-
- private List collectTextEditChanges() {
- List result= new ArrayList(10);
- ChangeElement[] children= getChildren();
- for (int i= 0; i < children.length; i++) {
- ChangeElement child= children[i];
- if (child instanceof TextEditChangeElement) {
- result.add(((TextEditChangeElement)child).getTextEditChange());
- } else if (child instanceof PseudoCChangeElement) {
- result.addAll(((PseudoCChangeElement)child).collectTextEditChanges());
- }
- }
- return result;
- }
-
- public IRegion getTextRange() throws CoreException {
- ISourceRange range= ((ISourceReference)fCElement).getSourceRange();
- return new Region(range.getStartPos(), range.getLength());
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringErrorDialogUtil.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringErrorDialogUtil.java
deleted file mode 100644
index ce8e27ce3f6..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringErrorDialogUtil.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringStatusContentProvider;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringStatusEntryLabelProvider;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatusCodes;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatusEntry;
-
-public class RefactoringErrorDialogUtil {
-
- private RefactoringErrorDialogUtil() {
- // no instance.
- }
-
- public static Object open(String dialogTitle, RefactoringStatus status, Shell parentShell) {
- if (status.getEntries().size() == 1) {
- RefactoringStatusEntry entry= (RefactoringStatusEntry)status.getEntries().get(0);
- String message= status.getFirstMessage(RefactoringStatus.FATAL);
-
- if ( entry.getCode() != RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD
- && entry.getCode() != RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE){
- MessageDialog.openInformation(parentShell, dialogTitle, message);
- return null;
- }
- message= message + RefactoringMessages.getString("RefactoringErrorDialogUtil.okToPerformQuestion"); //$NON-NLS-1$
- if (MessageDialog.openQuestion(parentShell, dialogTitle, message))
- return entry.getData();
- return null;
- } else {
- openListDialog(dialogTitle, status, parentShell);
- return null;
- }
- }
-
- private static void openListDialog(String dialogTitle, RefactoringStatus status, Shell parentShell) {
- ListDialog dialog= new ListDialog(parentShell);
- dialog.setInput(status);
- dialog.setTitle(dialogTitle);
- dialog.setMessage(RefactoringMessages.getString("RefactoringErrorDialogUtil.cannot_perform")); //$NON-NLS-1$
- dialog.setContentProvider(new RefactoringStatusContentProvider());
- dialog.setLabelProvider(new RefactoringStatusEntryLabelProvider());
- dialog.open();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java
deleted file mode 100644
index 875d58a0dcf..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IRewriteTarget;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-
-import org.eclipse.ui.IEditorPart;
-
-import org.eclipse.cdt.core.model.CoreModel;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.IRefactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.refactoring.AbortChangeExceptionHandler;
-import org.eclipse.cdt.internal.ui.refactoring.ChangeExceptionHandler;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-
-/**
- * A helper class to execute a refactoring. The class takes care of pushing the
- * undo change onto the undo stack and folding editor edits into one editor
- * undo object.
- */
-public class RefactoringExecutionHelper {
-
- private final IRefactoring fRefactoring;
- private final Shell fParent;
- private final IRunnableContext fExecContext;
- private final int fStopSeverity;
- private final boolean fNeedsSavedEditors;
- private ChangeContext fContext;
-
- private class Operation implements IRunnableWithProgress {
- public IChange fChange;
- public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
- try {
- pm.beginTask("", 10); //$NON-NLS-1$
- pm.subTask(""); //$NON-NLS-1$
- RefactoringStatus status= fRefactoring.checkPreconditions(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- if (status.getSeverity() >= fStopSeverity) {
- RefactoringStatusDialog dialog= new RefactoringStatusDialog(fParent, status, fRefactoring.getName(), false);
- if(dialog.open() == IDialogConstants.CANCEL_ID) {
- throw new InterruptedException();
- }
- }
- fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- try {
- fChange.aboutToPerform(fContext, new NullProgressMonitor());
- CoreModel.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- fChange.perform(fContext, monitor);
- }
- }, new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- } finally {
- fChange.performed();
- }
- } catch (ChangeAbortException e) {
- throw new InvocationTargetException(e);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- pm.done();
- }
- }
- public boolean isExecuted() {
- return fChange != null;
- }
- public boolean isUndoable() {
- return fChange.isUndoable();
- }
- public IChange getUndoChange() {
- return fChange.getUndoChange();
- }
- }
-
- public RefactoringExecutionHelper(IRefactoring refactoring, int stopSevertity, boolean needsSavedEditors, Shell parent, IRunnableContext context) {
- super();
- Assert.isNotNull(refactoring);
- Assert.isNotNull(parent);
- Assert.isNotNull(context);
- fRefactoring= refactoring;
- fStopSeverity= stopSevertity;
- fParent= parent;
- fExecContext= context;
- fNeedsSavedEditors= needsSavedEditors;
- }
-
- public void perform() throws InterruptedException, InvocationTargetException {
- RefactoringSaveHelper saveHelper= new RefactoringSaveHelper();
- if (fNeedsSavedEditors && !saveHelper.saveEditors(fParent))
- throw new InterruptedException();
- fContext= new ChangeContext(new ChangeExceptionHandler(fParent));
- boolean success= false;
- IUndoManager undoManager= Refactoring.getUndoManager();
- Operation op= new Operation();
- IRewriteTarget[] targets= null;
- try{
- targets= getRewriteTargets();
- beginCompoundChange(targets);
- undoManager.aboutToPerformRefactoring();
- fExecContext.run(false, false, op);
- if (op.isExecuted()) {
- if (!op.isUndoable()) {
- success= false;
- } else {
- undoManager.addUndo(fRefactoring.getName(), op.getUndoChange());
- success= true;
- }
- }
- } catch (InvocationTargetException e) {
- Throwable t= e.getTargetException();
- if (t instanceof ChangeAbortException) {
- handleChangeAbortException((ChangeAbortException)t);
- } else {
- throw e;
- }
- } finally {
- fContext.clearPerformedChanges();
- undoManager.refactoringPerformed(success);
- saveHelper.triggerBuild();
- if (targets != null)
- endCompoundChange(targets);
- }
- }
-
- private void handleChangeAbortException(ChangeAbortException exception) {
- if (!fContext.getTryToUndo())
- return;
-
- IRunnableWithProgress op= new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- CoreModel.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- ChangeContext undoContext= new ChangeContext(new AbortChangeExceptionHandler());
- IChange[] changes= fContext.getPerformedChanges();
- pm.beginTask(RefactoringMessages.getString("RefactoringWizard.undoing"), changes.length); //$NON-NLS-1$
- IProgressMonitor sub= new NullProgressMonitor();
- for (int i= changes.length - 1; i >= 0; i--) {
- IChange change= changes[i];
- pm.subTask(change.getName());
- change.getUndoChange().perform(undoContext, sub);
- pm.worked(1);
- }
- }
- }, monitor);
- } catch (ChangeAbortException e) {
- throw new InvocationTargetException(e.getThrowable());
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- };
-
- try {
- fExecContext.run(false, false, op);
- } catch (InvocationTargetException e) {
- handleUnexpectedException(e);
- } catch (InterruptedException e) {
- // not possible. Operation not cancelable.
- }
- }
-
- private void handleUnexpectedException(InvocationTargetException e) {
- ExceptionHandler.handle(e, RefactoringMessages.getString("RefactoringWizard.refactoring"), RefactoringMessages.getString("RefactoringWizard.unexpected_exception_1")); //$NON-NLS-2$ //$NON-NLS-1$
- }
-
- private static void beginCompoundChange(IRewriteTarget[] targets) {
- for (int i= 0; i < targets.length; i++) {
- targets[i].beginCompoundChange();
- }
- }
-
- private static void endCompoundChange(IRewriteTarget[] targets) {
- for (int i= 0; i < targets.length; i++) {
- targets[i].endCompoundChange();
- }
- }
-
- private static IRewriteTarget[] getRewriteTargets() {
- IEditorPart[] editors= CUIPlugin.getInstanciatedEditors();
- List result= new ArrayList(editors.length);
- for (int i= 0; i < editors.length; i++) {
- IRewriteTarget target= (IRewriteTarget)editors[i].getAdapter(IRewriteTarget.class);
- if (target != null) {
- result.add(target);
- }
- }
- return (IRewriteTarget[]) result.toArray(new IRewriteTarget[result.size()]);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringMessages.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringMessages.java
deleted file mode 100644
index 99a7dcd5694..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringMessages.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class RefactoringMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.ui.refactoring.refactoringui";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private RefactoringMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String[] getStrings(String keys[]) {
- String[] result= new String[keys.length];
- for (int i= 0; i < keys.length; i++) {
- result[i]= getString(keys[i]);
- }
- return result;
- }
-
- public static String getFormattedString(String key, Object arg) {
- return getFormattedString(key, new Object[] { arg });
- }
-
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringPreferences.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringPreferences.java
deleted file mode 100644
index 330009e63b4..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringPreferences.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.cdt.ui.PreferenceConstants;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-public class RefactoringPreferences {
-
- public static final String PREF_ERROR_PAGE_SEVERITY_THRESHOLD= PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD;
- public static final String PREF_SAVE_ALL_EDITORS= PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS;
-
- public static int getCheckPassedSeverity() {
- String value= CUIPlugin.getDefault().getPreferenceStore().getString(PREF_ERROR_PAGE_SEVERITY_THRESHOLD);
- try {
- return Integer.valueOf(value).intValue() - 1;
- } catch (NumberFormatException e) {
- return RefactoringStatus.ERROR;
- }
- }
-
- public static int getStopSeverity() {
- switch (getCheckPassedSeverity()) {
- case RefactoringStatus.OK:
- return RefactoringStatus.INFO;
- case RefactoringStatus.INFO:
- return RefactoringStatus.WARNING;
- case RefactoringStatus.WARNING:
- return RefactoringStatus.ERROR;
- }
- return RefactoringStatus.FATAL;
- }
-
- public static boolean getSaveAllEditors() {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(PREF_SAVE_ALL_EDITORS);
- }
-
- public static void setSaveAllEditors(boolean save) {
- IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
- store.setValue(RefactoringPreferences.PREF_SAVE_ALL_EDITORS, save);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java
deleted file mode 100644
index 8efa0726057..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.util.Arrays;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.actions.GlobalBuildAction;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.refactoring.ListDialog;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
-
-public class RefactoringSaveHelper {
-
- private boolean fFilesSaved;
-
- public RefactoringSaveHelper() {
- super();
- }
-
- public boolean saveEditors(Shell shell) {
- IEditorPart[] dirtyEditors= CUIPlugin.getDirtyEditors();
- if (dirtyEditors.length == 0)
- return true;
- if (! saveAllDirtyEditors(shell))
- return false;
- try {
- // Save isn't cancelable.
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IWorkspaceDescription description= workspace.getDescription();
- boolean autoBuild= description.isAutoBuilding();
- description.setAutoBuilding(false);
- workspace.setDescription(description);
- try {
- CUIPlugin.getActiveWorkbenchWindow().getWorkbench().saveAllEditors(false);
- fFilesSaved= true;
- } finally {
- description.setAutoBuilding(autoBuild);
- workspace.setDescription(description);
- }
- return true;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, shell,
- RefactoringMessages.getString("RefactoringStarter.saving"), RefactoringMessages.getString("RefactoringStarter.unexpected_exception")); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- }
-
- public void triggerBuild() {
- if (fFilesSaved && ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
- new GlobalBuildAction(CUIPlugin.getActiveWorkbenchWindow(), IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
- }
- }
-
- private boolean saveAllDirtyEditors(Shell shell) {
- if (RefactoringPreferences.getSaveAllEditors()) //must save everything
- return true;
- ListDialog dialog= new ListDialog(shell) {
- protected Control createDialogArea(Composite parent) {
- Composite result= (Composite) super.createDialogArea(parent);
- final Button check= new Button(result, SWT.CHECK);
- check.setText(RefactoringMessages.getString("RefactoringStarter.always_save")); //$NON-NLS-1$
- check.setSelection(RefactoringPreferences.getSaveAllEditors());
- check.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- RefactoringPreferences.setSaveAllEditors(check.getSelection());
- }
- });
- applyDialogFont(result);
- return result;
- }
- };
- dialog.setTitle(RefactoringMessages.getString("RefactoringStarter.save_all_resources")); //$NON-NLS-1$
- dialog.setAddCancelButton(true);
- dialog.setLabelProvider(createDialogLabelProvider());
- dialog.setMessage(RefactoringMessages.getString("RefactoringStarter.must_save")); //$NON-NLS-1$
- dialog.setContentProvider(new ListContentProvider());
- dialog.setInput(Arrays.asList(CUIPlugin.getDirtyEditors()));
- return dialog.open() == Window.OK;
- }
-
- private ILabelProvider createDialogLabelProvider() {
- return new LabelProvider() {
- public Image getImage(Object element) {
- return ((IEditorPart) element).getTitleImage();
- }
- public String getText(Object element) {
- return ((IEditorPart) element).getTitle();
- }
- };
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java
deleted file mode 100644
index 86c3515dc69..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.cdt.core.model.CModelException;
-
-import org.eclipse.cdt.internal.ui.refactoring.CheckConditionsOperation;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringWizard;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringWizardDialog;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringWizardDialog2;
-import org.eclipse.cdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-/**
- * A helper class to activate the UI of a refactoring
- */
-public class RefactoringStarter {
-
- private RefactoringSaveHelper fSaveHelper= new RefactoringSaveHelper();
-
- public Object activate(Refactoring refactoring, RefactoringWizard wizard, Shell parent, String dialogTitle, boolean mustSaveEditors) throws CModelException {
- if (! canActivate(mustSaveEditors, parent))
- return null;
- RefactoringStatus activationStatus= checkActivation(refactoring);
- if (activationStatus.hasFatalError()){
- return RefactoringErrorDialogUtil.open(dialogTitle, activationStatus, parent);
- } else {
- wizard.setActivationStatus(activationStatus);
- Dialog dialog;
- if (wizard.hasMultiPageUserInput()){
- dialog= new RefactoringWizardDialog(parent, wizard);
- }
- else {
- dialog= new RefactoringWizardDialog2(parent, wizard);
- }
- if (dialog.open() == Window.CANCEL)
- fSaveHelper.triggerBuild();
- return null;
- }
- }
-
- private RefactoringStatus checkActivation(Refactoring refactoring){
- try {
- CheckConditionsOperation cco= new CheckConditionsOperation(refactoring, CheckConditionsOperation.ACTIVATION);
- IRunnableContext context= new BusyIndicatorRunnableContext();
- context.run(false, false, cco);
- return cco.getStatus();
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, "Error", RefactoringMessages.getString("RefactoringStarter.unexpected_exception"));//$NON-NLS-1$ //$NON-NLS-2$
- return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RefactoringStarter.unexpected_exception"));//$NON-NLS-1$
- } catch (InterruptedException e) {
- Assert.isTrue(false);
- return null;
- }
- }
-
- private boolean canActivate(boolean mustSaveEditors, Shell shell) {
- return ! mustSaveEditors || fSaveHelper.saveEditors(shell);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusContentProvider.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusContentProvider.java
deleted file mode 100644
index fd5f21633db..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusContentProvider.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-public class RefactoringStatusContentProvider implements IStructuredContentProvider{
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object obj) {
- return ((RefactoringStatus)obj).getEntries().toArray();
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusDialog.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusDialog.java
deleted file mode 100644
index 602bb8a6059..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusDialog.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-class RefactoringStatusDialog extends Dialog {
-
- private RefactoringStatus fStatus;
- private String fWindowTitle;
- private boolean fBackButton;
-
- public RefactoringStatusDialog(Shell parent, RefactoringStatus status, String windowTitle, boolean backButton) {
- super(parent);
- fStatus= status;
- fWindowTitle= windowTitle;
- fBackButton= backButton;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- public RefactoringStatusDialog(Shell parent, ErrorWizardPage page, boolean backButton) {
- this(parent, page.getStatus(), parent.getText(), backButton);
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(fWindowTitle);
- }
- protected Control createDialogArea(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- initializeDialogUnits(result);
- GridLayout layout= new GridLayout();
- result.setLayout(layout);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.widthHint= 600;
- gd.heightHint= 400;
- result.setLayoutData(gd);
- Color background= parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- ViewForm messagePane= new ViewForm(result, SWT.BORDER | SWT.FLAT);
- messagePane.marginWidth= layout.marginWidth;
- messagePane.marginHeight= layout.marginHeight;
- gd= new GridData(GridData.FILL_HORIZONTAL);
- // XXX http://bugs.eclipse.org/bugs/show_bug.cgi?id=27572
- Rectangle rect= messagePane.computeTrim(0, 0, 0, convertHeightInCharsToPixels(2) + messagePane.marginHeight * 2);
- gd.heightHint= rect.height;
- messagePane.setLayoutData(gd);
- messagePane.setBackground(background);
- Label label= new Label(messagePane, SWT.LEFT | SWT.WRAP);
- if (fStatus.hasFatalError())
- label.setText(RefactoringMessages.getString("RefactoringStatusDialog.Cannot_proceed")); //$NON-NLS-1$
- else
- label.setText(RefactoringMessages.getString("RefactoringStatusDialog.Please_look")); //$NON-NLS-1$
- label.setBackground(background);
- messagePane.setContent(label);
- RefactoringStatusViewer viewer= new RefactoringStatusViewer(result, SWT.NONE);
- viewer.setLayoutData(new GridData(GridData.FILL_BOTH));
- viewer.setStatus(fStatus);
- applyDialogFont(result);
- return result;
- }
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.BACK_ID) {
- setReturnCode(IDialogConstants.BACK_ID);
- close();
- } else {
- super.buttonPressed(buttonId);
- }
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- if (!fStatus.hasFatalError()) {
- if (fBackButton)
- createButton(parent, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false); //$NON-NLS-1$
- createButton(parent, IDialogConstants.OK_ID, RefactoringMessages.getString("RefactoringStatusDialog.Continue"), true); //$NON-NLS-1$
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- } else {
- if (fBackButton)
- createButton(parent, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, true); //$NON-NLS-1$
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusEntryLabelProvider.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusEntryLabelProvider.java
deleted file mode 100644
index 7b958b23ff1..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusEntryLabelProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatusEntry;
-import org.eclipse.cdt.internal.ui.util.Strings;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-
-public class RefactoringStatusEntryLabelProvider extends LabelProvider{
- public String getText(Object element){
- return Strings.removeNewLine(((RefactoringStatusEntry)element).getMessage());
- }
- public Image getImage(Object element){
- RefactoringStatusEntry entry= (RefactoringStatusEntry)element;
- if (entry.isFatalError())
- return CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_FATAL);
- else if (entry.isError())
- return CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_ERROR);
- else if (entry.isWarning())
- return CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
- else
- return CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_INFO);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusViewer.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusViewer.java
deleted file mode 100644
index cb61dc7ca86..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringStatusViewer.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.util.List;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.Context;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatusEntry;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.util.PixelConverter;
-import org.eclipse.cdt.internal.ui.util.ViewerPane;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.part.PageBook;
-
-class RefactoringStatusViewer extends SashForm {
-
- private static class NullContextViewer implements IStatusContextViewer {
- private Label fLabel;
- public NullContextViewer() {
- }
- public void createControl(Composite parent) {
- fLabel= new Label(parent, SWT.CENTER | SWT.FLAT);
- fLabel.setText(RefactoringMessages.getString("ErrorWizardPage.no_context_information_available")); //$NON-NLS-1$
- }
- public void setInput(Context input) {
- // do nothing
- }
- public Control getControl() {
- return fLabel;
- }
- }
-
- private class NextProblem extends Action {
- public NextProblem() {
- setImageDescriptor(CompareUI.DESC_ETOOL_NEXT);
- setDisabledImageDescriptor(CompareUI.DESC_DTOOL_NEXT);
- setHoverImageDescriptor(CompareUI.DESC_CTOOL_NEXT);
- setToolTipText(RefactoringMessages.getString("ErrorWizardPage.next_Change")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.NEXT_PROBLEM_ACTION);
- }
- public void run() {
- revealElement(true);
- }
- public void update() {
- boolean enabled= false;
- List entries= null;
- if (fStatus != null && !(entries= fStatus.getEntries()).isEmpty()) {
- int index= fTableViewer.getTable().getSelectionIndex();
- enabled= index == -1 || index < entries.size() - 1;
- }
- setEnabled(enabled);
- }
- }
-
- private class PreviousProblem extends Action {
- public PreviousProblem() {
- setImageDescriptor(CompareUI.DESC_ETOOL_PREV);
- setDisabledImageDescriptor(CompareUI.DESC_DTOOL_PREV);
- setHoverImageDescriptor(CompareUI.DESC_CTOOL_PREV);
- setToolTipText(RefactoringMessages.getString("ErrorWizardPage.previous_Change")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.PREVIOUS_PROBLEM_ACTION);
- }
- public void run() {
- revealElement(false);
- }
- public void update() {
- boolean enabled= false;
- if (fStatus != null && !fStatus.getEntries().isEmpty()) {
- int index= fTableViewer.getTable().getSelectionIndex();
- enabled= index == -1 || index > 0;
- }
- setEnabled(enabled);
- }
- }
-
- private static class RefactoringStatusSorter extends ViewerSorter {
- public int compare(Viewer viewer, Object e1, Object e2) {
- int r1= ((RefactoringStatusEntry)e1).getSeverity();
- int r2= ((RefactoringStatusEntry)e2).getSeverity();
- if (r1 < r2)
- return 1;
- if (r2 < r1)
- return -1;
- return 0;
- }
-
- }
-
- private RefactoringStatus fStatus;
- private TableViewer fTableViewer;
- private PageBook fContextViewerContainer;
- private ViewerPane fContextViewerPane;
- private Image fPaneImage;
- private StatusContextViewerDescriptor fCurrentDescriptor;
- private IStatusContextViewer fCurrentContextViewer;
- private NullContextViewer fNullContextViewer;
-
- private NextProblem fNextProblem;
- private PreviousProblem fPreviousProblem;
-
- public RefactoringStatusViewer(Composite parent, int style) {
- super(parent, style | SWT.VERTICAL);
- createContents();
- }
-
- /**
- * Sets the refactoring status.
- * @param the refactoring status.
- */
- public void setStatus(RefactoringStatus status){
- fStatus= status;
- if (fTableViewer.getInput() != fStatus) {
- fTableViewer.setInput(fStatus);
- fTableViewer.getTable().getColumn(0).pack();
- ISelection selection= fTableViewer.getSelection();
- if (selection.isEmpty()) {
- RefactoringStatusEntry entry= getFirstEntry();
- if (entry != null) {
- fTableViewer.setSelection(new StructuredSelection(entry));
- showContextViewer(entry);
- fTableViewer.getControl().setFocus();
- }
- }
- fNextProblem.update();
- fPreviousProblem.update();
- }
- }
-
- /**
- * Returns the currently used RefactoringStatus.
- * @return the RefactoringStatus
- */
- public RefactoringStatus getStatus() {
- return fStatus;
- }
-
- //---- UI creation ----------------------------------------------------------------------
-
- public Point computeSize (int wHint, int hHint, boolean changed) {
- PixelConverter converter= new PixelConverter(this);
- return new Point(converter.convertWidthInCharsToPixels(90), converter.convertHeightInCharsToPixels(25));
- }
-
- private void createContents() {
- GridLayout layout= new GridLayout();
- layout.numColumns= 1; layout.marginWidth= 0; layout.marginHeight= 0;
- setLayout(layout);
-
- ViewerPane contextPane= new ViewerPane(this, SWT.BORDER | SWT.FLAT);
- contextPane.setText(RefactoringMessages.getString("RefactoringStatusViewer.Found_problems")); //$NON-NLS-1$
- ToolBarManager tbm= contextPane.getToolBarManager();
- tbm.add(fNextProblem= new NextProblem());
- tbm.add(fPreviousProblem= new PreviousProblem());
- tbm.update(true);
- createTableViewer(contextPane);
- contextPane.setContent(fTableViewer.getControl());
-
- fContextViewerPane= new ViewerPane(this, SWT.BORDER | SWT.FLAT);
- fContextViewerContainer= new PageBook(fContextViewerPane, SWT.NONE);
- fNullContextViewer= new NullContextViewer();
- fNullContextViewer.createControl(fContextViewerContainer);
- fContextViewerContainer.showPage(fNullContextViewer.getControl());
- fCurrentContextViewer= fNullContextViewer;
- fContextViewerPane.setContent(fContextViewerContainer);
- fCurrentContextViewer= fNullContextViewer;
- fCurrentDescriptor= null;
-
- setWeights(new int[]{35, 65});
-
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (fPaneImage != null) {
- fPaneImage.dispose();
- fPaneImage= null;
- }
- }
- });
- }
-
- private void createTableViewer(Composite parent) {
- fTableViewer= new TableViewer(new Table(parent, SWT.SINGLE | SWT.H_SCROLL));
- fTableViewer.setLabelProvider(new RefactoringStatusEntryLabelProvider());
- fTableViewer.setContentProvider(new RefactoringStatusContentProvider());
- fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- entrySelected(event.getSelection());
- fNextProblem.update();
- fPreviousProblem.update();
- }
- });
- fTableViewer.setSorter(new RefactoringStatusSorter());
- Table tableControl= fTableViewer.getTable();
- GridData gd= new GridData(GridData.FILL_BOTH);
- tableControl.setLayoutData(gd);
- // Add a column so that we can pack it in setVisible.
- TableColumn tc= new TableColumn(tableControl, SWT.NONE);
- tc.setResizable(false);
- }
-
- //---- Feed status entry into context viewer ---------------------------------------------------------
-
- private void entrySelected(ISelection s) {
- if (!(s instanceof IStructuredSelection))
- return;
- Object first= ((IStructuredSelection) s).getFirstElement();
- if (! (first instanceof RefactoringStatusEntry))
- return;
-
- RefactoringStatusEntry entry= (RefactoringStatusEntry)first;
- updateTitle(entry);
- showContextViewer(entry);
- }
-
- private void updateTitle(RefactoringStatusEntry first) {
- IAdaptable element= getCorrespondingElement(first);
- String title= null;
- ImageDescriptor imageDescriptor= null;
- if (element != null) {
- IWorkbenchAdapter adapter= (IWorkbenchAdapter)element.getAdapter(IWorkbenchAdapter.class);
- if (adapter != null) {
- title= adapter.getLabel(element);
- imageDescriptor= adapter.getImageDescriptor(element);
- }
- }
- if (title == null || title.length() == 0)
- title= RefactoringMessages.getString("RefactoringStatusViewer.Problem_context"); //$NON-NLS-1$
- fContextViewerPane.setText(title);
- if (imageDescriptor != null) {
- if (fPaneImage != null) {
- fPaneImage.dispose();
- fPaneImage= null;
- }
- fPaneImage= imageDescriptor.createImage(fContextViewerPane.getDisplay());
- fContextViewerPane.setImage(fPaneImage);
- }
- }
-
- private static IAdaptable getCorrespondingElement(RefactoringStatusEntry first){
- if (first.getContext() == null)
- return null;
- else
- return first.getContext().getCorrespondingElement();
- }
-
- private void showContextViewer(RefactoringStatusEntry entry) {
-/* Context context= entry.getContext();
- if (context == null) {
- showNullContextViewer();
- } else {
- try {
- StatusContextViewerDescriptor descriptor= StatusContextViewerDescriptor.get(context);
- if (fCurrentDescriptor != descriptor) {
- IStatusContextViewer newViewer;
- if (descriptor != null) {
- newViewer= descriptor.createViewer();
- newViewer.createControl(fContextViewerContainer);
- } else {
- newViewer= fNullContextViewer;
- }
- fCurrentDescriptor= descriptor;
- newViewer.setInput(context);
- if (fCurrentContextViewer != null && fCurrentContextViewer != fNullContextViewer)
- fCurrentContextViewer.getControl().dispose();
- fCurrentContextViewer= newViewer;
- fContextViewerContainer.showPage(fCurrentContextViewer.getControl());
- } else {
- fCurrentContextViewer.setInput(context);
- }
- } catch (CoreException e) {
- showNullContextViewer();
- }
- }
-*/ }
-
- private void showNullContextViewer() {
- fCurrentContextViewer= fNullContextViewer;
- fCurrentDescriptor= null;
- fContextViewerContainer.showPage(fCurrentContextViewer.getControl());
- }
-
- //---- Helpers ----------------------------------------------------------------------------------------
-
- private RefactoringStatusEntry getFirstEntry(){
- if (fStatus == null || fStatus.getEntries().isEmpty())
- return null;
- return (RefactoringStatusEntry)fStatus.getEntries().get(0);
- }
-
- private void revealElement(boolean next) {
- List entries= fStatus.getEntries();
- if (entries.isEmpty()) {
- return;
- }
- int index= fTableViewer.getTable().getSelectionIndex();
- int last= entries.size() - 1;
- boolean doIt= true;
- if (index == -1) {
- index= 0;
- } else if (next && index < last) {
- index++;
- } else if (!next && index > 0) {
- index--;
- } else {
- doIt= false;
- }
- if (doIt)
- fTableViewer.setSelection(new StructuredSelection(entries.get(index)));
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizard.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizard.java
deleted file mode 100644
index 7fa9f6d3f8b..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizard.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.PlatformUI;
-
-public class RefactoringWizard extends Wizard {
-
- private String fDefaultPageTitle;
- private Refactoring fRefactoring;
- private IChange fChange;
- private RefactoringStatus fActivationStatus= new RefactoringStatus();
- private RefactoringStatus fStatus;
- private boolean fHasUserInputPages;
- private boolean fExpandFirstNode;
- private boolean fIsChangeCreationCancelable;
- private boolean fPreviewReview;
- private boolean fPreviewShown;
-
- public RefactoringWizard(Refactoring refactoring) {
- this();
- Assert.isNotNull(refactoring);
- fRefactoring= refactoring;
- }
-
- public RefactoringWizard(Refactoring refactoring, String defaultPageTitle) {
- this(refactoring);
- Assert.isNotNull(defaultPageTitle);
- fDefaultPageTitle= defaultPageTitle;
- }
-
-
- /**
- * Creates a new refactoring wizard without initializing its
- * state. This constructor should only be used to create a
- * refactoring spcified via a plugin manifest file. Clients
- * that us this API must make sure that the initialize
- * method gets called.
- *
- * @see #initialize(Refactoring)
- */
- public RefactoringWizard() {
- setNeedsProgressMonitor(true);
- setChangeCreationCancelable(true);
- setWindowTitle(RefactoringMessages.getString("RefactoringWizard.title")); //$NON-NLS-1$
-// setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_REFACTOR);
- }
-
- /**
- * Initializes the refactoring with the given refactoring. This
- * method should be called right after the wizard has been created
- * using the default constructor.
- *
- * @param refactoring the refactoring this wizard is working
- * on
- * @see #RefactoringWizard()
- */
- public void initialize(Refactoring refactoring) {
- Assert.isNotNull(refactoring);
- fRefactoring= refactoring;
- }
-
- /**
- * Sets the default page title to the given value. This value is used
- * as a page title for wizard page's which don't provide their own
- * page title. Setting this value has only an effect as long as the
- * user interface hasn't been created yet.
- *
- * @param defaultPageTitle the default page title.
- * @see Wizard#setDefaultPageImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
- */
- public void setDefaultPageTitle(String defaultPageTitle) {
- fDefaultPageTitle= defaultPageTitle;
- }
-
- public void setChangeCreationCancelable(boolean isChangeCreationCancelable){
- fIsChangeCreationCancelable= isChangeCreationCancelable;
- }
-
- //---- Hooks to overide ---------------------------------------------------------------
-
- /**
- * Some refactorings do activation checking when the wizard is going to be opened.
- * They do this since activation checking is expensive and can't be performed on
- * opening a corresponding menu. Wizards that need activation checking on opening
- * should reimplement this method and should return true
. This default
- * implementation returns false
.
- *
- * @return true
if activation checking should be performed on opening;
- * otherwise
false
is returned
- */
- protected boolean checkActivationOnOpen() {
- return false;
- }
-
- /**
- * Hook to add user input pages to the wizard. This default implementation
- * adds nothing.
- */
- protected void addUserInputPages(){
- }
-
- /**
- * Hook to add the error page to the wizard. This default implementation
- * adds an ErrorWizardPage
to the wizard.
- */
- protected void addErrorPage(){
- addPage(new ErrorWizardPage());
- }
-
- /**
- * Hook to add the page the gives a prefix of the changes to be performed. This default
- * implementation adds a PreviewWizardPage
to the wizard.
- */
- protected void addPreviewPage(){
- addPage(new PreviewWizardPage());
- }
-
- /**
- * Hook to determine if the wizard has more than one user input page without
- * actually creating the pages.
- *
- * @return boolean true
if multi page user input exists.
- * Otherwise
false
is returned
- */
- public boolean hasMultiPageUserInput() {
- return false;
- }
-
- protected int getMessageLineWidthInChars() {
- return 80;
- }
-
- protected boolean hasUserInputPages() {
- return fHasUserInputPages;
- }
-
- protected boolean hasPreviewPage() {
- return true;
- }
-
- protected boolean yesNoStyle() {
- return false;
- }
-
- //---- Setter and Getters ------------------------------------------------------------
-
- /**
- * Returns the refactoring this wizard is using.
- */
- public Refactoring getRefactoring(){
- return fRefactoring;
- }
-
- /**
- * Sets the change object.
- */
- public void setChange(IChange change){
- IPreviewWizardPage page= (IPreviewWizardPage)getPage(IPreviewWizardPage.PAGE_NAME);
- if (page != null)
- page.setChange(change);
- fChange= change;
- }
-
- /**
- * Returns the current change object.
- */
- public IChange getChange() {
- return fChange;
- }
-
- /**
- * Sets the refactoring status.
- *
- * @param status the refactoring status to set.
- */
- public void setStatus(RefactoringStatus status) {
- ErrorWizardPage page= (ErrorWizardPage)getPage(ErrorWizardPage.PAGE_NAME);
- if (page != null)
- page.setStatus(status);
- fStatus= status;
- }
-
- /**
- * Returns the current refactoring status.
- */
- public RefactoringStatus getStatus() {
- return fStatus;
- }
-
- /**
- * Sets the refactoring status returned from input checking. Any previously
- * computed activation status is merged into the given status before it is set
- * to the error page.
- *
- * @param status the input status to set.
- * @see #getActivationStatus()
- */
- public void setInputStatus(RefactoringStatus status) {
- RefactoringStatus newStatus= new RefactoringStatus();
- if (fActivationStatus != null)
- newStatus.merge(fActivationStatus);
- newStatus.merge(status);
- setStatus(newStatus);
- }
-
- /**
- * Sets the refactoring status returned from activation checking.
- *
- * @param status the activation status to be set.
- */
- public void setActivationStatus(RefactoringStatus status) {
- fActivationStatus= status;
- setStatus(status);
- }
-
- /**
- * Returns the activation status computed during the start up off this
- * wizard. This methdod returns null
if no activation
- * checking has been performed during startup.
- *
- * @return the activation status computed during startup.
- */
- public RefactoringStatus getActivationStatus() {
- return fActivationStatus;
- }
-
- /**
- * Returns the default page title used for pages that don't
- * provide their own page title.
- *
- * @return the default page title.
- */
- public String getDefaultPageTitle() {
- return fDefaultPageTitle;
- }
-
- /**
- * Defines whether the frist node in the preview page is supposed to be expanded.
- *
- * @param expand true
if the first node is to be expanded. Otherwise
- * false
- */
- public void setExpandFirstNode(boolean expand) {
- fExpandFirstNode= true;
- }
-
- /**
- * Returns true
if the first node in the preview page is supposed to be
- * expanded. Otherwise false
is returned.
- *
- * @return true
if the first node in the preview page is supposed to be
- * expanded; otherwise false
- */
- public boolean getExpandFirstNode() {
- return fExpandFirstNode;
- }
-
- /**
- * Computes the wizard page that should follow the user input page. This is
- * either the error page or the proposed changes page, depending on the
- * result of the condition checking.
- *
- * @return the wizard page that should be shown after the last user input
- * page
- */
- public IWizardPage computeUserInputSuccessorPage(IWizardPage caller) {
- return computeUserInputSuccessorPage(caller, getContainer());
- }
-
- private IWizardPage computeUserInputSuccessorPage(IWizardPage caller, IRunnableContext context) {
- IChange change= createChange(CheckConditionsOperation.INPUT, RefactoringStatus.OK, true, context);
- // Status has been updated since we have passed true
- RefactoringStatus status= getStatus();
-
- // Creating the change has been canceled
- if (change == null && status == null) {
- setChange(change);
- return caller;
- }
-
- // Set change if we don't have fatal errors.
- if (!status.hasFatalError())
- setChange(change);
-
- if (status.isOK()) {
- return getPage(IPreviewWizardPage.PAGE_NAME);
- } else {
- return getPage(ErrorWizardPage.PAGE_NAME);
- }
- }
-
- /**
- * Initialize all pages with the managed page title.
- */
- private void initializeDefaultPageTitles() {
- if (fDefaultPageTitle == null)
- return;
-
- IWizardPage[] pages= getPages();
- for (int i= 0; i < pages.length; i++) {
- IWizardPage page= pages[i];
- if (page.getTitle() == null)
- page.setTitle(fDefaultPageTitle);
- }
- }
-
- /**
- * Forces the visiting of the preview page. The OK/Finish button will be
- * disabled until the user has reached the preview page.
- */
- public void setPreviewReview(boolean review) {
- fPreviewReview= review;
- getContainer().updateButtons();
- }
-
- public void setPreviewShown(boolean shown) {
- fPreviewShown= shown;
- getContainer().updateButtons();
- }
-
- public boolean canFinish() {
- if (fPreviewReview && !fPreviewShown)
- return false;
- return super.canFinish();
- }
-
-
- //---- Change management -------------------------------------------------------------
-
- /**
- * Creates a new change object for the refactoring. Method returns
- * null
if the change cannot be created.
- *
- * @param style the conditions to check before creating the change.
- * @param checkPassedSeverity the severity below which the conditions check
- * is treated as 'passed'
- * @param updateStatus if true
the wizard's status is updated
- * with the status returned from the CreateChangeOperation
.
- * if false
no status updating is performed.
- */
- IChange createChange(int style, int checkPassedSeverity, boolean updateStatus) {
- return createChange(style, checkPassedSeverity, updateStatus, getContainer());
- }
-
- private IChange createChange(int style, int checkPassedSeverity, boolean updateStatus, IRunnableContext context){
- CreateChangeOperation op= new CreateChangeOperation(fRefactoring, style);
- op.setCheckPassedSeverity(checkPassedSeverity);
-
- InvocationTargetException exception= null;
- try {
- context.run(true, fIsChangeCreationCancelable, op);
- } catch (InterruptedException e) {
- setStatus(null);
- return null;
- } catch (InvocationTargetException e) {
- exception= e;
- }
-
- if (updateStatus) {
- RefactoringStatus status= null;
- if (exception != null) {
- status= new RefactoringStatus();
- String msg= exception.getMessage();
- if (msg != null) {
- status.addFatalError(RefactoringMessages.getFormattedString("RefactoringWizard.see_log", msg)); //$NON-NLS-1$
- } else {
- status.addFatalError(RefactoringMessages.getString("RefactoringWizard.Internal_error")); //$NON-NLS-1$
- }
- CUIPlugin.getDefault().log(exception);
- } else {
- status= op.getStatus();
- }
- setStatus(status, style);
- } else {
- if (exception != null)
- ExceptionHandler.handle(exception, RefactoringMessages.getString("RefactoringWizard.refactoring"), RefactoringMessages.getString("RefactoringWizard.unexpected_exception")); //$NON-NLS-2$ //$NON-NLS-1$
- }
- IChange change= op.getChange();
- return change;
- }
-
- public boolean performFinish(PerformChangeOperation op) {
- return PerformRefactoringUtil.performRefactoring(op, fRefactoring, getContainer(), getContainer().getShell());
- }
-
- //---- Condition checking ------------------------------------------------------------
-
- public RefactoringStatus checkInput() {
- return internalCheckCondition(getContainer(), CheckConditionsOperation.INPUT);
- }
-
- /**
- * Checks the condition for the given style.
- * @param style the conditions to check.
- * @return the result of the condition check.
- * @see CheckConditionsOperation
- */
- protected RefactoringStatus internalCheckCondition(IRunnableContext context, int style) {
-
- CheckConditionsOperation op= new CheckConditionsOperation(fRefactoring, style);
-
- Exception exception= null;
- try {
- context.run(true, true, op);
- } catch (InterruptedException e) {
- exception= e;
- } catch (InvocationTargetException e) {
- exception= e;
- }
- RefactoringStatus status= null;
- if (exception != null) {
- CUIPlugin.getDefault().log(exception);
- status= new RefactoringStatus();
- status.addFatalError(RefactoringMessages.getString("RefactoringWizard.internal_error_1")); //$NON-NLS-1$
- } else {
- status= op.getStatus();
- }
- setStatus(status, style);
- return status;
- }
-
- /**
- * Sets the status according to the given style flag.
- *
- * @param status the refactoring status to set.
- * @param style a flag indicating if the status is a activation, input checking, or
- * precondition checking status.
- * @see CheckConditionsOperation
- */
- protected void setStatus(RefactoringStatus status, int style) {
- if ((style & CheckConditionsOperation.PRECONDITIONS) == CheckConditionsOperation.PRECONDITIONS)
- setStatus(status);
- else if ((style & CheckConditionsOperation.ACTIVATION) == CheckConditionsOperation.ACTIVATION)
- setActivationStatus(status);
- else if ((style & CheckConditionsOperation.INPUT) == CheckConditionsOperation.INPUT)
- setInputStatus(status);
- }
-
-
- //---- Reimplementation of Wizard methods --------------------------------------------
-
- public boolean performFinish() {
- Assert.isNotNull(fRefactoring);
-
- RefactoringWizardPage page= (RefactoringWizardPage)getContainer().getCurrentPage();
- return page.performFinish();
- }
-
- public IWizardPage getPreviousPage(IWizardPage page) {
- if (fHasUserInputPages)
- return super.getPreviousPage(page);
- if (! page.getName().equals(ErrorWizardPage.PAGE_NAME)){
- if (fStatus.isOK())
- return null;
- }
- return super.getPreviousPage(page);
- }
-
- public IWizardPage getStartingPage() {
- if (fHasUserInputPages)
- return super.getStartingPage();
- return computeUserInputSuccessorPage(null, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- }
-
- public void addPages() {
- if (checkActivationOnOpen()) {
- internalCheckCondition(new BusyIndicatorRunnableContext(), CheckConditionsOperation.ACTIVATION);
- }
- if (fActivationStatus.hasFatalError()) {
- addErrorPage();
- // Set the status since we added the error page
- setStatus(getStatus());
- } else {
- Assert.isTrue(getPageCount() == 0);
- addUserInputPages();
- if (getPageCount() > 0)
- fHasUserInputPages= true;
- addErrorPage();
- addPreviewPage();
- }
- initializeDefaultPageTitles();
- }
-
- public void addPage(IWizardPage page) {
- Assert.isTrue(page instanceof RefactoringWizardPage);
- super.addPage(page);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardDialog.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardDialog.java
deleted file mode 100644
index 6e8305e4eda..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardDialog.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardDialog;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * A dialog to host refactoring wizards.
- */
-public class RefactoringWizardDialog extends WizardDialog {
-
- private static final String DIALOG_SETTINGS= "RefactoringWizard"; //$NON-NLS-1$
- private static final String WIDTH= "width"; //$NON-NLS-1$
- private static final String HEIGHT= "height"; //$NON-NLS-1$
-
- private IDialogSettings fSettings;
-
- /*
- * note: this field must not be initialized - setter is called in the call to super
- * and java initializes fields 'after' the call to super is made. so initializing would override setting.
- */
- private boolean fMakeNextButtonDefault;
-
- /**
- * Creates a new refactoring wizard dialag with the given wizard.
- */
- public RefactoringWizardDialog(Shell parent, RefactoringWizard wizard) {
- super(parent, wizard);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- wizard.setDialogSettings(settings);
- fSettings= settings.getSection(DIALOG_SETTINGS);
- if (fSettings == null) {
- fSettings= new DialogSettings(DIALOG_SETTINGS);
- settings.addSection(fSettings);
- fSettings.put(WIDTH, 600);
- fSettings.put(HEIGHT, 400);
- }
- int width= 600;
- int height= 400;
- try {
- width= fSettings.getInt(WIDTH);
- height= fSettings.getInt(HEIGHT);
- } catch (NumberFormatException e) {
- }
- setMinimumPageSize(width, height);
- }
-
- /*
- * @see WizardDialog#finishPressed()
- */
- protected void finishPressed() {
- IWizardPage page= getCurrentPage();
- Control control= page.getControl().getParent();
- Point size = control.getSize();
- fSettings.put(WIDTH, size.x);
- fSettings.put(HEIGHT, size.y);
- super.finishPressed();
- }
-
- /*
- * @see IWizardContainer#updateButtons()
- */
- public void updateButtons() {
- super.updateButtons();
- if (! fMakeNextButtonDefault)
- return;
- if (getShell() == null)
- return;
- Button next= getButton(IDialogConstants.NEXT_ID);
- if (next.isEnabled())
- getShell().setDefaultButton(next);
- }
-
- /* usually called in the IWizard#setContainer(IWizardContainer) method
- */
- public void setMakeNextButtonDefault(boolean makeNextButtonDefault) {
- fMakeNextButtonDefault= makeNextButtonDefault;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardDialog2.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardDialog2.java
deleted file mode 100644
index 4133ab5de74..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardDialog2.java
+++ /dev/null
@@ -1,578 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.ModalContext;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-public class RefactoringWizardDialog2 extends Dialog implements IWizardContainer {
-
- private RefactoringWizard fWizard;
- private IWizardPage fCurrentPage;
- private IWizardPage fVisiblePage;
-
- private PageBook fPageContainer;
- private PageBook fStatusContainer;
- private MessageBox fMessageBox;
- private ProgressMonitorPart fProgressMonitorPart;
- private int fActiveRunningOperations;
- private Cursor fWaitCursor;
- private Cursor fArrowCursor;
-
- private static final int PREVIEW_ID= IDialogConstants.CLIENT_ID + 1;
-
- private int fPreviewWidth;
- private int fPreviewHeight;
- private IDialogSettings fSettings;
- private static final String DIALOG_SETTINGS= "RefactoringWizard.preview"; //$NON-NLS-1$
- private static final String WIDTH= "width"; //$NON-NLS-1$
- private static final String HEIGHT= "height"; //$NON-NLS-1$
-
- private static final Image INFO= CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_INFO);
- private static final Image WARNING= CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
- private static final Image ERROR= CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_ERROR);
-
- private static class MessageBox extends Composite {
- private Label fImage;
- private Label fText;
- public MessageBox(Composite parent, int style) {
- super(parent, style);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- setLayout(layout);
- fImage= new Label(this, SWT.NONE);
- fImage.setImage(INFO);
- Point size= fImage.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- GridData gd= new GridData();
- gd.verticalAlignment= SWT.TOP;
- gd.widthHint= size.x;
- gd.heightHint= size.y;
- fImage.setLayoutData(gd);
- fImage.setImage(null);
- fText= new Label(this, SWT.WRAP);
- fText.setText(" \n "); //$NON-NLS-1$
- size= fText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint= size.y;
- gd.verticalAlignment= SWT.TOP;
- fText.setLayoutData(gd);
- }
- public void setMessage(IWizardPage page) {
- String msg= page.getErrorMessage();
- int type= IMessageProvider.ERROR;
- if (msg == null || msg.length() == 0) {
- msg= page.getMessage();
- type= IMessageProvider.NONE;
- if (msg != null && page instanceof IMessageProvider)
- type = ((IMessageProvider)page).getMessageType();
- }
- Image image= null;
- switch (type) {
- case IMessageProvider.INFORMATION:
- image= INFO;
- break;
- case IMessageProvider.WARNING:
- image= WARNING;
- break;
- case IMessageProvider.ERROR:
- image= ERROR;
- break;
- }
- if (msg == null)
- msg= ""; //$NON-NLS-1$
- fText.setText(msg);
- if (image == null && msg.length() > 0)
- image= INFO;
- fImage.setImage(image);
- }
- }
-
- private static class PageBook extends Composite {
- private StackLayout fLayout;
- public PageBook(Composite parent, int style) {
- super(parent, style);
- fLayout= new StackLayout();
- setLayout(fLayout);
- fLayout.marginWidth= 5; fLayout.marginHeight= 5;
- }
- public void showPage(Control page) {
- fLayout.topControl= page;
- layout();
- }
- public Control getTopPage() {
- return fLayout.topControl;
- }
- }
-
- public RefactoringWizardDialog2(Shell shell, RefactoringWizard wizard) {
- super(shell);
- Assert.isNotNull(wizard);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- wizard.setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
- fWizard= wizard;
- fWizard.setContainer(this);
- fWizard.addPages();
- initSize();
- }
-
- private void initSize() {
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- fSettings= settings.getSection(DIALOG_SETTINGS);
- if (fSettings == null) {
- fSettings= new DialogSettings(DIALOG_SETTINGS);
- settings.addSection(fSettings);
- fSettings.put(WIDTH, 600);
- fSettings.put(HEIGHT, 100);
- }
- fPreviewWidth= 600;
- fPreviewHeight= 100;
- try {
- fPreviewWidth= fSettings.getInt(WIDTH);
- fPreviewHeight= fSettings.getInt(HEIGHT);
- } catch (NumberFormatException e) {
- }
- }
-
- private void saveSize() {
- if (fCurrentPage instanceof PreviewWizardPage) {
- Control control= fCurrentPage.getControl().getParent();
- Point size = control.getSize();
- fSettings.put(WIDTH, size.x);
- fSettings.put(HEIGHT, size.y);
- }
- }
-
- //---- IWizardContainer --------------------------------------------
-
- /* (non-Javadoc)
- * Method declared on IWizardContainer.
- */
- public void showPage(IWizardPage page) {
- fCurrentPage= page;
- }
-
- /* (non-Javadoc)
- * Method declared on IWizardContainer.
- */
- public void updateButtons() {
- boolean previewPage= isPreviewPageActive();
- boolean ok= fWizard.canFinish();
- boolean canFlip= fCurrentPage.canFlipToNextPage();
- Button previewButton= getButton(PREVIEW_ID);
- Button defaultButton= null;
- if (previewButton != null && !previewButton.isDisposed()) {
- previewButton.setEnabled(!previewPage);
- if (!previewPage)
- previewButton.setEnabled(canFlip);
- if (previewButton.isEnabled())
- defaultButton= previewButton;
- }
- Button okButton= getButton(IDialogConstants.OK_ID);
- if (okButton != null && !okButton.isDisposed()) {
- okButton.setEnabled(ok);
- if (ok)
- defaultButton= okButton;
- }
- if (defaultButton != null) {
- defaultButton.getShell().setDefaultButton(defaultButton);
- }
- }
-
- /* (non-Javadoc)
- * Method declared on IWizardContainer.
- */
- public void updateMessage() {
- if (fStatusContainer == null || fStatusContainer.isDisposed())
- return;
- fStatusContainer.showPage(fMessageBox);
- fMessageBox.setMessage(fCurrentPage);
- }
-
- /* (non-Javadoc)
- * Method declared on IWizardContainer.
- */
- public void updateTitleBar() {
- // we don't have a title bar.
- }
-
- /* (non-Javadoc)
- * Method declared on IWizardContainer.
- */
- public void updateWindowTitle() {
- getShell().setText(fWizard.getWindowTitle());
- }
-
- /* (non-Javadoc)
- * Method declared on IWizardContainer.
- */
- public IWizardPage getCurrentPage() {
- return fCurrentPage;
- }
-
- //---- IRunnableContext --------------------------------------------
-
- /* (non-Javadoc)
- * Method declared on IRunnableContext
- */
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
- if (fProgressMonitorPart == null) {
- ModalContext.run(runnable, false, new NullProgressMonitor(), getShell().getDisplay());
- } else {
- Object state = null;
- if(fActiveRunningOperations == 0)
- state = aboutToStart(fork && cancelable);
-
- fActiveRunningOperations++;
- try {
- ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay());
- } finally {
- fActiveRunningOperations--;
- //Stop if this is the last one
- if(state!= null)
- stopped(state);
- }
- }
- }
-
- private Object aboutToStart(boolean cancelable) {
- Map savedState = null;
- Shell shell= getShell();
- if (shell != null) {
- // Save focus control
- Control focusControl = getShell().getDisplay().getFocusControl();
- if (focusControl != null && focusControl.getShell() != getShell())
- focusControl = null;
-
- Button cancelButton= getButton(IDialogConstants.CANCEL_ID);
- // Set the busy cursor to all shells.
- Display d = getShell().getDisplay();
- fWaitCursor = new Cursor(d, SWT.CURSOR_WAIT);
- setDisplayCursor(d, fWaitCursor);
-
- // Set the arrow cursor to the cancel component.
- fArrowCursor= new Cursor(d, SWT.CURSOR_ARROW);
- cancelButton.setCursor(fArrowCursor);
-
- boolean hasProgressMonitor= fProgressMonitorPart != null;
-
- // Deactivate shell
- savedState= saveUIState(hasProgressMonitor && cancelable);
- if (focusControl != null)
- savedState.put("focus", focusControl); //$NON-NLS-1$
-
- if (hasProgressMonitor) {
- fProgressMonitorPart.attachToCancelComponent(cancelButton);
- fStatusContainer.showPage(fProgressMonitorPart);
- }
- // Update the status container since we are blocking the event loop right now.
- fStatusContainer.update();
- }
- return savedState;
- }
-
- private Map saveUIState(boolean keepCancelEnabled) {
- Map savedState= new HashMap(10);
- saveEnableStateAndSet(getButton(PREVIEW_ID), savedState, "preview", false); //$NON-NLS-1$
- saveEnableStateAndSet(getButton(IDialogConstants.OK_ID), savedState, "ok", false); //$NON-NLS-1$
- saveEnableStateAndSet(getButton(IDialogConstants.CANCEL_ID), savedState, "cancel", keepCancelEnabled); //$NON-NLS-1$
- savedState.put("page", ControlEnableState.disable(fVisiblePage.getControl())); //$NON-NLS-1$
- return savedState;
- }
-
- private void saveEnableStateAndSet(Control w, Map h, String key, boolean enabled) {
- if (w != null) {
- h.put(key, new Boolean(w.getEnabled()));
- w.setEnabled(enabled);
- }
- }
-
- private void setDisplayCursor(Display d, Cursor c) {
- Shell[] shells= d.getShells();
- for (int i= 0; i < shells.length; i++)
- shells[i].setCursor(c);
- }
-
- private void stopped(Object savedState) {
- Shell shell= getShell();
- if (shell != null) {
- Button cancelButton= getButton(IDialogConstants.CANCEL_ID);
-
- if (fProgressMonitorPart != null)
- fProgressMonitorPart.removeFromCancelComponent(cancelButton);
-
- fStatusContainer.showPage(fMessageBox);
- Map state = (Map)savedState;
- restoreUIState(state);
-
- setDisplayCursor(shell.getDisplay(), null);
- cancelButton.setCursor(null);
- fWaitCursor.dispose();
- fWaitCursor = null;
- fArrowCursor.dispose();
- fArrowCursor = null;
- Control focusControl = (Control)state.get("focus"); //$NON-NLS-1$
- if (focusControl != null)
- focusControl.setFocus();
- }
- }
-
- private void restoreUIState(Map state) {
- restoreEnableState(getButton(PREVIEW_ID), state, "preview");//$NON-NLS-1$
- restoreEnableState(getButton(IDialogConstants.OK_ID), state, "ok");//$NON-NLS-1$
- restoreEnableState(getButton(IDialogConstants.CANCEL_ID), state, "cancel");//$NON-NLS-1$
- ControlEnableState pageState = (ControlEnableState) state.get("page");//$NON-NLS-1$
- pageState.restore();
- }
-
- private void restoreEnableState(Control w, Map h, String key) {
- if (w != null) {
- Boolean b = (Boolean) h.get(key);
- if (b != null)
- w.setEnabled(b.booleanValue());
- }
- }
-
- //---- Dialog -----------------------------------------------------------
-
- public boolean close() {
- fWizard.dispose();
- return super.close();
- }
-
- protected void cancelPressed() {
- if (fActiveRunningOperations == 0) {
- if (fWizard.performCancel())
- super.cancelPressed();
- }
- }
-
- protected void okPressed() {
- IWizardPage current= fCurrentPage;
- if (fWizard.performFinish()) {
- saveSize();
- super.okPressed();
- return;
- }
- if (fCurrentPage == current)
- return;
- Assert.isTrue(ErrorWizardPage.PAGE_NAME.equals(fCurrentPage.getName()));
- if (showErrorDialog((ErrorWizardPage)fCurrentPage)) {
- if (fWizard.performFinish()) {
- super.okPressed();
- return;
- }
- }
- fCurrentPage= current;
- }
-
- private boolean isPreviewPageActive() {
- return IPreviewWizardPage.PAGE_NAME.equals(fCurrentPage.getName());
- }
-
- private void previewPressed() {
- IWizardPage current= fCurrentPage;
- fCurrentPage= fCurrentPage.getNextPage();
- if (current == fCurrentPage)
- return;
- String pageName= fCurrentPage.getName();
- if (ErrorWizardPage.PAGE_NAME.equals(pageName)) {
- if (showErrorDialog((ErrorWizardPage)fCurrentPage)) {
- fCurrentPage= fCurrentPage.getNextPage();
- pageName= fCurrentPage.getName();
- } else {
- return;
- }
- }
- if (IPreviewWizardPage.PAGE_NAME.equals(pageName)) {
- fCurrentPage.createControl(fPageContainer);
- makeVisible(fCurrentPage);
- updateButtons();
- if (((PreviewWizardPage)fCurrentPage).hasChanges())
- resize();
- else
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- } else {
- fCurrentPage= current;
- }
- }
-
- private boolean showErrorDialog(ErrorWizardPage page) {
- RefactoringStatusDialog dialog= new RefactoringStatusDialog(getShell(), page, true);
- switch (dialog.open()) {
- case IDialogConstants.OK_ID:
- return true;
- case IDialogConstants.BACK_ID:
- fCurrentPage= fCurrentPage.getPreviousPage();
- break;
- case IDialogConstants.CANCEL_ID:
- super.cancelPressed();
- }
- return false;
- }
-
- private void resize() {
- Control control= fPageContainer.getTopPage();
- Point size= control.getSize();
- int dw= Math.max(0, fPreviewWidth - size.x);
- int dh= Math.max(0, fPreviewHeight - size.y);
- int dx = dw / 2;
- int dy= dh / 2;
- Shell shell= getShell();
- Rectangle rect= shell.getBounds();
- Rectangle display= shell.getDisplay().getClientArea();
- rect.x= Math.max(0, rect.x - dx);
- rect.y= Math.max(0, rect.y - dy);
- rect.width= Math.min(rect.width + dw, display.width);
- rect.height= Math.min(rect.height + dh, display.height);
- int xe= rect.x + rect.width;
- if (xe > display.width) {
- rect.x-= xe - display.width;
- }
- int ye= rect.y + rect.height;
- if (ye > display.height) {
- rect.y-= ye - display.height;
- }
- shell.setBounds(rect);
- }
-
- //---- UI construction ---------------------------------------------------
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(fWizard.getDefaultPageTitle());
- }
-
- protected Control createContents(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0; layout.marginWidth= 0;
- layout.verticalSpacing= 0; layout.horizontalSpacing= 0;
- result.setLayout(layout);
- result.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // initialize the dialog units
- initializeDialogUnits(result);
-
- fPageContainer= new PageBook(result, SWT.NONE);
- GridData gd= new GridData(GridData.FILL_BOTH);
- fPageContainer.setLayoutData(gd);
- fCurrentPage= fWizard.getStartingPage();
- dialogArea= fPageContainer;
- if (fCurrentPage instanceof PreviewWizardPage) {
- gd.widthHint= fPreviewWidth;
- gd.heightHint= fPreviewHeight;
- }
-
- fStatusContainer= new PageBook(result, SWT.NONE);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(fWizard.getMessageLineWidthInChars());
- fStatusContainer.setLayoutData(gd);
- if (fWizard.needsProgressMonitor())
- createProgressMonitorPart();
- createMessageBox();
- fStatusContainer.showPage(fMessageBox);
-
- buttonBar= createButtonBar(result);
-
- fCurrentPage.createControl(fPageContainer);
- makeVisible(fCurrentPage);
-
- updateMessage();
- updateButtons();
- applyDialogFont(result);
- return result;
- }
-
- private void createProgressMonitorPart() {
- // Insert a progress monitor
- GridLayout pmlayout= new GridLayout();
- pmlayout.numColumns= 1;
- pmlayout.marginHeight= 0;
- fProgressMonitorPart= new ProgressMonitorPart(fStatusContainer, pmlayout);
- }
-
- private void createMessageBox() {
- fMessageBox= new MessageBox(fStatusContainer, SWT.NONE);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- if (! (fCurrentPage instanceof PreviewWizardPage) && fWizard.hasPreviewPage()) {
- Button preview= createButton(parent, PREVIEW_ID, RefactoringMessages.getString("RefactoringWizardDialog2.buttons.preview.label"), false); //$NON-NLS-1$
- preview.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- previewPressed();
- }
- });
- }
-
- String OK_LABEL= IDialogConstants.OK_LABEL;
- String CANCEL_LABEL= IDialogConstants.CANCEL_LABEL;
- if (fWizard.yesNoStyle()) {
- OK_LABEL= IDialogConstants.YES_LABEL;
- CANCEL_LABEL= IDialogConstants.NO_LABEL;
- }
- createButton(
- parent,
- IDialogConstants.OK_ID,
- OK_LABEL,
- true);
- createButton(
- parent,
- IDialogConstants.CANCEL_ID,
- CANCEL_LABEL,
- false);
- Button okButton= getButton(IDialogConstants.OK_ID);
- okButton.setFocus();
- }
-
- private void makeVisible(IWizardPage page) {
- if (fVisiblePage == page)
- return;
- if (fVisiblePage != null)
- fVisiblePage.setVisible(false);
- fVisiblePage= page;
- fPageContainer.showPage(page.getControl());
- fVisiblePage.setVisible(true);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardPage.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardPage.java
deleted file mode 100644
index 1bba3a11190..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RefactoringWizardPage.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardPage;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-
-/**
- * An abstract superclass for all wizard pages added to a refactoring wizard. The
- * class provides access to the refactoring and the refactoring wizard.
- *
- * @see RefactoringWizard
- */
-public abstract class RefactoringWizardPage extends WizardPage {
-
- public static final String REFACTORING_SETTINGS= "org.eclipse.cdt.ui.refactoring"; //$NON-NLS-1$
-
- /**
- * Creates a new refactoring wizard page.
- *
- * @param name the page's name.
- * @see org.eclipse.jface.wizard.IWizardPage#getName()
- */
- protected RefactoringWizardPage(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * Method declared on IWizardPage.
- */
- public void setWizard(IWizard newWizard) {
- Assert.isTrue(newWizard instanceof RefactoringWizard);
- super.setWizard(newWizard);
- }
-
- /**
- * Returns the refactoring used by the wizard to which this page belongs.
- * Returns null
if the page isn't added to any wizard yet.
- *
- * @return the refactoring associated with this refactoring wizard page
- */
- protected Refactoring getRefactoring() {
- RefactoringWizard wizard= getRefactoringWizard();
- if (wizard == null)
- return null;
- return wizard.getRefactoring();
- }
-
- /**
- * Returns the page's refactoring wizard.
- *
- * @return the page's refactoring wizard
- */
- protected RefactoringWizard getRefactoringWizard() {
- return (RefactoringWizard)getWizard();
- }
-
- /**
- * The user has pressed the finish button. Perform the page specific finish
- * action.
- *
- * @return true
if finish operation ended without errors.
- * Otherwise false
is returned.
- */
- protected boolean performFinish() {
- return true;
- }
-
- /**
- * Returns the refactoring dialog settings.
- *
- * @return the refactoring dialog settings.
- */
- protected IDialogSettings getRefactoringSettings() {
- IDialogSettings settings= getDialogSettings();
- if (settings == null)
- return null;
- IDialogSettings result= settings.getSection(REFACTORING_SETTINGS);
- if (result == null) {
- result= new DialogSettings(REFACTORING_SETTINGS);
- settings.addSection(result);
- }
- return result;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameElementWizard.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameElementWizard.java
deleted file mode 100644
index 48b0c962c1e..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameElementWizard.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-
-public class RenameElementWizard extends RenameRefactoringWizard {
- public RenameElementWizard() {
- super(
- RefactoringMessages.getString("RenameTypeWizard.defaultPageTitle"), //$NON-NLS-1$
- RefactoringMessages.getString("RenameTypeWizard.inputPage.description"), //$NON-NLS-1$
- CPluginImages.DESC_WIZBAN_REFACTOR_TYPE,
- ICHelpContextIds.RENAME_TYPE_WIZARD_PAGE);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameInputWizardPage.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameInputWizardPage.java
deleted file mode 100644
index 986ede6d579..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameInputWizardPage.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.cdt.internal.corext.refactoring.IReferenceUpdating;
-import org.eclipse.cdt.internal.corext.refactoring.ITextUpdating;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.ui.util.RowLayouter;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-abstract class RenameInputWizardPage extends TextInputWizardPage {
-
- private String fHelpContextID;
- private Button fUpdateReferences;
- private Button fUpdateComments;
- private Button fUpdateStrings;
- private Button fUpdateQualifiedNames;
- private static final String UPDATE_REFERENCES= "updateReferences"; //$NON-NLS-1$
- private static final String UPDATE_COMMENTS= "updateComments"; //$NON-NLS-1$
- private static final String UPDATE_STRINGS= "updateStrings"; //$NON-NLS-1$
- private static final String UPDATE_QUALIFIED_NAMES= "updateQualifiedNames"; //$NON-NLS-1$
-
- /**
- * Creates a new text input page.
- * @param isLastUserPage true
if this page is the wizard's last
- * user input page. Otherwise false
.
- * @param initialSetting the initialSetting.
- */
- public RenameInputWizardPage(String description, String contextHelpId, boolean isLastUserPage, String initialValue) {
- super(description, isLastUserPage, initialValue);
- fHelpContextID= contextHelpId;
- }
-
- /* non java-doc
- * @see DialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite superComposite= new Composite(parent, SWT.NONE);
- setControl(superComposite);
- initializeDialogUnits(superComposite);
-
- superComposite.setLayout(new GridLayout());
- Composite composite= new Composite(superComposite, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.verticalSpacing= 8;
- composite.setLayout(layout);
- RowLayouter layouter= new RowLayouter(2);
-
- Label oldNameLabel= new Label(composite, SWT.NONE);
- oldNameLabel.setText(getOldNameLabelText());
-
- Label oldName= new Label(composite, SWT.NONE);
- oldName.setText(fInitialValue);
-
- Label label= new Label(composite, SWT.NONE);
- label.setText(getLabelText());
-
- Text text= createTextInputField(composite);
- text.selectAll();
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(25);
- text.setLayoutData(gd);
-
-
- layouter.perform(label, text, 1);
-
- addOptionalUpdateReferencesCheckbox(composite, layouter);
-
- Dialog.applyDialogFont(superComposite);
- WorkbenchHelp.setHelp(getControl(), fHelpContextID);
-
- }
-
- protected boolean saveSettings() {
- if (getContainer() instanceof Dialog)
- return ((Dialog)getContainer()).getReturnCode() == IDialogConstants.OK_ID;
- return true;
- }
-
- public void dispose() {
- if (saveSettings()) {
- saveBooleanSetting(UPDATE_REFERENCES, fUpdateReferences);
- saveBooleanSetting(UPDATE_COMMENTS, fUpdateComments);
- saveBooleanSetting(UPDATE_STRINGS, fUpdateStrings);
- saveBooleanSetting(UPDATE_QUALIFIED_NAMES, fUpdateQualifiedNames);
- }
- super.dispose();
- }
-
- private void addOptionalUpdateReferencesCheckbox(Composite result, RowLayouter layouter) {
- final IReferenceUpdating ref= (IReferenceUpdating)getRefactoring().getAdapter(IReferenceUpdating.class);
- if (ref == null || !ref.canEnableUpdateReferences())
- return;
- String title= RefactoringMessages.getString("RenameInputWizardPage.update_references"); //$NON-NLS-1$
- boolean defaultValue= getBooleanSetting(UPDATE_REFERENCES, ref.getUpdateReferences());
- fUpdateReferences= createCheckbox(result, title, defaultValue, layouter);
- ref.setUpdateReferences(fUpdateReferences.getSelection());
- fUpdateReferences.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- ref.setUpdateReferences(fUpdateReferences.getSelection());
- }
- });
- }
-
- private void addOptionalUpdateCommentsAndStringCheckboxes(Composite result, RowLayouter layouter) {
- ITextUpdating refactoring= (ITextUpdating)getRefactoring().getAdapter(ITextUpdating.class);
-
- if (refactoring == null || !refactoring.canEnableTextUpdating())
- return;
-
- addUpdateCommentsCheckbox(result, layouter, refactoring);
- addUpdateStringsCheckbox(result, layouter, refactoring);
- }
-
- private void addUpdateCommentsCheckbox(Composite result, RowLayouter layouter, final ITextUpdating refactoring) {
- String title= RefactoringMessages.getString("RenameInputWizardPage.update_comment_references"); //$NON-NLS-1$
- boolean defaultValue= getBooleanSetting(UPDATE_COMMENTS, refactoring.getUpdateComments());
- fUpdateComments= createCheckbox(result, title, defaultValue, layouter);
- refactoring.setUpdateComments(fUpdateComments.getSelection());
- fUpdateComments.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- refactoring.setUpdateComments(fUpdateComments.getSelection());
- updateForcePreview();
- }
- });
- }
-
- private void addUpdateStringsCheckbox(Composite result, RowLayouter layouter, final ITextUpdating refactoring) {
- String title= RefactoringMessages.getString("RenameInputWizardPage.ppdate_string_references"); //$NON-NLS-1$
- boolean defaultValue= getBooleanSetting(UPDATE_STRINGS, refactoring.getUpdateStrings());
- fUpdateStrings= createCheckbox(result, title, defaultValue, layouter);
- refactoring.setUpdateStrings(fUpdateStrings.getSelection());
- fUpdateStrings.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- refactoring.setUpdateStrings(fUpdateStrings.getSelection());
- updateForcePreview();
- }
- });
- }
-
- protected String getLabelText() {
- return RefactoringMessages.getString("RenameInputWizardPage.enter_name"); //$NON-NLS-1$
- }
-
- protected String getOldNameLabelText() {
- return RefactoringMessages.getString("RenameInputWizardPage.old_name"); //$NON-NLS-1$
- }
-
- protected boolean getBooleanSetting(String key, boolean defaultValue) {
- String update= getRefactoringSettings().get(key);
- if (update != null)
- return Boolean.valueOf(update).booleanValue();
- else
- return defaultValue;
- }
-
- protected void saveBooleanSetting(String key, Button checkBox) {
- if (checkBox != null)
- getRefactoringSettings().put(key, checkBox.getSelection());
- }
-
- private static Button createCheckbox(Composite parent, String title, boolean value, RowLayouter layouter) {
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(title);
- checkBox.setSelection(value);
- layouter.perform(checkBox);
- return checkBox;
- }
-
- private void updateForcePreview() {
- boolean forcePreview= false;
- Refactoring refactoring= getRefactoring();
- ITextUpdating tu= (ITextUpdating)refactoring.getAdapter(ITextUpdating.class);
- if (tu != null) {
- forcePreview= tu.getUpdateComments() || tu.getUpdateJavaDoc() || tu.getUpdateStrings();
- }
- getRefactoringWizard().setPreviewReview(forcePreview);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameRefactoringWizard.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameRefactoringWizard.java
deleted file mode 100644
index 8149adb882b..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/RenameRefactoringWizard.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.cdt.internal.corext.refactoring.RefactoringStyles;
-import org.eclipse.cdt.internal.corext.refactoring.RenameRefactoring;
-import org.eclipse.cdt.internal.corext.refactoring.IRenameRefactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringWizard;
-
-public class RenameRefactoringWizard extends RefactoringWizard {
-
- private final String fInputPageDescription;
- private final String fPageContextHelpId;
- private final ImageDescriptor fInputPageImageDescriptor;
-
- public RenameRefactoringWizard(String defaultPageTitle, String inputPageDescription,
- ImageDescriptor inputPageImageDescriptor, String pageContextHelpId) {
- super();
- setDefaultPageTitle(defaultPageTitle);
- fInputPageDescription= inputPageDescription;
- fInputPageImageDescriptor= inputPageImageDescriptor;
- fPageContextHelpId= pageContextHelpId;
- }
-
- protected boolean hasPreviewPage() {
- Refactoring refactoring= getRefactoring();
- if (refactoring instanceof RenameRefactoring) {
- return (((RenameRefactoring)refactoring).getStyle() & RefactoringStyles.NEEDS_PREVIEW) != 0;
- }
- return super.hasPreviewPage();
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- String initialSetting= getRenameRefactoring().getCurrentName();
- RenameInputWizardPage inputPage= createInputPage(fInputPageDescription, initialSetting);
- inputPage.setImageDescriptor(fInputPageImageDescriptor);
- addPage(inputPage);
- }
-
- private IRenameRefactoring getRenameRefactoring() {
- return (IRenameRefactoring)getRefactoring();
- }
-
- protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
- return new RenameInputWizardPage(message, fPageContextHelpId, true, initialSetting) {
- protected RefactoringStatus validateTextField(String text) {
- return validateNewName(text);
- }
- };
- }
-
- protected RefactoringStatus validateNewName(String newName) {
- IRenameRefactoring ref= getRenameRefactoring();
- ref.setNewName(newName);
- try{
- return ref.checkNewName(newName);
- } catch (CoreException e){
- //XXX: should log the exception
- String msg= e.getMessage() == null ? "": e.getMessage(); //$NON-NLS-1$
- return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getFormattedString("RenameRefactoringWizard.internal_error", msg));//$NON-NLS-1$
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/StatusContextViewerDescriptor.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/StatusContextViewerDescriptor.java
deleted file mode 100644
index b3ee51cbb47..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/StatusContextViewerDescriptor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-public class StatusContextViewerDescriptor /*extends AbstractDescriptor */{
-
- private static final String EXT_ID= "statusContextViewers"; //$NON-NLS-1$
-/*
- private static DescriptorManager fgDescriptions= new DescriptorManager(EXT_ID) {
- protected AbstractDescriptor createDescriptor(IConfigurationElement element) {
- return new StatusContextViewerDescriptor(element);
- }
- };
-
- public static StatusContextViewerDescriptor get(Object element) throws CoreException {
- return (StatusContextViewerDescriptor)fgDescriptions.getDescriptor(element);
- }
-
- public StatusContextViewerDescriptor(IConfigurationElement element) {
- super(element);
- }
-
- public IStatusContextViewer createViewer() throws CoreException {
- return (IStatusContextViewer)fConfigurationElement.createExecutableExtension(CLASS);
- }
- */
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextChangePreviewViewer.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextChangePreviewViewer.java
deleted file mode 100644
index d55ba8d404f..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextChangePreviewViewer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.CompareViewerSwitchingPane;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange.EditChange;
-
-public class TextChangePreviewViewer implements IChangePreviewViewer {
-
- private ComparePreviewer fViewer;
-
- private static class TextEditChangeInput {
- EditChange change;
- int surroundingLines;
-
- EditChange[] changes;
- IRegion range;
- }
-
- private static class ComparePreviewer extends CompareViewerSwitchingPane {
- private CompareConfiguration fCompareConfiguration;
- public ComparePreviewer(Composite parent) {
- super(parent, SWT.BORDER | SWT.FLAT, true);
- fCompareConfiguration= new CompareConfiguration();
- fCompareConfiguration.setLeftEditable(false);
- fCompareConfiguration.setLeftLabel(RefactoringMessages.getString("ComparePreviewer.original_source")); //$NON-NLS-1$
- fCompareConfiguration.setRightEditable(false);
- fCompareConfiguration.setRightLabel(RefactoringMessages.getString("ComparePreviewer.refactored_source")); //$NON-NLS-1$
- }
- protected Viewer getViewer(Viewer oldViewer, Object input) {
- return CompareUI.findContentViewer(oldViewer, (ICompareInput)input, this, fCompareConfiguration);
- }
- public void setText(String text) {
- /*
- Object input= getInput();
- if (input instanceof CompareInput) {
- CompareInput cInput= (CompareInput)input;
- setImage(fLabelProvider.getImage(cInput.getChangeElement()));
- super.setText(fLabelProvider.getText(cInput.getChangeElement()));
- } else {
- super.setText(text);
- setImage(null);
- }
- */
- super.setText(text);
- }
- }
-
- private static class CompareElement implements ITypedElement, IStreamContentAccessor {
- private InputStream fContent;
- private String fType;
- public CompareElement(String content, String type) {
- fContent= createInputStream(content);
- fType= type;
- }
- public String getName() {
- return RefactoringMessages.getString("ComparePreviewer.element_name"); //$NON-NLS-1$
- }
- public Image getImage() {
- return null;
- }
- public String getType() {
- return fType;
- }
- public InputStream getContents() throws CoreException {
- return fContent;
- }
- private static InputStream createInputStream(String s) {
- try {
- return new ByteArrayInputStream(s.getBytes(ResourcesPlugin.getEncoding()));
- } catch (UnsupportedEncodingException e) {
- return new ByteArrayInputStream(s.getBytes());
- }
- }
- }
-
- public static Object createInput(TextChange change) {
- return change;
- }
-
- public static Object createInput(EditChange change, int surroundingLines) {
- TextEditChangeInput result= new TextEditChangeInput();
- result.change= change;
- result.surroundingLines= surroundingLines;
- return result;
- }
-
- public static Object createInput(EditChange[] changes, IRegion range) {
- TextEditChangeInput result= new TextEditChangeInput();
- result.changes= changes;
- result.range= range;
- return result;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.IChangePreviewViewer#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- fViewer= new ComparePreviewer(parent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.IChangePreviewViewer#getControl()
- */
- public Control getControl() {
- return fViewer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.IChangePreviewViewer#setInput(org.eclipse.jdt.internal.ui.refactoring.ChangeElement)
- */
- public void setInput(Object input) throws CoreException {
- if (input instanceof TextChange) {
- TextChange change= (TextChange)input;
- setInput(change.getCurrentContent(), change.getPreviewContent(), change.getTextType());
- return;
- } else if (input instanceof TextEditChangeInput) {
- TextEditChangeInput edi= (TextEditChangeInput)input;
- if (edi.change != null && edi.surroundingLines >= 0) {
- TextChange.EditChange editChange= edi.change;
- TextChange change= editChange.getTextChange();
- setInput(change.getCurrentContent(editChange, 2),
- change.getPreviewContent(editChange, 2),
- change.getTextType());
- return;
- } else if (edi.changes != null && edi.changes.length > 0 && edi.range != null) {
- TextChange change= edi.changes[0].getTextChange();
- setInput(change.getCurrentContent(edi.range),
- change.getPreviewContent(edi.changes, edi.range),
- change.getTextType());
- return;
- }
- } else {
- fViewer.setInput(null);
- }
- /*
- } else if (change instanceof CreateTextFileChange){
- CreateTextFileChange ctfc= (CreateTextFileChange)change;
- String type= ctfc.isJavaFile() ? JAVA_TYPE: TEXT_TYPE;
- setInput(input, ctfc.getCurrentContent(), ctfc.getPreview(), type);
- return;
- }
- */
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.IChangePreviewViewer#refresh()
- */
- public void refresh() {
- fViewer.getViewer().refresh();
- }
-
- private void setInput(String left, String right, String type) {
- fViewer.setInput(new DiffNode(
- new CompareElement(left, type),
- new CompareElement(right, type)));
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextEditChangeElement.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextEditChangeElement.java
deleted file mode 100644
index 96dcfc9b886..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextEditChangeElement.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.IChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange;
-import org.eclipse.cdt.internal.corext.refactoring.changes.TextChange.EditChange;
-
-/* package */ class TextEditChangeElement extends ChangeElement {
-
- private static final ChangeElement[] fgChildren= new ChangeElement[0];
-
- private EditChange fChange;
-
- public TextEditChangeElement(ChangeElement parent, EditChange change) {
- super(parent);
- fChange= change;
- Assert.isNotNull(fChange);
- }
-
- /**
- * Returns the TextEditChange
managed by this node.
- *
- * @return the TextEditChange
- */
- public EditChange getTextEditChange() {
- return fChange;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.ChangeElement#getChangePreviewViewer()
- */
-// public ChangePreviewViewerDescriptor getChangePreviewViewer() throws CoreException {
-// DefaultChangeElement element= getStandardChangeElement();
-// if (element == null)
-// return null;
-// return element.getChangePreviewViewer();
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.refactoring.ChangeElement#feedInput(org.eclipse.jdt.internal.ui.refactoring.IChangePreviewViewer)
- */
- public void feedInput(IChangePreviewViewer viewer) throws CoreException {
- DefaultChangeElement element= getStandardChangeElement();
- if (element != null) {
- IChange change= element.getChange();
- if (change instanceof TextChange) {
- IRegion range= getTextRange(this);
- Object input= null;
- if (range != null) {
- input= TextChangePreviewViewer.createInput(new EditChange[] {fChange}, range);
- } else {
- input= TextChangePreviewViewer.createInput(fChange, 2);
- }
- viewer.setInput(input);
- }
- } else {
- viewer.setInput(null);
- }
- }
-
- /* non Java-doc
- * @see ChangeElement#setActive
- */
- public void setActive(boolean active) {
- fChange.setActive(active);
- }
-
- /* non Java-doc
- * @see ChangeElement.getActive
- */
- public int getActive() {
- return fChange.isActive() ? ACTIVE : INACTIVE;
- }
-
- /* non Java-doc
- * @see ChangeElement.getChildren
- */
- public ChangeElement[] getChildren() {
- return fgChildren;
- }
-
- private DefaultChangeElement getStandardChangeElement() {
- ChangeElement element= getParent();
- while(!(element instanceof DefaultChangeElement) && element != null) {
- element= element.getParent();
- }
- return (DefaultChangeElement)element;
- }
-
- private static IRegion getTextRange(ChangeElement element) throws CoreException {
- if (element == null)
- return null;
- if (element instanceof PseudoCChangeElement) {
- return ((PseudoCChangeElement)element).getTextRange();
- } else
- if (element instanceof DefaultChangeElement) {
- return null;
- }
- return getTextRange(element.getParent());
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextInputWizardPage.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextInputWizardPage.java
deleted file mode 100644
index d1bbfd0da22..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/TextInputWizardPage.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-
-public abstract class TextInputWizardPage extends UserInputWizardPage{
-
- protected String fInitialValue;
- protected Text fTextField;
-
- public static final String PAGE_NAME= "TextInputPage";//$NON-NLS-1$
-
- /**
- * Creates a new text input page.
- * @param isLastUserPage true
if this page is the wizard's last
- * user input page. Otherwise false
.
- */
- public TextInputWizardPage(String description, boolean isLastUserPage) {
- this(description, isLastUserPage, ""); //$NON-NLS-1$
- }
-
- /**
- * Creates a new text input page.
- * @param isLastUserPage true
if this page is the wizard's last
- * user input page. Otherwise false
.
- * @param initialSetting the initialSetting.
- */
- public TextInputWizardPage(String description, boolean isLastUserPage, String initialValue) {
- super(PAGE_NAME, isLastUserPage);
- Assert.isNotNull(initialValue);
- setDescription(description);
- fInitialValue= initialValue;
- }
-
- /**
- * Returns whether the initial input is valid. Typically it is not, because the
- * user is required to provide some information e.g. a new type name etc.
- *
- * @return true
iff the input provided at initialization is valid
- */
- protected boolean isInitialInputValid(){
- return false;
- }
-
- /**
- * Returns whether an empty string is a valid input. Typically it is not, because
- * the user is required to provide some information e.g. a new type name etc.
- *
- * @return true
iff an empty string is valid
- */
- protected boolean isEmptyInputValid(){
- return false;
- }
-
- /**
- * Returns the content of the text input field.
- *
- * @return the content of the text input field. Returns null
if
- * not text input field has been created
- */
- protected String getText() {
- if (fTextField == null)
- return null;
- return fTextField.getText();
- }
-
- /**
- * Sets the new text for the text field. Does nothing if the text field has not been created.
- * @param text the new value
- */
- protected void setText(String text) {
- if (fTextField == null)
- return;
- fTextField.setText(text);
- }
-
- /**
- * Performs input validation. Returns a RefactoringStatus
which
- * describes the result of input validation. Null
is interpreted
- * as no error.
- */
- protected RefactoringStatus validateTextField(String text){
- return null;
- }
-
- protected Text createTextInputField(Composite parent) {
- return createTextInputField(parent, SWT.BORDER);
- }
-
- protected Text createTextInputField(Composite parent, int style) {
- fTextField= new Text(parent, style);
- fTextField.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- textModified(getText());
- }
- });
- fTextField.setText(fInitialValue);
- return fTextField;
- }
-
- /**
- * Checks the page's state and issues a corresponding error message. The page validation
- * is computed by calling
validatePage
.
- */
- protected void textModified(String text) {
- if (! isEmptyInputValid() && text.equals("")){ //$NON-NLS-1$
- setPageComplete(false);
- setErrorMessage(null);
- restoreMessage();
- return;
- }
- if ((! isInitialInputValid()) && text.equals(fInitialValue)){
- setPageComplete(false);
- setErrorMessage(null);
- //setErrorMessage(RefactoringMessages.getString("RenameInputWizardPage.no_undo")); //$NON-NLS-1$
- restoreMessage();
- return;
- }
-
- setPageComplete(validateTextField(text));
- }
-
- /**
- * Subclasses can override if they want to restore the message differently.
- * This implementation calls setMessage(null)
, which clears the message
- * thus exposing the description.
- */
- protected void restoreMessage(){
- setMessage(null);
- }
-
- /* (non-Javadoc)
- * Method declared in IDialogPage
- */
- public void dispose() {
- fTextField= null;
- }
-
- /* (non-Javadoc)
- * Method declared in WizardPage
- */
- public void setVisible(boolean visible) {
- if (visible) {
- textModified(getText());
- }
- super.setVisible(visible);
- if (visible && fTextField != null) {
- fTextField.setFocus();
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/UserInputWizardPage.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/UserInputWizardPage.java
deleted file mode 100644
index f3eb84a1cc4..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/UserInputWizardPage.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.wizard.IWizardPage;
-
-/**
- * An abstract wizard page that can be used to implement user input pages for
- * refactoring wizards. Usually user input pages are pages shown at the beginning
- * of a wizard. As soon as the "last" user input page is left a corresponding
- * precondition check is executed.
- */
-public abstract class UserInputWizardPage extends RefactoringWizardPage {
-
- private final boolean fIsLastUserPage;
-
- /**
- * Creates a new user input page.
- * @param name the page's name.
- * @param isLastUserPage true
if this page is the wizard's last
- * user input page. Otherwise false
.
- */
- public UserInputWizardPage(String name, boolean isLastUserPage) {
- super(name);
- fIsLastUserPage= isLastUserPage;
- }
-
- /**
- * Sets the page's complete status depending on the given
- * ReactoringStatus.
- *
- * @param status the RefactoringStatus
- */
- public void setPageComplete(RefactoringStatus status) {
- getRefactoringWizard().setStatus(status);
-
- int severity= status.getSeverity();
- if (severity == RefactoringStatus.FATAL){
- setPageComplete(false);
- setErrorMessage(status.getFirstMessage(severity));
- setImageDescriptor(CPluginImages.DESC_OBJS_DEFAULT_CHANGE);
- } else {
- setPageComplete(true);
- setErrorMessage(null);
- //setErrorMessage(RefactoringMessages.getString("RenameInputWizardPage.no_undo")); //$NON-NLS-1$
- if (severity == RefactoringStatus.OK)
- setMessage(null, NONE);
- else {
- setMessage(status.getFirstMessage(severity), getCorrespondingIStatusSeverity(severity));
- setImageDescriptor(CPluginImages.DESC_OBJS_DEFAULT_CHANGE);
- }
- }
- }
-
- /* (non-Javadoc)
- * Method declared in WizardPage
- */
- public void setVisible(boolean visible) {
- if (visible)
- getRefactoringWizard().setChange(null);
- super.setVisible(visible);
- }
-
- /* (non-JavaDoc)
- * Method declared in IWizardPage.
- */
- public IWizardPage getNextPage() {
- if (fIsLastUserPage)
- return getRefactoringWizard().computeUserInputSuccessorPage(this);
- else
- return super.getNextPage();
- }
-
- /* (non-JavaDoc)
- * Method declared in IWizardPage.
- */
- public boolean canFlipToNextPage() {
- if (fIsLastUserPage) {
- // we can't call getNextPage to determine if flipping is allowed since computing
- // the next page is quite expensive (checking preconditions and creating a
- // change). So we say yes if the page is complete.
- return isPageComplete();
- } else {
- return super.canFlipToNextPage();
- }
- }
-
- /* (non-JavaDoc)
- * Method defined in RefactoringWizardPage
- */
- protected boolean performFinish() {
- RefactoringWizard wizard= getRefactoringWizard();
- int threshold= RefactoringPreferences.getCheckPassedSeverity();
- RefactoringStatus activationStatus= wizard.getActivationStatus();
- RefactoringStatus inputStatus= null;
- RefactoringStatus status= new RefactoringStatus();
- Refactoring refactoring= getRefactoring();
- boolean result= false;
-
- if (activationStatus != null && activationStatus.getSeverity() > threshold) {
- inputStatus= wizard.checkInput();
- } else {
- CreateChangeOperation create= new CreateChangeOperation(refactoring, CreateChangeOperation.CHECK_INPUT);
- create.setCheckPassedSeverity(threshold);
-
- PerformChangeOperation perform= new PerformChangeOperation(create);
- perform.setCheckPassedSeverity(threshold);
-
- result= wizard.performFinish(perform);
- wizard.setChange(create.getChange());
- if (!result)
- return false;
- inputStatus= create.getStatus();
- }
-
- status.merge(activationStatus);
- status.merge(inputStatus);
-
- if (status.getSeverity() > threshold) {
- wizard.setStatus(status);
- IWizardPage nextPage= wizard.getPage(ErrorWizardPage.PAGE_NAME);
- wizard.getContainer().showPage(nextPage);
- return false;
- }
-
- return result;
- }
-
- private static int getCorrespondingIStatusSeverity(int severity) {
- if (severity == RefactoringStatus.FATAL)
- return IStatus.ERROR;
- if (severity == RefactoringStatus.ERROR)
- return IStatus.WARNING;
- if (severity == RefactoringStatus.WARNING)
- return IStatus.WARNING;
- if (severity == RefactoringStatus.INFO)
- return IStatus.INFO;
- return IStatus.OK;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/UserInterfaceStarter.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/UserInterfaceStarter.java
deleted file mode 100644
index fb9ec0d0e5a..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/UserInterfaceStarter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.cdt.internal.corext.refactoring.IRefactoringProcessor;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringStarter;
-
-/**
- * Opens the user interface for a given refactoring.
- */
-public class UserInterfaceStarter {
-
- protected static final String WIZARD= "wizard"; //$NON-NLS-1$
-
- private IConfigurationElement fConfigElement;
-
- /**
- * Opens the user interface for the given refactoring. The provided
- * shell should be used as a parent shell.
- *
- * @param refactoring the refactoring for which the user interface
- * should be opened
- * @param parent the parent shell to be used
- *
- * @exception CoreException if the user interface can't be activated
- */
- public static void run(Refactoring refactoring, Shell parent) throws CoreException {
- run(refactoring, parent, true);
- }
-
- /**
- * Opens the user interface for the given refactoring. The provided
- * shell should be used as a parent shell.
- *
- * @param refactoring the refactoring for which the user interface
- * should be opened
- * @param parent the parent shell to be used
- * @param forceSave true
if saving is needed before
- * executing the refactoring
- *
- * @exception CoreException if the user interface can't be activated
- */
- public static void run(Refactoring refactoring, Shell parent, boolean forceSave) throws CoreException {
- IRefactoringProcessor processor= (IRefactoringProcessor)refactoring.getAdapter(IRefactoringProcessor.class);
- // TODO this should change. Either IRefactoring models Refactoring API.
- Assert.isNotNull(processor);
- UserInterfaceStarter starter= new UserInterfaceStarter();
- if(starter != null) {
- starter.activate(refactoring, parent, forceSave);
- } else
- {
- MessageDialog.openInformation(parent,
- refactoring.getName(),
- RefactoringMessages.getString("UserInterfaceStarter.No_ui_found")); //$NON-NLS-1$
- }
- }
-
- protected void activate(Refactoring refactoring, Shell parent, boolean save) throws CoreException {
- RenameElementWizard wizard= new RenameElementWizard();
- wizard.initialize(refactoring);
- new RefactoringStarter().activate(refactoring, wizard, parent, wizard.getDefaultPageTitle(), save);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RedoRefactoringAction.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RedoRefactoringAction.java
deleted file mode 100644
index 76b89757d52..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RedoRefactoringAction.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring.actions;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchSite;
-
-public class RedoRefactoringAction extends UndoManagerAction {
-
- private int fPatternLength;
- private CEditor fEditor;
-
- public RedoRefactoringAction(CEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- }
-
- public RedoRefactoringAction(IWorkbenchSite site) {
- super(site);
- init(site.getWorkbenchWindow());
- }
-
- /* (non-Javadoc)
- * Method declared in UndoManagerAction
- */
- protected String getName() {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- return RefactoringMessages.getString("RedoRefactoringAction.name"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * Method declared in UndoManagerAction
- */
- protected IRunnableWithProgress createOperation(final ChangeContext context) {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- return new IRunnableWithProgress(){
- public void run(IProgressMonitor pm) throws InvocationTargetException {
- try {
- setPreflightStatus(Refactoring.getUndoManager().performRedo(context, pm));
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- } catch (ChangeAbortException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- };
- }
-
- /* (non-Javadoc)
- * Method declared in UndoManagerAction
- */
- protected UndoManagerAdapter createUndoManagerListener() {
- return new UndoManagerAdapter() {
- public void redoStackChanged(IUndoManager manager) {
- IAction action= getAction();
- if (action == null)
- return;
- boolean enabled= false;
- String text= null;
- if (manager.anythingToRedo()) {
- enabled= true;
- text= getActionText();
- } else {
- text= RefactoringMessages.getString("RedoRefactoringAction.label"); //$NON-NLS-1$
- }
- action.setEnabled(enabled);
- action.setText(text);
- }
- };
- }
-
- /* (non-Javadoc)
- */
- public void selectionChanged(ISelection s) {
- selectionChanged(this, s);
- }
-
- /* (non-Javadoc)
- */
- public void selectionChanged(IAction action, ISelection s) {
- if (!isHooked()) {
- hookListener(action);
- }
- fPatternLength= RefactoringMessages.getString("RedoRefactoringAction.extendedLabel").length(); //$NON-NLS-1$
- IUndoManager undoManager = Refactoring.getUndoManager();
- if (undoManager.anythingToRedo()) {
- if (undoManager.peekRedoName() != null)
- action.setText(getActionText());
- action.setEnabled(true);
- } else {
- action.setEnabled(false);
- }
- }
-
- private String getActionText() {
- return shortenText(RefactoringMessages.getFormattedString(
- "RedoRefactoringAction.extendedLabel", //$NON-NLS-1$
- Refactoring.getUndoManager().peekRedoName()), fPatternLength);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringAction.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringAction.java
deleted file mode 100644
index 6ee031a1868..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/RenameRefactoringAction.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring.actions;
-
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.corext.refactoring.RenameRefactoring;
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.cdt.internal.ui.refactoring.UserInterfaceStarter;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchSite;
-
-
-public class RenameRefactoringAction extends SelectionDispatchAction {
-
- private CEditor fEditor;
-
- public RenameRefactoringAction(CEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- }
-
- public RenameRefactoringAction(IWorkbenchSite site) {
- super(site);
- setText(RefactoringMessages.getString("RenameRefactoringAction.text"));//$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(selection.size() == 1);
- }
-
- public void selectionChanged(ITextSelection selection) {
- boolean enable = true;
- IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
- ICElement element = manager.getWorkingCopy(fEditor.getEditorInput());
- if((element == null) || (element instanceof ITranslationUnit)){
- setEnabled(false);
- return;
- }
- ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
-
- if (textSelection == null) {
- setEnabled(false);
- return;
- }
- if (element instanceof ISourceReference) {
- try {
- ISourceReference sourceRef = (ISourceReference)element;
- ISourceRange range = sourceRef.getSourceRange();
- if( (range.getIdStartPos() != textSelection.getOffset())
- || (range.getIdLength() != textSelection.getLength())) {
- enable = false;
- }
- } catch (CModelException e) {
- //
- }
- }
- setEnabled(enable);
- }
-
- public void run(ITextSelection selection) {
- try {
- Object element= SelectionConverter.getElementAtOffset(fEditor);
- RenameRefactoring refactoring= new RenameRefactoring(element);
- run(refactoring, getShell());
- } catch (CoreException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.getString("RenameRefactoringAction.label"), //$NON-NLS-1$
- RefactoringMessages.getString("RenameRefactoringAction.unexpected_exception"));//$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- Object element= selection.getFirstElement();
- try {
- RenameRefactoring refactoring= new RenameRefactoring(element);
- run(refactoring, getShell());
- } catch (CoreException e) {
- ExceptionHandler.handle(e, getShell(), RefactoringMessages.getString("RenameRefactoringAction.label"), //$NON-NLS-1$
- RefactoringMessages.getString("RenameRefactoringAction.unexpected_exception"));//$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- run();
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- action.setEnabled(true);
- }
-
- public static void run(RenameRefactoring refactoring, Shell parent) throws CoreException {
- if (refactoring.isAvailable()) {
- UserInterfaceStarter.run(refactoring, parent);
- } else {
- MessageDialog.openInformation(parent, RefactoringMessages.getString("RenameRefactoringAction.label"), //$NON-NLS-1$
- RefactoringMessages.getString("RenameRefactoringAction.no_refactoring_available")//$NON-NLS-1$
- );
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/UndoManagerAction.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/UndoManagerAction.java
deleted file mode 100644
index c17d4d42ad9..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/UndoManagerAction.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring.actions;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
-import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatusEntry;
-import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
-import org.eclipse.cdt.internal.ui.refactoring.AbortChangeExceptionHandler;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-abstract class UndoManagerAction extends SelectionDispatchAction {
-
- private static final int MAX_LENGTH= 30;
-
- private RefactoringStatus fPreflightStatus;
- private IAction fAction;
- private IWorkbenchWindow fWorkbenchWindow;
- private UndoManagerAdapter fUndoManagerListener;
-
- public UndoManagerAction(IWorkbenchSite site) {
- super(site);
- }
-
- protected abstract IRunnableWithProgress createOperation(ChangeContext context);
-
- protected abstract UndoManagerAdapter createUndoManagerListener();
-
- protected abstract String getName();
-
- protected IWorkbenchWindow getWorkbenchWindow() {
- return fWorkbenchWindow;
- }
-
- protected IAction getAction() {
- return fAction;
- }
-
- protected boolean isHooked() {
- return fAction != null;
- }
-
- protected void hookListener(IAction action) {
- if (isHooked())
- return;
- fAction= action;
- fUndoManagerListener= createUndoManagerListener();
- Refactoring.getUndoManager().addListener(fUndoManagerListener);
- }
-
- protected String shortenText(String text, int patternLength) {
- int length= text.length();
- final int finalLength = MAX_LENGTH + patternLength;
- if (text.length() <= finalLength)
- return text;
- StringBuffer result= new StringBuffer();
- int mid= finalLength / 2;
- result.append(text.substring(0, mid));
- result.append("..."); //$NON-NLS-1$
- result.append(text.substring(length - mid));
- return result.toString();
- }
-
- /* (non-Javadoc)
- * Method declared in IActionDelegate
- */
- public void dispose() {
- if (fUndoManagerListener != null)
- Refactoring.getUndoManager().removeListener(fUndoManagerListener);
- fWorkbenchWindow= null;
- fAction= null;
- fUndoManagerListener= null;
- }
-
- /* (non-Javadoc)
- */
- public void init(IWorkbenchWindow window) {
- fWorkbenchWindow= window;
- }
- public void run(IStructuredSelection selection) {
- run();
- }
- public void run(IAction action) {
- run();
- }
- /* (non-Javadoc)
- */
- public void run() {
- Shell parent= fWorkbenchWindow.getShell();
- ChangeContext context= new ChangeContext(new AbortChangeExceptionHandler(), getUnsavedFiles());
- IRunnableWithProgress op= createOperation(context);
- try {
- // Don't execute in separate thread since it updates the UI.
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(false, false, op);
- } catch (InvocationTargetException e) {
- Refactoring.getUndoManager().flush();
- ExceptionHandler.handle(e, RefactoringMessages.getString("UndoManagerAction.error"), RefactoringMessages.getString("UndoManagerAction.internal_error")); //$NON-NLS-2$ //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Opertation isn't cancelable.
- } finally {
- context.clearPerformedChanges();
- }
-
- if (fPreflightStatus != null && fPreflightStatus.hasError()) {
- String name= getName();
- MultiStatus status = createMultiStatus();
- String message= RefactoringMessages.getFormattedString("UndoManagerAction.cannot_be_executed", name); //$NON-NLS-1$
- ErrorDialog error= new ErrorDialog(parent, name, message, status, IStatus.ERROR) {
- public void create() {
- super.create();
- buttonPressed(IDialogConstants.DETAILS_ID);
- }
- };
- error.open();
- }
- fPreflightStatus= null;
- }
-
- /* package */ void setPreflightStatus(RefactoringStatus status) {
- fPreflightStatus= status;
- }
-
- private MultiStatus createMultiStatus() {
- MultiStatus status= new MultiStatus(
- CUIPlugin.getPluginId(),
- IStatus.ERROR,
- RefactoringMessages.getString("UndoManagerAction.unsaved_filed"), //$NON-NLS-1$
- null);
- String id= CUIPlugin.getPluginId();
- for (Iterator iter= fPreflightStatus.getEntries().iterator(); iter.hasNext(); ) {
- RefactoringStatusEntry entry= (RefactoringStatusEntry)iter.next();
- status.merge(new Status(
- IStatus.ERROR,
- id,
- IStatus.ERROR,
- entry.getMessage(),
- null));
- }
- return status;
- }
-
- private IFile[] getUnsavedFiles() {
- IEditorPart[] parts= CUIPlugin.getDirtyEditors();
- List result= new ArrayList(parts.length);
- for (int i= 0; i < parts.length; i++) {
- IEditorInput input= parts[i].getEditorInput();
- if (input instanceof IFileEditorInput) {
- result.add(((IFileEditorInput)input).getFile());
- }
- }
- return (IFile[])result.toArray(new IFile[result.size()]);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/UndoRefactoringAction.java b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/UndoRefactoringAction.java
deleted file mode 100644
index 11d802346cd..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/actions/UndoRefactoringAction.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.refactoring.actions;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
-import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
-import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
-import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchSite;
-
-public class UndoRefactoringAction extends UndoManagerAction {
-
- private int fPatternLength;
- private CEditor fEditor;
-
- public UndoRefactoringAction(CEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- }
-
- public UndoRefactoringAction(IWorkbenchSite site) {
- super(site);
- init(site.getWorkbenchWindow());
- }
-
- /* (non-Javadoc)
- * Method declared in UndoManagerAction
- */
- protected String getName() {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- return RefactoringMessages.getString("UndoRefactoringAction.name"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * Method declared in UndoManagerAction
- */
- protected IRunnableWithProgress createOperation(final ChangeContext context) {
- // PR: 1GEWDUH: ITPJCORE:WINNT - Refactoring - Unable to undo refactor change
- return new IRunnableWithProgress(){
- public void run(IProgressMonitor pm) throws InvocationTargetException {
- try {
- setPreflightStatus(Refactoring.getUndoManager().performUndo(context, pm));
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- } catch (ChangeAbortException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- };
- }
-
- /* (non-Javadoc)
- * Method declared in UndoManagerAction
- */
- protected UndoManagerAdapter createUndoManagerListener() {
- return new UndoManagerAdapter() {
- public void undoStackChanged(IUndoManager manager) {
- IAction action= getAction();
- if (action == null)
- return;
- boolean enabled= false;
- String text= null;
- if (manager.anythingToUndo()) {
- enabled= true;
- text= getActionText();
- } else {
- text= RefactoringMessages.getString("UndoRefactoringAction.label"); //$NON-NLS-1$
- }
- action.setEnabled(enabled);
- action.setText(text);
- }
- };
- }
- /* (non-Javadoc)
- */
- public void selectionChanged(ISelection s) {
- selectionChanged(this, s);
- }
- /* (non-Javadoc)
- */
- public void selectionChanged(IAction action, ISelection s) {
- if (!isHooked()) {
- hookListener(this);
- }
- fPatternLength= RefactoringMessages.getString("UndoRefactoringAction.extendedLabel").length(); //$NON-NLS-1$
- IUndoManager undoManager = Refactoring.getUndoManager();
- if (undoManager.anythingToUndo()) {
- if (undoManager.peekUndoName() != null)
- action.setText(getActionText());
- action.setEnabled(true);
- } else {
- action.setEnabled(false);
- }
- }
-
- private String getActionText() {
- return shortenText(RefactoringMessages.getFormattedString(
- "UndoRefactoringAction.extendedLabel", //$NON-NLS-1$
- Refactoring.getUndoManager().peekUndoName()), fPatternLength);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/refactoringui.properties b/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/refactoringui.properties
deleted file mode 100644
index cdf897a0fe6..00000000000
--- a/core/org.eclipse.cdt.ui/refactor/org/eclipse/cdt/internal/ui/refactoring/refactoringui.properties
+++ /dev/null
@@ -1,585 +0,0 @@
-###############################################################################
-# Copyright (c) 2004 IBM Corporation and others.
-# All rights reserved. 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:
-# IBM Rational Software - Initial API and implementation
-###############################################################################
-#######################################
-# org.eclipse.jdt.internal.ui.refactoring
-#######################################
-
-RefactorActionGroup.no_refactoring_available=
Assert
is useful for for embedding runtime sanity checks
- * in code. The static predicate methods all test a condition and throw some
- * type of unchecked exception if the condition does not hold.
- * assert
statement is slated to be added to the
- * Java language in JDK 1.4, rending this class obsolete.
- * AssertionFailedException
is a runtime exception thrown
- * by some of the methods in Assert
.
- * serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructs a new exception.
- */
- public AssertionFailedException() {
- }
-
- /**
- * Constructs a new exception with the given message.
- */
- public AssertionFailedException(String detail) {
- super(detail);
- }
- }
-
- /* This class is not intended to be instantiated. */
- private Assert() {
- }
-
- /**
- * Asserts that the given object is not null
. If this
- * is not the case, some kind of unchecked exception is thrown.
- * null
unless explicitly allowed in the method's
- * specification. Similarly, results returned from API methods are never
- * null
unless explicitly allowed in the method's
- * specification. Implementations are encouraged to make regular use of
- * Assert.isNotNull
to ensure that null
- * parameters are detected as early as possible.
- * null
. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- * null
unless explicitly allowed in the method's
- * specification. Similarly, results returned from API methods are never
- * null
unless explicitly allowed in the method's
- * specification. Implementations are encouraged to make regular use of
- * Assert.isNotNull
to ensure that null
- * parameters are detected as early as possible.
- * true
. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param expression the outcome of the check
- * @return true
if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression) {
- // succeed as quickly as possible
- if (expression) {
- return true;
- }
- return isTrue(expression, ""); //$NON-NLS-1$
- }
-
- /**
- * Asserts that the given boolean is true
. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcome of the check
- * @param message the message to include in the exception
- * @return true
if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression, String message) {
- if (!expression)
- throw new AssertionFailedException(RefactoringCoreMessages.getString("Assert.assertion_failed") + message); //$NON-NLS-1$
- return expression;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/GroupDescription.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/GroupDescription.java
index 8b7e89fc521..ebf724315a8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/GroupDescription.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/textmanipulation/GroupDescription.java
@@ -14,10 +14,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.IRegion;
-
import org.eclipse.text.edits.TextEdit;
-import org.eclipse.cdt.internal.corext.Assert;
public class GroupDescription {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
index b974e080006..892ba0bcff5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
@@ -14,8 +14,8 @@ import java.util.Map;
import org.eclipse.cdt.core.ToolFactory;
import org.eclipse.cdt.core.formatter.CodeFormatter;
-import org.eclipse.cdt.internal.corext.Assert;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
index 95bf90826e4..1f26b62c86e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
@@ -17,7 +17,6 @@ import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
-import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
@@ -78,7 +77,6 @@ public class MainActionGroup extends CViewActionGroup {
CustomFiltersActionGroup fCustomFiltersActionGroup;
SelectionSearchGroup selectionSearchGroup;
- RefactoringActionGroup refactoringActionGroup;
private NewWizardMenu newWizardMenu;
@@ -161,8 +159,6 @@ public class MainActionGroup extends CViewActionGroup {
// toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
- refactoringActionGroup = new RefactoringActionGroup(getCView().getSite(), null);
-
}
/**
@@ -177,8 +173,6 @@ public class MainActionGroup extends CViewActionGroup {
if (resources.isEmpty()) {
menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
- refactoringActionGroup.fillContextMenu(menu);
- menu.add(new Separator());
importAction.selectionChanged(resources);
menu.add(importAction);
exportAction.selectionChanged(resources);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java
index 4239eeec8af..eeb7fd8d59b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java
@@ -20,7 +20,6 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ILibraryEntry;
import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.internal.corext.Assert;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
@@ -38,6 +37,7 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
index 9200567fe7b..320ba233c42 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
@@ -13,40 +13,19 @@ package org.eclipse.cdt.internal.ui.editor;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.search.BasicSearchResultCollector;
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.cdt.core.search.OrPattern;
-import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
import org.eclipse.cdt.internal.ui.codemanipulation.AddIncludesOperation;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CSearchResultLabelProvider;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IRequiredInclude;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
-import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -56,15 +35,13 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.IUpdate;
-
+// TODO this is a big TODO.
public class AddIncludeOnSelectionAction extends Action implements IUpdate {
private ITextEditor fEditor;
@@ -189,18 +166,10 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
// Try the type caching.
if (fRequiredIncludes == null && fUsings == null) {
- ITypeInfo[] typeInfos= findTypeInfos(name);
- if (typeInfos != null && typeInfos.length > 0) {
- selectResult(typeInfos, name, getShell());
- }
}
// Do a full search
if (fRequiredIncludes == null && fUsings == null) {
- IMatch[] matches = findMatches(name);
- if (matches != null && matches.length > 0) {
- selectResult(matches, name, getShell());
- }
}
} catch (BadLocationException e) {
MessageDialog.openError(getShell(), CEditorMessages.getString("AddIncludeOnSelection.error.message3"), CEditorMessages.getString("AddIncludeOnSelection.error.message4") + e.getMessage()); //$NON-NLS-2$ //$NON-NLS-1$
@@ -240,223 +209,6 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
return fs[0];
}
- /**
- * Finds a type by the simple name.
- */
- private ITypeInfo[] findTypeInfos(final String name) {
- final ITypeInfo[][] infos = new ITypeInfo[1][];
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- ITranslationUnit unit = getTranslationUnit();
- int[] types= {ICElement.C_CLASS, ICElement.C_UNION, ICElement.C_STRUCT, ICElement.C_ENUMERATION, ICElement.C_TYPEDEF};
- ITypeSearchScope scope = new TypeSearchScope();
- scope.add(unit.getCProject().getProject());
- if (!AllTypesCache.isCacheUpToDate(scope)) {
- AllTypesCache.updateCache(scope, monitor);
- }
- ITypeInfo[] results = null;
- if (!monitor.isCanceled()) {
- results = AllTypesCache.getTypes(scope, new QualifiedTypeName(name), types, true);
- if (!monitor.isCanceled()) {
- for (int i = 0; i < results.length; ++i) {
- ITypeInfo info = results[i];
- AllTypesCache.resolveTypeLocation(info, monitor);
- if (monitor.isCanceled())
- break;
- }
- }
- }
- infos[0] = results;
- }
- };
- try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(op);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), CEditorMessages.getString("AddIncludeOnSelection.error.message1"), null); //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- }
- return infos[0];
- }
-
- private IMatch[] findMatches(final String name) {
- final BasicSearchResultCollector searchResultCollector = new BasicSearchResultCollector();
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- ICProject cproject = getTranslationUnit().getCProject();
- ICSearchScope scope = SearchEngine.createCSearchScope(new ICElement[]{cproject}, true);
- OrPattern orPattern = new OrPattern();
- orPattern.addPattern(SearchEngine.createSearchPattern(
- name, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- name, ICSearchConstants.TYPE, ICSearchConstants.DEFINITIONS, false));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- name, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, false));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- name, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- name, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- name, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, false));
-
- SearchEngine searchEngine = new SearchEngine();
- searchEngine.setWaitingPolicy(ICSearchConstants.FORCE_IMMEDIATE_SEARCH);
- searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, searchResultCollector, true);
- }
- };
- try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(op);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), CEditorMessages.getString("AddIncludeOnSelection.error.message1"), null); //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Do nothing. Operation has been canceled.
- }
-
- Set set = searchResultCollector.getSearchResults();
- if (set != null) {
- IMatch[] matches = new IMatch[set.size()];
- set.toArray(matches);
- return matches;
- }
- return null;
- }
-
- private void selectResult(ITypeInfo[] results, String name, Shell shell) {
- int nResults= results.length;
- ITranslationUnit unit = getTranslationUnit();
- if (nResults == 0) {
- return; // bail out
- }
-
- int occurences = 0;
- int index = 0;
- for (int i = 0; i < results.length; i++) {
- if (name.equals(results[i].getName())) {
- occurences++;
- index = i;
- }
- }
-
- // if only one
- if (occurences == 1 || results.length == 1) {
- ITypeInfo curr= results[index];
- IRequiredInclude include = getRequiredInclude(curr, unit);
- if (include != null) {
- fRequiredIncludes = new IRequiredInclude[] { include };
- }
- if (curr.hasEnclosedTypes()) {
- ITypeInfo[] ns = curr.getEnclosedTypes();
- fUsings = new String[ns.length];
- for (int j = 0; j < fUsings.length; j++) {
- fUsings[j] = ns[j].getName();
- }
- }
- return;
- }
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY));
- dialog.setElements(results);
- dialog.setTitle(CEditorMessages.getString("AddIncludeOnSelection.label")); //$NON-NLS-1$
- dialog.setMessage(CEditorMessages.getString("AddIncludeOnSelection.description")); //$NON-NLS-1$
- if (dialog.open() == Window.OK) {
- ITypeInfo[] selects = (ITypeInfo[])dialog.getResult();
- fRequiredIncludes = new IRequiredInclude[selects.length];
- List usings = new ArrayList(selects.length);
- for (int i = 0; i < fRequiredIncludes.length; i++) {
- IRequiredInclude include = getRequiredInclude(selects[i], unit);
- if (include != null) {
- fRequiredIncludes[i] = include;
- if (selects[i].hasEnclosedTypes()) {
- ITypeInfo[] ns = results[0].getEnclosedTypes();
- for (int j = 0; j < ns.length; j++) {
- usings.add(ns[j].getName());
- }
- }
- } else {
- fRequiredIncludes[i] = new RequiredIncludes(""); //$NON-NLS-1$
- }
- }
- if (!usings.isEmpty()) {
- fUsings = new String[usings.size()];
- usings.toArray(fUsings);
- }
- }
- }
-
- private IRequiredInclude getRequiredInclude(ITypeInfo curr, ITranslationUnit tu) {
- ITypeReference ref = curr.getResolvedReference();
- if (ref != null) {
- IPath typeLocation = ref.getLocation();
- IProject project = tu.getCProject().getProject();
- IPath projectLocation = project.getLocation();
- IPath headerLocation = tu.getResource().getLocation();
- boolean isSystemIncludePath = false;
-
- IPath includePath = PathUtil.makeRelativePathToProjectIncludes(typeLocation, project);
- if (includePath != null && !projectLocation.isPrefixOf(typeLocation)) {
- isSystemIncludePath = true;
- } else if (projectLocation.isPrefixOf(typeLocation)
- && projectLocation.isPrefixOf(headerLocation)) {
- includePath = PathUtil.makeRelativePath(typeLocation, headerLocation.removeLastSegments(1));
- }
- if (includePath == null)
- includePath = typeLocation;
- return new RequiredIncludes(includePath.toString(), isSystemIncludePath);
- }
- return null;
- }
-
- private void selectResult(IMatch[] results, String name, Shell shell) {
- int nResults = results.length;
- if (nResults == 0) {
- return;
- }
-
- int occurences = 0;
- int index = 0;
- for (int i= 0; i < results.length; i++) {
- IMatch curr= results[i];
- if (curr.getName().startsWith(name)) {
- occurences++;
- index = i;
- }
- }
-
- // if only one
- if (occurences == 1 || results.length == 1) {
- IMatch curr = results[index];
- fRequiredIncludes = new IRequiredInclude[1];
- fRequiredIncludes[0] = new RequiredIncludes(curr.getLocation().lastSegment());
- String parentName = curr.getParentName();
- if (parentName != null && parentName.length() > 0) {
- fUsings = new String[] {parentName};
- }
- return;
- }
-
- // Make them choose
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new CSearchResultLabelProvider(null));
- dialog.setElements(results);
- dialog.setTitle(CEditorMessages.getString("AddIncludeOnSelection.label")); //$NON-NLS-1$
- dialog.setMessage(CEditorMessages.getString("AddIncludeOnSelection.description")); //$NON-NLS-1$
- if (dialog.open() == Window.OK) {
- IMatch[] selects = (IMatch[])dialog.getResult();
- fRequiredIncludes = new IRequiredInclude[selects.length];
- List usings = new ArrayList(selects.length);
- for (int i = 0; i < fRequiredIncludes.length; i++) {
- fRequiredIncludes[i] = new RequiredIncludes(selects[i].getLocation().lastSegment());
- String parentName = selects[i].getParentName();
- if (parentName != null && parentName.length() > 0) {
- usings.add(parentName);
- }
- }
- if (!usings.isEmpty()) {
- fUsings = new String [usings.size()];
- usings.toArray(fUsings);
- }
- }
- }
-
public void setContentEditor(ITextEditor editor) {
fEditor= editor;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
index 5955561abac..a7133ba02d4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
@@ -35,7 +35,6 @@ import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -84,7 +83,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
private MemberFilterActionGroup fMemberFilterActionGroup;
private ActionGroup fSelectionSearchGroup;
- private ActionGroup fRefactoringActionGroup;
private ActionGroup fOpenViewActionGroup;
/**
* Custom filter action group.
@@ -245,8 +243,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
fSelectionSearchGroup.fillContextMenu(menu);
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
-
- fRefactoringActionGroup.fillContextMenu(menu);
}
protected CContentOutlinerProvider createContentProvider(TreeViewer viewer) {
@@ -300,7 +296,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
fSelectionSearchGroup = new SelectionSearchGroup(this);
- fRefactoringActionGroup = new RefactoringActionGroup(this, null);
fOpenViewActionGroup = new OpenViewActionGroup(this);
// Custom filter group
fCustomFiltersActionGroup= new CustomFiltersActionGroup("org.eclipse.cdt.ui.COutlinePage", getTreeViewer()); //$NON-NLS-1$
@@ -327,10 +322,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
fMemberFilterActionGroup= null;
}
- if (fRefactoringActionGroup != null) {
- fRefactoringActionGroup.dispose();
- fRefactoringActionGroup= null;
- }
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.dispose();
fOpenViewActionGroup= null;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index b39561fdb16..6aa710a1d85 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -31,7 +31,6 @@ import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
import org.eclipse.cdt.internal.ui.actions.JoinLinesAction;
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
-import org.eclipse.cdt.internal.ui.browser.typehierarchy.OpenTypeHierarchyAction;
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
@@ -43,7 +42,6 @@ import org.eclipse.cdt.internal.ui.util.CUIHelp;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
import org.eclipse.cdt.ui.actions.ShowInCViewAction;
import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
import org.eclipse.core.resources.IFile;
@@ -153,8 +151,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
/** Search actions **/
private ActionGroup fSelectionSearchGroup;
- /** Groups refactoring actions. */
- private ActionGroup fRefactoringActionGroup;
/** Action which shows selected element in CView. */
private ShowInCViewAction fShowInCViewAction;
@@ -573,7 +569,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fCEditorErrorTickUpdater = null;
}
- final CSourceViewer sourceViewer = (CSourceViewer) getSourceViewer();
if (fSelectionUpdateListener != null) {
getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener);
fSelectionUpdateListener = null;
@@ -600,11 +595,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fShowInCViewAction = null;
}
- if (fRefactoringActionGroup != null) {
- fRefactoringActionGroup.dispose();
- fRefactoringActionGroup = null;
- }
-
if (fSelectionSearchGroup != null) {
fSelectionSearchGroup.dispose();
fSelectionSearchGroup = null;
@@ -744,7 +734,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
//Assorted action groupings
fSelectionSearchGroup = new SelectionSearchGroup(this);
- fRefactoringActionGroup = new RefactoringActionGroup(this, null);
}
/**
@@ -776,9 +765,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ShowInCView"); //$NON-NLS-1$
- fRefactoringActionGroup.fillContextMenu(menu);
fSelectionSearchGroup.fillContextMenu(menu);
-
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
index b5652fde336..7bb85607486 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
@@ -16,6 +16,7 @@ import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IAnnotationModel;
@@ -51,18 +52,11 @@ public class ExternalSearchDocumentProvider extends FileDocumentProvider {
*/
private IAnnotationModel createExternalSearchAnnotationModel(ExternalEditorInput externalInput) {
- Object storage = externalInput.getStorage();
- ExternalSearchFile externalSearchFile = null;
- if (storage instanceof ExternalSearchFile){
- externalSearchFile = (ExternalSearchFile) storage;
- }
-
- if (externalSearchFile == null)
- return null;
+ IStorage storage = externalInput.getStorage();
IProject projectToUseForMarker = null;
- IFile resourceFile = CUIPlugin.getWorkspace().getRoot().getFileForLocation(externalSearchFile.searchMatch.getReferringElement());
+ IFile resourceFile = CUIPlugin.getWorkspace().getRoot().getFileForLocation(storage.getFullPath());
if (resourceFile == null){
IProject[] proj = CUIPlugin.getWorkspace().getRoot().getProjects();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchFile.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchFile.java
deleted file mode 100644
index 2847af1c223..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchFile.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.editor;
-
-import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.core.runtime.IPath;
-
-public class ExternalSearchFile extends FileStorage {
-
- IPath referringElement;
- BasicSearchMatch searchMatch;
- /**
- * @param path
- */
- public ExternalSearchFile(IPath path, BasicSearchMatch searchMatch) {
- super(path);
- this.searchMatch = searchMatch;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java
index 01196951793..2d4e3237e53 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java
@@ -11,6 +11,8 @@
package org.eclipse.cdt.internal.ui.indexview;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.ui.search.PDOMSearchBindingQuery;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -39,7 +41,11 @@ public class FindDeclarationsAction extends IndexAction {
}
public void run() {
- PDOMSearchBindingQuery query = new PDOMSearchBindingQuery(getBinding(),
+ PDOMBinding binding = getBinding();
+ ICProject project = binding.getPDOM().getProject();
+ PDOMSearchBindingQuery query = new PDOMSearchBindingQuery(
+ new ICElement[] { project },
+ getBinding(),
PDOMSearchBindingQuery.FIND_DECLARATIONS | PDOMSearchBindingQuery.FIND_DEFINITIONS);
NewSearchUI.activateSearchResultView();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java
index 9a0f1a8dbef..d8ecd501b53 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java
@@ -11,6 +11,8 @@
package org.eclipse.cdt.internal.ui.indexview;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.ui.search.PDOMSearchBindingQuery;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -39,7 +41,12 @@ public class FindReferencesAction extends IndexAction {
}
public void run() {
- PDOMSearchBindingQuery query = new PDOMSearchBindingQuery(getBinding(), PDOMSearchBindingQuery.FIND_REFERENCES);
+ PDOMBinding binding = getBinding();
+ ICProject project = binding.getPDOM().getProject();
+ PDOMSearchBindingQuery query = new PDOMSearchBindingQuery(
+ new ICElement[] { project },
+ getBinding(),
+ PDOMSearchBindingQuery.FIND_REFERENCES);
NewSearchUI.activateSearchResultView();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchContentProvider.java
deleted file mode 100644
index 2311f4fcc49..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchContentProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public abstract class CSearchContentProvider implements IStructuredContentProvider {
- protected CSearchResult _result;
- protected final Object[] EMPTY_ARR= new Object[0];
-
- public Object[] getElements(Object inputElement) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void dispose() {
- // TODO Auto-generated method stub
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- initialize((CSearchResult) newInput);
- }
-
- protected void initialize(CSearchResult result) {
- _result= result;
- }
-
- public abstract void elementsChanged(Object[] updatedElements);
- public abstract void clear();
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java
deleted file mode 100644
index 6f32c3f4357..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMatch.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 QNX Software Systems and others.
- * All rights reserved. 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Jun 27, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.search.ui.text.Match;
-
-/**
- * @author bgheorgh
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class CSearchMatch extends Match {
-
- private BasicSearchMatch searchMatch;
- /**
- * @param element
- * @param offset
- * @param length
- */
- public CSearchMatch(Object element, int offset, int length, IMatch match) {
- super(element, offset, length);
- if (match instanceof BasicSearchMatch)
- searchMatch = (BasicSearchMatch)match;
- }
-
- /**
- * @return Returns the searchMatch.
- */
- public BasicSearchMatch getSearchMatch() {
- return searchMatch;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
deleted file mode 100644
index b27fab154c8..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-/*
- * Created on Mar 26, 2004
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.ICSearchPattern;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.LimitTo;
-import org.eclipse.cdt.core.search.OrPattern;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.core.search.SearchFor;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-/**
- * @author bog
- */
-public class CSearchQuery implements ISearchQuery, ICSearchConstants {
-
- private IWorkspace _workspace;
- private ICSearchScope _scope;
- private String _stringPattern;
- private String _scopeDescription;
- private boolean _caseSensitive;
- private LimitTo _limitTo;
- private List _searchFor;
- private CSearchResult _result;
-
- public CSearchQuery(IWorkspace workspace, String pattern, boolean caseSensitive, List searchFor, LimitTo limitTo, ICSearchScope scope, String scopeDescription) {
- this( workspace, limitTo, scope, scopeDescription );
- _stringPattern = pattern;
- _caseSensitive = caseSensitive;
- _searchFor = searchFor;
- }
-
- public CSearchQuery(IWorkspace workspace, LimitTo limitTo, ICSearchScope scope, String scopeDescription){
- _workspace = workspace;
- _limitTo = limitTo;
- _scope = scope;
- _scopeDescription = scopeDescription;
- }
-
- /**
- * @return
- */
- public String getSingularLabel() {
- String desc = null;
-
- //if( _elementPattern != null ){
- // desc = _elementPattern.getElementName();
- //} else {
- desc = _stringPattern;
- //}
-
- String [] args = new String [] { desc, _scopeDescription };
-
- if( _limitTo == DECLARATIONS ){
- return CSearchMessages.getFormattedString( "CSearchOperation.singularDeclarationsPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else if( _limitTo == REFERENCES ){
- return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else {
- return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurrencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- }
- }
-
- /**
- * @return
- */
- public String getPluralLabelPattern() {
- String desc = null;
-
- // if( _elementPattern != null ){
- // desc = _elementPattern.getElementName();
- // } else {
- desc = _stringPattern;
- // }
-
- String [] args = new String [] { desc, "{0}", _scopeDescription }; //$NON-NLS-1$
- if( _limitTo == DECLARATIONS ){
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralDeclarationsPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else if ( _limitTo == REFERENCES ){
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else {
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurrencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- }
- }
-
- /**
- * @return
- */
- public ImageDescriptor getImageDescriptor() {
- if( _limitTo == ICSearchConstants.DECLARATIONS ){
- return CPluginImages.DESC_OBJS_SEARCH_DECL;
- } else {
- return CPluginImages.DESC_OBJS_SEARCH_REF;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus run(IProgressMonitor monitor) {
-
- final CSearchResult textResult= (CSearchResult) getSearchResult();
- textResult.removeAll();
-
- SearchEngine engine = new SearchEngine( CUIPlugin.getSharedWorkingCopies() );
-
- int totalTicks= 1000;
-
- monitor.beginTask("", totalTicks); //$NON-NLS-1$
- IProgressMonitor mainSearchPM= new SubProgressMonitor(monitor, 1000);
-
- NewSearchResultCollector finalCollector= new NewSearchResultCollector(textResult, mainSearchPM);
-
- ICSearchPattern pattern = null;
- if( _searchFor.size() > 0 ){
- if( _searchFor.size() > 1 ){
- OrPattern orPattern = new OrPattern();
- for (Iterator iter = _searchFor.iterator(); iter.hasNext();) {
- SearchFor element = (SearchFor)iter.next();
- orPattern.addPattern( SearchEngine.createSearchPattern( _stringPattern, element, _limitTo, _caseSensitive ) );
- }
-
- pattern = orPattern;
-
- } else {
- Iterator iter = _searchFor.iterator();
- pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive );
- }
-
- try {
- engine.search( _workspace, pattern, _scope, finalCollector, false );
- } catch (InterruptedException e) {
- }
- }
- monitor.done();
-
- return new Status(IStatus.OK, CUIPlugin.getPluginId(), 0,"", null); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchQuery#getLabel()
- */
- public String getLabel() {
- String label;
- if (_limitTo == REFERENCES)
- label = CSearchMessages.getString("CSearchQuery.searchfor_references"); //$NON-NLS-1$
- else if (_limitTo == DECLARATIONS)
- label = CSearchMessages.getString("CSearchQuery.searchfor_declarations"); //$NON-NLS-1$
- else if (_limitTo == DEFINITIONS)
- label = CSearchMessages.getString("CSearchQuery.searchfor_definitions"); //$NON-NLS-1$
- else if (_limitTo == ALL_OCCURRENCES)
- label = CSearchMessages.getString("CSearchQuery.searchfor_all"); //$NON-NLS-1$
- else
- label = CSearchMessages.getString("CSearchQuery.search_label"); //$NON-NLS-1$;
-
- label += " \""; //$NON-NLS-1$
- label += _stringPattern;
- label += '"';
- return label;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchQuery#canRerun()
- */
- public boolean canRerun() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground()
- */
- public boolean canRunInBackground() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchQuery#getSearchResult()
- */
- public ISearchResult getSearchResult() {
- if (_result == null)
- _result= new CSearchResult(this);
- return _result;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java
deleted file mode 100644
index d7d0bea8392..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Mar 26, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.IEditorMatchAdapter;
-import org.eclipse.search.ui.text.IFileMatchAdapter;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-/**
- * @author bog
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class CSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
- CSearchQuery cQuery;
- private static final Match[] NO_MATCHES= new Match[0];
-
- public CSearchResult(CSearchQuery query){
- cQuery = query;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#findContainedMatches(org.eclipse.core.resources.IFile)
- */
- public Match[] findContainedMatches(IFile file) {
- ICElement cElement= create(file);
- Set matches= new HashSet();
- collectMatches(matches, cElement);
- return (Match[]) matches.toArray(new Match[matches.size()]);
- }
-
- private ICElement create(IFile file){
- IProject project = file.getProject();
- ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
- return cProject;
- }
-
- private void collectMatches(Set matches, ICElement element) {
- Match[] m= getMatches(element);
- if (m.length != 0) {
- for (int i= 0; i < m.length; i++) {
- matches.add(m[i]);
- }
- }
- if (element instanceof IParent) {
- IParent parent= (IParent) element;
- try {
- ICElement[] children= parent.getChildren();
- for (int i= 0; i < children.length; i++) {
- collectMatches(matches, children[i]);
- }
- } catch (CModelException e) {
- // we will not be tracking these results
- }
-
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getFile(java.lang.Object)
- */
- public IFile getFile(Object element) {
- if (element instanceof ICElement) {
- ICElement cElement= (ICElement) element;
- element= cElement.getUnderlyingResource();
- }
- if (element instanceof IFile)
- return (IFile)element;
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#isShownInEditor(org.eclipse.search.ui.text.Match, org.eclipse.ui.IEditorPart)
- */
- public boolean isShownInEditor(Match match, IEditorPart editor) {
- IEditorInput editorInput= editor.getEditorInput();
- if (match.getElement() instanceof BasicSearchMatch) {
- BasicSearchMatch searchMatch = (BasicSearchMatch) match.getElement();
- if (editorInput instanceof IFileEditorInput){
- IFile inputFile= ((IFileEditorInput)editorInput).getFile();
- IResource matchFile = searchMatch.getResource();
- if (matchFile != null)
- return inputFile.equals(matchFile);
- else
- return false;
- }
- } else if (match instanceof CSearchMatch) {
- BasicSearchMatch searchMatch = ((CSearchMatch) match).getSearchMatch();
- if (editorInput instanceof IFileEditorInput){
- IFile inputFile= ((IFileEditorInput)editorInput).getFile();
- IResource matchFile = searchMatch.getResource();
- if (matchFile != null)
- return inputFile.equals(matchFile);
- else
- return false;
- }
- else if (editorInput instanceof ExternalEditorInput){
- String externalPath = ((ExternalEditorInput) editorInput).getFullPath();
- String searchMatchPath = searchMatch.getLocation().toString();
- if (searchMatchPath != null)
- return externalPath.equals(searchMatchPath);
- else
- return false;
-
- }
- } else if (match.getElement() instanceof IFile) {
- if (editorInput instanceof IFileEditorInput) {
- return ((IFileEditorInput)editorInput).getFile().equals(match.getElement());
- }
- }
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#findContainedMatches(org.eclipse.ui.IEditorPart)
- */
- public Match[] findContainedMatches(IEditorPart editor) {
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput instanceof IFileEditorInput) {
- IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
- return findContainedMatches(fileEditorInput.getFile());
- }
-
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getText()
- */
- public String getText() {
- int matchCount= getMatchCount();
- String format= null;
- if (matchCount == 1)
- format= cQuery.getSingularLabel();
- else
- format= cQuery.getPluralLabelPattern();
- return MessageFormat.format(format, new Object[] { new Integer(matchCount) });
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getTooltip()
- */
- public String getTooltip() {
- // TODO Auto-generated method stub
- return getText();
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return cQuery.getImageDescriptor();
- }
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getQuery()
- */
- public ISearchQuery getQuery() {
- return cQuery;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.ISearchResult#getLabel()
- */
- public String getLabel() {
- int matches = getMatchCount();
- String label = null;
- if (matches == 1)
- return cQuery.getSingularLabel();
- else
- label = cQuery.getPluralLabelPattern();
-
- return MessageFormat.format(label, new Object[]{new Integer(matches)});
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getEditorMatchAdapter()
- */
- public IEditorMatchAdapter getEditorMatchAdapter() {
- // TODO Auto-generated method stub
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getFileMatchAdapter()
- */
- public IFileMatchAdapter getFileMatchAdapter() {
- // TODO Auto-generated method stub
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.IEditorMatchAdapter#computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult, org.eclipse.ui.IEditorPart)
- */
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput instanceof IFileEditorInput) {
- IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
- return computeContainedMatches(result, fileEditorInput.getFile());
- }
- else if (editorInput instanceof ExternalEditorInput){
- ExternalEditorInput externalInput=(ExternalEditorInput) editorInput;
- return computerContainedMatches(result,externalInput.getFullPath());
- }
- return null;
- }
-
- /**
- * @param result
- * @param fullPath
- * @return
- */
- private Match[] computerContainedMatches(AbstractTextSearchResult result, String fullPath) {
- Set matches= new HashSet();
- Object[] test=result.getElements();
- collectMatches(matches, test, fullPath);
- return (Match[]) matches.toArray(new Match[matches.size()]);
- }
-
- /**
- * @param matches
- * @param test
- * @param fullPath
- */
- private void collectMatches(Set matches, Object[] test, String fullPath) {
- for (int i=0; itrue
if proposals should be ordered.
- */
- public void orderProposalsAlphabetically(boolean order) {
- fComparator.setOrderAlphabetically(order);
- }
-
- /**
- * @see IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- if (fNumberOfComputedResults == 0) {
- String errorMsg= resultCollector.getErrorMessage();
- if (errorMsg == null || errorMsg.length() == 0)
- errorMsg= CUIMessages.getString("CEditor.contentassist.noCompletions"); //$NON-NLS-1$
- return errorMsg;
- }
-
- return resultCollector.getErrorMessage();
- }
-
- /**
- * @see IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- if(fValidator == null) {
- fValidator = new CParameterListValidator();
- }
- return fValidator;
- }
-
- /**
- * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /**
- * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
- List result= addContextInformations(viewer, offset);
- return (IContextInformation[]) result.toArray(new IContextInformation[result.size()]);
- }
-
- private List addContextInformations(ITextViewer viewer, int offset) {
- ICompletionProposal[] proposals= internalComputeCompletionProposals(viewer, offset);
-
- List result= new ArrayList();
- for (int i= 0; i < proposals.length; i++) {
- IContextInformation contextInformation= proposals[i].getContextInformation();
- if (contextInformation != null) {
- ContextInformationWrapper wrapper= new ContextInformationWrapper(contextInformation);
- wrapper.setContextInformationPosition(offset);
- result.add(wrapper);
- }
- }
- return result;
- }
-
- /**
- * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return fProposalAutoActivationSet;
- }
-
- /**
- * Sets this processor's set of characters triggering the activation of the
- * completion proposal computation.
- *
- * @param activationSet the activation set
- */
- public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
- fProposalAutoActivationSet = activationSet;
- }
-
- /**
- * Tells this processor to restrict is proposals to those
- * starting with matching cases.
- *
- * @param restrict true
if proposals should be restricted
- */
- public void restrictProposalsToMatchingCases(boolean restrict) {
- // not yet supported
- }
-
- /**
- * Tells this processor to add include statement for proposals that have
- * a fully qualified type name
- *
- * @param restrict true
if import can be added
- */
- public void allowAddingIncludes(boolean allowAddingIncludes) {
- fAllowAddIncludes = allowAddingIncludes;
- }
-
- /**
- * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- return internalComputeCompletionProposals(viewer, offset);
- }
-
- private ICompletionProposal[] internalComputeCompletionProposals(ITextViewer viewer, int offset) {
- IWorkingCopy unit = fManager.getWorkingCopy(fEditor.getEditorInput());
-
- IDocument document = viewer.getDocument();
-
- // check for :: and ->
- int pos = offset -1;
- if(pos >= 0){
- try{
- if ((document.getChar(pos) == ':') && (document.getChar(pos -1) != ':')) {
- // ignore this request
- return null;
- } else if ((document.getChar(pos) == '>') && (document.getChar(pos - 1) != '-')) {
- // ignore this request
- return null;
- }
- } catch ( BadLocationException ex ){
- // ignore this request
- return null;
- }
- }
-
- ICCompletionProposal[] results = null;
- try {
- results = evalProposals(document, offset, unit, viewer);
- } catch (Exception e) {
- CUIPlugin.getDefault().log(e);
- }
-
- fNumberOfComputedResults= (results == null ? 0 : results.length);
-
- if (results == null)
- results = new ICCompletionProposal[0];
-
- /*
- * Order here and not in result collector to make sure that the order
- * applies to all proposals and not just those of the compilation unit.
- */
- order(results);
- return results;
- }
- /**
- * Order the given proposals.
- */
- private ICCompletionProposal[] order(ICCompletionProposal[] proposals) {
- if(proposals != null)
- Arrays.sort(proposals, fComparator);
- return proposals;
- }
-
- /**
- * Evaluate the actual proposals for C
- */
- public ICCompletionProposal[] evalProposals(IDocument document, int documentOffset, IWorkingCopy unit, ITextViewer viewer) {
- // setup the global variables
- fCurrentOffset = documentOffset;
- fCurrentSourceUnit = unit;
- fTextViewer = viewer;
-
- final List completions = new Vector();
-
- if (fCurrentSourceUnit == null)
- return null;
-
- // clear the completion list at the result collector
- resultCollector.reset(viewer);
-
- fCurrentCompletionNode = addProposalsFromModel(completions);
- if (fCurrentCompletionNode != null) {
- addProposalsFromSearch(fCurrentCompletionNode, completions);
- addProposalsFromCompletionContributors(fCurrentCompletionNode, completions);
- addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions);
- removeRepeatedProposals(completions);
- return order( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]));
- }
- return null;
- }
-
- /**
- * Removes duplicated proposals.
- * @param completions Completions to check.
- */
- private void removeRepeatedProposals(List completions) {
- final int size = completions.size();
- final ICompletionProposal[] proposalsToCheck = (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[size]);
- for (int i = 0; i < size; i++) {
- for (int j = i + 1; j < size; j++) {
- if (proposalsToCheck[i].equals(proposalsToCheck[j])) {
- completions.remove(proposalsToCheck[j]);
- break;
- }
- }
- }
- }
-
- private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){
- if (completionNode == null)
- return;
-
- if (viewer == null)
- return;
-
- IASTCompletionNode.CompletionKind kind = completionNode.getCompletionKind();
-
-
-// if ((kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE) ||
-// (kind == IASTCompletionNode.CompletionKind.CLASS_REFERENCE)
-// || (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)) {
- addProposalsFromTemplateEngine(viewer, fTemplateEngine, completions);
-// }
- }
-
- private void addProposalsFromTemplateEngine(ITextViewer viewer, TemplateEngine fTemplateEngine, List completions){
- if (fTemplateEngine != null) {
- try {
- fTemplateEngine.reset();
- fTemplateEngine.complete(viewer, fCurrentOffset, fCurrentSourceUnit);
- } catch (Exception x) {
- CUIPlugin.getDefault().log(x);
- }
- completions.addAll(fTemplateEngine.getResults());
- }
- }
-
- private void addProposalsFromCompletionContributors(IASTCompletionNode completionNode, List completions) {
- if(completionNode == null)
- return;
- String prefix = completionNode.getCompletionPrefix();
- int offset = fCurrentOffset - prefix.length();
- int length = prefix.length();
-
- // calling functions should happen only within the context of a code body
- if (completionNode.getCompletionContext() != null)
- return;
-
- IFunctionSummary[] summary;
-
- ICHelpInvocationContext context = new ICHelpInvocationContext() {
-
- public IProject getProject() {
- return fCurrentSourceUnit.getCProject().getProject();
- }
-
- public ITranslationUnit getTranslationUnit() {
- return fCurrentSourceUnit;
- }
- };
- summary = CHelpProviderManager.getDefault().getMatchingFunctions(context, prefix);
- if(summary == null) {
- return;
- }
-
- for (int i = 0; i < summary.length; i++) {
- String fname = summary[i].getName() + "()"; //$NON-NLS-1$
- String fdesc = summary[i].getDescription();
- IFunctionSummary.IFunctionPrototypeSummary fproto = summary[i].getPrototype();
- String fargs = fproto.getArguments();
-
- CCompletionProposal proposal;
- proposal = new CCompletionProposal(fname,
- offset,
- length,
- CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION),
- fproto.getPrototypeString(true),
- 2,
- fTextViewer);
-
- if(fdesc != null) {
- proposal.setAdditionalProposalInfo(fdesc);
- }
-
- if(fargs != null && fargs.length() > 0) {
- proposal.setContextInformation(new ContextInformation(fname, fargs));
- // set the cursor before the closing bracket
- proposal.setCursorPosition(fname.length() - 1);
- }
-
- completions.add(proposal);
- }
- }
-
-// private FunctionPrototypeSummary getPrototype (BasicSearchMatch match) {
-// switch(match.getElementType()){
-// case ICElement.C_FUNCTION:
-// case ICElement.C_FUNCTION_DECLARATION:
-// case ICElement.C_METHOD:
-// case ICElement.C_METHOD_DECLARATION:
-// {
-// return (new FunctionPrototypeSummary ( match.getReturnType() + " " + match.getName() )); //$NON-NLS-1$
-// }
-// default:
-// return null;
-// }
-// }
-
-
- private IASTCompletionNode addProposalsFromModel(List completions){
- //invoke the completion engine
- IASTCompletionNode completionNode = completionEngine.complete(fCurrentSourceUnit, fCurrentOffset);
- return completionNode;
- }
-
- private void addProposalsFromSearch (IASTCompletionNode completionNode, List completions) {
- if(completionNode == null)
- return;
- String prefix = completionNode.getCompletionPrefix();
- int offset = fCurrentOffset - prefix.length();
- int length = prefix.length();
-
- String searchPrefix = prefix + "*"; //$NON-NLS-1$
-
- // figure out the search scope
- IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- //boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
- boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_SEARCH_SCOPE);
- ICSearchScope scope = null;
-
- if ( (projectScope)
- && ( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
- || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
- || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
- || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FIELD_TYPE) )
- && (prefix.length() > 0)){
- List elementsFound = new LinkedList();
-
- ICElement[] projectScopeElement = new ICElement[1];
- projectScopeElement[0] = fCurrentSourceUnit.getCProject();
- scope = SearchEngine.createCSearchScope(projectScopeElement, true);
-
- // search for global variables, functions, classes, structs, unions, enums, macros, and namespaces
- OrPattern orPattern = new OrPattern();
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.NAMESPACE, ICSearchConstants.DEFINITIONS, false ));
-
- if( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
- || (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)){
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.FUNCTION, ICSearchConstants.DEFINITIONS, false ));
- orPattern.addPattern(SearchEngine.createSearchPattern(
- searchPrefix, ICSearchConstants.FUNCTION, ICSearchConstants.DECLARATIONS, false ));
- }
- try {
- searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, searchResultCollector, true);
- } catch (InterruptedException e) {
- }
- elementsFound.addAll(searchResultCollector.getSearchResults());
-
- sendResultsToCollector(elementsFound.iterator(), offset, length, prefix );
- }
-
- completions.addAll(resultCollector.getCompletions());
-
- }
-
- private void sendResultsToCollector(Iterator results , int completionStart, int completionLength, String prefix){
- while (results.hasNext()){
- ASTAccessVisibility visibility;
-
- BasicSearchMatch match = (BasicSearchMatch)results.next();
- int type = match.getElementType();
- int relevance = completionEngine.computeRelevance(type, prefix, match.getName());
- switch (type){
- case ICElement.C_FIELD:
- switch (match.getVisibility()){
- case ICElement.CPP_PUBLIC:
- visibility = ASTAccessVisibility.PUBLIC;
- break;
- case ICElement.CPP_PROTECTED:
- visibility = ASTAccessVisibility.PROTECTED;
- break;
- default:
- visibility = ASTAccessVisibility.PRIVATE;
- break;
- }
- resultCollector.acceptField(
- match.getName(),
- match.getReturnType(),
- visibility,
- completionStart,
- completionLength,
- relevance);
- break;
-
- case ICElement.C_VARIABLE:
- case ICElement.C_VARIABLE_DECLARATION:
- resultCollector.acceptVariable(
- match.getName(),
- match.getReturnType(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- switch (match.getVisibility()){
- case ICElement.CPP_PUBLIC:
- visibility = ASTAccessVisibility.PUBLIC;
- break;
- case ICElement.CPP_PROTECTED:
- visibility = ASTAccessVisibility.PROTECTED;
- break;
- default:
- visibility = ASTAccessVisibility.PRIVATE;
- break;
- }
- resultCollector.acceptMethod(
- match.getName(),
- null,
- match.getReturnType(),
- visibility,
- completionStart,
- completionLength,
- relevance, true, completionStart);
- break;
- case ICElement.C_FUNCTION:
- case ICElement.C_FUNCTION_DECLARATION:
- resultCollector.acceptFunction(
- match.getName(),
- null,
- match.getReturnType(),
- completionStart,
- completionLength,
- relevance, true, completionStart);
- break;
- case ICElement.C_CLASS:
- resultCollector.acceptClass(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_STRUCT:
- resultCollector.acceptStruct(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_UNION:
- resultCollector.acceptUnion(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_NAMESPACE:
- resultCollector.acceptNamespace(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_MACRO:
- resultCollector.acceptMacro(
- match.getName(),
- completionStart,
- completionLength,
- relevance, completionStart);
- break;
- case ICElement.C_ENUMERATION:
- resultCollector.acceptEnumeration(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- case ICElement.C_ENUMERATOR:
- resultCollector.acceptEnumerator(
- match.getName(),
- completionStart,
- completionLength,
- relevance);
- break;
- default :
- break;
- } // end switch
- } // end while
- }
- /**
- * @return Returns the fCurrentCompletionNode.
- * This method is added for JUnit tests.
- */
- public IASTCompletionNode getCurrentCompletionNode() {
- return fCurrentCompletionNode;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
index d51151845c1..7d9e4acee51 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
@@ -15,12 +15,12 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.corext.refactoring.ListenerList;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.util.IProblemChangedListener;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.internal.runtime.ListenerList;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java
index 5b34ba3b991..2691a302c85 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java
@@ -11,13 +11,10 @@
package org.eclipse.cdt.internal.ui.viewsupport;
-import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
-
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -34,8 +31,6 @@ public class StatusBarUpdater implements ISelectionChangedListener {
CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_PARAMETER_NAMES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.M_EXCEPTIONS |
CElementLabels.F_APP_TYPE_SIGNATURE;
- private final TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED + TypeInfoLabelProvider.SHOW_PATH);
-
private IStatusLineManager fStatusLineManager;
public StatusBarUpdater(IStatusLineManager statusLineManager) {
@@ -62,8 +57,6 @@ public class StatusBarUpdater implements ISelectionChangedListener {
Object elem= selection.getFirstElement();
if (elem instanceof ICElement) {
return formatCElementMessage((ICElement) elem);
- } else if (elem instanceof ITypeInfo) {
- return formatTypeInfoMessage((ITypeInfo) elem);
} else if (elem instanceof IResource) {
return formatResourceMessage((IResource) elem);
}
@@ -75,10 +68,6 @@ public class StatusBarUpdater implements ISelectionChangedListener {
return CElementLabels.getElementLabel(element, LABEL_FLAGS);
}
- private String formatTypeInfoMessage(ITypeInfo info) {
- return fTypeInfoLabelProvider.getText(info);
- }
-
private String formatResourceMessage(IResource element) {
IContainer parent= element.getParent();
if (parent != null && parent.getType() != IResource.ROOT)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java
index 38f3c76259a..f7611e94afe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java
@@ -10,26 +10,19 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard;
-import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class BaseClassInfo implements IBaseClassInfo {
- private ITypeInfo fType;
private ASTAccessVisibility fAccess;
private boolean fIsVirtual;
- public BaseClassInfo(ITypeInfo type, ASTAccessVisibility access, boolean isVirtual) {
- fType = type;
+ public BaseClassInfo(ASTAccessVisibility access, boolean isVirtual) {
fAccess = access;
fIsVirtual = isVirtual;
}
- public ITypeInfo getType() {
- return fType;
- }
-
public ASTAccessVisibility getAccess() {
return fAccess;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
index 030f72c6411..f75ff8879bd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
@@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.ui.wizards.classwizard;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
@@ -37,8 +36,6 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
return ACCESS_PUBLIC;
}
- private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
-
/*
* @see ITableLabelProvider#getColumnImage(Object, int)
*/
@@ -47,7 +44,7 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
return null;
IBaseClassInfo info = (IBaseClassInfo) element;
- return fTypeInfoLabelProvider.getImage(info.getType());
+ return null; //fTypeInfoLabelProvider.getImage(info.getType());
}
/*
@@ -58,7 +55,7 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
switch (columnIndex) {
case 0:
- return fTypeInfoLabelProvider.getText(info.getType());
+ return null; //fTypeInfoLabelProvider.getText(info.getType());
case 1:
return getAccessText(info.getAccess());
case 2:
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java
index 8c80b88ddb9..ee658e6874b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java
@@ -10,12 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard;
-import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public interface IBaseClassInfo {
- public ITypeInfo getType();
public ASTAccessVisibility getAccess();
public boolean isVirtual();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
index 4e648bf5d92..15b3a3f7e3d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
@@ -11,19 +11,13 @@
package org.eclipse.cdt.internal.ui.wizards.classwizard;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-import org.eclipse.cdt.core.browser.ITypeInfo;
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
@@ -34,7 +28,6 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
private List fTypeListeners;
public interface ITypeSelectionListener {
- void typeAdded(ITypeInfo baseClass);
}
public NewBaseClassSelectionDialog(Shell parent) {
@@ -58,19 +51,6 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
fTypeListeners.remove(listener);
}
- private void notifyTypeAddedListeners(ITypeInfo type) {
- // first copy listeners in case one calls removeListener
- List list = new ArrayList(fTypeListeners);
- for (Iterator i = list.iterator(); i.hasNext(); ) {
- ITypeSelectionListener listener = (ITypeSelectionListener) i.next();
- listener.typeAdded(type);
- }
- }
-
- public ITypeInfo[] getAddedTypes() {
- return (ITypeInfo[])fTypeList.toArray(new ITypeInfo[fTypeList.size()]);
- }
-
/*
* @see Dialog#createButtonsForButtonBar
*/
@@ -98,61 +78,6 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
}
private void addType(Object elem) {
- if (elem instanceof ITypeInfo) {
- ITypeInfo type = (ITypeInfo)elem;
- if (fTypeList.contains(type)) {
- String qualifiedName = type.getQualifiedTypeName().getFullyQualifiedName();
- String message = NewClassWizardMessages.getFormattedString("NewBaseClassSelectionDialog.classalreadyadded.info", qualifiedName); //$NON-NLS-1$
- updateStatus(new StatusInfo(IStatus.INFO, message));
- } else {
- String qualifiedName = type.getQualifiedTypeName().getFullyQualifiedName();
- String message = NewClassWizardMessages.getFormattedString("NewBaseClassSelectionDialog.addingclass.info", qualifiedName); //$NON-NLS-1$
- updateStatus(new StatusInfo(IStatus.INFO, message));
-
- boolean canAdd = true;
- if (verifyBaseClasses()) {
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- NewClassWizardUtil.resolveClassLocation(type, service);
- canAdd = (type.getResolvedReference() != null);
- }
-
-// // resolve location of base class
-// if (type.getResolvedReference() == null) {
-// final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
-// IRunnableWithProgress runnable = new IRunnableWithProgress() {
-// public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
-// AllTypesCache.resolveTypeLocation(typesToResolve[0], progressMonitor);
-// if (progressMonitor.isCanceled()) {
-// throw new InterruptedException();
-// }
-// }
-// };
-//
-// IProgressService service = PlatformUI.getWorkbench().getProgressService();
-// try {
-// service.busyCursorWhile(runnable);
-// } catch (InvocationTargetException e) {
-// String title= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.title"); //$NON-NLS-1$
-// String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$
-// ExceptionHandler.handle(e, title, errorMessage);
-// } catch (InterruptedException e) {
-// // cancelled by user
-// }
-// }
-
- if (canAdd) {
- fTypeList.add(type);
-
- message = NewClassWizardMessages.getFormattedString("NewBaseClassSelectionDialog.classadded.info", qualifiedName); //$NON-NLS-1$
- updateStatus(new StatusInfo(IStatus.INFO, message));
-
- notifyTypeAddedListeners(type);
- } else {
- message = NewClassWizardMessages.getFormattedString("NewBaseClassSelectionDialog.error.classnotadded", qualifiedName); //$NON-NLS-1$
- updateStatus(new StatusInfo(IStatus.ERROR, message));
- }
- }
- }
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
index e864b3987c1..a643b05c76b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
@@ -15,9 +15,6 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICContainer;
@@ -27,6 +24,8 @@ import org.eclipse.cdt.core.model.IIncludeEntry;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.model.util.IQualifiedTypeName;
+import org.eclipse.cdt.core.model.util.QualifiedTypeName;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
@@ -386,22 +385,22 @@ public class NewClassCodeGenerator {
if (fBaseClasses != null && fBaseClasses.length > 0) {
text.append(" : "); //$NON-NLS-1$
for (int i = 0; i < fBaseClasses.length; ++i) {
- IBaseClassInfo baseClass = fBaseClasses[i];
- String baseClassName = baseClass.getType().getQualifiedTypeName().getFullyQualifiedName();
- if (i > 0)
- text.append(", "); //$NON-NLS-1$
- if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE)
- text.append("private"); //$NON-NLS-1$
- else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED)
- text.append("private"); //$NON-NLS-1$
- else
- text.append("public"); //$NON-NLS-1$
- text.append(' ');
-
- if (baseClass.isVirtual())
- text.append("virtual "); //$NON-NLS-1$
-
- text.append(baseClassName);
+// IBaseClassInfo baseClass = fBaseClasses[i];
+// String baseClassName = baseClass.getType().getQualifiedTypeName().getFullyQualifiedName();
+// if (i > 0)
+// text.append(", "); //$NON-NLS-1$
+// if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE)
+// text.append("private"); //$NON-NLS-1$
+// else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED)
+// text.append("private"); //$NON-NLS-1$
+// else
+// text.append("public"); //$NON-NLS-1$
+// text.append(' ');
+//
+// if (baseClass.isVirtual())
+// text.append("virtual "); //$NON-NLS-1$
+//
+// text.append(baseClassName);
}
}
}
@@ -624,20 +623,20 @@ public class NewClassCodeGenerator {
private List getBaseClassPaths(boolean verifyLocation) throws CodeGeneratorException {
List list = new ArrayList();
for (int i = 0; i < fBaseClasses.length; ++i) {
- IBaseClassInfo baseClass = fBaseClasses[i];
- ITypeReference ref = baseClass.getType().getResolvedReference();
- IPath baseClassLocation = null;
- if (ref != null) {
- baseClassLocation = ref.getLocation();
- }
-
- if (baseClassLocation == null) {
- if (verifyLocation) {
- throw new CodeGeneratorException("Could not find base class " + baseClass.toString()); //$NON-NLS-1$
- }
- } else if (!list.contains(baseClassLocation)) {
- list.add(baseClassLocation);
- }
+// IBaseClassInfo baseClass = fBaseClasses[i];
+// ITypeReference ref = baseClass.getType().getResolvedReference();
+// IPath baseClassLocation = null;
+// if (ref != null) {
+// baseClassLocation = ref.getLocation();
+// }
+//
+// if (baseClassLocation == null) {
+// if (verifyLocation) {
+// throw new CodeGeneratorException("Could not find base class " + baseClass.toString()); //$NON-NLS-1$
+// }
+// } else if (!list.contains(baseClassLocation)) {
+// list.add(baseClassLocation);
+// }
}
return list;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
index 3e65de0cff8..7eaaf1780ef 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
@@ -10,40 +10,22 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
import org.eclipse.cdt.ui.CUIPlugin;
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.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -270,136 +252,5 @@ public class NewClassWizardUtil {
public static IWorkspaceRoot getWorkspaceRoot() {
return ResourcesPlugin.getWorkspace().getRoot();
}
-
- /**
- * Ensures the type cache is up to date.
- *
- * @param context the runnable context
- */
- public static void prepareTypeCache(IRunnableContext context) {
- final ITypeSearchScope scope = new TypeSearchScope(true);
- if (!AllTypesCache.isCacheUpToDate(scope)) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.updateCache(scope, monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- try {
- context.run(true, true, runnable);
- } catch (InvocationTargetException e) {
- String title = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.exception.title"); //$NON-NLS-1$
- String message = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- } catch (InterruptedException e) {
- // cancelled by user
- }
- }
- }
- /**
- * Resolve the location of the given class.
- *
- * @param type the class to resolve
- * @param context the runnable context
- * @return the class location, or null
if not found
- */
- public static ITypeReference resolveClassLocation(ITypeInfo type, IRunnableContext context) {
- prepareTypeCache(context);
-
- // resolve location of base class
- if (type.getResolvedReference() == null) {
- final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.resolveTypeLocation(typesToResolve[0], progressMonitor);
- if (progressMonitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- try {
- context.run(true, true, runnable);
- } catch (InvocationTargetException e) {
- String title = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.exception.title"); //$NON-NLS-1$
- String message = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return null;
- } catch (InterruptedException e) {
- // cancelled by user
- return null;
- }
- }
- return type.getResolvedReference();
- }
-
- private static final int[] CLASS_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
-
- /**
- * Returns all classes/structs which are accessible from the include
- * paths of the given project.
- *
- * @param project the given project
- * @return array of classes/structs
- */
- public static ITypeInfo[] getReachableClasses(IProject project) {
- ITypeInfo[] elements = AllTypesCache.getTypes(new TypeSearchScope(true), CLASS_TYPES);
- if (elements != null && elements.length > 0) {
- if (project != null) {
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- if (provider != null) {
- //TODO get the scanner info for the actual source folder
- IScannerInfo info = provider.getScannerInformation(project);
- if (info != null) {
- String[] includePaths = info.getIncludePaths();
- List filteredTypes = new ArrayList();
- for (int i = 0; i < elements.length; ++i) {
- ITypeInfo baseType = elements[i];
- if (isTypeReachable(baseType, project, includePaths)) {
- filteredTypes.add(baseType);
- }
- }
- return (ITypeInfo[]) filteredTypes.toArray(new ITypeInfo[filteredTypes.size()]);
- }
- }
- }
- }
- return elements;
- }
-
- /**
- * Checks whether the given type can be found in the given project or the
- * given include paths.
- *
- * @param type the type
- * @param project the project
- * @param includePaths the include paths
- * @return true
if the given type is found
- */
- public static boolean isTypeReachable(ITypeInfo type, IProject project, String[] includePaths) {
- IProject baseProject = type.getEnclosingProject();
- if (baseProject != null) {
- if (baseProject.equals(project)) {
- return true;
- }
- ITypeReference ref = type.getResolvedReference();
- for (int i = 0; i < includePaths.length; ++i) {
- IPath includePath = new Path(includePaths[i]);
- if (ref != null) {
- if (includePath.isPrefixOf(ref.getLocation()))
- return true;
- } else {
- // we don't have the real location, so just check the project path
- if (baseProject.getLocation().isPrefixOf(includePath))
- return true;
- }
- }
- }
- return false;
- }
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java
deleted file mode 100644
index 9e0351184f5..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-/*
- * Created on Jun 18, 2003
- */
-package org.eclipse.cdt.ui;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.search.CSearchMessages;
-import org.eclipse.cdt.internal.ui.search.CSearchResultPage;
-import org.eclipse.cdt.internal.ui.search.NewSearchResultCollector;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchResultLabelProvider extends LabelProvider {
-
- public static final int SHOW_NAME_ONLY = 0;
- public static final int SHOW_ELEMENT_CONTAINER = 1;
- public static final int SHOW_CONTAINER_ELEMENT = 2;
- public static final int SHOW_PATH = 3;//default
-
- public static final String POTENTIAL_MATCH = CSearchMessages.getString("CSearchResultLabelProvider.potentialMatch"); //$NON-NLS-1$
-
- public CSearchResultLabelProvider(){
- _sortOrder = SHOW_PATH;
- }
-
- /**
- * @param page
- */
- public CSearchResultLabelProvider(CSearchResultPage page) {
-
- // TODO Auto-generated constructor stub
- }
-
- public Image getImage( Object element ) {
- IMatch match = null;
- int elementType = -1;
- int visibility = -1;
-
- if ( element instanceof IMatch ){
- match = (IMatch) element;
- if( match == null )
- return null;
- elementType = match.getElementType();
- visibility = match.getVisibility();
- } else if (element instanceof ICElement){
- elementType = ((ICElement) element).getElementType();
- } else if (element instanceof String){
- String eleString = (String) element;
- int elIndex = eleString.indexOf(NewSearchResultCollector.ELEMENTTYPE);
- int vizIndex = eleString.indexOf(NewSearchResultCollector.VISIBILITY);
-
- String elType = eleString.substring(elIndex+NewSearchResultCollector.ELEMENTTYPE_LENGTH,vizIndex);
- String elViz = eleString.substring(vizIndex+NewSearchResultCollector.VISIBILITY_LENGTH,eleString.length());
-
- elementType = new Integer(elType).intValue();
- visibility = new Integer(elViz).intValue();
- } else if (element instanceof IPath){
- //External File; use Translation Unit
- elementType = ICElement.C_UNIT;
- }
-
-
- int flags = 0;
- ImageDescriptor imageDescriptor = null;
-
- switch( elementType ){
- case ICElement.C_PROJECT: imageDescriptor = CPluginImages.DESC_OBJS_SEARCHHIERPROJECT; break;
- case ICElement.C_CCONTAINER: imageDescriptor = CPluginImages.DESC_OBJS_SEARCHHIERFODLER; break;
- case ICElement.C_CLASS: imageDescriptor = CPluginImages.DESC_OBJS_CLASS; break;
- case ICElement.C_STRUCT: imageDescriptor = CPluginImages.DESC_OBJS_STRUCT; break;
- case ICElement.C_UNION: imageDescriptor = CPluginImages.DESC_OBJS_UNION; break;
- case ICElement.C_NAMESPACE: imageDescriptor = CPluginImages.DESC_OBJS_NAMESPACE; break;
- case ICElement.C_ENUMERATION: imageDescriptor = CPluginImages.DESC_OBJS_ENUMERATION; break;
- case ICElement.C_MACRO: imageDescriptor = CPluginImages.DESC_OBJS_MACRO; break;
- case ICElement.C_FUNCTION: imageDescriptor = CPluginImages.DESC_OBJS_FUNCTION; break;
- case ICElement.C_VARIABLE: imageDescriptor = CPluginImages.DESC_OBJS_VARIABLE; break;
- case ICElement.C_ENUMERATOR: imageDescriptor = CPluginImages.DESC_OBJS_ENUMERATOR; break;
- case ICElement.C_TYPEDEF: imageDescriptor = CPluginImages.DESC_OBJS_TYPEDEF; break;
- case ICElement.C_UNIT: imageDescriptor = CPluginImages.DESC_OBJS_TUNIT; break;
- case ICElement.C_FIELD:
- {
- switch( visibility ){
- case ICElement.CPP_PUBLIC: imageDescriptor = CPluginImages.DESC_OBJS_PUBLIC_FIELD; break;
- case ICElement.CPP_PRIVATE: imageDescriptor = CPluginImages.DESC_OBJS_PRIVATE_FIELD; break;
- default: imageDescriptor = CPluginImages.DESC_OBJS_PROTECTED_FIELD; break;
- }
- break;
- }
- case ICElement.C_METHOD:
- {
- switch( visibility ){
- case ICElement.CPP_PUBLIC: imageDescriptor = CPluginImages.DESC_OBJS_PUBLIC_METHOD; break;
- case ICElement.CPP_PRIVATE: imageDescriptor = CPluginImages.DESC_OBJS_PRIVATE_METHOD; break;
- default: imageDescriptor = CPluginImages.DESC_OBJS_PROTECTED_METHOD; break;
- }
- break;
- }
-
- case ICElement.C_TEMPLATE_CLASS:{
- imageDescriptor = CPluginImages.DESC_OBJS_CLASS;
- flags |= CElementImageDescriptor.TEMPLATE;
- break;
- }
-
- default:
- imageDescriptor = CPluginImages.DESC_OBJS_UNKNOWN;
- break;
- }
-
-
-
- if (match != null){
- if( match.isStatic() ) flags |= CElementImageDescriptor.STATIC;
- if( match.isConst() ) flags |= CElementImageDescriptor.CONSTANT;
- if( match.isVolatile() ) flags |= CElementImageDescriptor.VOLATILE;
- }
-
- imageDescriptor = new CElementImageDescriptor( imageDescriptor, flags, SMALL_SIZE );
-
- Image image = CUIPlugin.getImageDescriptorRegistry().get( imageDescriptor );
-
- return image;
- }
-
- public String getText( Object element ) {
- IMatch match = null;
-
- if( element instanceof IMatch ){
- match = (IMatch) element;
- } else if ( element instanceof ICElement){
- return getElementText((ICElement) element);
- } else if (element instanceof String){
- String elString = (String) element;
-
- int parentIndex = elString.indexOf(NewSearchResultCollector.PARENT);
- int nameIndex = elString.indexOf(NewSearchResultCollector.NAME);
- int locationIndex = elString.indexOf(NewSearchResultCollector.LOCATION);
- int elementIndex = elString.indexOf(NewSearchResultCollector.ELEMENTTYPE);
-
- String elParent = elString.substring(parentIndex+NewSearchResultCollector.PARENT_LENGTH,nameIndex);
- String elName = elString.substring(nameIndex+NewSearchResultCollector.NAME_LENGTH,locationIndex);
- String elPath = elString.substring(locationIndex+NewSearchResultCollector.LOCATION_LENGTH, elementIndex);
-
- return getCSearchSortElementText(elParent, elName, elPath);
- }
- else if (element instanceof IPath){
- return ((IPath) element).toOSString();
- }
-
- if( match == null )
- return ""; //$NON-NLS-1$
-
- IResource resource = match.getResource();
-
- String result = ""; //$NON-NLS-1$
- String path = ""; //$NON-NLS-1$
- if (resource != null){
- if (resource.isLinked()){
- path = match.getLocation().toOSString();
- }
- else{
- path = resource.getFullPath().toOSString();
- }
- }
-
- switch( getOrder() ){
- case SHOW_NAME_ONLY:
- result = match.getName();
- case SHOW_ELEMENT_CONTAINER:
- if( !match.getParentName().equals("") ) //$NON-NLS-1$
- result = match.getName() + " - " + match.getParentName() + " ( " + path + " )"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- else
- result = match.getName() + " ( " + path + " )"; //$NON-NLS-1$ //$NON-NLS-2$
-
- break;
- case SHOW_PATH:
- result = path + " - " + match.getParentName()+ "::" + match.getName(); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case SHOW_CONTAINER_ELEMENT:
- result = match.getParentName() + "::" + match.getName() + " ( " + path + " )"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- }
-
- return result;
- }
-
- /**
- * @param element
- * @return
- */
- private String getCSearchSortElementText(String parentName, String name, String path) {
- String result = ""; //$NON-NLS-1$
-
- switch( getOrder() ){
- case SHOW_NAME_ONLY:
- result = name;
- case SHOW_ELEMENT_CONTAINER:
- if( !parentName.equals("") ) //$NON-NLS-1$
- result = name + " - " + parentName + " ( " + path + " )"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- else
- result = name+ " ( " + path + " )"; //$NON-NLS-1$ //$NON-NLS-2$
-
- break;
- case SHOW_PATH:
- result = path + " - " + parentName + "::" + name; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case SHOW_CONTAINER_ELEMENT:
- result = parentName + "::" + name + " ( " + path + " )"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- }
-
- return result;
- }
-
- private String getElementText(ICElement element){
-
- String result=""; //$NON-NLS-1$
- String path=""; //$NON-NLS-1$
- ICElement parent=element.getParent();
-
-
- result = element.getElementName() + " ( " + element.getPath() + " )"; //$NON-NLS-1$ //$NON-NLS-2$
-
-
-
- return result;
- }
-
- public int getOrder(){
- return _sortOrder;
- }
- public void setOrder(int orderFlag) {
- _sortOrder = orderFlag;
- }
-
- private int _sortOrder;
- private int _textFlags;
- private int _imageFlags;
-
- private static final Point SMALL_SIZE= new Point(16, 16);
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
index 6960a028716..52e411a4bf9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
@@ -21,13 +21,11 @@ import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.browser.AllTypesCache;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
-import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
import org.eclipse.cdt.internal.corext.template.c.CContextType;
import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
import org.eclipse.cdt.internal.ui.ICStatusConstants;
@@ -433,17 +431,13 @@ public class CUIPlugin extends AbstractUIPlugin {
return CUIPlugin.getSharedWorkingCopies();
}
};
- AllTypesCache.initialize(workingCopyProvider);
CCorePlugin.getDefault().getDOM().setWorkingCopyProvider(workingCopyProvider);
-
}
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
- AllTypesCache.terminate();
-
if (fTextTools != null) {
fTextTools.dispose();
}
@@ -465,7 +459,6 @@ public class CUIPlugin extends AbstractUIPlugin {
fDocumentProvider.shutdown();
fDocumentProvider= null;
}
- Refactoring.getUndoManager().shutdown();
// Do this last.
super.stop(context);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/RefactoringActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/RefactoringActionGroup.java
deleted file mode 100644
index 2d0763d9e27..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/RefactoringActionGroup.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. 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:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.actions.ActionMessages;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
-import org.eclipse.cdt.internal.ui.refactoring.actions.RedoRefactoringAction;
-import org.eclipse.cdt.internal.ui.refactoring.actions.RenameRefactoringAction;
-import org.eclipse.cdt.internal.ui.refactoring.actions.UndoRefactoringAction;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.part.Page;
-
-/**
- * Action group that adds refactor actions (for example Rename..., Move..., etc)
- * to a context menu and the global menu bar.
- *
- * org.eclipse.cdt.ui.refactoring.menu
).
- *
- * @since 2.1
- */
- public static final String MENU_ID= "org.eclipse.cdt.ui.refactoring.menu"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: id of the reorg group of the refactor sub menu (value
- * reorgGroup
).
- *
- * @since 2.1
- */
- public static final String GROUP_REORG= "reorgGroup"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: id of the type group of the refactor sub menu (value
- * typeGroup
).
- *
- * @since 2.1
- */
- public static final String GROUP_TYPE= "typeGroup"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: id of the coding group of the refactor sub menu (value
- * codingGroup
).
- *
- * @since 2.1
- */
- public static final String GROUP_CODING= "codingGroup"; //$NON-NLS-1$
-
- /**
- * Refactor menu: name of standard Rename Element global action
- * (value "org.eclipse.cdt.ui.actions.refactor.Rename"
).
- */
- public static final String REFACTOR_RENAME= "org.eclipse.cdt.ui.actions.refactor.RenameAction"; //$NON-NLS-1$
- /**
- * Refactor menu: name of standard Undo global action
- * (value "org.eclipse.cdt.ui.actions.refactor.undo"
).
- */
- public static final String REFACTOR_UNDO= "org.eclipse.cdt.ui.actions.refactor.UndoAction"; //$NON-NLS-1$
- /**
- * Refactor menu: name of standard Redo global action
- * (value "org.eclipse.cdt.ui.actions.refactor.redo"
).
- */
- public static final String REFACTOR_REDO= "org.eclipse.cdt.ui.actions.refactor.RedoAction"; //$NON-NLS-1$
-
- private IWorkbenchSite fSite;
- private CEditor fEditor;
- private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
-
- private RenameRefactoringAction fRenameAction;
- private RedoRefactoringAction fRedoAction;
- private UndoRefactoringAction fUndoAction;
- private List fEditorActions;
-
- private static class NoActionAvailable extends Action {
- public NoActionAvailable() {
- setEnabled(false);
- setText(RefactoringMessages.getString("RefactorActionGroup.no_refactoring_available")); //$NON-NLS-1$
- }
- }
- private Action fNoActionAvailable= new NoActionAvailable();
-
- /**
- * Creates a new RefactorActionGroup
. 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 RefactoringActionGroup(IViewPart part, String groupName) {
- this(part.getSite(), groupName);
- }
-
- /**
- * Creates a new RefactorActionGroup
. The action 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 RefactoringActionGroup(Page page, String groupName) {
- this(page.getSite(), groupName);
- }
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- */
- public RefactoringActionGroup(CEditor editor, String groupName) {
- if (!isRefactoringPluginLoaded()) {
- fSite= editor.getEditorSite();
- fEditor= editor;
- if((groupName != null) && (groupName.length() > 0))
- fGroupName= groupName;
-
- ISelectionProvider provider= editor.getSelectionProvider();
- ISelection selection= provider.getSelection();
- fEditorActions= new ArrayList(3);
-
- fRenameAction= new RenameRefactoringAction(editor);
- fRenameAction.update(selection);
- editor.setAction("RenameElement", fRenameAction); //$NON-NLS-1$
- fEditorActions.add(fRenameAction);
-
- fUndoAction= new UndoRefactoringAction(editor);
- fUndoAction.update(selection);
- editor.setAction("UndoAction", fUndoAction); //$NON-NLS-1$
- fEditorActions.add(fUndoAction);
-
- fRedoAction= new RedoRefactoringAction(editor);
- fRedoAction.update(selection);
- editor.setAction("RedoAction", fRedoAction); //$NON-NLS-1$
- fEditorActions.add(fRedoAction);
- }
- }
-
- public RefactoringActionGroup(IWorkbenchSite site, String groupName) {
- if (!isRefactoringPluginLoaded()) {
- fSite= site;
- if((groupName != null) && (groupName.length() > 0))
- fGroupName= groupName;
- ISelectionProvider provider= fSite.getSelectionProvider();
- ISelection selection= provider.getSelection();
-
- fRenameAction= new RenameRefactoringAction(site);
- initAction(fRenameAction, provider, selection);
-
- fUndoAction= new UndoRefactoringAction(site);
- initAction(fUndoAction, provider, selection);
-
- fRedoAction= new RedoRefactoringAction(site);
- initAction(fRedoAction, provider, selection);
- }
- }
-
- private boolean isRefactoringPluginLoaded() {
- return Platform.getBundle("org.eclipse.cdt.refactoring") != null; //$NON-NLS-1$
- }
-
- private static void initAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection){
- action.update(selection);
- provider.addSelectionChangedListener(action);
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- if (fSite != null) {
- actionBars.setGlobalActionHandler(REFACTOR_RENAME, fRenameAction);
- actionBars.setGlobalActionHandler(REFACTOR_UNDO, fUndoAction);
- actionBars.setGlobalActionHandler(REFACTOR_REDO, fRedoAction);
- }
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- if (fSite != null) {
- addRefactorSubmenu(menu);
- }
- }
-
- /*
- * @see ActionGroup#dispose()
- */
- public void dispose() {
- if (fSite != null) {
- ISelectionProvider provider= fSite.getSelectionProvider();
-
- if (fRenameAction != null) {
- disposeAction(fRenameAction, provider);
- fRenameAction= null;
- }
-
- if (fUndoAction != null) {
- disposeAction(fUndoAction, provider);
- fUndoAction.dispose();
- fUndoAction= null;
- }
-
- if (fRedoAction != null) {
- disposeAction(fRedoAction, provider);
- fRedoAction.dispose();
- fRedoAction= null;
- }
-
- if (fEditorActions != null) {
- fEditorActions.clear();
- fEditorActions= null;
- }
- }
- super.dispose();
- }
-
- private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
- provider.removeSelectionChangedListener(action);
- }
-
- private void addRefactorSubmenu(IMenuManager menu) {
- IMenuManager refactorSubmenu= new MenuManager(ActionMessages.getString("RefactorMenu.label"), MENU_ID); //$NON-NLS-1$
- if (fEditor != null) {
- ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
- for (Iterator iter= fEditorActions.iterator(); iter.hasNext(); ) {
- SelectionDispatchAction action= (SelectionDispatchAction)iter.next();
- action.update(textSelection);
- }
- refactorSubmenu.removeAll();
- if (fillRefactorMenu(refactorSubmenu) == 0)
- refactorSubmenu.add(fNoActionAvailable);
- menu.appendToGroup(fGroupName, refactorSubmenu);
- } else {
- if (fillRefactorMenu(refactorSubmenu) > 0){
- menu.appendToGroup(fGroupName, refactorSubmenu);
- }
- }
- }
-
- private int fillRefactorMenu(IMenuManager refactorSubmenu) {
- int added= 0;
- refactorSubmenu.add(new Separator(GROUP_REORG));
- added+= addAction(refactorSubmenu, fRenameAction);
- added+= addAction(refactorSubmenu, fUndoAction);
- added+= addAction(refactorSubmenu, fRedoAction);
- return added;
- }
-
- private int addAction(IMenuManager menu, IAction action) {
- if (action != null && action.isEnabled()) {
- menu.add(action);
- return 1;
- }
- return 0;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CTagsIndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CTagsIndexerBlock.java
index f56918cbf43..abe4fb5b904 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CTagsIndexerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CTagsIndexerBlock.java
@@ -14,7 +14,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexer;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -82,26 +81,26 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
ICOptionContainer container = getContainer();
IProject proj = null;
- String internalExternalCTagsString = internalTagsFile ? CTagsIndexer.CTAGS_INTERNAL : CTagsIndexer.CTAGS_EXTERNAL;
+ String internalExternalCTagsString = ""; //internalTagsFile ? CTagsIndexer.CTAGS_INTERNAL : CTagsIndexer.CTAGS_EXTERNAL;
String cTagsFileLocation = ""; //$NON-NLS-1$
if (!internalTagsFile)
cTagsFileLocation = cTagsFile.getText();
String indexIncludeFiles = new Boolean(indexIncludePaths.getSelection()).toString();
- String cTagsLocationType = useDefaultCTags ? CTagsIndexer.CTAGS_PATH_DEFAULT : CTagsIndexer.CTAGS_PATH_SPECIFIED;
+ String cTagsLocationType = ""; //useDefaultCTags ? CTagsIndexer.CTAGS_PATH_DEFAULT : CTagsIndexer.CTAGS_PATH_SPECIFIED;
String cTagsLocation = ""; //$NON-NLS-1$
if (!useDefaultCTags)
cTagsLocation=cTagsExecutable.getText();
//if external has been chosen, ensure that there is a cTagsFileLocation selected; otherwise default
//to internal file
- if (internalExternalCTagsString.equals(CTagsIndexer.CTAGS_EXTERNAL) && cTagsFileLocation.equals("")) //$NON-NLS-1$
- internalExternalCTagsString=CTagsIndexer.CTAGS_INTERNAL;
+// if (internalExternalCTagsString.equals(CTagsIndexer.CTAGS_EXTERNAL) && cTagsFileLocation.equals("")) //$NON-NLS-1$
+// internalExternalCTagsString=CTagsIndexer.CTAGS_INTERNAL;
//if an external CPaths has been selected but no path has been provided, switch back to default setting
- if (cTagsLocationType.equals(CTagsIndexer.CTAGS_PATH_SPECIFIED) && cTagsLocation.equals("")) //$NON-NLS-1$
- cTagsLocationType=CTagsIndexer.CTAGS_PATH_DEFAULT;
+// if (cTagsLocationType.equals(CTagsIndexer.CTAGS_PATH_SPECIFIED) && cTagsLocation.equals("")) //$NON-NLS-1$
+// cTagsLocationType=CTagsIndexer.CTAGS_PATH_DEFAULT;
if (container != null){
proj = container.getProject();
@@ -127,7 +126,7 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
if (orig == null || !orig.equals(indexIncludeFiles)) {
cext[i].setExtensionData("ctagsindexincludes", indexIncludeFiles); //$NON-NLS-1$
if (indexIncludeFiles.equals( "true")){ //$NON-NLS-1$
- CCorePlugin.getDefault().getCoreModel().getIndexManager().addResource(proj,proj);
+// CCorePlugin.getDefault().getCoreModel().getIndexManager().addResource(proj,proj);
}
}
orig = cext[i].getExtensionData("ctagslocationtype"); //$NON-NLS-1$
@@ -188,10 +187,10 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
useSpecifiedCTagsExecutable = useCTagsExecutable.getSelection();
if (useDefaultCTags){
- setButtonState(CTagsIndexer.CTAGS_PATH_DEFAULT);
+// setButtonState(CTagsIndexer.CTAGS_PATH_DEFAULT);
}
if (useSpecifiedCTagsExecutable){
- setButtonState(CTagsIndexer.CTAGS_PATH_SPECIFIED);
+// setButtonState(CTagsIndexer.CTAGS_PATH_SPECIFIED);
}
}
};
@@ -246,10 +245,10 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
externalTagsFile = externalCTagsFile.getSelection();
if (externalTagsFile){
- setButtonState(CTagsIndexer.CTAGS_EXTERNAL);
+// setButtonState(CTagsIndexer.CTAGS_EXTERNAL);
}
if (internalTagsFile){
- setButtonState(CTagsIndexer.CTAGS_INTERNAL);
+// setButtonState(CTagsIndexer.CTAGS_INTERNAL);
}
}
};
@@ -335,31 +334,31 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
}
private void setButtonState(String orig){
- if (orig.equals(CTagsIndexer.CTAGS_INTERNAL)){
- internalTagsFile=true;
- externalTagsFile=false;
- internalCTagsFile.setSelection(true);
- externalCTagsFile.setSelection(false);
- browseButton.setEnabled(false);
- } else if (orig.equals(CTagsIndexer.CTAGS_EXTERNAL)){
- externalTagsFile=true;
- internalTagsFile=false;
- externalCTagsFile.setSelection(true);
- internalCTagsFile.setSelection(false);
- browseButton.setEnabled(true);
- } else if(orig.equals(CTagsIndexer.CTAGS_PATH_DEFAULT)){
- useDefaultCTags=true;
- useSpecifiedCTagsExecutable=false;
- useCTagsPath.setSelection(true);
- useCTagsExecutable.setSelection(false);
- browseButtonCTagsExec.setEnabled(false);
- } else if(orig.equals(CTagsIndexer.CTAGS_PATH_SPECIFIED)){
- useDefaultCTags=false;
- useSpecifiedCTagsExecutable=true;
- useCTagsPath.setSelection(false);
- useCTagsExecutable.setSelection(true);
- browseButtonCTagsExec.setEnabled(true);
- }
+// if (orig.equals(CTagsIndexer.CTAGS_INTERNAL)){
+// internalTagsFile=true;
+// externalTagsFile=false;
+// internalCTagsFile.setSelection(true);
+// externalCTagsFile.setSelection(false);
+// browseButton.setEnabled(false);
+// } else if (orig.equals(CTagsIndexer.CTAGS_EXTERNAL)){
+// externalTagsFile=true;
+// internalTagsFile=false;
+// externalCTagsFile.setSelection(true);
+// internalCTagsFile.setSelection(false);
+// browseButton.setEnabled(true);
+// } else if(orig.equals(CTagsIndexer.CTAGS_PATH_DEFAULT)){
+// useDefaultCTags=true;
+// useSpecifiedCTagsExecutable=false;
+// useCTagsPath.setSelection(true);
+// useCTagsExecutable.setSelection(false);
+// browseButtonCTagsExec.setEnabled(false);
+// } else if(orig.equals(CTagsIndexer.CTAGS_PATH_SPECIFIED)){
+// useDefaultCTags=false;
+// useSpecifiedCTagsExecutable=true;
+// useCTagsPath.setSelection(false);
+// useCTagsExecutable.setSelection(true);
+// browseButtonCTagsExec.setEnabled(true);
+// }
}
public void loadPreferences() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
index e640a7a5e72..38ea3478757 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
@@ -14,9 +14,7 @@ package org.eclipse.cdt.ui.dialogs;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
-import org.eclipse.cdt.core.index.ICDTIndexer;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
@@ -59,7 +57,7 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
ICOptionContainer container = getContainer();
IProject proj = null;
- String indexMarkers = getIndexerProblemsValuesString();
+// String indexMarkers = getIndexerProblemsValuesString();
if (container != null){
proj = container.getProject();
@@ -75,16 +73,16 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
for (int i = 0; i < cext.length; i++) {
String id = cext[i].getID();
String orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
- String indexProblems = getIndexerProblemsValuesString();
- if (orig == null || !orig.equals(indexProblems)) {
- cext[i].setExtensionData("indexmarkers", indexProblems); //$NON-NLS-1$
- }
+// String indexProblems = getIndexerProblemsValuesString();
+// if (orig == null || !orig.equals(indexProblems)) {
+// cext[i].setExtensionData("indexmarkers", indexProblems); //$NON-NLS-1$
+// }
}
}
} else {
if (prefStore != null) {
- prefStore.setValue(PREF_INDEX_MARKERS, indexMarkers);
+// prefStore.setValue(PREF_INDEX_MARKERS, indexMarkers);
}
}
@@ -92,14 +90,6 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
//an indexAll as one will come through the DeltaProcessor
if (currentProject == null)
return;
-
- ICDTIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(currentProject.getProject());
-
- int indexMarkersInt = Integer.parseInt(indexMarkers);
- if (indexMarkersInt != oldIndexerProblemsValue && indexMarkersInt == 0)
- if (indexer instanceof DOMSourceIndexer)
- ((DOMSourceIndexer) indexer).removeIndexerProblems(currentProject.getProject());
-
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
@@ -129,16 +119,16 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
}
- public String getIndexerProblemsValuesString(){
- int result = 0;
- result |= preprocessorProblemsEnabled.getSelection() ? DOMSourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0;
- if( syntacticProblemsEnabled != null )
- result |= syntacticProblemsEnabled.getSelection() ? DOMSourceIndexer.SYNTACTIC_PROBLEMS_BIT : 0;
- result |= semanticProblemsEnabled.getSelection() ? DOMSourceIndexer.SEMANTIC_PROBLEMS_BIT : 0;
- Integer tempInt = new Integer(result);
-
- return tempInt.toString();
- }
+// public String getIndexerProblemsValuesString(){
+// int result = 0;
+// result |= preprocessorProblemsEnabled.getSelection() ? DOMSourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0;
+// if( syntacticProblemsEnabled != null )
+// result |= syntacticProblemsEnabled.getSelection() ? DOMSourceIndexer.SYNTACTIC_PROBLEMS_BIT : 0;
+// result |= semanticProblemsEnabled.getSelection() ? DOMSourceIndexer.SEMANTIC_PROBLEMS_BIT : 0;
+// Integer tempInt = new Integer(result);
+//
+// return tempInt.toString();
+// }
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.index2.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
@@ -151,7 +141,7 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
} catch (CoreException e) {}
//Set the IProblem checkboxes
- setIndexerProblemValues(oldIndexerProblemsValue);
+// setIndexerProblemValues(oldIndexerProblemsValue);
}
public void loadPersistedValues(IProject project) throws CoreException {
@@ -172,18 +162,18 @@ public class DOMSourceIndexerBlock extends AbstractIndexerPage {
}
- public void setIndexerProblemValues( int value ){
- preprocessorProblemsEnabled.setSelection( (value & DOMSourceIndexer.PREPROCESSOR_PROBLEMS_BIT) != 0 );
- if( syntacticProblemsEnabled != null )
- syntacticProblemsEnabled.setSelection( (value & DOMSourceIndexer.SYNTACTIC_PROBLEMS_BIT) != 0 );
- semanticProblemsEnabled.setSelection( (value & DOMSourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0 );
- }
+// public void setIndexerProblemValues( int value ){
+// preprocessorProblemsEnabled.setSelection( (value & DOMSourceIndexer.PREPROCESSOR_PROBLEMS_BIT) != 0 );
+// if( syntacticProblemsEnabled != null )
+// syntacticProblemsEnabled.setSelection( (value & DOMSourceIndexer.SYNTACTIC_PROBLEMS_BIT) != 0 );
+// semanticProblemsEnabled.setSelection( (value & DOMSourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0 );
+// }
public void loadPreferences() {
String indexerId=prefStore.getString(PREF_INDEX_MARKERS);
if (!indexerId.equals("")) { //$NON-NLS-1$
oldIndexerProblemsValue = (new Integer(indexerId)).intValue();
- setIndexerProblemValues(oldIndexerProblemsValue);
+// setIndexerProblemValues(oldIndexerProblemsValue);
}
}
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 edecd4fa29f..7e1a4358d14 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
@@ -18,7 +18,6 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.internal.core.index.nullindexer.NullIndexer;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
@@ -64,8 +63,6 @@ public class IndexerBlock extends AbstractCOptionPage {
private Composite parentComposite;
private ICOptionPage currentPage;
- int nullIndexerIndex;
-
String initialSelected;
public IndexerBlock(){
@@ -241,8 +238,6 @@ public class IndexerBlock extends AbstractCOptionPage {
for (int i = 0; i < infos.length; i++) {
if (infos[i].getName().equals("indexerUI")) { //$NON-NLS-1$
String id = infos[i].getAttribute("indexerID"); //$NON-NLS-1$
- if (NullIndexer.ID.equals(id))
- nullIndexerIndex = i;
indexerPageMap.put(id, new IndexerPageConfiguration(infos[i]));
indexerPageList.add(id);
}
@@ -347,10 +342,6 @@ public class IndexerBlock extends AbstractCOptionPage {
if (currentPage != null && currentPage.getControl() != null) {
currentPage.performApply(new SubProgressMonitor(monitor, 1));
}
- //Only send out an index changed notification if the indexer has actually changed
- if (initialSelected == null || !selected.equals(initialSelected)) {
- CCorePlugin.getDefault().getCoreModel().getIndexManager().indexerChangeNotification(project);
- }
} else {
if (initialSelected == null || !selected.equals(initialSelected)) {
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 cc72c4654a7..29148d39b44 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
@@ -10,47 +10,37 @@
*******************************************************************************/
package org.eclipse.cdt.ui.wizards;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.CConventions;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeUtil;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.model.util.IQualifiedTypeName;
+import org.eclipse.cdt.core.model.util.QualifiedTypeName;
+import org.eclipse.cdt.core.model.util.TypeUtil;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog;
-import org.eclipse.cdt.internal.ui.wizards.classwizard.BaseClassInfo;
import org.eclipse.cdt.internal.ui.wizards.classwizard.BaseClassesListDialogField;
import org.eclipse.cdt.internal.ui.wizards.classwizard.ConstructorMethodStub;
import org.eclipse.cdt.internal.ui.wizards.classwizard.DestructorMethodStub;
import org.eclipse.cdt.internal.ui.wizards.classwizard.IBaseClassInfo;
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.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.SourceFileSelectionDialog;
import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardUtil;
-import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog.ITypeSelectionListener;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.SourceFileSelectionDialog;
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;
@@ -73,8 +63,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -689,25 +677,25 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
* @param access the access visibility (public/private/protected)
* @param isVirtual true
if the inheritance is virtual
*/
- protected void addBaseClass(ITypeInfo newBaseClass, ASTAccessVisibility access, boolean isVirtual) {
- // check if already exists
- List baseClasses = fBaseClassesDialogField.getElements();
- if (baseClasses != null) {
- for (Iterator i = baseClasses.iterator(); i.hasNext(); ) {
- BaseClassInfo info = (BaseClassInfo) i.next();
- if (info.getType().equals(newBaseClass)) {
- // already added
- return;
- }
- }
- }
-
- if (verifyBaseClasses()) {
- NewClassWizardUtil.resolveClassLocation(newBaseClass, getContainer());
- }
-
- fBaseClassesDialogField.addBaseClass(new BaseClassInfo(newBaseClass, access, isVirtual));
- }
+// protected void addBaseClass(ITypeInfo newBaseClass, ASTAccessVisibility access, boolean isVirtual) {
+// // check if already exists
+// List baseClasses = fBaseClassesDialogField.getElements();
+// if (baseClasses != null) {
+// for (Iterator i = baseClasses.iterator(); i.hasNext(); ) {
+// BaseClassInfo info = (BaseClassInfo) i.next();
+// if (info.getType().equals(newBaseClass)) {
+// // already added
+// return;
+// }
+// }
+// }
+//
+// if (verifyBaseClasses()) {
+// NewClassWizardUtil.resolveClassLocation(newBaseClass, getContainer());
+// }
+//
+// fBaseClassesDialogField.addBaseClass(new BaseClassInfo(newBaseClass, access, isVirtual));
+// }
/**
* Returns the selection state of the file group checkbox.
@@ -975,34 +963,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
*/
private final class NamespaceFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
public void changeControlPressed(DialogField field) {
- ITypeInfo ns = chooseNamespace();
- if (ns != null) {
- int changedFields = NAMESPACE_ID|CLASS_NAME_ID;
- IPath oldFolderPath = getSourceFolderFullPath();
- if (oldFolderPath == null) {
- IPath headerPath = getHeaderFileFullPath();
- IPath sourcePath = getSourceFileFullPath();
- IPath newFolderPath = updateSourceFolderFromPath(ns.getEnclosingProject().getFullPath());
- if (newFolderPath != null) {
- changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID;
- // adjust the relative paths
- if (oldFolderPath != null && oldFolderPath.matchingFirstSegments(newFolderPath) == 0) {
- if (headerPath != null) {
- headerPath = newFolderPath.append(headerPath.lastSegment());
- }
- if (sourcePath != null) {
- sourcePath = newFolderPath.append(sourcePath.lastSegment());
- }
- }
- setSourceFolderFullPath(newFolderPath, false);
- // adjust the relative paths
- setHeaderFileFullPath(headerPath, false);
- setSourceFileFullPath(sourcePath, false);
- }
- }
- setNamespaceText(ns.getQualifiedTypeName().toString(), false);
- handleFieldChanged(changedFields);
- }
}
public void dialogFieldChanged(DialogField field) {
@@ -1028,35 +988,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
return null;
}
- private ITypeInfo chooseNamespace() {
- ITypeSearchScope scope;
- IProject project = getCurrentProject();
- if (project != null) {
- scope = new TypeSearchScope(project);
- } else {
- scope = new TypeSearchScope(true);
- }
-
- NewClassWizardUtil.prepareTypeCache(getContainer());
-
- ITypeInfo[] elements = AllTypesCache.getNamespaces(scope, false);
- if (elements == null || elements.length == 0) {
- String title = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.noNamespaces.title"); //$NON-NLS-1$
- String message = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.noNamespaces.message"); //$NON-NLS-1$
- 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
*/
@@ -1090,29 +1021,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
private void chooseBaseClasses() {
- NewClassWizardUtil.prepareTypeCache(getContainer());
-
- ITypeInfo[] elements = NewClassWizardUtil.getReachableClasses(getCurrentProject());
- if (elements == null || elements.length == 0) {
- String title = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.noClasses.title"); //$NON-NLS-1$
- String message = NewClassWizardMessages.getString("NewClassCreationWizardPage.getTypes.noClasses.message"); //$NON-NLS-1$
- MessageDialog.openInformation(getShell(), title, message);
- return;
- }
-
- List oldContents = fBaseClassesDialogField.getElements();
- NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell());
- dialog.addListener(new ITypeSelectionListener() {
- public void typeAdded(ITypeInfo newBaseClass) {
- addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false);
- }
- });
- dialog.setElements(elements);
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID) {
- // restore the old contents
- fBaseClassesDialogField.setElements(oldContents);
- }
}
/**
@@ -1486,62 +1394,12 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
IQualifiedTypeName typeName = new QualifiedTypeName(namespace);
IProject project = getCurrentProject();
if (project != null) {
- NewClassWizardUtil.prepareTypeCache(getContainer());
-
if (typeName.isQualified()) {
// make sure enclosing namespace exists
- ITypeInfo parentNamespace = AllTypesCache.getType(project, ICElement.C_NAMESPACE, typeName.getEnclosingTypeName());
- if (parentNamespace == null) {
- status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.EnclosingNamespaceNotExists")); //$NON-NLS-1$
- return status;
- }
}
- ITypeInfo[] types = AllTypesCache.getTypes(project, typeName, false, true);
- if (types.length > 0) {
// look for namespace
- boolean foundNamespace = false;
- boolean exactMatch = false;
- for (int i = 0; i < types.length; ++i) {
- ITypeInfo currType = types[i];
- if (currType.getCElementType() == ICElement.C_NAMESPACE) {
- foundNamespace = true;
- exactMatch = currType.getQualifiedTypeName().equals(typeName);
- if (exactMatch) {
- // found a matching namespace
- break;
- }
- }
- }
- if (foundNamespace) {
- if (exactMatch) {
- // we're good to go
- status.setOK();
- } else {
- status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.NamespaceExistsDifferentCase")); //$NON-NLS-1$
- }
- return status;
- }
// look for other types
- exactMatch = false;
- for (int i = 0; i < types.length; ++i) {
- ITypeInfo currType = types[i];
- if (currType.getCElementType() != ICElement.C_NAMESPACE) {
- exactMatch = currType.getQualifiedTypeName().equals(typeName);
- if (exactMatch) {
- // found a matching type
- break;
- }
- }
- }
- if (exactMatch) {
- status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.TypeMatchingNamespaceExists")); //$NON-NLS-1$
- } else {
- status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.TypeMatchingNamespaceExistsDifferentCase")); //$NON-NLS-1$
- }
- } else {
- status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.warning.NamespaceNotExists")); //$NON-NLS-1$
- }
}
val = CConventions.validateNamespaceName(typeName.lastSegment());
@@ -1586,8 +1444,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
IProject project = getCurrentProject();
if (project != null) {
- NewClassWizardUtil.prepareTypeCache(getContainer());
-
IQualifiedTypeName fullyQualifiedName = typeName;
if (isNamespaceSelected()) {
String namespace = getNamespaceText();
@@ -1596,51 +1452,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
}
}
- ITypeInfo[] types = AllTypesCache.getTypes(project, fullyQualifiedName, false, true);
- if (types.length > 0) {
// look for class
- boolean foundClass = false;
- boolean exactMatch = false;
- for (int i = 0; i < types.length; ++i) {
- ITypeInfo currType = types[i];
- if (currType.getCElementType() == ICElement.C_CLASS
- || currType.getCElementType() == ICElement.C_STRUCT) {
- foundClass = true;
- exactMatch = currType.getQualifiedTypeName().equals(fullyQualifiedName);
- if (exactMatch) {
- // found a matching class
- break;
- }
- }
- }
- if (foundClass) {
- if (exactMatch) {
- status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.ClassNameExists")); //$NON-NLS-1$
- } else {
- status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.ClassNameExistsDifferentCase")); //$NON-NLS-1$
- }
- return status;
- }
// look for other types
- exactMatch = false;
- for (int i = 0; i < types.length; ++i) {
- ITypeInfo currType = types[i];
- if (currType.getCElementType() != ICElement.C_CLASS
- && currType.getCElementType() != ICElement.C_STRUCT) {
- exactMatch = currType.getQualifiedTypeName().equals(fullyQualifiedName);
- if (exactMatch) {
- // found a matching type
- break;
- }
- }
- }
- if (exactMatch) {
- status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.TypeMatchingClassExists")); //$NON-NLS-1$
- } else {
- status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.TypeMatchingClassExistsDifferentCase")); //$NON-NLS-1$
- }
- return status;
- }
}
return status;
}
@@ -1691,11 +1504,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
String[] includePaths = info.getIncludePaths();
for (int i = 0; i < baseClasses.length; ++i) {
IBaseClassInfo baseClass = baseClasses[i];
- ITypeInfo baseType = baseClass.getType();
StatusInfo baseClassStatus = new StatusInfo();
- if (!NewClassWizardUtil.isTypeReachable(baseType, project, includePaths)) {
- baseClassStatus.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.BaseClassNotExistsInProject", baseType.getQualifiedTypeName().toString())); //$NON-NLS-1$
- }
status.add(baseClassStatus);
}
}