Examples of PythonNature


Examples of org.python.pydev.plugin.nature.PythonNature

                        //Change the pythonNatures given the selection done (so, just investigate the passed nature, not
                        //all of the input natures).
                        if (additional.additionalInfo instanceof AdditionalProjectInterpreterInfo) {
                            AdditionalProjectInterpreterInfo projectInterpreterInfo = (AdditionalProjectInterpreterInfo) additional.additionalInfo;
                            IProject project = projectInterpreterInfo.getProject();
                            PythonNature pythonNature = PythonNature.getPythonNature(project);
                            if (pythonNature != null) {
                                pythonNatures = new ArrayList<IPythonNature>();
                                pythonNatures.add(pythonNature);
                            }

                        } else if (additional.additionalInfo instanceof AdditionalSystemInterpreterInfo) {
                            AdditionalSystemInterpreterInfo systemInterpreterInfo = (AdditionalSystemInterpreterInfo) additional.additionalInfo;
                            SystemPythonNature pythonNature = new SystemPythonNature(systemInterpreterInfo.getManager());
                            pythonNatures = new ArrayList<IPythonNature>();
                            pythonNatures.add(pythonNature);
                        }
                    } catch (Throwable e) {
                        Log.log(e);
                    }
                    entry = additional.info;

                } else {
                    entry = (IInfo) obj;
                }
                List<ItemPointer> pointers = new ArrayList<ItemPointer>();

                CompletionCache completionCache = new CompletionCache();
                for (IPythonNature pythonNature : pythonNatures) {
                    //try to find in one of the natures...
                    ICodeCompletionASTManager astManager = pythonNature.getAstManager();
                    if (astManager == null) {
                        continue;
                    }
                    AnalysisPlugin.getDefinitionFromIInfo(pointers, astManager, pythonNature, entry, completionCache);
                    if (pointers.size() > 0) {
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    /**
     * 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();
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    /**
     * Test if intercepting an object that does not have a parent works.
     */
    public void testInterceptRefresh() 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);
        provider = new PythonModelProvider();

        PipelinedViewerUpdate update = new PipelinedViewerUpdate();
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    public void testProjectIsRoot2() throws Exception {
        String pythonpathLoc = TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot";
        final HashSet<String> pythonPathSet = new HashSet<String>();
        pythonPathSet.add(pythonpathLoc);

        PythonNature nature = createNature(pythonPathSet);

        WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub();
        project = new ProjectStub(new File(pythonpathLoc), nature);
        provider = new PythonModelProvider();
        FolderStub folder = new FolderStub(project,
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    public void testProjectIsRoot() throws Exception {
        String pythonpathLoc = TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot";
        final HashSet<String> pythonPathSet = new HashSet<String>();
        pythonPathSet.add(pythonpathLoc);

        PythonNature nature = createNature(pythonPathSet);

        WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub();
        project = new ProjectStub(new File(pythonpathLoc), nature);
        provider = new PythonModelProvider();
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

     * is kept inside as a reference, so, changing that reference will affect the pythonpath
     * that is set in the nature.
     */
    private PythonNature createNature(final HashSet<String> pythonPathSet) {

        PythonNature nature = new PythonNature() {
            @Override
            public IPythonPathNature getPythonPathNature() {
                return new PythonPathNatureStub(pythonPathSet);
            }
        };
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

     */
    public void testPythonpathChanges() throws Exception {
        final HashSet<String> pythonPathSet = new HashSet<String>();
        pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot/source");
        pythonPathSet.add("invalid");
        PythonNature nature = createNature(pythonPathSet);

        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature, true);
        provider = new PythonModelProvider();
        Object[] children1 = provider.getChildren(project);
        assertTrue(children1[0] instanceof PythonSourceFolder);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    }

    public void testDontRemoveOtherPluginElements() throws Exception {
        final HashSet<String> pythonPathSet = new HashSet<String>();
        pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot/source");
        PythonNature nature = createNature(pythonPathSet);

        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature);
        provider = new PythonModelProvider();

        HashSet<Object> currentChildren = new HashSet<Object>();
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    }

    public void testCreateChildrenInWrappedResource() throws Exception {
        final HashSet<String> pythonPathSet = new HashSet<String>();
        pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"); //root is the source
        PythonNature nature = createNature(pythonPathSet);

        WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub();
        ArrayList<Object> additionalChildren = new ArrayList<Object>();
        additionalChildren.add("string");
        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature, true,
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

     * @return as we're not below a source folder here, we have still not entered the 'python' domain,
     * and as the starting point for the 'python' domain is always a source folder, the things
     * that can be returned are IResources and PythonSourceFolders.
     */
    private Object[] getChildrenForIResourceOrWorkingSet(Object parentElement) {
        PythonNature nature = null;
        IProject project = null;
        if (parentElement instanceof IResource) {
            project = ((IResource) parentElement).getProject();
        }

        //we can only get the nature if the project is open
        if (project != null && project.isOpen()) {
            nature = PythonNature.getPythonNature(project);
        }

        //replace folders -> source folders (we should only get here on a path that's not below a source folder)
        Object[] childrenToReturn = super.getChildren(parentElement);

        //if we don't have a python nature in this project, there is no way we can have a PythonSourceFolder
        List<Object> ret = new ArrayList<Object>(childrenToReturn.length);
        for (int i = 0; i < childrenToReturn.length; i++) {
            PythonNature localNature = nature;
            IProject localProject = project;

            //now, first we have to try to get it (because it might already be created)
            Object child = childrenToReturn[i];

            if (child == null) {
                continue;
            }

            //only add it if it wasn't null
            ret.add(child);

            if (!(child instanceof IResource)) {
                //not an element that we can treat in pydev (but still, it was already added)
                continue;
            }
            child = getResourceInPythonModel((IResource) child);

            if (child == null) {
                //ok, it was not in the python model (but it was already added with the original representation, so, that's ok)
                continue;
            } else {
                ret.set(ret.size() - 1, child); //replace the element added for the one in the python model
            }

            //if it is a folder (that is not already a PythonSourceFolder, it might be that we have to create a PythonSourceFolder)
            if (child instanceof IContainer && !(child instanceof PythonSourceFolder)) {
                IContainer container = (IContainer) child;

                try {
                    //check if it is a source folder (and if it is, create it)
                    if (localNature == null) {
                        if (container instanceof IProject) {
                            localProject = (IProject) container;
                            if (localProject.isOpen() == false) {
                                continue;
                            } else {
                                localNature = PythonNature.getPythonNature(localProject);
                            }
                        } else {
                            continue;
                        }
                    }
                    //if it's a python project, the nature can't be null
                    if (localNature == null) {
                        continue;
                    }

                    Set<String> sourcePathSet = localNature.getPythonPathNature().getProjectSourcePathSet(true);
                    IPath fullPath = container.getFullPath();
                    if (sourcePathSet.contains(fullPath.toString())) {
                        PythonSourceFolder createdSourceFolder;
                        if (container instanceof IFolder) {
                            createdSourceFolder = new PythonSourceFolder(parentElement, (IFolder) container);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.