1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

RESOLVED - bug 179393: factor IScanner.addDefinition(IMacro) into its own interface

https://bugs.eclipse.org/bugs/show_bug.cgi?id=179393
This commit is contained in:
Chris Recoskie 2007-04-04 15:51:14 +00:00
parent 3139aa5792
commit 30b7b74871
8 changed files with 57 additions and 17 deletions

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
/**
* This is the interface that an AST Service uses to delegate the construction
@ -43,7 +42,7 @@ public interface ICodeReaderFactory {
* @param path
* @return CodeReader for contents at that path.
*/
public CodeReader createCodeReaderForInclusion(IScanner scanner, String path);
public CodeReader createCodeReaderForInclusion(IMacroCollector callback, String path);
/**
* Returns the ICodeReaderCache used for this ICodeReaderFacotry.

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.parser.IMacro;
/**
* Allows an ICodeReaderFactory to retrieve macro definitions from the index,
* and then add these definitions to the scanner.
*
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
* </p>
*
* @since 4.0
*
*/
public interface IMacroCollector {
public void addDefinition(IMacro macro);
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.core.parser;
import java.util.Map;
import org.eclipse.cdt.core.dom.IMacroCollector;
import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
@ -19,8 +20,15 @@ import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
/**
* @author jcamelon
*
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
* </p>
*
*/
public interface IScanner {
public interface IScanner extends IMacroCollector {
public static final int tPOUNDPOUND = -6;
public static final int tPOUND = -7;

View file

@ -26,6 +26,7 @@ import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.IMacroCollector;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexFileLocation;
@ -35,7 +36,6 @@ import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IMacro;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
@ -103,7 +103,7 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
return ParserUtil.createReader(path, null);
}
public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
public CodeReader createCodeReaderForInclusion(IMacroCollector scanner, String path) {
// if the file is in the index, we skip it
File location= new File(path);
String canonicalPath= path;

View file

@ -11,10 +11,10 @@
package org.eclipse.cdt.internal.core.parser.scanner2;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.IMacroCollector;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.EmptyCodeReaderCache;
/**
@ -49,9 +49,9 @@ public class FileCodeReaderFactory implements ICodeReaderFactory {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(org.eclipse.cdt.core.dom.ICodeReaderFactoryCallback, java.lang.String)
*/
public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
public CodeReader createCodeReaderForInclusion(IMacroCollector scanner, String path) {
return cache.get(path);
}

View file

@ -11,9 +11,9 @@
package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.IMacroCollector;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
/**
* A <code>ICodeReaderFactory</code> which creates dummy <code>CodeReader</code>s without content.
@ -34,9 +34,9 @@ public class NullCodeReaderFactory implements ICodeReaderFactory {
}
/*
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(org.eclipse.cdt.core.parser.IScanner, java.lang.String)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(org.eclipse.cdt.core.dom.ICodeReaderFactoryCallback, java.lang.String)
*/
public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
public CodeReader createCodeReaderForInclusion(IMacroCollector scanner, String path) {
return new CodeReader(path, EMPTY_CHARS);
}

View file

@ -15,11 +15,11 @@ import java.util.Iterator;
import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.IMacroCollector;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
@ -70,9 +70,9 @@ public class PartialWorkingCopyCodeReaderFactory
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(org.eclipse.cdt.core.dom.ICodeReaderFactoryCallback, java.lang.String)
*/
public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
public CodeReader createCodeReaderForInclusion(IMacroCollector scanner, String path) {
return cache.get( path );
}

View file

@ -13,11 +13,11 @@ package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.IMacroCollector;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.CodeReaderCache;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.core.runtime.Preferences;
/**
@ -84,9 +84,9 @@ public class SavedCodeReaderFactory implements ICodeReaderFactory {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(org.eclipse.cdt.core.dom.ICodeReaderFactoryCallback, java.lang.String)
*/
public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
public CodeReader createCodeReaderForInclusion(IMacroCollector scanner, String path) {
return cache.get(path);
}