1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Create temporary files with ResourceHelper so they get cleanedup

Part of #117
This commit is contained in:
Jonah Graham 2022-10-28 10:32:14 -04:00
parent 23399e83eb
commit 6ea56953d0
3 changed files with 9 additions and 8 deletions

View file

@ -21,6 +21,7 @@ import java.io.InputStream;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.FileManager; import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds; import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
@ -54,7 +55,7 @@ import org.eclipse.ui.texteditor.AbstractTextEditor;
* *
* @author dsteffle * @author dsteffle
*/ */
public class BaseSelectionTestsIndexer extends BaseSelectionTests { public abstract class BaseSelectionTestsIndexer extends BaseSelectionTests {
protected ICProject fCProject; protected ICProject fCProject;
static FileManager fileManager = new FileManager(); static FileManager fileManager = new FileManager();
IProgressMonitor monitor = new NullProgressMonitor(); IProgressMonitor monitor = new NullProgressMonitor();
@ -109,8 +110,7 @@ public class BaseSelectionTestsIndexer extends BaseSelectionTests {
//Obtain file handle //Obtain file handle
IFile file = fCProject.getProject().getFile(fileName); IFile file = fCProject.getProject().getFile(fileName);
IPath location = new Path( IPath location = ResourceHelper.createTemporaryFolder().append(fileName);
fCProject.getProject().getLocation().removeLastSegments(1).toOSString() + File.separator + fileName);
File linkFile = new File(location.toOSString()); File linkFile = new File(location.toOSString());
if (linkFile.exists()) { if (linkFile.exists()) {

View file

@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager; import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
@ -137,7 +138,7 @@ public class CPPSelectionNoIndexerTests extends BaseSelectionTests {
//Obtain file handle //Obtain file handle
IFile file = project.getProject().getFile(fileName); IFile file = project.getProject().getFile(fileName);
IPath location = new Path(project.getLocation().removeLastSegments(1).toOSString() + File.separator + fileName); IPath location = ResourceHelper.createTemporaryFolder().append(fileName);
File linkFile = new File(location.toOSString()); File linkFile = new File(location.toOSString());
if (!linkFile.exists()) { if (!linkFile.exists()) {

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager; import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -118,12 +119,11 @@ public class CSelectionNoIndexerTests extends BaseSelectionTests {
//Obtain file handle //Obtain file handle
IFile file = project.getProject().getFile(fileName); IFile file = project.getProject().getFile(fileName);
IPath location = new Path(project.getLocation().removeLastSegments(1).toOSString() + File.separator + fileName); IPath location = ResourceHelper.createTemporaryFolder().append(fileName);
File linkFile = new File(location.toOSString()); File linkFile = new File(location.toOSString());
if (!linkFile.exists()) { assertFalse(linkFile.exists());
linkFile.createNewFile(); linkFile.createNewFile();
}
file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null); file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null);