mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Removal / deprecation of options to create ast with comment nodes, bug 259841.
This commit is contained in:
parent
11d97b0055
commit
7982f97b6c
10 changed files with 54 additions and 56 deletions
|
@ -3975,8 +3975,8 @@ public class AST2Tests extends AST2BaseTest {
|
|||
// INVALID(1, 2)
|
||||
//
|
||||
public void test192639() throws Exception {
|
||||
parse( getAboveComment(), ParserLanguage.CPP, false, false, true );
|
||||
parse( getAboveComment(), ParserLanguage.C, false, false, true );
|
||||
parse( getAboveComment(), ParserLanguage.CPP, false, false );
|
||||
parse( getAboveComment(), ParserLanguage.C, false, false );
|
||||
}
|
||||
|
||||
public void test195943() throws Exception {
|
||||
|
@ -5786,10 +5786,8 @@ public class AST2Tests extends AST2BaseTest {
|
|||
buf.append(input[2].toString());
|
||||
final String code= buf.toString();
|
||||
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||
IASTTranslationUnit tu= parse(code, lang, false, true, true);
|
||||
tu= null;
|
||||
long mem= memoryUsed();
|
||||
tu= parse(code, lang, false, true, true);
|
||||
IASTTranslationUnit tu= parse(code, lang, false, true, true);
|
||||
long diff= memoryUsed()-mem;
|
||||
final int expected = 1024*20 + code.length()*2; // a copy of the buffer + some
|
||||
assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected);
|
||||
|
|
|
@ -30,14 +30,14 @@ public class CommentTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testCountCommentsInHeaderFile() throws ParserException{
|
||||
IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true, true);
|
||||
IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals(9, comments.length);
|
||||
}
|
||||
|
||||
public void testCommentsInHeaderFile() throws ParserException{
|
||||
IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true, true);
|
||||
IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals("/* A very cool class\n * isn't it?\n */", new String(comments[0].getComment()));
|
||||
|
@ -52,14 +52,14 @@ public class CommentTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testCountCommentsInCPPFile() throws ParserException{
|
||||
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true, true);
|
||||
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals(10, comments.length);
|
||||
}
|
||||
|
||||
public void testCommentsInCPPFile() throws ParserException{
|
||||
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true, true);
|
||||
IASTTranslationUnit tu = parse(getCppSource(), ParserLanguage.CPP, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals("// Comment in cpp", new String(comments[0].getComment()));
|
||||
|
@ -75,14 +75,14 @@ public class CommentTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testCountCommentsInCFile() throws ParserException{
|
||||
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true, true);
|
||||
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals(4, comments.length);
|
||||
}
|
||||
|
||||
public void testCommentsInCFile() throws ParserException{
|
||||
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true, true);
|
||||
IASTTranslationUnit tu = parse(getCSource(), ParserLanguage.C, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals("//A little input/output programm", new String(comments[0].getComment()));
|
||||
|
@ -202,7 +202,7 @@ public class CommentTests extends AST2BaseTest {
|
|||
// #endif
|
||||
public void testCommentsInInactiveCode_bug183930() throws Exception {
|
||||
StringBuffer code= getContents(1)[0];
|
||||
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true, true);
|
||||
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals(2, comments.length);
|
||||
|
@ -213,14 +213,14 @@ public class CommentTests extends AST2BaseTest {
|
|||
// //comment
|
||||
public void testCommentLocation_bug186337() throws Exception{
|
||||
StringBuffer code= getContents(1)[0];
|
||||
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true, true);
|
||||
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals(1, comments.length);
|
||||
assertNotNull(comments[0].getFileLocation());
|
||||
assertNotNull(comments[0].getNodeLocations());
|
||||
|
||||
tu = parse(code.toString(), ParserLanguage.C, false, true, true);
|
||||
tu = parse(code.toString(), ParserLanguage.C, false, true);
|
||||
comments = tu.getComments();
|
||||
|
||||
assertEquals(1, comments.length);
|
||||
|
@ -237,7 +237,7 @@ public class CommentTests extends AST2BaseTest {
|
|||
|
||||
public void testCommentInDirectives_bug192546() throws Exception {
|
||||
StringBuffer code= getContents(1)[0];
|
||||
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false, true);
|
||||
IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false);
|
||||
IASTComment[] comments = tu.getComments();
|
||||
|
||||
assertEquals(5, comments.length);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TaskParserTest extends AST2BaseTest {
|
|||
"// TODO FIXME tag 5\n" +
|
||||
"\n" +
|
||||
"const char* x = \"TODO Not a tag\";";
|
||||
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, false, true, true);
|
||||
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, false, true);
|
||||
TodoTaskParser parser = new TodoTaskParser(taskTags, taskPriorities, isTaskCaseSensitive);
|
||||
Task[] tasks = parser.parse(tu.getComments());
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@ public interface ILanguage extends IAdaptable {
|
|||
public final static int OPTION_SKIP_FUNCTION_BODIES= 0x1;
|
||||
|
||||
/**
|
||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||
* Instructs the parser to add comment nodes to the ast.
|
||||
* @deprecated, has no effect.
|
||||
*/
|
||||
@Deprecated
|
||||
public final static int OPTION_ADD_COMMENTS= 0x2;
|
||||
|
||||
/**
|
||||
|
@ -140,7 +140,7 @@ public interface ILanguage extends IAdaptable {
|
|||
* @param index (optional) index to use to provide support for ambiguity
|
||||
* resolution.
|
||||
* @param options A combination of
|
||||
* {@link #OPTION_SKIP_FUNCTION_BODIES}, {@link #OPTION_ADD_COMMENTS},
|
||||
* {@link #OPTION_SKIP_FUNCTION_BODIES},
|
||||
* {@link #OPTION_NO_IMAGE_LOCATIONS}, {@link #OPTION_IS_SOURCE_UNIT},
|
||||
* or <code>0</code>.
|
||||
* @param log logger
|
||||
|
|
|
@ -72,10 +72,10 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
public static final int AST_SKIP_IF_NO_BUILD_INFO = 0x8;
|
||||
|
||||
/**
|
||||
* Style constant for {@link #getAST(IIndex, int)}.
|
||||
* Meaning: Add nodes for comments to the ast.
|
||||
* @deprecated The option has no effect.
|
||||
* @since 4.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static final int AST_CREATE_COMMENT_NODES = 0x10;
|
||||
|
||||
/**
|
||||
|
@ -491,7 +491,7 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
* translation unit does not support ASTs.
|
||||
* @param index index to back up the parsing of the AST, may be <code>null</code>
|
||||
* @param style <code>0</code> or a combination of {@link #AST_SKIP_ALL_HEADERS},
|
||||
* {@link #AST_SKIP_IF_NO_BUILD_INFO}, {@link #AST_SKIP_INDEXED_HEADERS}, {@link #AST_CREATE_COMMENT_NODES}
|
||||
* {@link #AST_SKIP_IF_NO_BUILD_INFO}, {@link #AST_SKIP_INDEXED_HEADERS}
|
||||
* and {@link #AST_CONFIGURE_USING_SOURCE_CONTEXT}.
|
||||
* @return the AST requested or <code>null</code>
|
||||
* @throws CoreException
|
||||
|
|
|
@ -820,9 +820,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
if ((style & AST_SKIP_FUNCTION_BODIES) != 0) {
|
||||
options |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
|
||||
}
|
||||
if ((style & AST_CREATE_COMMENT_NODES) != 0) {
|
||||
options |= ILanguage.OPTION_ADD_COMMENTS;
|
||||
}
|
||||
if ((style & AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) {
|
||||
options |= ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,6 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
|
|||
ICodeReaderFactory codeReaderFactory, IIndex index, int options, IParserLogService log) throws CoreException {
|
||||
|
||||
final IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
||||
scanner.setScanComments((options & OPTION_ADD_COMMENTS) != 0);
|
||||
scanner.setComputeImageLocations((options & OPTION_NO_IMAGE_LOCATIONS) == 0);
|
||||
|
||||
final ISourceCodeParser parser= createParser(scanner, log, index, false, options);
|
||||
|
|
|
@ -26,27 +26,11 @@ import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
|
|||
* work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
* </p>
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IScanner {
|
||||
|
||||
/**
|
||||
* Puts the scanner into content assist mode.
|
||||
*/
|
||||
public void setContentAssistMode( int offset );
|
||||
|
||||
/**
|
||||
* Turns on/off comment parsing.
|
||||
* @since 4.0
|
||||
*/
|
||||
public void setScanComments(boolean val);
|
||||
|
||||
/**
|
||||
* Turns on/off creation of image locations.
|
||||
* @see IASTName#getImageLocation()
|
||||
* @since 5.0
|
||||
*/
|
||||
public void setComputeImageLocations(boolean val);
|
||||
|
||||
/**
|
||||
* Returns a map from {@link String} to {@link IMacroBinding} containing
|
||||
* all the definitions that are defined at the current point in the
|
||||
|
@ -73,6 +57,29 @@ public interface IScanner {
|
|||
|
||||
/**
|
||||
* Returns the location resolver associated with this scanner.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public ILocationResolver getLocationResolver();
|
||||
|
||||
/**
|
||||
* Puts the scanner into content assist mode.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void setContentAssistMode(int offset);
|
||||
|
||||
/**
|
||||
* Method has no effect.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
* @since 4.0
|
||||
*/
|
||||
@Deprecated
|
||||
public void setScanComments(boolean val);
|
||||
|
||||
/**
|
||||
* Turns on/off creation of image locations.
|
||||
* @see IASTName#getImageLocation()
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
* @since 5.0
|
||||
*/
|
||||
public void setComputeImageLocations(boolean val);
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
fTodoTaskUpdater= createTodoTaskUpdater();
|
||||
|
||||
fASTOptions= ILanguage.OPTION_ADD_COMMENTS | ILanguage.OPTION_NO_IMAGE_LOCATIONS
|
||||
fASTOptions= ILanguage.OPTION_NO_IMAGE_LOCATIONS
|
||||
| ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
|
||||
if (getSkipReferences() == SKIP_ALL_REFERENCES) {
|
||||
fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
|
||||
|
|
|
@ -71,14 +71,14 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
|||
* @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit()
|
||||
*/
|
||||
public IASTTranslationUnit getTranslationUnit(IFile fileToParse) throws UnsupportedDialectException {
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, SavedCodeReaderFactory.getInstance(), null, false);
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, SavedCodeReaderFactory.getInstance(), null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.IASTServiceProvider#getTranslationUnit(org.eclipse.cdt.core.dom.ICodeReaderFactory)
|
||||
*/
|
||||
public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator) throws UnsupportedDialectException {
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, null, false);
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -86,11 +86,11 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
|||
*/
|
||||
public IASTTranslationUnit getTranslationUnit(
|
||||
IFile fileToParse, ICodeReaderFactory fileCreator, IParserConfiguration configuration) throws UnsupportedDialectException {
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, configuration, false);
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, configuration);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(
|
||||
String filename, IResource infoProvider, ICodeReaderFactory fileCreator, IParserConfiguration configuration, boolean parseComment) throws UnsupportedDialectException
|
||||
String filename, IResource infoProvider, ICodeReaderFactory fileCreator, IParserConfiguration configuration) throws UnsupportedDialectException
|
||||
{
|
||||
IProject project = infoProvider.getProject();
|
||||
IScannerInfo scanInfo = null;
|
||||
|
@ -127,7 +127,6 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
|||
scannerExtensionConfiguration = C_GNU_SCANNER_EXTENSION;
|
||||
scanner= createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, l, ParserFactory.createDefaultLogService(),
|
||||
scannerExtensionConfiguration, fileCreator);
|
||||
scanner.setScanComments(parseComment);
|
||||
//assume GCC
|
||||
if( l == ParserLanguage.C )
|
||||
parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(), new GCCParserExtensionConfiguration() );
|
||||
|
@ -146,8 +145,6 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
|||
else
|
||||
throw new UnsupportedDialectException();
|
||||
|
||||
scanner.setScanComments(parseComment);
|
||||
|
||||
if( dialect.equals( dialects[0]))
|
||||
{
|
||||
ICParserExtensionConfiguration config = new ANSICParserExtensionConfiguration();
|
||||
|
@ -278,18 +275,18 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
|||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project, ICodeReaderFactory fileCreator) throws UnsupportedDialectException{
|
||||
return getTranslationUnit( fileToParse.getFullPath().toOSString(), project, fileCreator, null, false);
|
||||
return getTranslationUnit( fileToParse.getFullPath().toOSString(), project, fileCreator, null);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IStorage fileToParse, IProject project) throws UnsupportedDialectException {
|
||||
return getTranslationUnit( fileToParse.getFullPath().toOSString(), project, SavedCodeReaderFactory.getInstance(), null, false);
|
||||
return getTranslationUnit( fileToParse.getFullPath().toOSString(), project, SavedCodeReaderFactory.getInstance(), null);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IFile fileToParse, boolean parseComments) throws UnsupportedDialectException {
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, SavedCodeReaderFactory.getInstance(), null, parseComments);
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, SavedCodeReaderFactory.getInstance(), null);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(IFile fileToParse, ICodeReaderFactory fileCreator, boolean parseComments) throws UnsupportedDialectException {
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, null, parseComments);
|
||||
return getTranslationUnit( fileToParse.getLocation().toOSString(), fileToParse, fileCreator, null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue