本文整理汇总了C#中TextDocument.GetCodeLanguage方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.GetCodeLanguage方法的具体用法?C# TextDocument.GetCodeLanguage怎么用?C# TextDocument.GetCodeLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextDocument
的用法示例。
在下文中一共展示了TextDocument.GetCodeLanguage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CodeComment
/// <summary>
/// Initializes a new instance of the <see cref="CodeComment" /> class.
/// </summary>
public CodeComment(TextPoint point, int tabSize)
{
if (point == null)
{
throw new ArgumentNullException(nameof(point));
}
_document = point.Parent;
_commentLineRegex = CodeCommentHelper.GetCommentRegex(_document.GetCodeLanguage());
_tabSize = tabSize;
Expand(point);
}
示例2: GetFileHeaderFromSettings
/// <summary>
/// Gets the file header from settings based on the language of the specified document.
/// </summary>
/// <param name="textDocument">The text document.</param>
/// <returns>A file header from settings.</returns>
private static string GetFileHeaderFromSettings(TextDocument textDocument)
{
switch (textDocument.GetCodeLanguage())
{
case CodeLanguage.CPlusPlus: return Settings.Default.Cleaning_UpdateFileHeaderCPlusPlus;
case CodeLanguage.CSharp: return Settings.Default.Cleaning_UpdateFileHeaderCSharp;
case CodeLanguage.CSS: return Settings.Default.Cleaning_UpdateFileHeaderCSS;
case CodeLanguage.FSharp: return Settings.Default.Cleaning_UpdateFileHeaderFSharp;
case CodeLanguage.HTML: return Settings.Default.Cleaning_UpdateFileHeaderHTML;
case CodeLanguage.JavaScript: return Settings.Default.Cleaning_UpdateFileHeaderJavaScript;
case CodeLanguage.JSON: return Settings.Default.Cleaning_UpdateFileHeaderJSON;
case CodeLanguage.LESS: return Settings.Default.Cleaning_UpdateFileHeaderLESS;
case CodeLanguage.PHP: return Settings.Default.Cleaning_UpdateFileHeaderPHP;
case CodeLanguage.PowerShell: return Settings.Default.Cleaning_UpdateFileHeaderPowerShell;
case CodeLanguage.R: return Settings.Default.Cleaning_UpdateFileHeaderR;
case CodeLanguage.SCSS: return Settings.Default.Cleaning_UpdateFileHeaderSCSS;
case CodeLanguage.TypeScript: return Settings.Default.Cleaning_UpdateFileHeaderTypeScript;
case CodeLanguage.VisualBasic: return Settings.Default.Cleaning_UpdateFileHeaderVB;
case CodeLanguage.XAML: return Settings.Default.Cleaning_UpdateFileHeaderXAML;
case CodeLanguage.XML: return Settings.Default.Cleaning_UpdateFileHeaderXML;
default: return null;
}
}
示例3: GetCommentPrefix
/// <summary>
/// Get the comment prefix (regex) for the given document's language.
/// </summary>
/// <param name="document">The document.</param>
/// <returns>The comment prefix regex, without trailing spaces.</returns>
internal static string GetCommentPrefix(TextDocument document)
{
return GetCommentPrefixForLanguage(document.GetCodeLanguage());
}
示例4: RemoveEOFTrailingNewLine
/// <summary>
/// Removes the trailing newline from the end of the specified text document.
/// </summary>
/// <param name="textDocument">The text document to cleanup.</param>
internal void RemoveEOFTrailingNewLine(TextDocument textDocument)
{
if (!Settings.Default.Cleaning_RemoveEndOfFileTrailingNewLine) return;
EditPoint cursor = textDocument.EndPoint.CreateEditPoint();
if (cursor.AtEndOfDocument && cursor.AtStartOfLine && cursor.AtEndOfLine)
{
// Make an exception for C++ resource files to work-around known EOF issue: http://connect.microsoft.com/VisualStudio/feedback/details/173903/resource-compiler-returns-a-rc1004-unexpected-eof-found-error#details
if (textDocument.GetCodeLanguage() == CodeLanguage.CPlusPlus &&
(textDocument.Parent.FullName.EndsWith(".h") || textDocument.Parent.FullName.EndsWith(".rc2")))
{
return;
}
var backCursor = cursor.CreateEditPoint();
backCursor.CharLeft();
backCursor.Delete(cursor);
}
}