use of org.python.pydev.shared_core.resource_stubs.FileStub in project Pydev by fabioz.
the class Flake8AnalysisTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
tempDir = FileUtils.getTempFileAt(new File("."), "data_flake8_analysis");
tempDir.mkdirs();
ProjectStub project = new ProjectStub(tempDir, new PythonNature());
file = new FileStub(project, new File("snippet.py"));
}
use of org.python.pydev.shared_core.resource_stubs.FileStub in project Pydev by fabioz.
the class RefactoringRenameTestBase method setUpConfigWorkspaceFiles.
public void setUpConfigWorkspaceFiles() throws Exception {
projectStub = new org.python.pydev.shared_core.resource_stubs.ProjectStub(new File(TestDependent.TEST_COM_REFACTORING_PYSRC_LOC), natureRefactoring);
TextEditCreation.createWorkspaceFile = new ICallback<IFile, File>() {
@Override
public IFile call(File file) {
return new FileStub(projectStub, file) {
@Override
public IPath getFullPath() {
return Path.fromOSString(this.file.getAbsolutePath());
}
};
}
};
}
use of org.python.pydev.shared_core.resource_stubs.FileStub in project Pydev by fabioz.
the class ProjectStub method getChildren.
// workbench adapter
@Override
public Object[] getChildren(Object o) {
Object[] found = stubsCache.get(o);
if (found != null) {
return found;
}
File folder = null;
if (o instanceof ProjectStub) {
ProjectStub projectStub = (ProjectStub) o;
folder = projectStub.projectRoot;
} else {
throw new RuntimeException("Shouldn't happen");
}
ArrayList<Object> ret = new ArrayList<Object>();
for (File file : folder.listFiles()) {
String lower = file.getName().toLowerCase();
if (lower.equals("cvs") || lower.equals(".svn")) {
continue;
}
if (file.isDirectory()) {
ret.add(new FolderStub(this, file));
} else {
ret.add(new FileStub(this, file));
}
}
if (addNullChild) {
ret.add(null);
}
ret.addAll(this.additionalChildren);
return ret.toArray();
}
use of org.python.pydev.shared_core.resource_stubs.FileStub in project Pydev by fabioz.
the class PythonModelProviderTest method testInterceptAdd.
/**
* Test if intercepting an add deep within the pythonpath structure will correctly return an object
* from the python model.
*/
public void testInterceptAdd() throws Exception {
PythonNature nature = createNature(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot/source/python");
project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature);
file = new FileStub(project, new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot/source/python/pack1/pack2/mod2.py"));
provider = new PythonModelProvider();
HashSet<Object> files = new HashSet<Object>();
files.add(file);
files.add(null);
files.add("string");
provider.interceptAdd(new PipelinedShapeModification(file.getParent(), files));
assertEquals(2, files.size());
for (Object wrappedResource : files) {
assertTrue((wrappedResource instanceof IWrappedResource && ((IWrappedResource) wrappedResource).getActualObject() == file) || wrappedResource.equals("string"));
}
}
use of org.python.pydev.shared_core.resource_stubs.FileStub in project Pydev by fabioz.
the class MypyAnalysisTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
tempDir = FileUtils.getTempFileAt(new File("."), "data_mypy_analysis");
tempDir.mkdirs();
ProjectStub project = new ProjectStub(tempDir, null);
file = new FileStub(project, new File(tempDir, "snippet.py"));
}
Aggregations