Skip to content

Commit

Permalink
Don't throw exception getting substitution variables if project is st…
Browse files Browse the repository at this point in the history
…ill not fully configured.
  • Loading branch information
fabioz committed Jan 16, 2025
1 parent 4a576c6 commit 2764171
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.python.pydev.core.IPythonNature;
import org.python.pydev.core.IPythonPathNature;
import org.python.pydev.core.MisconfigurationException;
import org.python.pydev.core.ProjectMisconfiguredException;
import org.python.pydev.core.PropertiesHelper;
import org.python.pydev.core.PythonNatureWithoutProjectException;
import org.python.pydev.core.docutils.StringSubstitution;
Expand Down Expand Up @@ -503,17 +502,15 @@ public List<String> getProjectExternalSourcePathAsList(boolean replaceVariables)
}

@Override
public Map<String, String> getVariableSubstitution() throws CoreException, MisconfigurationException,
PythonNatureWithoutProjectException {
public Map<String, String> getVariableSubstitution() {
return getVariableSubstitution(true);
}

/**
* Returns the variables in the python nature and in the interpreter.
*/
@Override
public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSubstitutions) throws CoreException,
MisconfigurationException, PythonNatureWithoutProjectException {
public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSubstitutions) {
PythonNature nature = this.fNature;
if (nature == null) {
return new HashMap<String, String>();
Expand All @@ -530,9 +527,10 @@ public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSub
} else {
variableSubstitution = PropertiesHelper.createMapFromProperties(stringSubstitutionVariables);
}
} catch (ProjectMisconfiguredException e) {
} catch (MisconfigurationException | PythonNatureWithoutProjectException e) {
Log.logInfo(
"Interpreter info still not fully configured (interpreter substitutions won't be available).",
"Interpreter info still not fully configured (interpreter substitutions won't be available). Project: "
+ nature.getProject(),
e);
variableSubstitution = new HashMap<String, String>();
}
Expand All @@ -541,8 +539,13 @@ public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSub
}

//no need to validate because those are always 'file-system' related
Map<String, String> variableSubstitution2 = nature.getStore().getMapProperty(
PythonPathNature.getProjectVariableSubstitutionQualifiedName());
Map<String, String> variableSubstitution2 = null;
try {
variableSubstitution2 = nature.getStore().getMapProperty(
PythonPathNature.getProjectVariableSubstitutionQualifiedName());
} catch (CoreException e) {
Log.logInfo("Unable to get variable substitutions for project: " + nature.getProject(), e);
}
if (variableSubstitution2 != null && !variableSubstitution2.isEmpty()) {
if (variableSubstitution != null) {
variableSubstitution.putAll(variableSubstitution2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.python.pydev.core.IPythonPathNature;
import org.python.pydev.core.MisconfigurationException;
import org.python.pydev.core.PropertiesHelper;
import org.python.pydev.core.PythonNatureWithoutProjectException;
import org.python.pydev.core.TokensList;
import org.python.pydev.core.log.Log;
import org.python.pydev.core.nature.AbstractPythonNature;
Expand Down Expand Up @@ -67,14 +66,12 @@ public void setProject(IProject project, IPythonNature nature) {
}

@Override
public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSubstitutions)
throws CoreException, MisconfigurationException, PythonNatureWithoutProjectException {
public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSubstitutions) {
return getVariableSubstitution();
}

@Override
public Map<String, String> getVariableSubstitution() throws CoreException, MisconfigurationException,
PythonNatureWithoutProjectException {
public Map<String, String> getVariableSubstitution() {
Properties stringSubstitutionVariables = SystemPythonNature.this.info.getStringSubstitutionVariables(false);
Map<String, String> variableSubstitution;
if (stringSubstitutionVariables == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ public List<String> getOnlyProjectPythonPathStr(boolean addExternal, boolean add
/**
* Same as getVariableSubstitution(true);
*/
public Map<String, String> getVariableSubstitution() throws CoreException, MisconfigurationException,
PythonNatureWithoutProjectException;
public Map<String, String> getVariableSubstitution();

/**
* @param addInterpreterInfoSubstitutions if true the substitutions in the interpreter will also be added.
* Otherwise, only the substitutions from this nature will be returned.
*/
public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSubstitutions) throws CoreException,
MisconfigurationException, PythonNatureWithoutProjectException;
public Map<String, String> getVariableSubstitution(boolean addInterpreterInfoSubstitutions);

/**
* The nature that contains this pythonpath nature.
Expand Down

0 comments on commit 2764171

Please sign in to comment.