mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Cosmetics.
This commit is contained in:
parent
56cae6fd61
commit
56690dafd4
2 changed files with 46 additions and 65 deletions
|
@ -18,41 +18,34 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Implementation of the {@link IScannerInfo} interface. Allows to configure the preprocessor.
|
* Implementation of the {@link IScannerInfo} interface. Allows to configure the preprocessor.
|
||||||
*/
|
*/
|
||||||
public class ScannerInfo implements IScannerInfo
|
public class ScannerInfo implements IScannerInfo {
|
||||||
{
|
private final Map<String, String> definedSymbols;
|
||||||
private Map<String, String> definedSymbols = Collections.emptyMap();
|
private final String[] includePaths;
|
||||||
private String [] includePaths = {};
|
|
||||||
|
|
||||||
public ScannerInfo()
|
public ScannerInfo() {
|
||||||
{
|
this(null, null);
|
||||||
}
|
|
||||||
|
|
||||||
public ScannerInfo(Map<String, String> macroDefinitions, String[] includeSearchPath)
|
|
||||||
{
|
|
||||||
if (macroDefinitions != null) {
|
|
||||||
definedSymbols = macroDefinitions;
|
|
||||||
}
|
|
||||||
if (includeSearchPath != null) {
|
|
||||||
includePaths = includeSearchPath;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScannerInfo(Map<String, String> macroDefinitions) {
|
public ScannerInfo(Map<String, String> macroDefinitions) {
|
||||||
this(macroDefinitions, null);
|
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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols()
|
* @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols()
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getDefinedSymbols()
|
public Map<String, String> getDefinedSymbols() {
|
||||||
{
|
|
||||||
return definedSymbols;
|
return definedSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.IScannerInfo#getIncludePaths()
|
* @see org.eclipse.cdt.core.parser.IScannerInfo#getIncludePaths()
|
||||||
*/
|
*/
|
||||||
public String[] getIncludePaths()
|
public String[] getIncludePaths() {
|
||||||
{
|
|
||||||
return includePaths;
|
return includePaths;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,29 +33,23 @@ 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.
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
*/
|
*/
|
||||||
public class ParserUtil
|
public class ParserUtil {
|
||||||
{
|
|
||||||
|
|
||||||
public static IParserLogService getParserLogService()
|
|
||||||
{
|
|
||||||
return parserLogService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IParserLogService parserLogService = new ParserLogService(DebugLogConstants.PARSER);
|
private static IParserLogService parserLogService = new ParserLogService(DebugLogConstants.PARSER);
|
||||||
private static IParserLogService scannerLogService = new ParserLogService(DebugLogConstants.SCANNER);
|
private static IParserLogService scannerLogService = new ParserLogService(DebugLogConstants.SCANNER);
|
||||||
|
|
||||||
|
public static IParserLogService getParserLogService() {
|
||||||
|
return parserLogService;
|
||||||
|
}
|
||||||
|
|
||||||
public static IParserLogService getScannerLogService() {
|
public static IParserLogService getScannerLogService() {
|
||||||
return scannerLogService;
|
return scannerLogService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char [] findWorkingCopyBuffer( String path, Iterator<IWorkingCopy> workingCopies )
|
public static char[] findWorkingCopyBuffer(String path, Iterator<IWorkingCopy> workingCopies) {
|
||||||
{
|
|
||||||
IResource resultingResource = getResourceForFilename(path);
|
IResource resultingResource = getResourceForFilename(path);
|
||||||
|
|
||||||
if( resultingResource != null && resultingResource.getType() == IResource.FILE )
|
if (resultingResource != null && resultingResource.getType() == IResource.FILE) {
|
||||||
{
|
// This is the file for sure. Check the working copy.
|
||||||
// this is the file for sure
|
|
||||||
// check the working copy
|
|
||||||
if (workingCopies.hasNext())
|
if (workingCopies.hasNext())
|
||||||
return findWorkingCopy(resultingResource, workingCopies);
|
return findWorkingCopy(resultingResource, workingCopies);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +79,6 @@ public class ParserUtil
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static IResource getResourceForFilename(String finalPath) {
|
public static IResource getResourceForFilename(String finalPath) {
|
||||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||||
if (workspace == null)
|
if (workspace == null)
|
||||||
|
@ -97,8 +90,7 @@ public class ParserUtil
|
||||||
if (root.getLocation().isPrefixOf(path))
|
if (root.getLocation().isPrefixOf(path))
|
||||||
path = path.removeFirstSegments(root.getLocation().segmentCount());
|
path = path.removeFirstSegments(root.getLocation().segmentCount());
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
IFile file = root.getFile(path);
|
IFile file = root.getFile(path);
|
||||||
if (file != null && file.exists())
|
if (file != null && file.exists())
|
||||||
return file;
|
return file;
|
||||||
|
@ -113,9 +105,7 @@ public class ParserUtil
|
||||||
return file;
|
return file;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
} catch (IllegalArgumentException e) { // thrown on invalid paths
|
||||||
catch( IllegalArgumentException iae ) //thrown on invalid paths
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,11 +113,9 @@ public class ParserUtil
|
||||||
protected static char[] findWorkingCopy(IResource resultingResource, Iterator<IWorkingCopy> workingCopies) {
|
protected static char[] findWorkingCopy(IResource resultingResource, Iterator<IWorkingCopy> workingCopies) {
|
||||||
if (parserLogService.isTracing())
|
if (parserLogService.isTracing())
|
||||||
parserLogService.traceLog("Attempting to find the working copy for " + resultingResource.getName()); //$NON-NLS-1$
|
parserLogService.traceLog("Attempting to find the working copy for " + resultingResource.getName()); //$NON-NLS-1$
|
||||||
while( workingCopies.hasNext() )
|
while (workingCopies.hasNext()) {
|
||||||
{
|
|
||||||
IWorkingCopy copy = workingCopies.next();
|
IWorkingCopy copy = workingCopies.next();
|
||||||
if (resultingResource.equals(copy.getResource()))
|
if (resultingResource.equals(copy.getResource())) {
|
||||||
{
|
|
||||||
if (parserLogService.isTracing())
|
if (parserLogService.isTracing())
|
||||||
parserLogService.traceLog("Working copy found!!"); //$NON-NLS-1$
|
parserLogService.traceLog("Working copy found!!"); //$NON-NLS-1$
|
||||||
return copy.getContents();
|
return copy.getContents();
|
||||||
|
|
Loading…
Add table
Reference in a new issue