use of org.eclipse.titan.common.utils.environment.EnvironmentVariableResolver.VariableNotFoundException in project titan.EclipsePlug-ins by eclipse.
the class TITANPathUtilities method resolvePathURI.
/**
* Resolves the provided path relative to the provided base path. If the
* pathToBeConverted is absolute or the basePath is null or empty string,
* the basePath is not used
*
* @param pathToBeResolved
* the path to be resolved.
* @param basePath
* the full path to which the resolvable one might be relative
* to.
*
* @return the resolved path.
*/
private static URI resolvePathURI(final String pathToBeResolved, final String basePath, final Map<?, ?> envVariables, final IPathVariableManager pathVariableManager) {
String tmp2 = null;
try {
final String tmp1 = EnvironmentVariableResolver.eclipseStyle().resolve(pathToBeResolved, envVariables);
// In case of error,
tmp2 = EnvironmentVariableResolver.unixStyle().resolve(tmp1, envVariables);
// it throws exception
} catch (VariableNotFoundException e) {
// this is a normal behavior
ErrorReporter.logWarning("There was an error while resolving `" + pathToBeResolved + "'");
return null;
}
final URI uri = URIUtil.toURI(tmp2);
URI resolvedURI = pathVariableManager.resolveURI(uri);
if (basePath != null && !"".equals(basePath) && !resolvedURI.isAbsolute()) {
final String temp = PathUtil.getAbsolutePath(basePath, tmp2);
if (temp != null) {
resolvedURI = URIUtil.toURI(temp);
}
}
return resolvedURI;
}
use of org.eclipse.titan.common.utils.environment.EnvironmentVariableResolver.VariableNotFoundException in project titan.EclipsePlug-ins by eclipse.
the class TITANPathUtilities method resolvePath.
/**
* Resolves the provided uri relative to the provided base uri. Environment
* variables and path variables will be resolved
*
* @param pathToBeResolved
* the path to be resolved.
* @param basePath
* the full path to which the resolvable one might be relative
* to.
*
* @return the resolved uri.
*/
// TODO: call resolvePathURI, it is the same functionality!!!
public static URI resolvePath(final String pathToBeResolved, final URI basePath) {
Map<?, ?> envVariables;
if (DebugPlugin.getDefault() != null) {
envVariables = DebugPlugin.getDefault().getLaunchManager().getNativeEnvironmentCasePreserved();
} else {
envVariables = null;
}
String tmp2 = null;
try {
final String tmp1 = EnvironmentVariableResolver.eclipseStyle().resolve(pathToBeResolved, envVariables);
tmp2 = EnvironmentVariableResolver.unixStyle().resolveIgnoreErrors(tmp1, envVariables);
} catch (VariableNotFoundException e) {
ErrorReporter.logError("There was an error while resolving `" + pathToBeResolved + "'");
return null;
}
final IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
// the trailing dots are removed but later corrected
URI uri = URIUtil.toURI(tmp2);
uri = pathVariableManager.resolveURI(uri);
if (basePath != null && uri != null && !uri.isAbsolute()) {
final String basePathString = URIUtil.toPath(basePath).toOSString();
final String temp = PathUtil.getAbsolutePath(basePathString, tmp2);
if (temp != null) {
uri = URIUtil.toURI(temp);
}
}
return uri;
}
Aggregations