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;
@ -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,22 +10,16 @@
*******************************************************************************/ *******************************************************************************/
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)

View file

@ -61,8 +61,8 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
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) {
@ -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
@ -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;
} }
} }
@ -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
@ -384,7 +382,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
// 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);
@ -400,15 +398,14 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
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()).length()!=0) { if (!newPath.trim().isEmpty()) {
// add new values to the LLVM environment variable // add new values to the LLVM environment variable
llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable( llvmEnvironmentVariables.put(name, new LlvmBuildEnvironmentVariable(name, newPath,
name, newPath, IBuildEnvironmentVariable.ENVVAR_APPEND)); IBuildEnvironmentVariable.ENVVAR_APPEND));
} }
} }
} }
@ -427,31 +424,13 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
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]);
} }
} }