Search in sources :

Example 1 with FileStub

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"));
}
Also used : ProjectStub(org.python.pydev.shared_core.resource_stubs.ProjectStub) PythonNature(org.python.pydev.plugin.nature.PythonNature) FileStub(org.python.pydev.shared_core.resource_stubs.FileStub) File(java.io.File)

Example 2 with FileStub

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());
                }
            };
        }
    };
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) FileStub(org.python.pydev.shared_core.resource_stubs.FileStub) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 3 with FileStub

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();
}
Also used : IProjectStub(org.python.pydev.shared_core.resource_stubs.IProjectStub) AbstractIProjectStub(org.python.pydev.shared_core.resource_stubs.AbstractIProjectStub) ArrayList(java.util.ArrayList) FileStub(org.python.pydev.shared_core.resource_stubs.FileStub) FolderStub(org.python.pydev.shared_core.resource_stubs.FolderStub) File(java.io.File) IFile(org.eclipse.core.resources.IFile)

Example 4 with FileStub

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"));
    }
}
Also used : PythonNature(org.python.pydev.plugin.nature.PythonNature) PipelinedShapeModification(org.eclipse.ui.navigator.PipelinedShapeModification) FileStub(org.python.pydev.shared_core.resource_stubs.FileStub) File(java.io.File) IWrappedResource(org.python.pydev.navigator.elements.IWrappedResource) HashSet(java.util.HashSet)

Example 5 with FileStub

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"));
}
Also used : ProjectStub(org.python.pydev.shared_core.resource_stubs.ProjectStub) FileStub(org.python.pydev.shared_core.resource_stubs.FileStub) File(java.io.File)

Aggregations

File (java.io.File)7 FileStub (org.python.pydev.shared_core.resource_stubs.FileStub)7 ProjectStub (org.python.pydev.shared_core.resource_stubs.ProjectStub)4 IFile (org.eclipse.core.resources.IFile)2 PythonNature (org.python.pydev.plugin.nature.PythonNature)2 FolderStub (org.python.pydev.shared_core.resource_stubs.FolderStub)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IContainer (org.eclipse.core.resources.IContainer)1 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 Document (org.eclipse.jface.text.Document)1 IDocument (org.eclipse.jface.text.IDocument)1 PipelinedShapeModification (org.eclipse.ui.navigator.PipelinedShapeModification)1 IWrappedResource (org.python.pydev.navigator.elements.IWrappedResource)1 PythonNatureStub (org.python.pydev.parser.PythonNatureStub)1 MarkerInfo (org.python.pydev.shared_core.markers.PyMarkerUtils.MarkerInfo)1 AbstractIProjectStub (org.python.pydev.shared_core.resource_stubs.AbstractIProjectStub)1 IProjectStub (org.python.pydev.shared_core.resource_stubs.IProjectStub)1