本文整理汇总了Java中org.python.pydev.plugin.nature.PythonNature.getAstManager方法的典型用法代码示例。如果您正苦于以下问题:Java PythonNature.getAstManager方法的具体用法?Java PythonNature.getAstManager怎么用?Java PythonNature.getAstManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.python.pydev.plugin.nature.PythonNature
的用法示例。
在下文中一共展示了PythonNature.getAstManager方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addModuleManagers
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* @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(projectModulesManager);
}
} else {
//Removed the warning below: this may be common when starting up...
//String msg = "No ast manager configured for :" + project.getName();
//Log.log(IStatus.WARNING, msg, new RuntimeException(msg));
}
}
IModulesManager javaModulesManagerForProject = JavaProjectModulesManagerCreator
.createJavaProjectModulesManagerIfPossible(project);
if (javaModulesManagerForProject != null) {
list.add(javaModulesManagerForProject);
}
}
}
示例2: isInPythonPath
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* @param resource the resource we want to know about
* @return true if it is in the pythonpath
*/
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);
}
}
return false;
}
示例3: visitChangedResource
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* The code completion visitor is responsible for checking the changed resources in order to
* update the code completion cache for the project.
*
* This visitor just passes one resource and updates the code completion cache for it.
*/
@Override
public void visitChangedResource(IResource resource, ICallback0<IDocument> document, IProgressMonitor monitor) {
PythonNature pythonNature = getPythonNature(resource);
if (pythonNature != null) {
ICodeCompletionASTManager astManager = pythonNature.getAstManager();
if (astManager != null) {
IPath location = resource.getLocation();
astManager.rebuildModule(new File(location.toOSString()), document, resource.getProject(),
new NullProgressMonitor(), pythonNature);
}
}
}
示例4: visitRemovedResource
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
public void visitRemovedResource(IResource resource, ICallback0<IDocument> document, IProgressMonitor monitor) {
PythonNature pythonNature = getPythonNature(resource);
if (pythonNature != null) {
ICodeCompletionASTManager astManager = pythonNature.getAstManager();
if (astManager != null) {
IPath location = resource.getLocation();
astManager.removeModule(new File(location.toOSString()), resource.getProject(),
new NullProgressMonitor());
}
}
}
示例5: setAstManager
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* This method sets the ast manager for a nature and restores the pythonpath
* with the path passed
* @param path the pythonpath that shoulb be set for this nature
* @param projectStub the project where the nature should be set
* @param pNature the nature we're interested in
*/
protected void setAstManager(String path, ProjectStub projectStub, PythonNature pNature) {
pNature.setProject(projectStub); //references the project 1
projectStub.setNature(pNature);
pNature.setAstManager(new ASTManager());
ASTManager astManager = ((ASTManager) pNature.getAstManager());
astManager.setNature(pNature);
astManager.setProject(projectStub, pNature, false);
astManager.changePythonPath(path, projectStub, getProgressMonitor());
}
示例6: waitForNatureToBeRecreated
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* This method will wait some time until the given nature is properly configured with the ast manager.
*/
protected void waitForNatureToBeRecreated(PythonNature nature) {
//Let's give it some time to run the jobs that restore the nature
long finishAt = System.currentTimeMillis() + 5000; //5 secs is the max time
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
if (finishAt < System.currentTimeMillis()) {
break;
}
if (nature != null) {
if (nature.getAstManager() != null) {
break;
}
}
}
assertTrue(nature != null);
assertTrue(nature.getAstManager() != null);
}
示例7: performOk
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* Saves values.
*/
@Override
public boolean performOk() {
try {
IPythonPathNature pythonPathNature = PythonNature.getPythonPathNature(project);
Map<String, String> variableSubstitution = pythonPathNature.getVariableSubstitution(false);
boolean changed = update(DjangoConstants.DJANGO_MANAGE_VARIABLE, variableSubstitution,
textDjangoManage.getText(), pythonPathNature);
changed = update(DjangoConstants.DJANGO_SETTINGS_MODULE, variableSubstitution,
textDjangoSettings.getText(), pythonPathNature) || changed;
if (changed) {
pythonPathNature.setVariableSubstitution(variableSubstitution);
PythonNature pythonNature = PythonNature.getPythonNature(project);
if (pythonNature != null && (changed || pythonNature.getAstManager() == null)) {
pythonNature.rebuildPath();
}
}
} catch (Exception e) {
Log.log(e);
}
return true;
}
示例8: getChildrenForIWrappedResource
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* @param wrappedResourceParent: this is the parent that is an IWrappedResource (which means
* that children will also be IWrappedResources)
*
* @return the children (an array of IWrappedResources)
*/
private Object[] getChildrenForIWrappedResource(IWrappedResource wrappedResourceParent) {
//------------------------------------------------------------------- get python nature
PythonNature nature = null;
Object[] childrenToReturn = null;
Object obj = wrappedResourceParent.getActualObject();
IProject project = null;
if (obj instanceof IResource) {
IResource resource = (IResource) obj;
project = resource.getProject();
if (project != null && project.isOpen()) {
nature = PythonNature.getPythonNature(project);
}
}
//------------------------------------------------------------------- treat python nodes
if (wrappedResourceParent instanceof PythonNode) {
PythonNode node = (PythonNode) wrappedResourceParent;
childrenToReturn = getChildrenFromParsedItem(wrappedResourceParent, node.entry, node.pythonFile);
//------------------------------------- treat python files (add the classes/methods,etc)
} else if (wrappedResourceParent instanceof PythonFile) {
// if it's a file, we want to show the classes and methods
PythonFile file = (PythonFile) wrappedResourceParent;
if (PythonPathHelper.isValidSourceFile(file.getActualObject())) {
if (nature != null) {
ICodeCompletionASTManager astManager = nature.getAstManager();
//the nature may still not be completely restored...
if (astManager != null) {
IModulesManager modulesManager = astManager.getModulesManager();
if (modulesManager instanceof IProjectModulesManager) {
IProjectModulesManager projectModulesManager = (IProjectModulesManager) modulesManager;
String moduleName = projectModulesManager.resolveModuleInDirectManager(file
.getActualObject());
if (moduleName != null) {
IModule module = projectModulesManager.getModuleInDirectManager(moduleName, nature,
true);
if (module == null) {
//ok, something strange happened... it shouldn't be null... maybe empty, but not null at this point
//so, if it exists, let's try to create it...
//TODO: This should be moved to somewhere else.
String resourceOSString = PydevPlugin.getIResourceOSString(file.getActualObject());
if (resourceOSString != null) {
File f = new File(resourceOSString);
if (f.exists()) {
projectModulesManager.addModule(new ModulesKey(moduleName, f));
module = projectModulesManager.getModuleInDirectManager(moduleName, nature,
true);
}
}
}
if (module instanceof SourceModule) {
SourceModule sourceModule = (SourceModule) module;
OutlineCreatorVisitor visitor = OutlineCreatorVisitor.create(sourceModule.getAst());
ParsedItem root = new ParsedItem(visitor.getAll().toArray(
new ASTEntryWithChildren[0]), null);
childrenToReturn = getChildrenFromParsedItem(wrappedResourceParent, root, file);
}
}
}
}
}
}
}
//------------------------------------------------------------- treat folders and others
else {
Object[] children = super.getChildren(wrappedResourceParent.getActualObject());
childrenToReturn = wrapChildren(wrappedResourceParent, wrappedResourceParent.getSourceFolder(), children);
}
return childrenToReturn;
}
示例9: doIt
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* Save the pythonpath - only updates model if asked to.
* @return
*/
private boolean doIt(boolean force) {
if (project != null) {
try {
boolean changed = false;
IPythonPathNature pythonPathNature = PythonNature.getPythonPathNature(project);
String sourcePath = pythonPathNature.getProjectSourcePath(false);
String externalSourcePath = pythonPathNature.getProjectExternalSourcePath(false);
Map<String, String> variableSubstitution = pythonPathNature.getVariableSubstitution(false);
String newSourcePath = StringUtils.leftAndRightTrim(treeSourceFolders.getTreeItemsAsStr(), '|');
String newExternalSourcePath = StringUtils.leftAndRightTrim(treeExternalLibs.getTreeItemsAsStr(), '|');
Map<String, String> newVariableSubstitution = tabVariables.getTreeItemsAsMap();
if (checkIfShouldBeSet(sourcePath, newSourcePath)) {
pythonPathNature.setProjectSourcePath(newSourcePath);
changed = true;
}
if (checkIfShouldBeSet(externalSourcePath, newExternalSourcePath)) {
pythonPathNature.setProjectExternalSourcePath(newExternalSourcePath);
changed = true;
}
if (checkIfShouldBeSet(variableSubstitution, newVariableSubstitution)) {
pythonPathNature.setVariableSubstitution(newVariableSubstitution);
changed = true;
}
PythonNature pythonNature = PythonNature.getPythonNature(project);
if (pythonNature != null && (changed || force || pythonNature.getAstManager() == null)) {
pythonNature.rebuildPath();
}
} catch (Exception e) {
Log.log(IStatus.ERROR, "Unexpected error setting project properties", e);
}
}
return true;
}