本文整理汇总了C#中ITextSource类的典型用法代码示例。如果您正苦于以下问题:C# ITextSource类的具体用法?C# ITextSource怎么用?C# ITextSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextSource类属于命名空间,在下文中一共展示了ITextSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SimpleReadonlyDocument
SimpleReadonlyDocument (ITextSource readOnlyTextSource, string fileName, string mimeType)
{
textSource = readOnlyTextSource;
FileName = fileName;
MimeType = mimeType;
Initalize (readOnlyTextSource.Text);
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:7,代码来源:SimpleReadonlyDocument.cs
示例2: CreateNewFoldings
/// <summary>
/// Create <see cref="NewFolding"/>s for the specified document.
/// </summary>
public IEnumerable<NewFolding> CreateNewFoldings(ITextSource document)
{
List<NewFolding> newFoldings = new List<NewFolding>();
Stack<int> startOffsets = new Stack<int>();
int lastNewLineOffset = 0;
int len = document.TextLength;
foreach(var segment in _tokenservice.GetSegments()) {
if(segment.Token == Token.BlockOpen || segment.Token == Token.BlockClosed) {
if(segment.Token == _openingBrace) {
startOffsets.Push(segment.Range.Offset);
} else if(segment.Token == _closingBrace && startOffsets.Count > 0) {
int startOffset = startOffsets.Pop();
// don't fold if opening and closing brace are on the same line
if(startOffset < lastNewLineOffset) {
int endoffset = segment.Range.Offset + 1;
if(startOffset < len && endoffset < len) {
newFoldings.Add(new NewFolding(startOffset, endoffset));
}
}
}
} else if(segment.Token == Token.NewLine) {
lastNewLineOffset = segment.Range.Offset;
}
}
newFoldings.Sort((a, b) => a.StartOffset.CompareTo(b.StartOffset));
return newFoldings;
}
开发者ID:RaptorOne,项目名称:SmartDevelop,代码行数:34,代码来源:FoldingStrategyAHKv1.cs
示例3: CreateNewFoldings
public IEnumerable<NewFolding> CreateNewFoldings(ITextSource document)
{
if (document == null)
throw new ArgumentNullException("document");
var newFoldings = new List<NewFolding>();
var startOffsets = new Stack<int>();
int lastNewLineOffset = 0;
char openingBrace = OpeningBrace;
char closingBrace = ClosingBrace;
for (int i = 0; i < document.TextLength; i++)
{
char c = document.GetCharAt(i);
if (c == openingBrace)
{
startOffsets.Push(i);
}
else if (c == closingBrace && startOffsets.Count > 0)
{
int startOffset = startOffsets.Pop();
// don't fold if opening and closing brace are on the same line
if (startOffset < lastNewLineOffset)
{
newFoldings.Add(new NewFolding(startOffset, i + 1));
}
}
else if (c == '\n' || c == '\r')
{
lastNewLineOffset = i + 1;
}
}
newFoldings.Sort((a, b) => a.StartOffset.CompareTo(b.StartOffset));
return newFoldings;
}
开发者ID:Xamarui,项目名称:elasticops,代码行数:35,代码来源:BraceFoldingStrategy.cs
示例4: GetSingleIndentationSegment
/// <summary>
/// Gets a single indentation segment starting at <paramref name="offset" /> - at most one tab
/// or <paramref name="indentationSize" /> spaces.
/// </summary>
/// <param name="textSource">The text source.</param>
/// <param name="offset">The offset where the indentation segment starts.</param>
/// <param name="indentationSize">The size of an indentation unit. See <see cref="TextEditorOptions.IndentationSize" />.</param>
/// <returns>
/// The indentation segment.
/// If there is no indentation character at the specified <paramref name="offset" />,
/// an empty segment is returned.
/// </returns>
public static ISegment GetSingleIndentationSegment(ITextSource textSource, int offset, int indentationSize)
{
if (textSource == null)
throw new ArgumentNullException("textSource");
var pos = offset;
while (pos < textSource.TextLength)
{
var c = textSource.GetCharAt(pos);
if (c == '\t')
{
if (pos == offset)
return new SimpleSegment(offset, 1);
break;
}
if (c == ' ')
{
if (pos - offset >= indentationSize)
break;
}
else
{
break;
}
// continue only if c==' ' and (pos-offset)<tabSize
pos++;
}
return new SimpleSegment(offset, pos - offset);
}
开发者ID:VitalElement,项目名称:AvalonStudio,代码行数:40,代码来源:TextUtilities.cs
示例5: CreateNewFoldings
/// <summary>
/// Create <see cref="NewFolding"/>s for the specified document.
/// </summary>
public IEnumerable<NewFolding> CreateNewFoldings(ITextSource document)
{
List<NewFolding> newFoldings = new List<NewFolding>();
Stack<int> startOffsets = new Stack<int>();
int lastNewLineOffset = 0;
char openingBrace = this.OpeningBrace;
char closingBrace = this.ClosingBrace;
for (int i = 0; i < document.TextLength; i++)
{
char c = document.GetCharAt(i);
bool isFirstInLine = IsFirstInLine(document, i);
if (c == openingBrace && isFirstInLine)
startOffsets.Push(i);
else if (c == closingBrace && isFirstInLine && startOffsets.Count > 0)
{
int startOffset = startOffsets.Pop();
// don't fold if opening and closing brace are on the same line
if (startOffset < lastNewLineOffset)
newFoldings.Add(new NewFolding(startOffset, i + 1));
}
else if (c == '\n' || c == '\r')
{
lastNewLineOffset = i + 1;
}
}
newFoldings.Sort((a, b) => a.StartOffset.CompareTo(b.StartOffset));
return newFoldings;
}
开发者ID:netintellect,项目名称:NetOffice,代码行数:32,代码来源:BraceFoldingStrategy.cs
示例6: CreateNewFoldings
/// <summary>
/// Create <see cref="NewFolding" />s for the specified document.
/// </summary>
public IEnumerable<NewFolding> CreateNewFoldings(ITextSource document)
{
var newFoldings = new List<NewFolding>();
var startOffsets = new Stack<int>();
var lastNewLineOffset = 0;
var openingBrace = OpeningBrace;
var closingBrace = ClosingBrace;
for (var i = 0; i < document.TextLength; i++)
{
var c = document.GetCharAt(i);
if (c == openingBrace)
startOffsets.Push(i);
else if (c == closingBrace && startOffsets.Count > 0)
{
var startOffset = startOffsets.Pop();
// don't fold if opening and closing brace are on the same line
if (startOffset < lastNewLineOffset)
newFoldings.Add(new NewFolding(startOffset, i + 1));
}
else if (c == '\n' || c == '\r')
lastNewLineOffset = i + 1;
}
newFoldings.Sort((a, b) => a.StartOffset.CompareTo(b.StartOffset));
return newFoldings;
}
开发者ID:Dessix,项目名称:TUM.CMS.VPLControl,代码行数:29,代码来源:BraceFoldingStrategy.cs
示例7: FindNextNewLine
/// <summary>
/// Finds the next new line character starting at offset.
/// </summary>
/// <param name="text">The text source to search in.</param>
/// <param name="offset">The starting offset for the search.</param>
/// <param name="newLineType">The string representing the new line that was found, or null if no new line was found.</param>
/// <returns>The position of the first new line starting at or after <paramref name="offset"/>,
/// or -1 if no new line was found.</returns>
public static int FindNextNewLine(ITextSource text, int offset, out string newLineType)
{
if (text == null)
throw new ArgumentNullException(nameof(text));
if (offset < 0 || offset > text.TextLength)
throw new ArgumentOutOfRangeException(nameof(offset), offset, "offset is outside of text source");
SimpleSegment s = NewLineFinder.NextNewLine(text, offset);
if (s == SimpleSegment.Invalid)
{
newLineType = null;
return -1;
}
else
{
if (s.Length == 2)
{
newLineType = "\r\n";
}
else if (text.GetCharAt(s.Offset) == '\n')
{
newLineType = "\n";
}
else
{
newLineType = "\r";
}
return s.Offset;
}
}
开发者ID:arkanoid1,项目名称:Yanitta,代码行数:37,代码来源:NewLineFinder.cs
示例8: MenuText
public MenuText(ContentManager content, Vector2 position, ITextSource textSource)
{
this.position = position;
this.textSource = textSource;
font = content.Load<SpriteFont>("Fonts/Menu_Font");
}
开发者ID:CtrlC-CtrlV,项目名称:megaman-mario,代码行数:7,代码来源:MenuText.cs
示例9: HtmlTokenizer
/// <summary>
/// See 8.2.4 Tokenization
/// </summary>
/// <param name="source">The source code manager.</param>
public HtmlTokenizer(ITextSource source)
: base(source)
{
_state = HtmlParseMode.PCData;
_acceptsCharacterData = false;
_buffer = new StringBuilder();
}
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:11,代码来源:HtmlTokenizer.cs
示例10: TagReader
public TagReader(AXmlParser tagSoupParser, ITextSource input, bool collapseProperlyNestedElements)
: base(input)
{
this.tagSoupParser = tagSoupParser;
if (collapseProperlyNestedElements)
elementNameStack = new Stack<string>();
}
开发者ID:CSRedRat,项目名称:NRefactory,代码行数:7,代码来源:TagReader.cs
示例11: Parse
public ParseInformation Parse(
FileName fileName,
ITextSource fileContent,
TypeScriptProject project,
IEnumerable<TypeScriptFile> files)
{
try {
using (TypeScriptContext context = contextFactory.CreateContext()) {
context.AddFile(fileName, fileContent.Text);
context.RunInitialisationScript();
NavigationBarItem[] navigation = context.GetNavigationInfo(fileName);
var unresolvedFile = new TypeScriptUnresolvedFile(fileName);
unresolvedFile.AddNavigation(navigation, fileContent);
if (project != null) {
context.AddFiles(files);
var document = new TextDocument(fileContent);
Diagnostic[] diagnostics = context.GetDiagnostics(fileName, project.GetOptions());
TypeScriptService.TaskService.Update(diagnostics, fileName);
}
return new ParseInformation(unresolvedFile, fileContent.Version, true);
}
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
LoggingService.Debug(ex.ToString());
}
return new ParseInformation(
new TypeScriptUnresolvedFile(fileName),
fileContent.Version,
true);
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:34,代码来源:TypeScriptParser.cs
示例12: DocumentViewModel
public DocumentViewModel(ITextSource document)
{
Ensure.ArgumentNotNull(document, "document");
Document = document;
Document.TextChanged += OnTextChanged;
}
开发者ID:ryanwentzel,项目名称:Proverb,代码行数:7,代码来源:DocumentViewModel.cs
示例13: getOffsets
protected IEnumerable<NewFolding> getOffsets(char opening, char closing, ITextSource document)
{
List<NewFolding> ret = new List<NewFolding>();
Stack<int> openings = new Stack<int>();
bool multiline = false; //flag of multiline braces
for(int pos = 0; pos < document.TextLength; ++pos)
{
char c = document.GetCharAt(pos);
if(c == opening) {
openings.Push(pos + 1);
multiline = false;
}
else if(char.IsControl(c)) {
multiline = true;
}
else if(openings.Count > 0 && c == closing)
{
int offset = openings.Pop();
if(multiline) {
ret.Add(new NewFolding(offset, pos));
}
}
}
return ret;
}
开发者ID:3F,项目名称:vsCommandEvent,代码行数:27,代码来源:BraceFoldingStrategy.cs
示例14: FindAllValidating
public IEnumerable<ISearchResult> FindAllValidating(ITextSource document, int offset, int length)
{
using (var stream = document.CreateReader())
{
var doc = (IDocument)document;
var xmlDoc = new XPathDocument(stream); ;
var navigator = xmlDoc.CreateNavigator();
XPathExpression expr = null;
XPathNodeIterator iterator;
try
{
expr = navigator.Compile(_xPath);
iterator = navigator.Select(expr);
}
catch (System.Xml.XPath.XPathException)
{
yield break;
}
while (iterator.MoveNext())
{
var current = iterator.Current;
var segment = XmlSegment(doc, ((IXmlLineInfo)current).LineNumber, ((IXmlLineInfo)current).LinePosition);
if (segment != null && segment.Offset >= offset && segment.EndOffset <= (offset + length))
{
yield return new XPathSearchResult()
{
StartOffset = segment.Offset,
Length = segment.Length
};
}
}
}
}
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:35,代码来源:XPathSearchStrategy.cs
示例15: Parse
public ParseInformation Parse(FileName fileName, ITextSource fileContent, bool fullParseInformationRequested,
IProject parentProject, CancellationToken cancellationToken)
{
var csharpProject = parentProject as CSharpProject;
CSharpParser parser = new CSharpParser(csharpProject != null ? csharpProject.CompilerSettings : null);
parser.GenerateTypeSystemMode = !fullParseInformationRequested;
SyntaxTree cu = parser.Parse(fileContent, fileName);
cu.Freeze();
CSharpUnresolvedFile file = cu.ToTypeSystem();
ParseInformation parseInfo;
if (fullParseInformationRequested)
parseInfo = new CSharpFullParseInformation(file, fileContent.Version, cu);
else
parseInfo = new ParseInformation(file, fileContent.Version, fullParseInformationRequested);
IDocument document = fileContent as IDocument;
AddCommentTags(cu, parseInfo.TagComments, fileContent, parseInfo.FileName, ref document);
if (fullParseInformationRequested) {
if (document == null)
document = new ReadOnlyDocument(fileContent, parseInfo.FileName);
((CSharpFullParseInformation)parseInfo).newFoldings = CreateNewFoldings(cu, document);
}
return parseInfo;
}
开发者ID:asiazhang,项目名称:SharpDevelop,代码行数:29,代码来源:Parser.cs
示例16: StringBuilderDocument
/// <summary>
/// Creates a new StringBuilderDocument with the initial text copied from the specified text source.
/// </summary>
public StringBuilderDocument(ITextSource textSource)
{
if (textSource == null)
throw new ArgumentNullException("textSource");
b = new StringBuilder(textSource.TextLength);
textSource.WriteTextTo(new StringWriter(b));
}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:10,代码来源:StringBuilderDocument.cs
示例17: CreateNewFoldings
/// <summary>
/// Create <see cref="NewFolding"/>s for the specified document.
/// </summary>
public IEnumerable<NewFolding> CreateNewFoldings(ITextSource document)
{
var newFoldings = new List<NewFolding>();
var template = FoldingTemplates[0];
var regexOpenFolding = new Regex(template.OpeningPhrase);
var matchesOpenFolding = regexOpenFolding.Matches(document.Text);
var regexCloseFolding = new Regex(template.ClosingPhrase);
var matchesCloseFolding = regexCloseFolding.Matches(document.Text);
var currentOpenIndex = 0;
for (var i = 0; i < matchesCloseFolding.Count && currentOpenIndex < matchesOpenFolding.Count; i++)
{
if (matchesOpenFolding[currentOpenIndex].Index >= matchesCloseFolding[i].Index)
continue;
var folding = new NewFolding(matchesOpenFolding[currentOpenIndex].Index + 1,
matchesCloseFolding[i].Index + 10)
{
DefaultClosed = template.IsDefaultFolded,
Name = template.Name
};
newFoldings.Add(folding);
while (currentOpenIndex < matchesOpenFolding.Count &&
matchesOpenFolding[currentOpenIndex].Index < matchesCloseFolding[i].Index)
{
currentOpenIndex++;
}
}
return newFoldings;
}
开发者ID:gdv1811,项目名称:PdfCodeEditor,代码行数:34,代码来源:FoldingStrategy.cs
示例18: CreateNewFoldings
/// <summary>
/// Create <see cref="NewFolding"/>s for the specified document.
/// </summary>
public IEnumerable<NewFolding> CreateNewFoldings(ITextSource document)
{
List<NewFolding> newFoldings = new List<NewFolding>();
Stack<int> startOffsets = new Stack<int>();
int lastNewLineOffset = 0;
char openingBrace = OpeningBrace;
char closingBrace = ClosingBrace;
foreach (var startKeyword in foldingKeywords.Keys)
{
int lastKeywordPos = 0;
int pos = 0;
while ((pos = document.Text.IndexOf(startKeyword, pos)) > lastKeywordPos)
{
int endOffset = document.Text.IndexOf(foldingKeywords[startKeyword], pos);
if (endOffset > pos)
{
var offset = document.Text.IndexOf("\r\n", pos);
var name = document.Text.Substring(pos + 8, offset - (pos + 8));
var folding = new NewFolding(pos, endOffset + 10);
folding.Name = name;
// Add the folding
newFoldings.Add(folding);
}
lastKeywordPos = pos;
}
}
for (int i = 0; i < document.TextLength; i++)
{
char c = document.GetCharAt(i);
if (c == openingBrace)
{
startOffsets.Push(i);
}
else if (c == closingBrace && startOffsets.Count > 0)
{
int startOffset = startOffsets.Pop();
// don't fold if opening and closing brace are on the same line
if (startOffset < lastNewLineOffset)
{
newFoldings.Add(new NewFolding(startOffset, i + 1));
}
}
else if (c == '\n' || c == '\r')
{
lastNewLineOffset = i + 1;
}
}
newFoldings.Sort((a, b) => a.StartOffset.CompareTo(b.StartOffset));
return newFoldings;
}
开发者ID:peterschen,项目名称:SMAStudio,代码行数:62,代码来源:PowershellFoldingStrategy.cs
示例19: FindAll
public IEnumerable<ISearchResult> FindAll(ITextSource document, int offset, int length)
{
int endOffset = offset + length;
foreach (Match result in searchPattern.Matches(document.Text)) {
if (offset <= result.Index && endOffset >= (result.Length + result.Index))
yield return new SearchResult { StartOffset = result.Index, Length = result.Length, Data = result };
}
}
开发者ID:NightmareX1337,项目名称:lfs,代码行数:8,代码来源:RegexSearchStrategy.cs
示例20: TextSourceAdapter
protected TextSourceAdapter(ITextSource textSource)
{
if (textSource == null)
{
throw new ArgumentNullException("textSource");
}
TextSource = textSource;
}
开发者ID:mookiejones,项目名称:miEditor,代码行数:8,代码来源:TextSourceAdapter.cs
注:本文中的ITextSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论