/// <summary> /// The CreateTranslationUnit /// </summary> /// <param name="sourceFileName">The sourceFileName<see cref="string"/></param> /// <param name="commandLineArgs">The cmdArgs<see cref="string[]"/></param> /// <param name="unsavedFiles">The unsavedFiles<see cref="UnsavedFile[]"/></param> /// <returns>The <see cref="TranslationUnit"/></returns> public TranslationUnit CreateTranslationUnit(string sourceFileName, string[] commandLineArgs, UnsavedFile[] unsavedFiles) { IntPtr pTranslationUnit = IntPtr.Zero; string[] commandLineArgsArray = commandLineArgs; UnsavedFile[] unsavedFilesArray = unsavedFiles; if (commandLineArgsArray == null) { commandLineArgsArray = new string[0]; } if (unsavedFilesArray == null) { unsavedFilesArray = new UnsavedFile[0]; } pTranslationUnit = clang.clang_createTranslationUnitFromSourceFile(this.m_value, sourceFileName, commandLineArgsArray.Length, commandLineArgsArray, (uint)unsavedFilesArray.Length, unsavedFilesArray.Select(x => (CXUnsavedFile)x.Value).ToArray()); if (pTranslationUnit == IntPtr.Zero) { return(null); } return(new TranslationUnit(pTranslationUnit)); }
/// <summary> /// The Parse /// </summary> /// <param name="sourceFileName">The sourceFileName<see cref="string"/></param> /// <param name="globalOptFlags">The globalOptFlags<see cref="CXGlobalOptFlags"/></param> /// <param name="commandLineArgs">The commandLineArgs<see cref="string[]"/></param> /// <param name="unsavedFiles">The unsavedFiles<see cref="UnsavedFile[]"/></param> /// <param name="errorCode">The errorCode<see cref="CXErrorCode"/></param> /// <returns>The <see cref="TranslationUnit"/></returns> public TranslationUnit Parse(string sourceFileName, string[] commandLineArgs, UnsavedFile[] unsavedFiles, CXTranslationUnit_Flags globalOptFlags, out CXErrorCode errorCode) { IntPtr pTranslationUnit = IntPtr.Zero; string[] commandLineArgsArray = commandLineArgs; UnsavedFile[] unsavedFilesArray = unsavedFiles; if (commandLineArgsArray == null) { commandLineArgsArray = new string[0]; } if (unsavedFilesArray == null) { unsavedFilesArray = new UnsavedFile[0]; } errorCode = clang.clang_parseTranslationUnit2(this.m_value, sourceFileName, commandLineArgsArray, commandLineArgsArray.Length, unsavedFilesArray.Select(x => (CXUnsavedFile)x.Value).ToArray(), (uint)unsavedFilesArray.Length, (uint)globalOptFlags, out pTranslationUnit); if (pTranslationUnit == IntPtr.Zero) { return(null); } return(new TranslationUnit(pTranslationUnit)); }
/// <summary> /// The CodeCompleteAt /// </summary> /// <param name="completeFileName">The completeFileName<see cref="string"/></param> /// <param name="completeline">The completeline<see cref="uint"/></param> /// <param name="completeColumn">The completeColumn<see cref="uint"/></param> /// <param name="unsavedFiles">The unsavedFiles<see cref="UnsavedFile[]"/></param> /// <param name="flags">The flags<see cref="CXCodeComplete_Flags"/></param> /// <returns>The <see cref="CodeCompleteResults"/></returns> public unsafe CodeCompleteResults CodeCompleteAt(string completeFileName, uint completeline, uint completeColumn, UnsavedFile[] unsavedFiles, CXCodeComplete_Flags flags) { if (completeFileName == null) { throw new ArgumentNullException("completeFileName"); } if (unsavedFiles == null) { unsavedFiles = new UnsavedFile[0]; } CXCodeCompleteResults *pCodeComplete = clang.clang_codeCompleteAt(this.m_value, completeFileName, completeline, completeColumn, unsavedFiles.Select(x => (CXUnsavedFile)x.Value).ToArray(), (uint)unsavedFiles.Length, (uint)flags); return(new CodeCompleteResults(pCodeComplete)); }
/// <summary> /// The Reparse /// </summary> /// <param name="unsavedFiles">The unsavedFiles<see cref="UnsavedFile[]"/></param> /// <param name="reparseFlags">The reparseFlags<see cref="CXReparse_Flags"/></param> public CXErrorCode Reparse(UnsavedFile[] unsavedFiles, CXReparse_Flags reparseFlags) { UnsavedFile[] unsavedFilesArray = unsavedFiles; if (unsavedFilesArray == null) { unsavedFilesArray = new UnsavedFile[0]; } CXErrorCode errorCode = (CXErrorCode)clang.clang_reparseTranslationUnit(this.m_value, (uint)unsavedFilesArray.Length, unsavedFilesArray.Select(x => (CXUnsavedFile)x.Value).ToArray(), (uint)reparseFlags); return(errorCode); }
/// <summary> /// The ParseWithFullArguments /// </summary> /// <param name="sourceFileName">The sourceFileName<see cref="string"/></param> /// <param name="globalOptFlags">The globalOptFlags<see cref="CXGlobalOptFlags"/></param> /// <param name="commandLineArgs">The commandLineArgs<see cref="string[]"/></param> /// <param name="unsavedFiles">The unsavedFiles<see cref="UnsavedFile[]"/></param> /// <param name="errorCode">The errorCode<see cref="CXErrorCode"/></param> /// <returns>The <see cref="TranslationUnit"/></returns> public TranslationUnit Parse(string sourceFileName, string clangExecutablePath, string[] commandLineArgs, UnsavedFile[] unsavedFiles, CXTranslationUnit_Flags globalOptFlags, out CXErrorCode errorCode) { IntPtr pTranslationUnit = IntPtr.Zero; string[] commandLineArgsArray = commandLineArgs; UnsavedFile[] unsavedFilesArray = unsavedFiles; if (string.IsNullOrEmpty(clangExecutablePath) || string.IsNullOrWhiteSpace(clangExecutablePath)) { errorCode = CXErrorCode.CXError_InvalidArguments; return(null); } if (commandLineArgsArray == null || commandLineArgsArray.Length == 0) { commandLineArgsArray = new string[1] { clangExecutablePath }; } else { commandLineArgsArray = Array.CreateInstance(typeof(string), 1 + commandLineArgs.Length) as string[]; commandLineArgsArray[0] = clangExecutablePath; Array.Copy(commandLineArgs, 0, commandLineArgsArray, 1, commandLineArgs.Length); } if (unsavedFilesArray == null) { unsavedFilesArray = new UnsavedFile[0]; } errorCode = clang.clang_parseTranslationUnit2FullArgv(this.m_value, sourceFileName, commandLineArgsArray, commandLineArgsArray.Length, unsavedFiles.Select(x => (CXUnsavedFile)x.Value).ToArray(), (uint)unsavedFiles.Length, (uint)globalOptFlags, out pTranslationUnit); if (pTranslationUnit == IntPtr.Zero) { return(null); } return(new TranslationUnit(pTranslationUnit)); }
/// <summary> /// The IndexSourceFile /// </summary> /// <param name="sourceFile">The sourceFile<see cref="string"/></param> /// <param name="commandLineArgs">The commandLineArgs<see cref="string[]"/></param> /// <param name="unsavedFiles">The unsavedFiles<see cref="UnsavedFile[]"/></param> /// <param name="indexOptFlags">The indexOptFlags<see cref="CXIndexOptFlags"/></param> /// <param name="translationUnit_Flags">The translationUnit_Flags<see cref="CXTranslationUnit_Flags"/></param> /// <param name="errorCode">The errorCode<see cref="CXErrorCode"/></param> /// <returns>The <see cref="CXErrorCode"/></returns> public TranslationUnit IndexSourceFile(string sourceFile, string[] commandLineArgs, UnsavedFile[] unsavedFiles, CXIndexOptFlags indexOptFlags, CXTranslationUnit_Flags translationUnit_Flags, out CXErrorCode errorCode) { TranslationUnit translationUnit = null; string[] commandLineArgsArray = commandLineArgs; UnsavedFile[] unsavedFilesArray = unsavedFiles; if (commandLineArgsArray == null) { commandLineArgsArray = new string[0]; } if (unsavedFilesArray == null) { unsavedFilesArray = new UnsavedFile[0]; } using (Pointer <IndexerCallbacks> ptrIndexerCallbacks = new Pointer <IndexerCallbacks>(this._indexerCallbacks)) { IntPtr pTU = IntPtr.Zero; errorCode = (CXErrorCode)clang.clang_indexSourceFile(this.m_value, IntPtr.Zero, ptrIndexerCallbacks, (uint)(ptrIndexerCallbacks.Size), (uint)indexOptFlags, sourceFile, commandLineArgsArray, commandLineArgsArray.Length, unsavedFilesArray.Select(x => (CXUnsavedFile)x.Value).ToArray(), (uint)unsavedFilesArray.Length, out pTU, (uint)translationUnit_Flags ); if (pTU != IntPtr.Zero) { translationUnit = new TranslationUnit(pTU); } return(translationUnit); } }