当前位置: 首页>>代码示例>>C#>>正文


C# SnapshotPoint.GetChar方法代码示例

本文整理汇总了C#中SnapshotPoint.GetChar方法的典型用法代码示例。如果您正苦于以下问题:C# SnapshotPoint.GetChar方法的具体用法?C# SnapshotPoint.GetChar怎么用?C# SnapshotPoint.GetChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SnapshotPoint的用法示例。


在下文中一共展示了SnapshotPoint.GetChar方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveToken

 /// <summary>
 /// Removes a token using the enhanced token stream class.
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="position"></param>
 /// <returns></returns>
 private CommonTokenStream RemoveToken(string sql, SnapshotPoint snapPos)
 {
   MemoryStream ms = new MemoryStream(ASCIIEncoding.ASCII.GetBytes(sql));
   CaseInsensitiveInputStream input = new CaseInsensitiveInputStream(ms);
   //ANTLRInputStream input = new ANTLRInputStream(ms);
   Version ver = LanguageServiceUtil.GetVersion(LanguageServiceUtil.GetConnection().ServerVersion);
   MySQLLexer lexer = new MySQLLexer(input);
   lexer.MySqlVersion = ver;
   TokenStreamRemovable tokens = new TokenStreamRemovable(lexer);      
   IToken tr = null;
   int position = snapPos.Position;
   tokens.Fill();      
   if (!char.IsWhiteSpace(snapPos.GetChar()))
   {
     foreach (IToken t in tokens.GetTokens())
     {
       if ((t.StartIndex <= position) && (t.StopIndex >= position))
       {
         tr = t;
         break;
       }
     }
     tokens.Remove(tr);
   }
   return tokens;
 }    
开发者ID:eeeee,项目名称:mysql-connector-net,代码行数:32,代码来源:MySqlCompletionSource.cs

示例2: ReadComment

        public static SnapshotSpan ReadComment(this ITextSnapshot snapshot, ref SnapshotPoint point)
        {
            if (point.Position == snapshot.Length || point.GetChar() != RobotsTxtSyntaxFacts.Comment)
                return new SnapshotSpan(point, 0);

            return snapshot.ReadToLineEndWhile(ref point, _ => true);
        }
开发者ID:peterwie,项目名称:RobotsTxtLanguageService,代码行数:7,代码来源:RobotsTxtSyntacticParser.cs

示例3: IsPreceededByEventAddSyntax

        /// <summary>
        /// Is the provided SnapshotPoint preceded by the '+= SomeEventType(Some_HandlerName' line
        /// </summary>
        private bool IsPreceededByEventAddSyntax(SnapshotSpan span)
        {
            // First find the last + character
            var snapshot = span.Snapshot;
            SnapshotPoint? plusPoint = null;
            for (int i = span.Length - 1; i >= 0; i--)
            {
                var position = span.Start.Position + i;
                var point = new SnapshotPoint(snapshot, position);
                if (point.GetChar() == '+')
                {
                    plusPoint = point;
                    break;
                }
            }

            if (plusPoint == null)
            {
                return false;
            }

            var eventSpan = new SnapshotSpan(plusPoint.Value, span.End);
            var eventText = eventSpan.GetText();
            return 
                s_fullEventSyntaxRegex.IsMatch(eventText) ||
                s_shortEventSyntaxRegex.IsMatch(eventText);
        }
开发者ID:aesire,项目名称:VsVim,代码行数:30,代码来源:CSharpAdapter.cs

示例4: ReadExact

        public static SnapshotSpan ReadExact(this ITextSnapshot snapshot, ref SnapshotPoint point, char @char)
        {
            SnapshotPoint start = point;

            if (point < snapshot.Length && point.GetChar() == @char)
            {
                point = point + 1;
                return new SnapshotSpan(start, point);
            }

            return new SnapshotSpan(point, 0);
        }
开发者ID:Peter-Juhasz,项目名称:RegistryLanguageService,代码行数:12,代码来源:ISyntacticParser.cs

示例5: ReadToLineEndWhile

        public static SnapshotSpan ReadToLineEndWhile(this ITextSnapshot snapshot, ref SnapshotPoint point, Predicate<char> predicate, bool rewindWhiteSpace = true)
        {
            SnapshotPoint start = point;

            while (
                point.Position < snapshot.Length &&
                point.GetChar() != '\n' && point.GetChar() != '\r' &&
                predicate(point.GetChar())
            )
                point = point + 1;

            if (rewindWhiteSpace)
            {
                while (
                    point - 1 >= start &&
                    Char.IsWhiteSpace((point - 1).GetChar())
                )
                    point = point - 1;
            }

            return new SnapshotSpan(start, point);
        }
开发者ID:Peter-Juhasz,项目名称:RegistryLanguageService,代码行数:22,代码来源:ISyntacticParser.cs

示例6: ReadDelimiter

        public static SnapshotSpan ReadDelimiter(this ITextSnapshot snapshot, ref SnapshotPoint point)
        {
            if (point.Position == snapshot.Length)
                return new SnapshotSpan(point, 0);

            var @char = point.GetChar();

            if (@char != RobotsTxtSyntaxFacts.NameValueDelimiter)
                return new SnapshotSpan(point, 0);

            point = point + 1;
            return new SnapshotSpan(point - 1, 1);
        }
开发者ID:peterwie,项目名称:RobotsTxtLanguageService,代码行数:13,代码来源:RobotsTxtSyntacticParser.cs

示例7: GetCharOrDefault2

 public void GetCharOrDefault2()
 {
     Create("foo", "bar");
     var endPoint = new SnapshotPoint(_buffer.CurrentSnapshot, _buffer.CurrentSnapshot.Length);
     var didSee = false;
     try
     {
         var notUsed = endPoint.GetChar();
     }
     catch (ArgumentException)
     {
         didSee = true;
     }
     Assert.IsTrue(didSee);
     Assert.AreEqual('f', SnapshotPointUtil.GetCharOrDefault(endPoint, 'f'));
 }
开发者ID:minhajuddin,项目名称:VsVim,代码行数:16,代码来源:SnapshotPointUtilTest.cs

示例8: GetVariableNameAndSpan

        private static string GetVariableNameAndSpan(SnapshotPoint point, out SnapshotSpan span)
        {
            var line = point.GetContainingLine();
            var hoveredIndex = point.Position - line.Start.Position;

            var c = point.GetChar();
            if (!Char.IsDigit(c) && !Char.IsLetter(c) && (c != '_'))
            {
                span = new SnapshotSpan();
                return null;
            }

            // Find the name of the variable under the mouse pointer (ex: 'gesture.Pose.Name' when the mouse is hovering over the 'o' of pose)
            var match = m_variableExtractor.Matches(line.GetText()).OfType<Match>().SingleOrDefault(x => x.Index <= hoveredIndex && (x.Index + x.Length) >= hoveredIndex);
            if ((match == null) || (match.Value.Length == 0))
            {
                span = new SnapshotSpan();
                return null;
            }
            var name = match.Value;

            // Find the first '.' after the hoveredIndex and cut it off
            int relativeIndex = hoveredIndex - match.Index;
            var lastIndex = name.IndexOf('.', relativeIndex);
            if (lastIndex >= 0)
            {
                name = name.Substring(0, lastIndex);
            }
            else
            {
                lastIndex = name.Length;
            }

            var matchStartIndex = name.LastIndexOf('.', relativeIndex) + 1;
            span = new SnapshotSpan(line.Start.Add(match.Index + matchStartIndex), lastIndex - matchStartIndex);

            return name;
        }
开发者ID:wtf42,项目名称:VSGraphVis,代码行数:38,代码来源:DebuggerHandler.cs

示例9: AddAdornments

        private void AddAdornments()
        {
            Debug.Assert(_easyMotionUtil.State == EasyMotionState.LookingForDecision);

            if (_wpfTextView.InLayout)
            {
                return;
            }

            _navigateMap.Clear();
            var textViewLines = _wpfTextView.TextViewLines;
            var startPoint = textViewLines.FirstVisibleLine.Start;
            var endPoint = textViewLines.LastVisibleLine.End;
            var snapshot = startPoint.Snapshot;

            var count = 0;
            for (int i = startPoint.Position; i < endPoint.Position; i++)
            {
                var point = new SnapshotPoint(snapshot, i);
                if (char.ToLower(point.GetChar()) == char.ToLower(_easyMotionUtil.TargetChar))
                {
                    count++;
                }
            }
            var navigationKeys = _navigationKeysShort;
            if (count > _navigationKeysShort.Length)
            {
                navigationKeys = _navigationKeysLong;
            }
            int navigateIndex = 0;
            for (int i = startPoint.Position; i < endPoint.Position; i++)
            {
                var point = new SnapshotPoint(snapshot, i);

                if (char.ToLower(point.GetChar()) == char.ToLower(_easyMotionUtil.TargetChar) && navigateIndex < navigationKeys.Length)
                {
                    var key = navigationKeys[navigateIndex];
                    navigateIndex++;
                    AddNavigateToPoint(textViewLines, point, key);
                }
            }

            if (navigateIndex == 0)
            {
                _easyMotionUtil.ChangeToLookingCharNotFound();
            }
        }
开发者ID:bordev,项目名称:EasyMotion,代码行数:47,代码来源:EasyMotionAdornmentController.cs

示例10: GetWordKind

		static WordKind GetWordKind(SnapshotPoint currentPosition) {
			if (currentPosition.Position >= currentPosition.Snapshot.Length)
				return WordKind.Whitespace;
			return GetWordKind(currentPosition.GetChar());
		}
开发者ID:0xd4d,项目名称:dnSpy,代码行数:5,代码来源:WordParser.cs

示例11: GetWordSpanFromPosition

        private static SnapshotSpan GetWordSpanFromPosition(SnapshotPoint positon)
        {
            if (positon.Position >= positon.Snapshot.Length)
                return new SnapshotSpan(positon, 0);

            char charAtPos = positon.GetChar();
            string text = positon.Snapshot.GetText();
            ITextSnapshotLine lineSnapshot = positon.Snapshot.GetLineFromPosition(positon);
            int left, right;
            left = right = positon.Position;

            if (IsWordChar(charAtPos))
            {
                while (left - 1 >= lineSnapshot.Start.Position && IsWordChar(text[left - 1]))
                {
                    left--;
                }
                while (right + 1 < lineSnapshot.End.Position && IsWordChar(text[right + 1]))
                {
                    right++;
                }

                return new SnapshotSpan(positon.Snapshot, left, right + 1 - left);
            }
            else
            {
                return new SnapshotSpan(positon, 1);
            }
        }
开发者ID:GeertVL,项目名称:SnippetDesigner,代码行数:29,代码来源:CodeWindow.cs

示例12: FindOtherBrace

        // returns true if brace is actually a brace.
        private bool FindOtherBrace(SnapshotPoint possibleBrace, out SnapshotPoint? otherBrace)
        {
            otherBrace = null;
              var rainbow = this.textBuffer.Get<RainbowProvider>();
              if ( rainbow == null ) {
            return false;
              }
              if ( !possibleBrace.IsValid() ) {
            return false;
              }

              if ( !rainbow.BraceCache.Language.BraceList.Contains(possibleBrace.GetChar()) ) {
            return false;
              }
              var bracePair = rainbow.BraceCache.GetBracePair(possibleBrace);
              if ( bracePair == null ) {
            return true;
              }
              if ( possibleBrace.Position == bracePair.Item1.Position ) {
            otherBrace = bracePair.Item2.ToPoint(possibleBrace.Snapshot);
              } else {
            otherBrace = bracePair.Item1.ToPoint(possibleBrace.Snapshot);
              }
              return true;
        }
开发者ID:ssatta,项目名称:viasfora,代码行数:26,代码来源:RainbowToolTipSource.cs

示例13: GetCompleteStatement

 private string GetCompleteStatement(
   ITextSnapshot snapshot, SnapshotPoint snapPos, out StringBuilder sbErrors, out ITree treeStmt)
 {
   int position = snapPos.Position;
   StringBuilder sb = new StringBuilder();
   CommonTokenStream tokens;
   string sql = snapshot.GetText();
   MySQL51Parser.statement_list_return r = 
     LanguageServiceUtil.ParseSql( sql, false, out sb, out tokens);
   sbErrors = sb;
   if (sbErrors.Length != 0)
     position--;
   StringBuilder sbTokens = new StringBuilder();
   ITree t = r.Tree as ITree;
   treeStmt = t;
   if (t.IsNil)
   {
     ITree child = null;
     for (int idx = 0; idx < t.ChildCount; idx++)
     {
       child = t.GetChild(idx);
       if (child.TokenStartIndex == -1 || child.TokenStopIndex == -1) return null;
       if ((position >= tokens.Get(child.TokenStartIndex).StartIndex) &&
           (position <= tokens.Get(child.TokenStopIndex).StopIndex))
       {
         break;
       }
     }
     treeStmt = child;
   }
   else
   {
     treeStmt = t;        
   }
   //int upperToken = (sb.Length == 0) ? treeStmt.TokenStopIndex - 1 : treeStmt.TokenStopIndex;
   string sqlOutput;
   int lastToken = treeStmt.TokenStopIndex;
   // Get last not EOF token
   while (tokens.Get(lastToken).Text == "<EOF>" && lastToken > 0)
     lastToken--;
   int len = 
     tokens.Get( treeStmt.TokenStopIndex ).StopIndex - 
     tokens.Get( treeStmt.TokenStartIndex ).StartIndex + 1;
   if (char.IsWhiteSpace(snapPos.GetChar()))
   {
     sqlOutput = sql.Substring(tokens.Get(treeStmt.TokenStartIndex).StartIndex,
       Math.Min(len, sql.Length - tokens.Get(treeStmt.TokenStartIndex).StartIndex));
   }
   else
   {
     // remove last token
     // sometimes the parser itself removes the last token.
     if ((sbErrors.Length == 0) || (tokens.Get(lastToken).StopIndex - 1 == position))
     {
       if (tokens.Get(lastToken).StopIndex - 1 == position && 
         lastToken != treeStmt.TokenStartIndex && lastToken > 0  ) lastToken--;
       int start = tokens.Get(treeStmt.TokenStartIndex).StartIndex,
         stop = tokens.Get( lastToken ).StartIndex;
       sqlOutput = sql.Substring(start, Math.Min(stop - start, sql.Length - start));
     }
     else
     {
       sqlOutput = sql.Substring(tokens.Get(treeStmt.TokenStartIndex).StartIndex, 
         Math.Min(len, sql.Length - tokens.Get(treeStmt.TokenStartIndex).StartIndex));
     }
   }
   //if ( /*treeStmt.TokenStartIndex < treeStmt.TokenStopIndex && */
   //    char.IsWhiteSpace(snapPos.GetChar()))
   //{
   //  stop = tokens.Get(treeStmt.TokenStopIndex - 1).StopIndex;
   //}
   //else
   //{
   //  stop = tokens.Get(treeStmt.TokenStopIndex).StartIndex;
   //}
   //int start = tokens.Get(treeStmt.TokenStartIndex).StartIndex;
   //  //stop = tokens.Get(upperToken).StopIndex;
   ////string sqlOutput = sql.Substring(start, Math.Min(stop - start + 1, sql.Length - start));
   
   //if (treeStmt is CommonErrorNode || sbErrors.Length != 0)
   //{
   //  sqlOutput = sql.Substring(start, sql.Length - start);
   //}
   //else
   //{
   //  sqlOutput = sql.Substring(start, Math.Min(stop - start + 1, sql.Length - start));
   //}
   treeStmt = LanguageServiceUtil.ParseSql(sqlOutput, false, out sbErrors).Tree as ITree;
   return sqlOutput;      
 }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:90,代码来源:MySqlCompletionSource+-+Copy.cs


注:本文中的SnapshotPoint.GetChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。