Examples of IPythonNature


Examples of org.python.pydev.core.IPythonNature

            IInterpreterManager manager = null;
            if (projectName != null) {
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
                if (project != null) {
                    IPythonNature nature = PythonNature.getPythonNature(project);
                    if (nature != null) {
                        AbstractAdditionalDependencyInfo additionalInfo;
                        try {
                            additionalInfo = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
                        } catch (Exception e) {
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

    /**
     * @return The nature to be used for this breakpoint or null if it cannot be determined.
     */
    private IPythonNature getPythonNature() {
        IMarker marker = getMarker();
        IPythonNature nature = PythonNature.getPythonNature(marker.getResource());
        if (nature == null) {
            try {
                String externalPath = (String) marker.getAttribute(PyBreakpoint.PY_BREAK_EXTERNAL_PATH_ID);
                if (externalPath != null) {
                    Tuple<IPythonNature, String> infoForFile = PydevPlugin.getInfoForFile(new File(externalPath));
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        CompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();

        PyEdit edit = s.getEdit();
        RefactoringRequest request;
        IPythonNature nature = null;
        try {
            nature = edit.getPythonNature();
            request = new RefactoringRequest(edit.getEditorFile(), ps, new NullProgressMonitor(), nature, edit);
        } catch (MisconfigurationException e) {
            return;
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        if (file.lastModified() == lastModifiedTimeCached) {
            return functionName;
        }

        try {
            IPythonNature nature = getPythonNature();
            if (nature == null) {
                lastModifiedTimeCached = 0;
                return "None";
            }
            ICodeCompletionASTManager astManager = nature.getAstManager();
            if (astManager == null) {
                lastModifiedTimeCached = 0;
                return "None";
            }
            //Only mark it as found if we were able to get the python nature (otherwise, this could change later
            //if requesting during a setup)
            if (nature.startRequests()) { //start requests, as we'll ask for resolve and get module.
                SourceModule sourceModule = null;
                try {
                    String modName = nature.resolveModule(fileStr);
                    if (modName != null) {
                        //when all is set up, this is the most likely path we're going to use
                        //so, we shouldn't have delays when the module is changed, as it's already
                        //ok for use.
                        IModule module = astManager.getModule(modName, nature, true);
                        if (module instanceof SourceModule) {
                            sourceModule = (SourceModule) module;
                        }
                    }
                } finally {
                    nature.endRequests();
                }
                lastModifiedTimeCached = file.lastModified();

                if (sourceModule == null) {
                    //the text for the breakpoint requires the function name, and it may be requested before
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        int whenAnalyze = AnalysisPreferences.getAnalysisPreferences().getWhenAnalyze();
        if (whenAnalyze == IAnalysisPreferences.ANALYZE_ON_SUCCESFUL_PARSE || force) {

            //create the module
            final IPythonNature nature = PythonNature.getPythonNature(fileAdapter);
            if (nature == null) {
                return;
            }

            //don't analyze it if we're still not 'all set'
            if (!nature.isOkToUse()) {
                Job job = new AnalyzeLaterJob("Analyze later", info, root, fileAdapter, force, nature);
                job.schedule(100);
                return;
            }
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

import com.python.pydev.analysis.additionalinfo.IInfo;

public class PyGlobalsBrowser extends PyAction {

    public void run(IAction action) {
        IPythonNature pythonNature;
        try {
            pythonNature = getPyEdit().getPythonNature();
        } catch (MisconfigurationException e1) {
            handle(e1);
            return;
        }
        PySelection ps = new PySelection(this.getPyEdit());
        String selectedText = ps.getSelectedText();
        if (selectedText == null || selectedText.length() == 0) {
            try {
                selectedText = ps.getCurrToken().o1;
            } catch (BadLocationException e) {
                //ignore
            }
        }

        if (pythonNature != null) {
            IInterpreterManager manager = pythonNature.getRelatedInterpreterManager();
            getFromManagerAndRelatedNatures(selectedText, manager);
        } else {
            getFromSystemManager(selectedText);
        }
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

     */
    private void getFromSystemManager(String selectedText) {
        //is null
        Tuple<IPythonNature, String> infoForFile = PydevPlugin.getInfoForFile(getPyEdit().getEditorFile());
        if (infoForFile != null) {
            IPythonNature systemPythonNature = infoForFile.o1;
            if (systemPythonNature == null) {
                getFromWorkspace(selectedText);
                return;
            }

View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        PyEdit pyEdit = (PyEdit) part;
        SimpleNode ast = pyEdit.getAST();
        if (ast == null) {
            IDocument doc = pyEdit.getDocument();
            SourceModule sourceModule;
            IPythonNature nature = null;
            try {
                nature = pyEdit.getPythonNature();
            } catch (MisconfigurationException e) {
                // Let's try to find a suitable nature
                File editorFile = pyEdit.getEditorFile();
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        if (project == null) { //Ok, we could not find it out
            throw Log.log("Could not get project for configuration: " + conf);
        }

        // We need the project to find out the default interpreter from the InterpreterManager.
        IPythonNature pythonNature = PythonNature.getPythonNature(project);
        if (pythonNature == null) {
            CoreException e = Log.log("No python nature for project: " + project.getName());
            throw e;
        }

        //now, go on configuring other things
        this.configuration = conf;
        this.run = run;
        isDebug = mode.equals(ILaunchManager.DEBUG_MODE);
        isInteractive = mode.equals("interactive");

        resource = getLocation(conf, pythonNature);
        arguments = getArguments(conf, makeArgumentsVariableSubstitution);
        IPath workingPath = getWorkingDirectory(conf, pythonNature);
        workingDirectory = workingPath == null ? null : workingPath.toFile();
        acceptTimeout = PydevPrefs.getPreferences().getInt(PydevEditorPrefs.CONNECT_TIMEOUT);

        interpreterLocation = getInterpreterLocation(conf, pythonNature, this.getRelatedInterpreterManager());
        interpreter = getInterpreter(interpreterLocation, conf, pythonNature);

        //make the environment
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        envp = launchManager.getEnvironment(conf);
        IInterpreterManager manager;
        if (isJython()) {
            manager = PydevPlugin.getJythonInterpreterManager();
        } else if (isIronpython()) {
            manager = PydevPlugin.getIronpythonInterpreterManager();
        } else {
            manager = PydevPlugin.getPythonInterpreterManager();
        }

        boolean win32 = PlatformUtils.isWindowsPlatform();

        if (envp == null) {
            //ok, the user has done nothing to the environment, just get all the default environment which has the pythonpath in it
            envp = SimpleRunner.getEnvironment(pythonNature, interpreterLocation, manager);

        } else {
            //ok, the user has done something to configure it, so, just add the pythonpath to the
            //current env (if he still didn't do so)
            Map envMap = conf.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map) null);

            String pythonpath = SimpleRunner.makePythonPathEnvString(pythonNature, interpreterLocation, manager);
            updateVar(pythonNature, manager, win32, envMap, "PYTHONPATH", pythonpath);
            if (isJython()) {
                //Also update the classpath env variable.
                updateVar(pythonNature, manager, win32, envMap, "CLASSPATH", pythonpath);
                // And the jythonpath env variable
                updateVar(pythonNature, manager, win32, envMap, "JYTHONPATH", pythonpath);

            } else if (isIronpython()) {
                //Also update the ironpythonpath env variable.
                updateVar(pythonNature, manager, win32, envMap, "IRONPYTHONPATH", pythonpath);

            }

            //And we also must get the environment variables specified in the interpreter manager.
            envp = interpreterLocation.updateEnv(envp, envMap.keySet());
        }

        String settingsModule = null;
        Map<String, String> variableSubstitution = null;
        final String djangoSettingsKey = "DJANGO_SETTINGS_MODULE";
        String djangoSettingsEnvEntry = null;
        try {
            variableSubstitution = pythonNature.getPythonPathNature().getVariableSubstitution();
            settingsModule = variableSubstitution.get(djangoSettingsKey);
            if (settingsModule != null) {
                if (settingsModule.trim().length() > 0) {
                    djangoSettingsEnvEntry = djangoSettingsKey + "=" + settingsModule.trim();
                }
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        //project... (external projects), so, let's go on and see if there's some match there.

        List<IPythonNature> allPythonNatures = PythonNature.getAllPythonNatures();
        int size = allPythonNatures.size();
        for (int i = 0; i < size; i++) {
            IPythonNature nature = allPythonNatures.get(i);
            try {
                //Note: only resolve in the project sources, as we've already checked the system and we'll be
                //checking all projects anyways.
                String modName = nature.resolveModuleOnlyInProjectSources(FileUtils.getFileAbsolutePath(file), true);
                if (modName != null) {
                    return new Tuple<IPythonNature, String>(nature, modName);
                }
            } catch (Exception e) {
                Log.log(e);
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.