Java Code Examples for org.eclipse.cdt.core.parser.IncludeFileContentProvider#getEmptyFilesProvider()
The following examples show how to use
org.eclipse.cdt.core.parser.IncludeFileContentProvider#getEmptyFilesProvider() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCdtAstExtractor.java From api-mining with GNU General Public License v3.0 | 5 votes |
/** * Return an AST for the following CDT-compatible code; * * @param code * @return * @throws CoreException */ public final IASTTranslationUnit getAST(final char[] code, final String baseIncludePath) throws CoreException { final FileContent fc = FileContent.create(baseIncludePath, code); final Map<String, String> macroDefinitions = Maps.newHashMap(); final String[] includeSearchPaths = new String[0]; final IScannerInfo si = new ScannerInfo(macroDefinitions, includeSearchPaths); final IncludeFileContentProvider ifcp = IncludeFileContentProvider .getEmptyFilesProvider(); final IIndex idx = null; final int options = ILanguage.OPTION_IS_SOURCE_UNIT; final IParserLogService log = new DefaultLogService(); return getAstForLanguage(fc, si, ifcp, idx, options, log); }
Example 2
Source File: AbstractCdtAstExtractor.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Return an AST for the following CDT-compatible code; * * @param code * @return * @throws CoreException */ public final IASTTranslationUnit getAST(final char[] code, final String baseIncludePath) throws CoreException { final FileContent fc = FileContent.create(baseIncludePath, code); final Map<String, String> macroDefinitions = Maps.newHashMap(); final String[] includeSearchPaths = new String[0]; final IScannerInfo si = new ScannerInfo(macroDefinitions, includeSearchPaths); final IncludeFileContentProvider ifcp = IncludeFileContentProvider .getEmptyFilesProvider(); final IIndex idx = null; final int options = ILanguage.OPTION_IS_SOURCE_UNIT; final IParserLogService log = new DefaultLogService(); return getAstForLanguage(fc, si, ifcp, idx, options, log); }
Example 3
Source File: AbstractCdtAstExtractor.java From codemining-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Return an AST for the following CDT-compatible code; * * @param code * @return * @throws CoreException */ public final IASTTranslationUnit getAST(final char[] code, final String baseIncludePath) throws CoreException { final FileContent fc = FileContent.create(baseIncludePath, code); final Map<String, String> macroDefinitions = Maps.newHashMap(); final String[] includeSearchPaths = new String[0]; final IScannerInfo si = new ScannerInfo(macroDefinitions, includeSearchPaths); final IncludeFileContentProvider ifcp = IncludeFileContentProvider .getEmptyFilesProvider(); final IIndex idx = null; final int options = ILanguage.OPTION_IS_SOURCE_UNIT; final IParserLogService log = new DefaultLogService(); return getAstForLanguage(fc, si, ifcp, idx, options, log); }
Example 4
Source File: Scanner.java From depends with MIT License | 4 votes |
/** * Build a scanner used for parser * @param file -- the scanned source file * @param macroMap -- the macro maps * @param sysIncludePath -- the included paths * @param shouldScanInclusionFiles -- whether to scan the included files * @return the scanner */ public static IScanner buildScanner(String file, Map<String, String> macroMap, List<String> sysIncludePath, boolean shouldScanInclusionFiles) { String content = ""; try { CodeReader cr = new CodeReader(file); content = new String(cr.buffer); } catch (IOException e) { } IScannerInfo scannerInfo = new ScannerInfo(macroMap, sysIncludePath.toArray(new String[] {})); IScannerExtensionConfiguration configuration = GPPScannerExtensionConfiguration.getInstance(scannerInfo); InternalFileContentProvider ifcp = new InternalFileContentProvider() { @Override public InternalFileContent getContentForInclusion(String filePath, IMacroDictionary macroDictionary) { InternalFileContent ifc = null; if (!shouldScanInclusionFiles) { ifc = new InternalFileContent(filePath, InclusionKind.SKIP_FILE); }else { ifc = FileCache.getInstance().get(filePath); } if (ifc == null) { ifc = (InternalFileContent) FileContent.createForExternalFileLocation(filePath); FileCache.getInstance().put(filePath, ifc); } return ifc; } @Override public InternalFileContent getContentForInclusion(IIndexFileLocation ifl, String astPath) { InternalFileContent c = FileCache.getInstance().get(ifl); if (c == null) { c = (InternalFileContent) FileContent.create(ifl); FileCache.getInstance().put(ifl, c); } return c; } }; ParserLanguage lang = ParserLanguage.CPP; if (file.endsWith(".c")) lang = ParserLanguage.C; IScanner scanner = new CPreprocessor(FileContent.create(file, content.toCharArray()), scannerInfo, lang, new NullLogService(), configuration, IncludeFileContentProvider.getEmptyFilesProvider()); scanner.setProcessInactiveCode(true); return scanner; }