1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 13:05:22 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2015-01-06 16:40:11 -08:00
parent ce73d736bd
commit 693185186e
5 changed files with 78 additions and 154 deletions

View file

@ -48,11 +48,6 @@ public class CContainer extends Openable implements ICContainer {
super(parent, res, type); super(parent, res, type);
} }
/**
* Returns a the collection of binary files in this ccontainer
*
* @see ICContainer#getBinaries()
*/
@Override @Override
public IBinary[] getBinaries() throws CModelException { public IBinary[] getBinaries() throws CModelException {
List<?> list = getChildrenOfType(C_BINARY); List<?> list = getChildrenOfType(C_BINARY);
@ -61,9 +56,6 @@ public class CContainer extends Openable implements ICContainer {
return array; return array;
} }
/**
* @see ICContainer#getBinary(String)
*/
@Override @Override
public IBinary getBinary(String name) { public IBinary getBinary(String name) {
IFile file = getContainer().getFile(new Path(name)); IFile file = getContainer().getFile(new Path(name));
@ -78,11 +70,6 @@ public class CContainer extends Openable implements ICContainer {
return new Binary(this, file, null); return new Binary(this, file, null);
} }
/**
* Returns a the collection of archive files in this ccontainer
*
* @see ICContainer#getArchives()
*/
@Override @Override
public IArchive[] getArchives() throws CModelException { public IArchive[] getArchives() throws CModelException {
List<?> list = getChildrenOfType(C_ARCHIVE); List<?> list = getChildrenOfType(C_ARCHIVE);
@ -91,9 +78,6 @@ public class CContainer extends Openable implements ICContainer {
return array; return array;
} }
/**
* @see ICContainer#getArchive(String)
*/
@Override @Override
public IArchive getArchive(String name) { public IArchive getArchive(String name) {
IFile file = getContainer().getFile(new Path(name)); IFile file = getContainer().getFile(new Path(name));
@ -108,9 +92,6 @@ public class CContainer extends Openable implements ICContainer {
return new Archive(this, file, null); return new Archive(this, file, null);
} }
/**
* @see ICContainer#getTranslationUnits()
*/
@Override @Override
public ITranslationUnit[] getTranslationUnits() throws CModelException { public ITranslationUnit[] getTranslationUnits() throws CModelException {
List<?> list = getChildrenOfType(C_UNIT); List<?> list = getChildrenOfType(C_UNIT);
@ -119,11 +100,6 @@ public class CContainer extends Openable implements ICContainer {
return array; return array;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.model.ICContainer#getTranslationUnit(java.lang.String)
*/
@Override @Override
public ITranslationUnit getTranslationUnit(String name) { public ITranslationUnit getTranslationUnit(String name) {
IFile file = getContainer().getFile(new Path(name)); IFile file = getContainer().getFile(new Path(name));
@ -135,11 +111,6 @@ public class CContainer extends Openable implements ICContainer {
return new TranslationUnit(this, file, id); return new TranslationUnit(this, file, id);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
*/
@Override @Override
public ICContainer[] getCContainers() throws CModelException { public ICContainer[] getCContainers() throws CModelException {
List<?> list = getChildrenOfType(C_CCONTAINER); List<?> list = getChildrenOfType(C_CCONTAINER);
@ -148,11 +119,6 @@ public class CContainer extends Openable implements ICContainer {
return array; return array;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.model.ICContainer#getCContainer(java.lang.String)
*/
@Override @Override
public ICContainer getCContainer(String name) { public ICContainer getCContainer(String name) {
IFolder folder = getContainer().getFolder(new Path(name)); IFolder folder = getContainer().getFolder(new Path(name));
@ -164,7 +130,7 @@ public class CContainer extends Openable implements ICContainer {
} }
public IContainer getContainer() { public IContainer getContainer() {
return (IContainer) getResource(); return getResource();
} }
@Override @Override
@ -178,9 +144,6 @@ public class CContainer extends Openable implements ICContainer {
return getPath().hashCode(); return getPath().hashCode();
} }
/**
* @see Openable
*/
@Override @Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource) protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
throws CModelException { throws CModelException {
@ -200,19 +163,13 @@ public class CContainer extends Openable implements ICContainer {
return validInfo; return validInfo;
} }
/*
* (non-Javadoc) Returns an array of non-c resources contained in the
* receiver.
*
* @see org.eclipse.cdt.core.model.ICContainer#getNonCResources()
*/
@Override @Override
public Object[] getNonCResources() throws CModelException { public Object[] getNonCResources() throws CModelException {
return ((CContainerInfo) getElementInfo()).getNonCResources(getResource()); return ((CContainerInfo) getElementInfo()).getNonCResources(getResource());
} }
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
ArrayList<ICElement> vChildren = new ArrayList<ICElement>(); ArrayList<ICElement> vChildren = new ArrayList<>();
try { try {
IResource[] resources = null; IResource[] resources = null;
if (res instanceof IContainer) { if (res instanceof IContainer) {
@ -221,8 +178,8 @@ public class CContainer extends Openable implements ICContainer {
} }
if (resources != null) { if (resources != null) {
ICProject cproject = getCProject(); ICProject cproject = getCProject();
for (IResource resource2 : resources) { for (IResource resource : resources) {
ICElement celement = computeChild(resource2, cproject); ICElement celement = computeChild(resource, cproject);
if (celement != null) { if (celement != null) {
vChildren.add(celement); vChildren.add(celement);
} }
@ -325,5 +282,4 @@ public class CContainer extends Openable implements ICContainer {
protected char getHandleMementoDelimiter() { protected char getHandleMementoDelimiter() {
return CElement.CEM_SOURCEFOLDER; return CElement.CEM_SOURCEFOLDER;
} }
} }

View file

@ -25,10 +25,6 @@ import org.eclipse.core.runtime.Path;
public class SourceRoot extends CContainer implements ISourceRoot { public class SourceRoot extends CContainer implements ISourceRoot {
ICSourceEntry sourceEntry; ICSourceEntry sourceEntry;
/**
* @param parent
* @param res
*/
public SourceRoot(ICElement parent, IResource res, ICSourceEntry entry) { public SourceRoot(ICElement parent, IResource res, ICSourceEntry entry) {
super(parent, res); super(parent, res);
sourceEntry = entry; sourceEntry = entry;
@ -78,7 +74,7 @@ public class SourceRoot extends CContainer implements ISourceRoot {
} else { } else {
path= Path.EMPTY; path= Path.EMPTY;
} }
((CElement)getParent()).getHandleMemento(buff); ((CElement) getParent()).getHandleMemento(buff);
buff.append(getHandleMementoDelimiter()); buff.append(getHandleMementoDelimiter());
escapeMementoName(buff, path.toString()); escapeMementoName(buff, path.toString());
} }
@ -90,5 +86,4 @@ public class SourceRoot extends CContainer implements ISourceRoot {
protected char getHandleMementoDelimiter() { protected char getHandleMementoDelimiter() {
return CElement.CEM_SOURCEROOT; return CElement.CEM_SOURCEROOT;
} }
} }

View file

@ -1165,12 +1165,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
} }
public static String getAbsoluteInclusionPath(String includeDirective, String currentFile) { public static String getAbsoluteInclusionPath(String includeDirective, String currentFile) {
// Filename is an absolute path // Filename is an absolute path.
if (new File(includeDirective).isAbsolute()) { if (new File(includeDirective).isAbsolute()) {
return includeDirective; return includeDirective;
} }
// Filename is a Linux absolute path on a Windows machine // Filename is a Linux absolute path on a Windows machine.
if (File.separatorChar == '\\' && includeDirective.length() > 0) { if (File.separatorChar == '\\' && !includeDirective.isEmpty()) {
final char firstChar = includeDirective.charAt(0); final char firstChar = includeDirective.charAt(0);
if (firstChar == '\\' || firstChar == '/') { if (firstChar == '\\' || firstChar == '/') {
if (currentFile != null && currentFile.length() > 1 && currentFile.charAt(1) == ':') { if (currentFile != null && currentFile.length() > 1 && currentFile.charAt(1) == ':') {

View file

@ -10,28 +10,22 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.filters; package org.eclipse.cdt.internal.ui.filters;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.resources.IResource;
/** /**
* Filters closed projects * Filters closed projects
*/ */
public class ClosedProjectFilter extends ViewerFilter { public class ClosedProjectFilter extends ViewerFilter {
/*
* @see ViewerFilter
*/
@Override @Override
public boolean select(Viewer viewer, Object parent, Object element) { public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof ICElement) if (element instanceof ICElement)
return ((ICElement)element).getCProject().getProject().isOpen(); return ((ICElement) element).getCProject().getProject().isOpen();
if (element instanceof IResource) if (element instanceof IResource)
return ((IResource)element).getProject().isOpen(); return ((IResource) element).getProject().isOpen();
return true; return true;
} }
} }

View file

@ -33,12 +33,12 @@ import org.eclipse.core.runtime.Path;
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmentVariableSupplier { public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmentVariableSupplier {
//toggle for preference changes // toggle for preference changes
private static boolean preferencesChanged = true; private static boolean preferencesChanged = true;
//LLVM environment variable data structure // LLVM environment variable data structure
private static HashMap<String, LlvmBuildEnvironmentVariable> llvmEnvironmentVariables = private static HashMap<String, LlvmBuildEnvironmentVariable> llvmEnvironmentVariables =
new HashMap<String, LlvmBuildEnvironmentVariable>(6); new HashMap<String, LlvmBuildEnvironmentVariable>(6);
//Environment variables for HashMap usage // Environment variables for HashMap usage
private static final String ENV_VAR_NAME_LLVM_BIN = "LLVM_BIN_PATH"; //$NON-NLS-1$ private static final String ENV_VAR_NAME_LLVM_BIN = "LLVM_BIN_PATH"; //$NON-NLS-1$
private static final String ENV_VAR_NAME_LLVMINTERP = "LLVMINTERP"; //$NON-NLS-1$ private static final String ENV_VAR_NAME_LLVMINTERP = "LLVMINTERP"; //$NON-NLS-1$
private static final String ENV_VAR_NAME_PATH = "PATH"; //$NON-NLS-1$ private static final String ENV_VAR_NAME_PATH = "PATH"; //$NON-NLS-1$
@ -50,40 +50,40 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
* Initializes llvm environment variable paths from the system environment variables. * Initializes llvm environment variable paths from the system environment variables.
*/ */
public static void initializePaths() { //TODO: Is this actually called anywhere? public static void initializePaths() { //TODO: Is this actually called anywhere?
//get bin path // get bin path
String binPath = getBinPath(); String binPath = getBinPath();
//set LLVM bin path environment variable // set LLVM bin path environment variable
setLlvmEnvironmentVariableReplace(ENV_VAR_NAME_LLVM_BIN, binPath); setLlvmEnvironmentVariableReplace(ENV_VAR_NAME_LLVM_BIN, binPath);
//if bin path exists // if bin path exists
if (binPath != null && binPath.length()!=0) { if (binPath != null && binPath.length()!=0) {
String pathStr = binPath; String pathStr = binPath;
//if OS is Windows (Windows specific settings) // if OS is Windows (Windows specific settings)
if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { //$NON-NLS-1$ //$NON-NLS-2$ if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { //$NON-NLS-1$ //$NON-NLS-2$
try { try {
//try to find mingw or cygwin path from PATH environment variable // try to find mingw or cygwin path from PATH environment variable
IBuildEnvironmentVariable envPath = llvmEnvironmentVariables IBuildEnvironmentVariable envPath =
.get(ENV_VAR_NAME_PATH); llvmEnvironmentVariables.get(ENV_VAR_NAME_PATH);
IBuildEnvironmentVariable mingwPath=null, cygwinPath=null; IBuildEnvironmentVariable mingwPath=null, cygwinPath=null;
//if path is empty // if path is empty
if (envPath == null) { if (envPath == null) {
//try to find mingw path from MingwEnvironmentVariableSupplier // try to find mingw path from MingwEnvironmentVariableSupplier
IConfigurationEnvironmentVariableSupplier mingwEnvironmentVariables = IConfigurationEnvironmentVariableSupplier mingwEnvironmentVariables =
new MingwEnvironmentVariableSupplier(); new MingwEnvironmentVariableSupplier();
mingwPath = mingwEnvironmentVariables.getVariable( mingwPath = mingwEnvironmentVariables.getVariable(
ENV_VAR_NAME_PATH, null, null); ENV_VAR_NAME_PATH, null, null);
//try to find cygwin path from GnuCygwinConfigurationEnvironmentSupplier // try to find cygwin path from GnuCygwinConfigurationEnvironmentSupplier
IConfigurationEnvironmentVariableSupplier cygwinEnvironmentVariables = IConfigurationEnvironmentVariableSupplier cygwinEnvironmentVariables =
new GnuCygwinConfigurationEnvironmentSupplier(); new GnuCygwinConfigurationEnvironmentSupplier();
cygwinPath = cygwinEnvironmentVariables.getVariable( cygwinPath = cygwinEnvironmentVariables.getVariable(
ENV_VAR_NAME_PATH, null, null); ENV_VAR_NAME_PATH, null, null);
} }
//if mingw found // if mingw found
if (mingwPath != null) { if (mingwPath != null) {
//form full path //form full path
pathStr = pathStr + System.getProperty("path.separator") + mingwPath.getValue(); //$NON-NLS-1$ pathStr = pathStr + System.getProperty("path.separator") + mingwPath.getValue(); //$NON-NLS-1$
} }
//if cygwin found // if cygwin found
if (cygwinPath != null) { if (cygwinPath != null) {
//form full path //form full path
pathStr = pathStr + System.getProperty("path.separator") + cygwinPath.getValue(); //$NON-NLS-1$ pathStr = pathStr + System.getProperty("path.separator") + cygwinPath.getValue(); //$NON-NLS-1$
@ -104,7 +104,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Get LLVM bin path * Returns LLVM bin path
* *
* @return LLVM bin path * @return LLVM bin path
*/ */
@ -113,7 +113,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Get LLVM include paths * Returns LLVM include paths
* *
* @return LLVM include paths * @return LLVM include paths
*/ */
@ -122,7 +122,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Get LLVM library paths * Returns LLVM library paths
* *
* @return LLVM library paths * @return LLVM library paths
*/ */
@ -131,17 +131,16 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Get LLVM libraries * Returns LLVM libraries
* *
* @return LLVM libraries * @return LLVM libraries
*/ */
public static String getLibraries() { public static String getLibraries() {
return getLlvmEnvironmentVariable(ENV_VAR_NAME_LIBRARIES).getValue(); return getLlvmEnvironmentVariable(ENV_VAR_NAME_LIBRARIES).getValue();
} }
/** /**
* Set path to LLVM bin. * Sets path to LLVM bin.
* *
* @param path Path to LLVM bin location. * @param path Path to LLVM bin location.
*/ */
@ -150,7 +149,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Append a new include path. * Appends a new include path.
* *
* @param path Include path * @param path Include path
*/ */
@ -163,7 +162,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Append a new library path. * Appends a new library path.
* *
* @param path Library path * @param path Library path
*/ */
@ -176,7 +175,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Append a new library. * Appends a new library.
* *
* @param lib Library file * @param lib Library file
*/ */
@ -196,7 +195,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Get a specific path for given parameters. * Returns a specific path for given parameters.
* *
* @param pathKey Path for specific location * @param pathKey Path for specific location
* @param subDirName Additional sub-path * @param subDirName Additional sub-path
@ -204,12 +203,11 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
*/ */
private static String findBinDir(String pathKey, String subDirName) { private static String findBinDir(String pathKey, String subDirName) {
String resultPath = null; String resultPath = null;
//if preferences haven't been changed // If preferences haven't been changed, try to find the bin path from the LLVM environment
//try to find the bin path from the LLVM environment variable HashMap // variable map.
if (!preferencesChanged) { //TODO: Change if (!preferencesChanged) { //TODO: Change
//get current path //get current path
LlvmBuildEnvironmentVariable earlierValue = llvmEnvironmentVariables LlvmBuildEnvironmentVariable earlierValue = llvmEnvironmentVariables.get(pathKey);
.get(pathKey);
//if earlier LlvmBuildEnvironmentVariable exists //if earlier LlvmBuildEnvironmentVariable exists
if (null != earlierValue) { if (null != earlierValue) {
//return current path //return current path
@ -218,15 +216,15 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} else { } else {
// Try if the path is set in the LLVM plug-in preferences // Try if the path is set in the LLVM plug-in preferences
String preferenceLocation = LlvmPreferenceStore.getBinPath(); String preferenceLocation = LlvmPreferenceStore.getBinPath();
//if preference exists // if preference exists
if (null != preferenceLocation) { if (null != preferenceLocation) {
//remove white spaces from preference location // remove white spaces from preference location
preferenceLocation = preferenceLocation.trim(); preferenceLocation = preferenceLocation.trim();
//if preference location is not empty // if preference location is not empty
if (preferenceLocation.length()!=0) { if (preferenceLocation.length()!=0) {
//get path for LLVM executable // get path for LLVM executable
resultPath = getDirIfLlvmFound(preferenceLocation, null); resultPath = getDirIfLlvmFound(preferenceLocation, null);
//if LLVM executable path doesn't exist // if LLVM executable path doesn't exist
if (null == resultPath) { if (null == resultPath) {
// If no luck check next with sub directory name appended // If no luck check next with sub directory name appended
resultPath = getDirIfLlvmFound(preferenceLocation, resultPath = getDirIfLlvmFound(preferenceLocation,
@ -237,18 +235,18 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
if (null == resultPath) { if (null == resultPath) {
// If still no luck try all folders listed in PATH // If still no luck try all folders listed in PATH
String pathVariable = System.getenv(ENV_VAR_NAME_PATH); String pathVariable = System.getenv(ENV_VAR_NAME_PATH);
//split paths to String array // split paths to String array
String[] paths = pathVariable.split(Separators.getPathSeparator()); String[] paths = pathVariable.split(Separators.getPathSeparator());
//check every path if LLVM executable is found // check every path if LLVM executable is found
for (String pathStr : paths) { for (String pathStr : paths) {
resultPath = getDirIfLlvmFound(pathStr, null); resultPath = getDirIfLlvmFound(pathStr, null);
//stop loop if LLVM executable path is found // stop loop if LLVM executable path is found
if (null != resultPath) { if (null != resultPath) {
break; break;
} }
} }
} }
//return found path // return found path
return resultPath; return resultPath;
} }
return null; return null;
@ -279,7 +277,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Get the full path for llvm executable if the bin path given * Returns the full path for llvm executable if the bin path given
* as a parameter is found and executable exists in that path. * as a parameter is found and executable exists in that path.
* *
* @param binPathTemp User provided bin directory path * @param binPathTemp User provided bin directory path
@ -298,7 +296,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
arFileFullPath = new File(binPathTemp, llvm_executable); arFileFullPath = new File(binPathTemp, llvm_executable);
// Check if file exists -> proper LLVM installation exists. // Check if file exists -> proper LLVM installation exists.
if (arFileFullPath.isFile()) { if (arFileFullPath.isFile()) {
// Return path where llvm-ar exists // Return path where llvm-ar exists.
return binPathTemp; return binPathTemp;
} }
} }
@ -311,7 +309,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
* @return stdc++ library path for MinGW * @return stdc++ library path for MinGW
*/ */
public static String getMinGWStdLib() { public static String getMinGWStdLib() {
//get mingw bin path // get mingw bin path
IPath mingwBinPath = MingwEnvironmentVariableSupplier.getBinDir(); IPath mingwBinPath = MingwEnvironmentVariableSupplier.getBinDir();
if (mingwBinPath != null) { if (mingwBinPath != null) {
StringBuilder sB = new StringBuilder(mingwBinPath.toOSString()); StringBuilder sB = new StringBuilder(mingwBinPath.toOSString());
@ -338,7 +336,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
/** /**
* *
* Get LLVM environment variable. * Returns LLVM environment variable.
* *
* @param envName Name of the environment variable * @param envName Name of the environment variable
*/ */
@ -347,32 +345,32 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
} }
/** /**
* Set LLVM environment variable. * Sets LLVM environment variable.
* *
* @param name Name for the environment variable * @param name Name for the environment variable
* @param path Path for the environment variable * @param path Path for the environment variable
*/ */
private static void setLlvmEnvironmentVariable(String name, String path) { private static void setLlvmEnvironmentVariable(String name, String path) {
//appends a new path in front of the the old path in HashMap that contains // append a new path in front of the the old path in HashMap that contains
//the specific LLVM environment variable // the specific LLVM environment variable
llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable( llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable(
name, path, IBuildEnvironmentVariable.ENVVAR_APPEND)); name, path, IBuildEnvironmentVariable.ENVVAR_APPEND));
} }
/** /**
* Set LLVM environment variable by replacing the existing paths. * Sets LLVM environment variable by replacing the existing paths.
* *
* @param name Name for the environment variable * @param name Name for the environment variable
* @param path Path for the environment variable * @param path Path for the environment variable
*/ */
public static void setLlvmEnvironmentVariableReplace(String name, String path) { public static void setLlvmEnvironmentVariableReplace(String name, String path) {
//replaces the old path in HashMap that contains the specific LLVM environment variable // replace the old path in HashMap that contains the specific LLVM environment variable
llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable( llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable(
name, path, IBuildEnvironmentVariable.ENVVAR_REPLACE)); name, path, IBuildEnvironmentVariable.ENVVAR_REPLACE));
} }
/** /**
* Append a new LLVM environment variable to existing list. * Appends a new LLVM environment variable to existing list.
* *
* @param name Name of the preference * @param name Name of the preference
* @param oldPath Old paths/preference values * @param oldPath Old paths/preference values
@ -381,34 +379,33 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
public static void appendLlvmEnvironmentVariable(String name, String oldPath, String path) { public static void appendLlvmEnvironmentVariable(String name, String oldPath, String path) {
String newPath = null; String newPath = null;
boolean ok = false; boolean ok = false;
//if oldPath exists // if oldPath exists
if (oldPath!=null) { if (oldPath!=null) {
//if the oldPath isn't empty //if the oldPath isn't empty
if((oldPath.trim()).length()!=0) { if (!oldPath.trim().isEmpty()) {
StringBuffer sB = new StringBuffer(); StringBuffer sB = new StringBuffer();
//append old path // append old path
sB.append(oldPath); sB.append(oldPath);
//append a path separator // append a path separator
sB.append(Separators.getPathSeparator()); sB.append(Separators.getPathSeparator());
//append the new path // append the new path
sB.append(path); sB.append(path);
//construct a new full path // construct a new full path
newPath = sB.toString(); newPath = sB.toString();
ok=true; ok = true;
} }
} }
if (!ok) { if (!ok) {
newPath=path; newPath=path;
} }
//set new path to the HashMap that contains // Set new path to the HashMap that contains the specific LLVM environment variable
//the specific LLVM environment variable // if newPath exists.
//if newPath exists if (newPath != null) {
if (newPath!=null) { // if the newPath isn't empty
//if the newPath isn't empty if (!newPath.trim().isEmpty()) {
if((newPath.trim()).length()!=0) { // add new values to the LLVM environment variable
//add new values to the LLVM environment variable llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable(name, newPath,
llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable( IBuildEnvironmentVariable.ENVVAR_APPEND));
name, newPath, IBuildEnvironmentVariable.ENVVAR_APPEND));
} }
} }
} }
@ -421,37 +418,19 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
*/ */
private static String getSysEnvPath(String envName) { private static String getSysEnvPath(String envName) {
String path = System.getenv(envName); String path = System.getenv(envName);
if(path != null) { if (path != null) {
return path; return path;
} }
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
/* public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration,
* (non-Javadoc) IEnvironmentVariableProvider provider) {
*
* @see org.eclipse.cdt.managedbuilder.envvar.
* IConfigurationEnvironmentVariableSupplier#getVariable(java.lang.String,
* org.eclipse.cdt.managedbuilder.core.IConfiguration,
* org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider)
*/
public IBuildEnvironmentVariable getVariable(String variableName,
IConfiguration configuration, IEnvironmentVariableProvider provider) {
return llvmEnvironmentVariables.get(variableName); return llvmEnvironmentVariables.get(variableName);
} }
/* public IBuildEnvironmentVariable[] getVariables(IConfiguration configuration,
* (non-Javadoc) IEnvironmentVariableProvider provider) {
* return llvmEnvironmentVariables.values().toArray(new IBuildEnvironmentVariable[0]);
* @see org.eclipse.cdt.managedbuilder.envvar.
* IConfigurationEnvironmentVariableSupplier
* #getVariables(org.eclipse.cdt.managedbuilder.core.IConfiguration,
* org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider)
*/
public IBuildEnvironmentVariable[] getVariables(
IConfiguration configuration, IEnvironmentVariableProvider provider) {
return llvmEnvironmentVariables.values().toArray(
new IBuildEnvironmentVariable[0]);
} }
} }