mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Restoring non-API methods of ITranslationUnit, providing public methods for accessing shared working copies, bug 293617.
This commit is contained in:
parent
b2ab87de80
commit
d550905a0d
8 changed files with 118 additions and 34 deletions
|
@ -389,15 +389,6 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
||||||
*/
|
*/
|
||||||
boolean isWorkingCopy();
|
boolean isWorkingCopy();
|
||||||
|
|
||||||
/**
|
|
||||||
* parse()
|
|
||||||
* returns a map of all new elements and their element info
|
|
||||||
* @deprecated this is currently only used by the core tests. It should
|
|
||||||
* be removed from the interface.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Map<?,?> parse();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the language for this translation unit.
|
* Return the language for this translation unit.
|
||||||
*/
|
*/
|
||||||
|
@ -467,4 +458,30 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
||||||
* Return the completion node using the given index and parsing style at the given offset.
|
* Return the completion node using the given index and parsing style at the given offset.
|
||||||
*/
|
*/
|
||||||
public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException;
|
public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getSharedWorkingCopy(IProgressMonitor, IProblemRequestor)}, instead.
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
@Deprecated IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException;
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getSharedWorkingCopy(IProgressMonitor, IProblemRequestor)}, instead.
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
@Deprecated IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor requestor) throws CModelException;
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #findSharedWorkingCopy()}, instead.
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
@Deprecated IWorkingCopy findSharedWorkingCopy(IBufferFactory bufferFactory);
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getWorkingCopy(IProgressMonitor)}, instead.
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
@Deprecated IWorkingCopy getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException;
|
||||||
|
/**
|
||||||
|
* @deprecated don't use this method.
|
||||||
|
*/
|
||||||
|
@Deprecated Map<?,?> parse();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1110,4 +1110,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public IWorkingCopy findSharedWorkingCopy(IBufferFactory bufferFactory) {
|
||||||
|
return CModelManager.getDefault().findSharedWorkingCopy(bufferFactory, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor requestor) throws CModelException {
|
||||||
|
return CModelManager.getDefault().getSharedWorkingCopy(factory, this, requestor, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException {
|
||||||
|
return CModelManager.getDefault().getSharedWorkingCopy(factory, this, null, monitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,10 @@ import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
|
import org.eclipse.cdt.ui.CDTUITools;
|
||||||
import org.eclipse.cdt.ui.CElementGrouping;
|
import org.eclipse.cdt.ui.CElementGrouping;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.cdt.ui.IncludesGrouping;
|
import org.eclipse.cdt.ui.IncludesGrouping;
|
||||||
import org.eclipse.cdt.ui.NamespacesGrouping;
|
import org.eclipse.cdt.ui.NamespacesGrouping;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base content provider for C elements. It provides access to the
|
* A base content provider for C elements. It provides access to the
|
||||||
|
@ -210,7 +208,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
// if it is not already a working copy
|
// if it is not already a working copy
|
||||||
if (!(element instanceof IWorkingCopy)){
|
if (!(element instanceof IWorkingCopy)){
|
||||||
// if it has a valid working copy
|
// if it has a valid working copy
|
||||||
IWorkingCopy copy = CModelManager.getDefault().findSharedWorkingCopy(CUIPlugin.getDefault().getBufferFactory(), tu);
|
IWorkingCopy copy = CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(tu);
|
||||||
if (copy != null) {
|
if (copy != null) {
|
||||||
tu = copy;
|
tu = copy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,12 +77,11 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.IPersistableProblem;
|
import org.eclipse.cdt.core.parser.IPersistableProblem;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
import org.eclipse.cdt.ui.CDTUITools;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.text.ICPartitions;
|
import org.eclipse.cdt.ui.text.ICPartitions;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
|
||||||
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
|
import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
|
||||||
|
@ -861,8 +860,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
setUpSynchronization(tuInfo);
|
setUpSynchronization(tuInfo);
|
||||||
|
|
||||||
IProblemRequestor requestor= tuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) tuInfo.fModel : null;
|
IProblemRequestor requestor= tuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) tuInfo.fModel : null;
|
||||||
IBufferFactory factory = CUIPlugin.getDefault().getBufferFactory();
|
tuInfo.fCopy = CDTUITools.getWorkingCopyManager().getSharedWorkingCopy(original, requestor, getProgressMonitor());
|
||||||
tuInfo.fCopy = CModelManager.getDefault().getSharedWorkingCopy(factory, original, requestor, getProgressMonitor());
|
|
||||||
|
|
||||||
if (tuInfo.fModel == null) {
|
if (tuInfo.fModel == null) {
|
||||||
IPath location = original.getLocation();
|
IPath location = original.getLocation();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,19 +8,26 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.IProblemRequestor;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
|
import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,6 +39,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
|
||||||
private CDocumentProvider fDocumentProvider;
|
private CDocumentProvider fDocumentProvider;
|
||||||
private Map<IEditorInput, IWorkingCopy> fMap;
|
private Map<IEditorInput, IWorkingCopy> fMap;
|
||||||
private boolean fIsShuttingDown;
|
private boolean fIsShuttingDown;
|
||||||
|
private IBufferFactory fBufferFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new working copy manager that co-operates with the given
|
* Creates a new working copy manager that co-operates with the given
|
||||||
|
@ -103,4 +111,27 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
|
||||||
if (fMap.isEmpty())
|
if (fMap.isEmpty())
|
||||||
fMap= null;
|
fMap= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBufferFactory getBufferFactory() {
|
||||||
|
if (fBufferFactory == null) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (fBufferFactory == null)
|
||||||
|
fBufferFactory= new CustomBufferFactory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fBufferFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IWorkingCopy findSharedWorkingCopy(ITranslationUnit tu) {
|
||||||
|
return CModelManager.getDefault().findSharedWorkingCopy(getBufferFactory(), tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IWorkingCopy[] getSharedWorkingCopies() {
|
||||||
|
return CModelManager.getDefault().getSharedWorkingCopies(getBufferFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IWorkingCopy getSharedWorkingCopy(ITranslationUnit original, IProblemRequestor requestor,
|
||||||
|
IProgressMonitor progressMonitor) throws CModelException {
|
||||||
|
return CModelManager.getDefault().getSharedWorkingCopy(getBufferFactory(), original, requestor, progressMonitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,9 @@ import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.resources.FileStorage;
|
import org.eclipse.cdt.core.resources.FileStorage;
|
||||||
|
import org.eclipse.cdt.ui.CDTUITools;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
|
||||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
||||||
|
@ -542,7 +542,7 @@ public class EditorUtility {
|
||||||
if (cu.isWorkingCopy())
|
if (cu.isWorkingCopy())
|
||||||
return cu;
|
return cu;
|
||||||
|
|
||||||
return CModelManager.getDefault().findSharedWorkingCopy(CUIPlugin.getDefault().getBufferFactory(), cu);
|
return CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -73,7 +73,6 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
|
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
|
||||||
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||||
import org.eclipse.cdt.internal.corext.template.c.CContextType;
|
import org.eclipse.cdt.internal.corext.template.c.CContextType;
|
||||||
import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
|
import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
|
||||||
|
@ -88,7 +87,6 @@ import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
|
||||||
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
|
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
|
||||||
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
|
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
|
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CustomBufferFactory;
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
|
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.CTextFileChangeFactory;
|
import org.eclipse.cdt.internal.ui.refactoring.CTextFileChangeFactory;
|
||||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||||
|
@ -246,15 +244,15 @@ public class CUIPlugin extends AbstractUIPlugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @noreference This method is not intended to be referenced by clients.
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
* @deprecated use {@link CDTUITools#getWorkingCopyManager()}, instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public synchronized IBufferFactory getBufferFactory() {
|
public synchronized IBufferFactory getBufferFactory() {
|
||||||
if (fBufferFactory == null)
|
return ((WorkingCopyManager) getWorkingCopyManager()).getBufferFactory();
|
||||||
fBufferFactory= new CustomBufferFactory();
|
|
||||||
return fBufferFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IWorkingCopy[] getSharedWorkingCopies() {
|
public static IWorkingCopy[] getSharedWorkingCopies() {
|
||||||
return CModelManager.getDefault().getSharedWorkingCopies(getDefault().getBufferFactory());
|
return getDefault().getWorkingCopyManager().getSharedWorkingCopies();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getResourceString(String key) {
|
public static String getResourceString(String key) {
|
||||||
|
@ -384,7 +382,6 @@ public class CUIPlugin extends AbstractUIPlugin {
|
||||||
|
|
||||||
private CoreModel fCoreModel;
|
private CoreModel fCoreModel;
|
||||||
private CDocumentProvider fDocumentProvider;
|
private CDocumentProvider fDocumentProvider;
|
||||||
private IBufferFactory fBufferFactory;
|
|
||||||
private WorkingCopyManager fWorkingCopyManager;
|
private WorkingCopyManager fWorkingCopyManager;
|
||||||
private CTextTools fTextTools;
|
private CTextTools fTextTools;
|
||||||
private ProblemMarkerManager fProblemMarkerManager;
|
private ProblemMarkerManager fProblemMarkerManager;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,10 +10,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui;
|
package org.eclipse.cdt.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.IProblemRequestor;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for accessing working copies of <code>ITranslationUnit</code>
|
* Interface for accessing working copies of <code>ITranslationUnit</code>
|
||||||
* objects. The original translation unit is only given indirectly by means
|
* objects. The original translation unit is only given indirectly by means
|
||||||
|
@ -31,7 +36,7 @@ import org.eclipse.ui.IEditorInput;
|
||||||
* </p>
|
* </p>
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*
|
*
|
||||||
* @see CUIPlugin#getWorkingCopyManager
|
* @see CDTUITools#getWorkingCopyManager
|
||||||
*/
|
*/
|
||||||
public interface IWorkingCopyManager {
|
public interface IWorkingCopyManager {
|
||||||
|
|
||||||
|
@ -73,4 +78,27 @@ public interface IWorkingCopyManager {
|
||||||
* by this manager are destroyed.
|
* by this manager are destroyed.
|
||||||
*/
|
*/
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a shared working copy for the given translation unit. If necessary, a new
|
||||||
|
* working copy will be created.
|
||||||
|
* @param tu a translation unit
|
||||||
|
* @param requestor call back interface for reporting problems, may be <code>null</code>.
|
||||||
|
* @param monitor a monitor to report progress
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
IWorkingCopy getSharedWorkingCopy(ITranslationUnit tu, IProblemRequestor requestor, IProgressMonitor monitor) throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all shared working copies, currently available.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
IWorkingCopy[] getSharedWorkingCopies();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shared working copy for the given translation unit, if it exists, or <code>null</code>, otherwise.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
IWorkingCopy findSharedWorkingCopy(ITranslationUnit tu);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue