Is there a simple way to add and change interpreters using the Pydev plugin interface? I'm running pydev 1.6.1 and I'd like to be able to add and use a given interpreter based on a list of available interpreters in my environment.
Right now I can see the PythonInterpreterManager has a createInterpreterInfo call, but that doesn't seem to do anything. Looking at the source for pydev, it seems like I have to actually work with the preference pages to keep track of all of them.
Is there a simpler set of functions I can call to add these?
PythonInterpreterManager manager = (PythonInterpreterManager)PydevPlugin.getPythonInterpreterManager(true);
IInterpreterInfo info = manager.createInterpreterInfo(execPath, new NullProgressMonitor());
manager.addInterpreterInfo(info);
I can already do the above, but that only caches it, but doesn't display it as a valid interpreter option in the preferences.
I've even tried doing reflection to add these without much luck. I can call addNewInput on the editor as the Add button does, but then it says it doesn't have any knowledge of that interpreter. I've tried creating a popup preferences page and adding the values to the various members via reflection as getNewInput() would, but still don't see any more options in the preference page. I'm not sure if this is because I'm missing something or the popup preference page I make is totally unrelated to the page that pops up using the Window->"Preferences" pulldown.
The API is something as:
IInterpreterManager iMan = PydevPlugin.getPythonInterpreterManager(true);
IInterpreterInfo interpreterInfo = iMan.createInterpreterInfo("c:/python/python.exe", monitor, false);
iMan.setInfos(new IInterpreterInfo[]{interpreterInfo}, null, null);
Note that if you have 'manager.addInterpreterInfo' in there, you probably have an old version of PyDev... (and at that call you set all the interpreters available, so, if you want to keep some configuration, you should query it and add them back).
You can use: org.python.pydev.editor.codecompletion.revisited.javaintegration.AbstractWorkbenchTestCase.createPythonInterpreterManager(NullProgressMonitor) as a reference.
Related
I'm working on a Visual Studio Code extension, where some settings are required for it to work properly. Right now, in case the user has forgotten something, I'm showing a warning message indicating this, and telling them to fix this property in the settings. I would, however, like to add a button that opens the settings page of that property.
However, after looking around for over an hour, I can't seem to find any support for this in the Api, or anyone else asking this question (which I find a bit weird?). If it really doesn't exist, I'd still expect at least 1 other person asking this somewhere, but as far as I can see there's absolutely nothing.
Is it possible to open the settings window (preferably even filtering them down to only my extension's properties/the one property that has to be filled in) from code?
Thanks in advance
I found it out myself after digging through the keybinds window. You can use the following to open the settings:
vscode.commands.executeCommand("workbench.action.openSettings2");
I did not, however, find how to pass a search query into it to open a specific place in the settings.
EDIT: You can use openSettings & add the search query as an extra argument to executeCommand. For example - if your property is defined as my.extension.property in package.json, you can use this:
vscode.commands.executeCommand("workbench.action.openSettings", "my.extension.property");
I'm working on an extension and I'm checking to see if settings have values, if not, I want to show an error and provide a button that launches the settings editor so the user can add those settings.
I think my path forward is to use executeCommand and provide a built in command that does this for me, but I've been having trouble finding a list of built-in available commands.
Hidden in the key-bindings section of the documentation, I found the command I was looking for - workbench.action.openGlobalSettings
The full solution looks like
commands.executeCommand('workbench.action.openGlobalSettings');
I have added a new preference page in my application. and performing some task when user press ok button. problem is my code is executing even other node(preference page) is selected in the preference dialog.now i need to check whether currently selected node is my preference page before executing my code inside ok button. any help will be appreciated.
Sorry to say, but I think your problem have started a bit earlier. If done without too many hooks and nooks, you should only be called when necessary, so it sounds a bit odd to me.
I can usually just override performOk or in some cases performApply without these problems.
Have a look at the docs, just in case
For example, I have an ajax request and it returns <script src='buggy.js'></script>.
Problem is, it doesn't show up in sources or resources panel. That means I can't do all the cool stuffs like adding breakpoint and inspecting the elements as they run.
I could only see the source of the js file under the Network panel.
Is there anyway to make chrome add them to the sources panel?
Or how do you guys go about debugging dynamically added scripts?
Using Canary.
I was having the same problem, and I found a workaround that is better than the deliberate exception. It does still require changing the code as opposed to just setting a breakpoint inside the chrome dev tools.
I tried using the "//# sourceURL=dynamicScript.js" that was suggested as a workaround by the OP, but it still wasn't showing up for me unless it already existed in my tabs from a previous time when it produced an exception.
Coding a "debugger;" line forced it to break at that location. Then once it was in my tabs in the Sources panel, I could set breakpoints like normal and remove the "debugger;" line.
Please refer to https://developer.chrome.com/devtools/docs/javascript-debugging#breakpoints-dynamic-javascript
(Original link is broken-- archived link below)
http://web.archive.org/web/20141016164821/https://developer.chrome.com/devtools/docs/javascript-debugging#breakpoints-dynamic-javascript ("Breakpoints in Dynamic JavaScript").
I am currently working on a Eclipse Plugin, where I need to make an action, when a person opens a file with certain properties. However I'm not sure on how to set a listener, I have been looking into the IWorkspace and IResource API, but I can't find the simple API call saying "AddListenerToOnOpenFile".
The file is expected to be opened in the package explorer view.
Use the answer supplied by #MarttiKäärik to find out when editors are open. Then you can use the IEditorInput to see if it is an IResource you care about.
if (part instanceof IEditorPart) {
IEditorPart editor = (IEditorPart) part;
IResource resource = editor.getEditorInput().getAdapter(IResource.class);
// ...
}
Question already answered, so only to make it a bit more complete...
You don't necessarily have to implement a view or action (as described in the question linked to by Martti Käärik in a comment) to get a window for your listener. Call to PlatformUI.getWorkbench().get...() can be used as well. See the older, probably duplicate, question called just Eclipse Plugin.
BTW Eclipse Wiki FAQ page contains a good description of the ways how to obtain the current workbench window and possible "gotchas".
Moreover, you can even listen for newly opened windows if there is a need:
PlatformUI.getWorkbench().addWindowListener(listener);