Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // Lol Engine - VsLol add-in for Visual Studio
  3. //
  4. // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using Microsoft.VisualStudio;
  15. using Microsoft.VisualStudio.Package;
  16. using Microsoft.VisualStudio.TextManager.Interop;
  17. using Microsoft.VisualStudio.OLE.Interop;
  18. namespace lol
  19. {
  20. class LolFxLanguageService : LanguageService
  21. {
  22. public override string GetFormatFilterList()
  23. {
  24. return "LolFx files (*.lolfx)\n*.lolfx\n";
  25. }
  26. public override LanguagePreferences GetLanguagePreferences()
  27. {
  28. if (m_preferences == null)
  29. {
  30. m_preferences = new LanguagePreferences(this.Site,
  31. typeof(LolFxLanguageService).GUID, this.Name);
  32. m_preferences.Init();
  33. }
  34. return m_preferences;
  35. }
  36. public override IScanner GetScanner(IVsTextLines buffer)
  37. {
  38. if (m_scanner == null)
  39. {
  40. m_scanner = new LolFxScanner(buffer);
  41. }
  42. return m_scanner;
  43. }
  44. public override string Name
  45. {
  46. get { return "LolFx"; }
  47. }
  48. public override AuthoringScope ParseSource(ParseRequest req)
  49. {
  50. return new LolFxAuthoringScope();
  51. }
  52. private LanguagePreferences m_preferences;
  53. private LolFxScanner m_scanner;
  54. internal class LolFxScanner : IScanner
  55. {
  56. public LolFxScanner(IVsTextBuffer buffer)
  57. {
  58. m_buffer = buffer;
  59. }
  60. bool IScanner.ScanTokenAndProvideInfoAboutIt(TokenInfo tokeninfo, ref int state)
  61. {
  62. while (m_offset < m_source.Length)
  63. {
  64. if (m_source[m_offset] == ' ' || m_source[m_offset] == '\t')
  65. {
  66. ++m_offset;
  67. continue;
  68. }
  69. tokeninfo.StartIndex = m_offset;
  70. tokeninfo.EndIndex = m_offset;
  71. tokeninfo.Type = TokenType.Unknown;
  72. switch (state % 4)
  73. {
  74. case 0: tokeninfo.Color = TokenColor.Number; break;
  75. case 1: tokeninfo.Color = TokenColor.Text; break;
  76. case 2: tokeninfo.Color = TokenColor.Keyword; break;
  77. case 3: tokeninfo.Color = TokenColor.Comment; break;
  78. }
  79. // Disable this crap for now
  80. tokeninfo.Color = TokenColor.Text;
  81. ++m_offset;
  82. ++state;
  83. return true;
  84. }
  85. return false;
  86. }
  87. enum State
  88. {
  89. Default,
  90. CComment,
  91. CppComment,
  92. String,
  93. }
  94. void IScanner.SetSource(string source, int offset)
  95. {
  96. m_source = source;
  97. m_offset = offset;
  98. }
  99. private IVsTextBuffer m_buffer;
  100. string m_source;
  101. int m_offset;
  102. }
  103. internal class LolFxAuthoringScope : AuthoringScope
  104. {
  105. public override string GetDataTipText(int line, int col, out TextSpan span)
  106. {
  107. span = new TextSpan();
  108. return null;
  109. }
  110. public override Declarations GetDeclarations(IVsTextView view,
  111. int line,
  112. int col,
  113. TokenInfo info,
  114. ParseReason reason)
  115. {
  116. return null;
  117. }
  118. public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView, int line, int col, out TextSpan span)
  119. {
  120. span = new TextSpan();
  121. return null;
  122. }
  123. public override Methods GetMethods(int line, int col, string name)
  124. {
  125. return null;
  126. }
  127. }
  128. }
  129. } /* namespace lol */