示例#1
0
 public override string GetDataTipText(int line, int col, out TextSpan span)
 {
     CMakeParsing.TokenData tokenData;
     if (_lines != null &&
         CMakeParsing.ParseForToken(_lines, line, col, out tokenData) &&
         !tokenData.InParens)
     {
         if (tokenData.TokenInfo.Token == (int)CMakeToken.Keyword)
         {
             // Get a Quick Info tip for the command at the cursor.
             span = tokenData.TokenInfo.ToTextSpan(line);
             string         lineText  = _lines.ToList()[line];
             string         tokenText = lineText.ExtractToken(tokenData.TokenInfo);
             CMakeCommandId id        = CMakeKeywords.GetCommandId(tokenText);
             if (CMakeSubcommandMethods.HasSubcommands(id))
             {
                 // Parse to get the subcommand, if there is one.
                 CMakeParsing.ParameterInfoResult result =
                     CMakeParsing.ParseForParameterInfo(_lines, line, -1, true);
                 return(CMakeSubcommandMethods.GetSubcommandQuickInfoTip(id,
                                                                         result.SubcommandName));
             }
             return(CMakeMethods.GetCommandQuickInfoTip(id));
         }
         else if (tokenData.TokenInfo.Token == (int)CMakeToken.Identifier)
         {
             // Get a Quick Info tip for the function called at the cursor, if
             // there is one.
             string        lineText   = _lines.ToList()[line];
             string        tokenText  = lineText.ExtractToken(tokenData.TokenInfo);
             List <string> parameters = CMakeParsing.ParseForParameterNames(_lines,
                                                                            tokenText);
             if (parameters != null)
             {
                 span = tokenData.TokenInfo.ToTextSpan(line);
                 return(string.Format("{0}({1})", tokenText,
                                      string.Join(" ", parameters)));
             }
         }
     }
     span = new TextSpan();
     return(null);
 }
示例#2
0
        public void TestQuickInfoTips()
        {
            // Test ordinary commands.
            Assert.AreEqual("if(expression)",
                            CMakeMethods.GetCommandQuickInfoTip(CMakeCommandId.If));
            Assert.AreEqual("set(variable value)",
                            CMakeMethods.GetCommandQuickInfoTip(CMakeCommandId.Set));
            Assert.IsNull(CMakeMethods.GetCommandQuickInfoTip(
                              CMakeCommandId.AddCustomCommand));

            // Test subcommands.
            Assert.AreEqual("cmake_policy(PUSH)",
                            CMakeSubcommandMethods.GetSubcommandQuickInfoTip(
                                CMakeCommandId.CMakePolicy, "PUSH"));
            Assert.AreEqual("export(PACKAGE name)",
                            CMakeSubcommandMethods.GetSubcommandQuickInfoTip(
                                CMakeCommandId.Export, "PACKAGE"));
            Assert.AreEqual("file(READ filename variable)",
                            CMakeSubcommandMethods.GetSubcommandQuickInfoTip(
                                CMakeCommandId.File, "READ"));
            Assert.IsNull(CMakeSubcommandMethods.GetSubcommandQuickInfoTip(
                              CMakeCommandId.Install, "CODE"));
        }