Пример #1
0
        public NSSource(NSLangServ service, IVsTextLines textLines, Colorizer colorizer)
            : base(service, textLines, colorizer)
        {
            string path = GetFilePath();
            Service = service;

            this.m_scanner = colorizer.Scanner as NSScanner;
            if (m_scanner != null)
                m_scanner.m_nssource = this;

            //Scanner = colorizer.Scanner as NSScanner;
            LastParseTime = 0;
            DirtyTime = DateTime.Now;
            FullScanTime = 0;
        }
Пример #2
0
        public NSScanner m_scanner = null; // { get; set; }

        public NSSource(NSLangServ service, IVsTextLines textLines, Colorizer colorizer) : base(service, textLines, colorizer)
        {
            string path = GetFilePath();

            Service = service;

            this.m_scanner = colorizer.Scanner as NSScanner;
            if (m_scanner != null)
            {
                m_scanner.m_nssource = this;
            }

            //Scanner = colorizer.Scanner as NSScanner;
            LastParseTime = 0;
            DirtyTime     = DateTime.Now;
            FullScanTime  = 0;
        }
Пример #3
0
        protected override void Initialize()
        {
            //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();
            nspackage = this;

            #if ivslang
            LangInfo = new VSNLanguageInfo();
            ((IServiceContainer)this).AddService(typeof(VSNLanguageInfo), LangInfo, true);
            #endif

            menucmds = new Dictionary<int, string>() {
                { 0x0100, "NSMenuCmdOptionsEdit"},
                { 0x0101, "NSMenuCmdOptionsLoad"}
            };

            // menu commands - .vsct file
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (mcs != null) {
                foreach (int dkey in menucmds.Keys) {
                    CommandID cmdid = new CommandID(GuidList.NSMenuCmdTopGUID, dkey);
                    MenuCommand menucmd = new MenuCommand(MenuItemCallback, cmdid);
                    mcs.AddCommand(menucmd);
                }
            }

            IServiceContainer ServiceCnt = this as IServiceContainer;
            NSLangServ ServiceLng = new NSLangServ();
            ServiceLng.SetSite(this);
            ServiceCnt.AddService(typeof(NSLangServ), ServiceLng, true);

            IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;
            if (m_ComponentID == 0 && mgr != null) {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_ComponentID);
            }

            nimsettingsini = System.IO.Path.Combine(UserDataPath, "nimstudio.ini");
            NSIni.Init(nimsettingsini);
            NSSugInit();

            if (NSIni.Get("Main", "exttoolsadded") != "true") {
                NSIni.Add("Main", "exttoolsadded", "true");
                NSIni.Write();
                string reg_keyname = "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\12.0\\External Tools";
                object reg_ret;
                bool regstateok=false;
                reg_ret = Registry.GetValue(reg_keyname, "ToolNumKeys", -1);
                while (true) {
                    if (reg_ret==null) break;
                    if (reg_ret.GetType()!=typeof(int)) break;
                    int totkeys = (int)reg_ret;
                    if (totkeys==-1) break;
                    for (int rloop = 0; rloop < totkeys; rloop++) {
                        reg_ret = Registry.GetValue(reg_keyname, "ToolTitle" + rloop.ToString(), null);
                        if (reg_ret==null) break;
                        if (reg_ret.GetType()!=typeof(string)) break;
                        if (reg_ret=="NimStudio Compile+Run") break;
                        if (rloop==totkeys-1) regstateok=true;
                    }
                    if (regstateok) {
                        Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile+Run", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord);
                        Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath) & echo ****Running**** & $(ItemDir)$(ItemFileName).exe""", RegistryValueKind.String);
                        totkeys++;
                        Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord);
                        Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath)""", RegistryValueKind.String);
                        totkeys++;
                        Registry.SetValue(reg_keyname, "ToolNumKeys", totkeys, RegistryValueKind.DWord);
                    }
                }
            }
        }
Пример #4
0
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            List <string> strList = new List <string>();

            if (NSPackage.nimsuggest == null)
            {
                return;
            }

            var caretpos = NSLangServ.CaretPosGet();

            NSPackage.nimsuggest.Query(NimSuggestProc.Qtype.sug, caretpos["line"], caretpos["col"]);
            m_compList = new List <Completion>();

            foreach (string skey in NSPackage.nimsuggest.sugdct.Keys)
            {
                var    sugdct   = NSPackage.nimsuggest.sugdct[skey];
                string procname = skey;
                int    per_spot = skey.IndexOf(".");
                if (per_spot != -1)
                {
                    procname = skey.Substring(per_spot + 1, skey.Length - per_spot - 1);
                }
                else
                {
                    procname = skey;
                }
                if (m_glyphdct.ContainsKey(sugdct["type"]))
                {
                    m_compList.Add(new Completion(skey, procname, sugdct["type"] + sugdct["help"], m_glyphdct[sugdct["type"]], "icon text"));
                }
                else
                {
                    m_compList.Add(new Completion(skey, procname, sugdct["type"] + sugdct["help"], null, "icon text"));
                }
            }

            SnapshotPoint           currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1;
            ITextStructureNavigator navigator    = m_sourceProvider.NavigatorService.GetTextStructureNavigator(m_textBuffer);
            TextExtent extent     = navigator.GetExtentOfWord(currentPoint);
            string     w1         = currentPoint.Snapshot.GetText(extent.Span);
            var        startpoint = session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(currentPoint.Snapshot);

            ITrackingSpan applicableTo;

            if (w1 == ".")
            {
                applicableTo = currentPoint.Snapshot.CreateTrackingSpan(startpoint, 0, SpanTrackingMode.EdgeInclusive);
            }
            else
            {
                applicableTo = currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive);
            }


            //var applicableTo = m_textBuffer.CurrentSnapshot.CreateTrackingSpan(session.GetTriggerPoint(session.TextView.TextBuffer).GetPosition(currentPoint.Snapshot), 0, SpanTrackingMode.EdgeInclusive);

            //completionSets.Add(new CompletionSet("Tokens", "Tokens", applicableTo, m_compList, null));
            completionSets.Add(new CompletionSet("Tokens", "Tokens", applicableTo, m_compList, null));
            //completionSets.Add(new CompletionSet(m_compList));

            //completionSets.Add(new CompletionSet("Tokens", "Tokens", FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), session), m_compList, null));
        }
Пример #5
0
        protected override void Initialize()
        {
            //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();
            nspackage = this;

            #if ivslang
            LangInfo = new VSNLanguageInfo();
            ((IServiceContainer)this).AddService(typeof(VSNLanguageInfo), LangInfo, true);
            #endif

            menucmds = new Dictionary <int, string>()
            {
                { 0x0100, "NSMenuCmdOptionsEdit" },
                { 0x0101, "NSMenuCmdOptionsLoad" }
            };

            // menu commands - .vsct file
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (mcs != null)
            {
                foreach (int dkey in menucmds.Keys)
                {
                    CommandID   cmdid   = new CommandID(GuidList.NSMenuCmdTopGUID, dkey);
                    MenuCommand menucmd = new MenuCommand(MenuItemCallback, cmdid);
                    mcs.AddCommand(menucmd);
                }
            }

            IServiceContainer ServiceCnt = this as IServiceContainer;
            NSLangServ        ServiceLng = new NSLangServ();
            ServiceLng.SetSite(this);
            ServiceCnt.AddService(typeof(NSLangServ), ServiceLng, true);

            IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;
            if (m_ComponentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_ComponentID);
            }

            nimsettingsini = System.IO.Path.Combine(UserDataPath, "nimstudio.ini");
            NSIni.Init(nimsettingsini);
            NSSugInit();

            if (NSIni.Get("Main", "exttoolsadded") != "true")
            {
                NSIni.Add("Main", "exttoolsadded", "true");
                NSIni.Write();
                string reg_keyname = "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\12.0\\External Tools";
                object reg_ret;
                bool   regstateok = false;
                reg_ret = Registry.GetValue(reg_keyname, "ToolNumKeys", -1);
                while (true)
                {
                    if (reg_ret == null)
                    {
                        break;
                    }
                    if (reg_ret.GetType() != typeof(int))
                    {
                        break;
                    }
                    int totkeys = (int)reg_ret;
                    if (totkeys == -1)
                    {
                        break;
                    }
                    for (int rloop = 0; rloop < totkeys; rloop++)
                    {
                        reg_ret = Registry.GetValue(reg_keyname, "ToolTitle" + rloop.ToString(), null);
                        if (reg_ret == null)
                        {
                            break;
                        }
                        if (reg_ret.GetType() != typeof(string))
                        {
                            break;
                        }
                        if (reg_ret == "NimStudio Compile+Run")
                        {
                            break;
                        }
                        if (rloop == totkeys - 1)
                        {
                            regstateok = true;
                        }
                    }
                    if (regstateok)
                    {
                        Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile+Run", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord);
                        Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath) & echo ****Running**** & $(ItemDir)$(ItemFileName).exe""", RegistryValueKind.String);
                        totkeys++;
                        Registry.SetValue(reg_keyname, "ToolTitle" + totkeys.ToString(), "NimStudio Compile", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolSourceKey" + totkeys.ToString(), "", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolOpt" + totkeys.ToString(), 26, RegistryValueKind.DWord);
                        Registry.SetValue(reg_keyname, "ToolDir" + totkeys.ToString(), "$(ItemDir)", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolCmd" + totkeys.ToString(), "cmd.exe", RegistryValueKind.String);
                        Registry.SetValue(reg_keyname, "ToolArg" + totkeys.ToString(), @"/c """"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"" & del $(ItemDir)$(ItemFileName).exe 2>nul & ""c:\Nim\bin\nim.exe"" c $(ItemPath)""", RegistryValueKind.String);
                        totkeys++;
                        Registry.SetValue(reg_keyname, "ToolNumKeys", totkeys, RegistryValueKind.DWord);
                    }
                }
            }
        }
Пример #6
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures)
        {
            //if (!session.TextView.Properties.ContainsProperty(SessionKey)) {
            //    return;
            //}
            NSUtil.DebugPrintAlways("NSSig - AugmentSignatureHelpSession");

            if (NSPackage.nimsuggest == null)
            {
                return;
            }

            signatures.Clear();
            var caretpos = NSLangServ.CaretPosGet();

            NSPackage.nimsuggest.Query(NimSuggestProc.Qtype.con, caretpos["line"], caretpos["col"]);

            SnapshotPoint?point_trigger = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);

            if (!point_trigger.HasValue)
            {
                return;
            }

            //ITextSnapshot snapshot = subjectBuffer.CurrentSnapshot;
            //int position = session.GetTriggerPoint(subjectBuffer).GetPosition(subjectBuffer.CurrentSnapshot);
            int position = point_trigger.Value.Position;

            string text = subjectBuffer.CurrentSnapshot.GetText();

            SnapshotPoint point_curr = session.GetTriggerPoint(subjectBuffer).GetPoint(subjectBuffer.CurrentSnapshot);

            point_curr = point_trigger.Value;
            SnapshotPoint point_left  = point_curr;
            SnapshotPoint point_right = point_curr;

            ITextSnapshotLine line  = point_left.GetContainingLine();
            string            terms = "\n\r\t.:()[]{}?/+-;=*!<>";

            while (true)
            {
                point_left -= 1;
                if (point_left <= line.Start)
                {
                    point_left = line.Start;
                    break;
                }
                if (terms.IndexOf(point_left.GetChar()) != -1)
                {
                    point_left += 1;
                    break;
                }
            }
            while (true)
            {
                if (point_right >= line.End)
                {
                    point_right = line.End;
                    break;
                }
                if (terms.IndexOf(point_right.GetChar()) != -1)
                {
                    point_right -= 1;
                    break;
                }
                point_right += 1;
            }
            if (point_left > point_right)
            {
                point_right = point_left;
            }
            ITrackingSpan applicable_to_span = subjectBuffer.CurrentSnapshot.CreateTrackingSpan(point_left, point_right - point_left, SpanTrackingMode.EdgeInclusive);
            //ITrackingSpan applicableToSpan = subjectBuffer.CurrentSnapshot.CreateTrackingSpan(new Span(position, 0), SpanTrackingMode.EdgeInclusive, 0);

            string sig_help_default = "";

            foreach (string skey in NSPackage.nimsuggest.sugdct.Keys)
            {
                var sigdct = NSPackage.nimsuggest.sugdct[skey];
                if (sigdct["help"].Length > sig_help_default.Length)
                {
                    sig_help_default = sigdct["help"];
                }
            }

            foreach (string skey in NSPackage.nimsuggest.sugdct.Keys)
            {
                var sigdct = NSPackage.nimsuggest.sugdct[skey];
                //SortedDictionary<string,string>
                signatures.Add(SigAdd(subjectBuffer, skey, sigdct, sig_help_default, applicable_to_span, session));
            }

            //var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            //var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
            //var applicableToSpan = currentSnapshot.CreateTrackingSpan(querySpan.Start.Position, 0, SpanTrackingMode.EdgeInclusive);

            //signatures.Add(CreateSignature(subjectBuffer, "add(int firstInt, int secondInt)", "Documentation for adding integers.", applicableToSpan));
            //signatures.Add(CreateSignature(subjectBuffer, "add(double firstDouble, double secondDouble)", "Documentation for adding doubles.", applicableToSpan));

            //string sighelp = "hey1";
            //if (sighelp != null) {
            //}
        }
Пример #7
0
 public NSColorizer(NSLangServ ls, IVsTextLines buffer, NSScanner scanner) : base(ls, buffer, scanner)
 {
     m_scanner = scanner;
     m_buffer  = buffer;
 }