[2118] | 1 | using System; |
---|
| 2 | using System.Collections.Generic; |
---|
| 3 | using System.Linq; |
---|
| 4 | using System.Text; |
---|
| 5 | |
---|
| 6 | using Microsoft.VisualStudio; |
---|
| 7 | using Microsoft.VisualStudio.Package; |
---|
| 8 | using Microsoft.VisualStudio.TextManager.Interop; |
---|
| 9 | using Microsoft.VisualStudio.OLE.Interop; |
---|
| 10 | |
---|
| 11 | namespace Lol.VisualStudio.Plugin |
---|
| 12 | { |
---|
| 13 | class LolFxLanguageService : LanguageService |
---|
| 14 | { |
---|
| 15 | public override string GetFormatFilterList() |
---|
| 16 | { |
---|
| 17 | throw new NotImplementedException(); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | public override LanguagePreferences GetLanguagePreferences() |
---|
| 21 | { |
---|
| 22 | if (m_preferences == null) |
---|
| 23 | { |
---|
| 24 | m_preferences = new LanguagePreferences(this.Site, |
---|
| 25 | typeof(LolFxLanguageService).GUID, this.Name); |
---|
| 26 | m_preferences.Init(); |
---|
| 27 | } |
---|
| 28 | return m_preferences; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | public override IScanner GetScanner(IVsTextLines buffer) |
---|
| 32 | { |
---|
| 33 | if (m_scanner == null) |
---|
| 34 | { |
---|
| 35 | m_scanner = new LolFxScanner(buffer); |
---|
| 36 | } |
---|
| 37 | return m_scanner; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | public override string Name |
---|
| 41 | { |
---|
| 42 | get { return "LolFx"; } |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | public override AuthoringScope ParseSource(ParseRequest req) |
---|
| 46 | { |
---|
| 47 | return new LolFxAuthoringScope(); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | private LanguagePreferences m_preferences; |
---|
| 51 | private LolFxScanner m_scanner; |
---|
| 52 | |
---|
| 53 | internal class LolFxScanner : IScanner |
---|
| 54 | { |
---|
| 55 | public LolFxScanner(IVsTextBuffer buffer) |
---|
| 56 | { |
---|
| 57 | m_buffer = buffer; |
---|
| 58 | } |
---|
| 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 | |
---|
| 70 | tokeninfo.StartIndex = m_offset; |
---|
| 71 | tokeninfo.EndIndex = m_offset; |
---|
| 72 | tokeninfo.Type = TokenType.Unknown; |
---|
| 73 | switch (state % 4) |
---|
| 74 | { |
---|
| 75 | case 0: tokeninfo.Color = TokenColor.Number; break; |
---|
| 76 | case 1: tokeninfo.Color = TokenColor.Text; break; |
---|
| 77 | case 2: tokeninfo.Color = TokenColor.Keyword; break; |
---|
| 78 | case 3: tokeninfo.Color = TokenColor.Comment; break; |
---|
| 79 | } |
---|
| 80 | ++m_offset; |
---|
| 81 | ++state; |
---|
| 82 | return true; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | return false; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | enum State |
---|
| 89 | { |
---|
| 90 | Default, |
---|
| 91 | CComment, |
---|
| 92 | CppComment, |
---|
| 93 | String, |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | void IScanner.SetSource(string source, int offset) |
---|
| 97 | { |
---|
| 98 | m_source = source; |
---|
| 99 | m_offset = offset; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | private IVsTextBuffer m_buffer; |
---|
| 103 | string m_source; |
---|
| 104 | int m_offset; |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | internal class LolFxAuthoringScope : AuthoringScope |
---|
| 108 | { |
---|
| 109 | public override string GetDataTipText(int line, int col, out TextSpan span) |
---|
| 110 | { |
---|
| 111 | span = new TextSpan(); |
---|
| 112 | return null; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | public override Declarations GetDeclarations(IVsTextView view, |
---|
| 116 | int line, |
---|
| 117 | int col, |
---|
| 118 | TokenInfo info, |
---|
| 119 | ParseReason reason) |
---|
| 120 | { |
---|
| 121 | return null; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView, int line, int col, out TextSpan span) |
---|
| 125 | { |
---|
| 126 | span = new TextSpan(); |
---|
| 127 | return null; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | public override Methods GetMethods(int line, int col, string name) |
---|
| 131 | { |
---|
| 132 | return null; |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | |
---|