1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 00:36:16 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-03-27 05:15:15 +00:00
parent 56cae6fd61
commit 56690dafd4
2 changed files with 46 additions and 65 deletions

View file

@ -18,41 +18,34 @@ import java.util.Map;
/**
* Implementation of the {@link IScannerInfo} interface. Allows to configure the preprocessor.
*/
public class ScannerInfo implements IScannerInfo
{
private Map<String, String> definedSymbols = Collections.emptyMap();
private String [] includePaths = {};
public class ScannerInfo implements IScannerInfo {
private final Map<String, String> definedSymbols;
private final String[] includePaths;
public ScannerInfo()
{
}
public ScannerInfo(Map<String, String> macroDefinitions, String[] includeSearchPath)
{
if (macroDefinitions != null) {
definedSymbols = macroDefinitions;
}
if (includeSearchPath != null) {
includePaths = includeSearchPath;
}
public ScannerInfo() {
this(null, null);
}
public ScannerInfo(Map<String, String> macroDefinitions) {
this(macroDefinitions, null);
}
public ScannerInfo(Map<String, String> macroDefinitions, String[] includeSearchPath) {
definedSymbols = macroDefinitions != null ? macroDefinitions : Collections.<String, String>emptyMap();
includePaths = includeSearchPath != null ? includeSearchPath : new String[] {};
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols()
*/
public Map<String, String> getDefinedSymbols()
{
public Map<String, String> getDefinedSymbols() {
return definedSymbols;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IScannerInfo#getIncludePaths()
*/
public String[] getIncludePaths()
{
public String[] getIncludePaths() {
return includePaths;
}
}

View file

@ -33,29 +33,23 @@ import org.eclipse.core.runtime.Path;
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class ParserUtil
{
public static IParserLogService getParserLogService()
{
return parserLogService;
}
public class ParserUtil {
private static IParserLogService parserLogService = new ParserLogService(DebugLogConstants.PARSER);
private static IParserLogService scannerLogService = new ParserLogService(DebugLogConstants.SCANNER);
public static IParserLogService getParserLogService() {
return parserLogService;
}
public static IParserLogService getScannerLogService() {
return scannerLogService;
}
public static char [] findWorkingCopyBuffer( String path, Iterator<IWorkingCopy> workingCopies )
{
public static char[] findWorkingCopyBuffer(String path, Iterator<IWorkingCopy> workingCopies) {
IResource resultingResource = getResourceForFilename(path);
if( resultingResource != null && resultingResource.getType() == IResource.FILE )
{
// this is the file for sure
// check the working copy
if (resultingResource != null && resultingResource.getType() == IResource.FILE) {
// This is the file for sure. Check the working copy.
if (workingCopies.hasNext())
return findWorkingCopy(resultingResource, workingCopies);
}
@ -85,7 +79,6 @@ public class ParserUtil
return null;
}
public static IResource getResourceForFilename(String finalPath) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace == null)
@ -97,8 +90,7 @@ public class ParserUtil
if (root.getLocation().isPrefixOf(path))
path = path.removeFirstSegments(root.getLocation().segmentCount());
try
{
try {
IFile file = root.getFile(path);
if (file != null && file.exists())
return file;
@ -113,9 +105,7 @@ public class ParserUtil
return file;
return null;
}
catch( IllegalArgumentException iae ) //thrown on invalid paths
{
} catch (IllegalArgumentException e) { // thrown on invalid paths
return null;
}
}
@ -123,11 +113,9 @@ public class ParserUtil
protected static char[] findWorkingCopy(IResource resultingResource, Iterator<IWorkingCopy> workingCopies) {
if (parserLogService.isTracing())
parserLogService.traceLog("Attempting to find the working copy for " + resultingResource.getName()); //$NON-NLS-1$
while( workingCopies.hasNext() )
{
while (workingCopies.hasNext()) {
IWorkingCopy copy = workingCopies.next();
if (resultingResource.equals(copy.getResource()))
{
if (resultingResource.equals(copy.getResource())) {
if (parserLogService.isTracing())
parserLogService.traceLog("Working copy found!!"); //$NON-NLS-1$
return copy.getContents();