use of org.python.pydev.core.MisconfigurationException in project Pydev by fabioz.
the class AnalysisBuilderRunnableForRemove method removeInfoForModule.
/**
* @param moduleName this is the module name
* @param nature this is the nature
*/
public static void removeInfoForModule(String moduleName, IPythonNature nature, boolean isFullBuild) {
if (moduleName != null && nature != null) {
AbstractAdditionalDependencyInfo info;
try {
info = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
} catch (MisconfigurationException e) {
Log.log(e);
return;
}
boolean generateDelta;
if (isFullBuild) {
generateDelta = false;
} else {
generateDelta = true;
}
info.removeInfoFromModule(moduleName, generateDelta);
} else {
if (DebugSettings.DEBUG_ANALYSIS_REQUESTS) {
org.python.pydev.shared_core.log.ToLogFile.toLogFile("Unable to remove info. name: " + moduleName + " or nature:" + nature + " is null.", AnalysisBuilderRunnableForRemove.class);
}
}
}
use of org.python.pydev.core.MisconfigurationException in project Pydev by fabioz.
the class AnalysisBuilderVisitor method visitChangedResource.
public void visitChangedResource(final IResource resource, final ICallback0<IDocument> document, final IProgressMonitor monitor, boolean forceAnalysis) {
// we may need to 'force' the analysis when a module is renamed, because the first message we receive is
// a 'delete' and after that an 'add' -- which is later mapped to this method, so, if we don't have info
// on the module we should analyze it because it is 'probably' a rename.
final PythonNature nature = getPythonNature(resource);
if (nature == null) {
return;
}
// Put things from the memo to final variables as we might need them later on and we cannot get them from
// the memo later.
final String moduleName;
final SourceModule[] module = new SourceModule[] { null };
final IDocument doc;
doc = document.call();
if (doc == null) {
return;
}
try {
moduleName = getModuleName(resource, nature);
} catch (MisconfigurationException e) {
Log.log(e);
return;
}
// depending on the level of analysis we have to do, we'll decide whether we want
// to make the full parse (slower) or the definitions parse (faster but only with info
// related to the definitions)
ICallback<IModule, Integer> moduleCallback = new ICallback<IModule, Integer>() {
@Override
public IModule call(Integer arg) {
if (arg == IAnalysisBuilderRunnable.FULL_MODULE) {
if (module[0] != null) {
return module[0];
} else {
try {
module[0] = getSourceModule(resource, doc, nature);
} catch (MisconfigurationException e1) {
throw new RuntimeException(e1);
}
if (module[0] != null) {
return module[0];
}
try {
module[0] = createSoureModule(resource, doc, moduleName);
} catch (MisconfigurationException e) {
throw new RuntimeException(e);
}
return module[0];
}
} else if (arg == IAnalysisBuilderRunnable.DEFINITIONS_MODULE) {
if (DebugSettings.DEBUG_ANALYSIS_REQUESTS) {
org.python.pydev.shared_core.log.ToLogFile.toLogFile(this, "PyDevBuilderPrefPage.getAnalyzeOnlyActiveEditor()");
}
IFile f = (IFile) resource;
IPath location = f.getLocation();
if (location != null) {
String file = location.toOSString();
File f2 = new File(file);
return new SourceModule(moduleName, f2, FastDefinitionsParser.parse(doc.get(), moduleName, f2), null, nature);
}
return null;
} else {
throw new RuntimeException("Unexpected parameter: " + arg);
}
}
};
long documentTime = this.getDocumentTime();
if (documentTime == -1) {
Log.log("Warning: The document time in the visitor is -1. Changing for current time.");
documentTime = System.currentTimeMillis();
}
doVisitChangedResource(nature, resource, doc, moduleCallback, null, monitor, forceAnalysis, AnalysisBuilderRunnable.ANALYSIS_CAUSE_BUILDER, documentTime, false);
}
use of org.python.pydev.core.MisconfigurationException in project Pydev by fabioz.
the class AbstractAdditionalDependencyInfo method load.
/**
* actually does the load
* @return true if it was successfully loaded and false otherwise
*/
protected boolean load() {
Throwable errorFound = null;
synchronized (lock) {
File file;
try {
file = getPersistingLocation();
} catch (MisconfigurationException e) {
Log.log("Unable to restore previous info... (persisting location not available).", e);
return false;
}
if (file.exists() && file.isFile()) {
try {
return loadContentsFromFile(file, getNature()) != null;
} catch (Throwable e) {
errorFound = new RuntimeException("Unable to read: " + file, e);
}
}
}
try {
String msg = "Info: Rebuilding internal caches: " + this.getPersistingLocation();
if (errorFound == null) {
msg += " (Expected error to be provided and got no error!)";
Log.log(IStatus.ERROR, msg, errorFound);
} else {
Log.log(IStatus.INFO, msg, errorFound);
}
} catch (Exception e1) {
Log.log("Rebuilding internal caches (error getting persisting location).");
}
return false;
}
use of org.python.pydev.core.MisconfigurationException in project Pydev by fabioz.
the class IOUtils method save.
/**
* this can be used to save the file
*/
public void save() {
File persistingLocation;
try {
persistingLocation = getPersistingLocation();
} catch (MisconfigurationException e) {
Log.log("Error. Unable to get persisting location for additional interprer info. Configuration may be corrupted.", e);
return;
}
if (DEBUG_ADDITIONAL_INFO) {
System.out.println("Saving to " + persistingLocation);
}
save(persistingLocation);
}
use of org.python.pydev.core.MisconfigurationException in project Pydev by fabioz.
the class AdditionalProjectInterpreterInfo method getAdditionalInfoAndNature.
public static List<Tuple<AbstractAdditionalTokensInfo, IPythonNature>> getAdditionalInfoAndNature(IPythonNature nature, boolean addSystemInfo, boolean addReferencingProjects, boolean addReferencedProjects) throws MisconfigurationException {
List<Tuple<AbstractAdditionalTokensInfo, IPythonNature>> ret = new ArrayList<Tuple<AbstractAdditionalTokensInfo, IPythonNature>>();
IProject project = nature.getProject();
// get for the system info
if (addSystemInfo) {
AbstractAdditionalTokensInfo systemInfo;
try {
systemInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(InterpreterManagersAPI.getInterpreterManager(nature), nature.getProjectInterpreter().getExecutableOrJar());
} catch (MisconfigurationException e) {
throw e;
} catch (PythonNatureWithoutProjectException e) {
throw new RuntimeException(e);
}
ret.add(new Tuple<AbstractAdditionalTokensInfo, IPythonNature>(systemInfo, new SystemPythonNature(nature.getRelatedInterpreterManager())));
}
// get for the current project
if (project != null) {
AbstractAdditionalTokensInfo additionalInfoForProject = getAdditionalInfoForProject(nature);
if (additionalInfoForProject != null) {
ret.add(new Tuple<AbstractAdditionalTokensInfo, IPythonNature>(additionalInfoForProject, nature));
}
try {
if (addReferencedProjects) {
// get for the referenced projects
Set<IProject> referencedProjects = ProjectModulesManager.getReferencedProjects(project);
for (IProject refProject : referencedProjects) {
additionalInfoForProject = getAdditionalInfoForProject(PythonNature.getPythonNature(refProject));
if (additionalInfoForProject != null) {
ret.add(new Tuple<AbstractAdditionalTokensInfo, IPythonNature>(additionalInfoForProject, PythonNature.getPythonNature(refProject)));
}
}
}
if (addReferencingProjects) {
Set<IProject> referencingProjects = ProjectModulesManager.getReferencingProjects(project);
for (IProject refProject : referencingProjects) {
additionalInfoForProject = getAdditionalInfoForProject(PythonNature.getPythonNature(refProject));
if (additionalInfoForProject != null) {
ret.add(new Tuple<AbstractAdditionalTokensInfo, IPythonNature>(additionalInfoForProject, PythonNature.getPythonNature(refProject)));
}
}
}
} catch (Exception e) {
Log.log(e);
}
}
return ret;
}
Aggregations