mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
patch from Jason Montojo for Bugzilla 165378
This commit is contained in:
parent
a6693eba42
commit
d462042f3a
6 changed files with 31 additions and 9 deletions
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
@ -18,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
@ -107,6 +109,17 @@ public interface ILanguage extends IAdaptable {
|
||||||
*/
|
*/
|
||||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu);
|
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu);
|
||||||
|
|
||||||
// mstodo javadoc
|
/**
|
||||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index) throws CoreException;
|
* Construct an AST for the source code provided by <code>reader</code>.
|
||||||
|
* @param reader source code to be parsed.
|
||||||
|
* @param scanInfo provides include paths and defined symbols.
|
||||||
|
* @param fileCreator factory that provides CodeReaders for files included
|
||||||
|
* by the source code being parsed.
|
||||||
|
* @param index (optional) index to use to provide support for ambiguity
|
||||||
|
* resolution.
|
||||||
|
* @param log logger
|
||||||
|
* @return an AST for the source code provided by reader.
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log) throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
@ -770,7 +771,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
|
|
||||||
ILanguage language= getLanguage();
|
ILanguage language= getLanguage();
|
||||||
if (language != null) {
|
if (language != null) {
|
||||||
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index);
|
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.dom.ast.gnu.c;
|
package org.eclipse.cdt.core.dom.ast.gnu.c;
|
||||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
@ -78,12 +80,12 @@ public class GCCLanguage extends AbstractLanguage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader,
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader,
|
||||||
IScannerInfo scanInfo, ICodeReaderFactory codeReaderFactory, IIndex index) throws CoreException {
|
IScannerInfo scanInfo, ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
||||||
IScannerExtensionConfiguration scannerExtensionConfiguration= C_GNU_SCANNER_EXTENSION;
|
IScannerExtensionConfiguration scannerExtensionConfiguration= C_GNU_SCANNER_EXTENSION;
|
||||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||||
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
||||||
//assume GCC
|
//assume GCC
|
||||||
ISourceCodeParser parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(),
|
ISourceCodeParser parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
|
||||||
new GCCParserExtensionConfiguration() );
|
new GCCParserExtensionConfiguration() );
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
||||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
@ -78,12 +80,12 @@ public class GPPLanguage extends AbstractLanguage {
|
||||||
|
|
||||||
|
|
||||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||||
ICodeReaderFactory codeReaderFactory, IIndex index) throws CoreException {
|
ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
||||||
IScannerExtensionConfiguration scannerExtensionConfiguration= CPP_GNU_SCANNER_EXTENSION;
|
IScannerExtensionConfiguration scannerExtensionConfiguration= CPP_GNU_SCANNER_EXTENSION;
|
||||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||||
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
||||||
//assume GCC
|
//assume GCC
|
||||||
ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, ParserUtil.getParserLogService(),
|
ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
|
||||||
new GPPParserExtensionConfiguration() );
|
new GPPParserExtensionConfiguration() );
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||||
|
@ -24,6 +25,7 @@ import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
||||||
|
@ -86,7 +88,7 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
// get the AST in a "Fast" way
|
// get the AST in a "Fast" way
|
||||||
IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanner, codeReaderFactory, index);
|
IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanner, codeReaderFactory, index, ParserUtil.getParserLogService());
|
||||||
if (pm.isCanceled()) {
|
if (pm.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Sergey Prigogin, Google
|
* Sergey Prigogin, Google
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.formatter;
|
package org.eclipse.cdt.internal.formatter;
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -163,7 +165,7 @@ public class CCodeFormatter extends CodeFormatter {
|
||||||
}
|
}
|
||||||
IASTTranslationUnit ast;
|
IASTTranslationUnit ast;
|
||||||
try {
|
try {
|
||||||
ast= language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, null);
|
ast= language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, null, ParserUtil.getParserLogService());
|
||||||
CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length);
|
CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length);
|
||||||
edit= codeFormatter.format(source, ast);
|
edit= codeFormatter.format(source, ast);
|
||||||
} catch (CoreException exc) {
|
} catch (CoreException exc) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue