Package org.python.pydev.plugin.nature

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


     * @param list the list that will be filled with the managers
     * @param projects the projects that should have the managers added
     */
    private void addModuleManagers(ArrayList<IModulesManager> list, Collection<IProject> projects) {
        for (IProject project : projects) {
            PythonNature nature = PythonNature.getPythonNature(project);
            if (nature != null) {
                ICodeCompletionASTManager otherProjectAstManager = nature.getAstManager();
                if (otherProjectAstManager != null) {
                    IModulesManager projectModulesManager = otherProjectAstManager.getModulesManager();
                    if (projectModulesManager != null) {
                        list.add((IModulesManager) projectModulesManager);
                    }
View Full Code Here


     * @throws MisconfigurationException
     */
    protected SourceModule createSoureModule(IResource resource, IDocument document, String moduleName)
            throws MisconfigurationException {
        SourceModule module;
        PythonNature nature = PythonNature.getPythonNature(resource.getProject());
        IFile f = (IFile) resource;
        String file = f.getRawLocation().toOSString();
        module = (SourceModule) AbstractModule.createModuleFromDoc(moduleName, new File(file), document, nature, true);
        return module;
    }
View Full Code Here

    /**
     * @param resource the resource we are analyzing
     * @return the nature associated to the project where the resource is contained
     */
    protected PythonNature getPythonNature(IResource resource) {
        PythonNature pythonNature = PythonNature.getPythonNature(resource);
        return pythonNature;
    }
View Full Code Here

    public static boolean isInPythonPath(IResource resource) {
        if (resource == null) {
            return false;
        }
        IProject project = resource.getProject();
        PythonNature nature = PythonNature.getPythonNature(project);
        if (project != null && nature != null) {
            ICodeCompletionASTManager astManager = nature.getAstManager();
            if (astManager != null) {
                IModulesManager modulesManager = astManager.getModulesManager();
                return modulesManager.isInPythonPath(resource, project);
            }
        }
View Full Code Here

                assertTrue(appEnginePage.isPageComplete());

                assertTrue(appEngineWizard.performFinish());

                IProject createdProject = appEngineWizard.getCreatedProject();
                PythonNature nature = PythonNature.getPythonNature(createdProject);
                Map<String, String> expected = new HashMap<String, String>();
                expected.put(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE, new File(
                        TestDependent.GOOGLE_APP_ENGINE_LOCATION).getAbsolutePath());
                IPythonPathNature pythonPathNature = nature.getPythonPathNature();
                try {
                    assertEquals(expected, pythonPathNature.getVariableSubstitution());

                    String projectExternalSourcePath = pythonPathNature.getProjectExternalSourcePath(false);
                    assertTrue(projectExternalSourcePath.indexOf(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE) != -1);
View Full Code Here

        try {
            if (monitor.isCanceled()) {
                throw new OperationCanceledException();
            }
            PythonNature nature = PythonNature.getPythonNature(projectHandle);
            Assert.isNotNull(nature);
            ICodeCompletionASTManager astManager = nature.getAstManager();
            Object sync = new Object();
            //Wait up to 10 seconds for it to be restored
            for (int i = 0; i < 100 && astManager == null; i++) {
                synchronized (sync) {
                    try {
                        sync.wait(100);
                    } catch (InterruptedException e) {
                    }
                }
                astManager = nature.getAstManager();
            }

            if (astManager == null) {
                throw new RuntimeException(
                        "Error creating Django project. ASTManager not available after 10 seconds.\n"
View Full Code Here

    public void testRefreshAnalyzesFiles() throws Exception {
        editor.close(false);
        goToIdleLoopUntilCondition(getInitialParsesCondition(), getParsesDone(), false); //just to have any parse events consumed
        goToManual(TIME_FOR_ANALYSIS); //give it a bit more time...

        PythonNature nature = PythonNature.getPythonNature(mod1);
        AbstractAdditionalTokensInfo info = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
        //all modules are empty
        assertEquals(new HashSet<String>(), info.getAllModulesWithTokens());

        ICallback<Object, IResource> analysisCallback = getAnalysisCallback();
View Full Code Here

        sourceFolder = createSourceFolder(monitor, project, true, false);
        IFile initFile = createPackageStructure(sourceFolder, "pack_cov", monitor);
        modCov = initFile.getParent().getFile(new Path("mod_cov.py"));
        setFileContents(modCov, getModCovContents());

        PythonNature nature = PythonNature.getPythonNature(project);
        waitForNatureToBeRecreated(nature);
    }
View Full Code Here

                        - start));
    }

    protected void addFooModule(final SimpleNode ast, File f) {
        String modName = "foo";
        PythonNature natureToAdd = nature;
        addModuleToNature(ast, modName, natureToAdd, f);
    }
View Full Code Here

    public void run(IAction action) {
        try {
            //        this.launchDjangoCommand("shell", false);

            PythonNature nature = PythonNature.getPythonNature(selectedProject);
            if (nature == null) {
                MessageDialog.openError(PyAction.getShell(), "PyDev nature not found",
                        "Unable to perform action because the Pydev nature is not properly set.");
                return;
            }
            IPythonPathNature pythonPathNature = nature.getPythonPathNature();
            String settingsModule = null;
            Map<String, String> variableSubstitution = null;
            try {
                variableSubstitution = pythonPathNature.getVariableSubstitution();
                settingsModule = variableSubstitution.get(DjangoConstants.DJANGO_SETTINGS_MODULE);
            } catch (Exception e1) {
                throw new RuntimeException(e1);
            }
            if (settingsModule == null) {
                InputDialog d = new InputDialog(PyAction.getShell(), "Settings module",
                        "Please enter the settings module to be used.\n" + "\n"
                                + "Note that it can be edited later in:\np"
                                + "roject properties > pydev pythonpath > string substitution variables.",
                        selectedProject.getName() + ".settings", new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.length() == 0) {
                                    return "Text must be entered.";
                                }
                                for (char c : newText.toCharArray()) {
                                    if (c == ' ') {
                                        return "Whitespaces not accepted";
                                    }
                                    if (c != '.' && !Character.isJavaIdentifierPart(c)) {
                                        return "Invalid char: " + c;
                                    }
                                }
                                return null;
                            }
                        });

                int retCode = d.open();

                if (retCode == InputDialog.OK) {
                    settingsModule = d.getValue();
                    variableSubstitution.put(DjangoConstants.DJANGO_SETTINGS_MODULE, settingsModule);
                    try {
                        pythonPathNature.setVariableSubstitution(variableSubstitution);
                    } catch (Exception e) {
                        Log.log(e);
                    }

                }

                if (settingsModule == null) {
                    return;
                }
            }

            List<IPythonNature> natures = Collections.singletonList((IPythonNature) nature);
            PydevConsoleFactory consoleFactory = new PydevConsoleFactory();
            PydevConsoleLaunchInfo launchInfo = new PydevIProcessFactory().createLaunch(
                    nature.getRelatedInterpreterManager(),
                    nature.getProjectInterpreter(),
                    nature.getPythonPathNature().getCompleteProjectPythonPath(nature.getProjectInterpreter(),
                            nature.getRelatedInterpreterManager()), nature, natures);

            PydevConsoleInterpreter interpreter = PydevConsoleFactory.createPydevInterpreter(launchInfo, natures);

            String importStr = "";//"from " + selectedProject.getName() + " import settings;";
            importStr = "import " + settingsModule + " as settings;";
View Full Code Here

TOP

Related Classes of org.python.pydev.plugin.nature.PythonNature

Copyright © 2018 www.massapicom. 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.