コード例 #1
0
ファイル: WatchForms.cs プロジェクト: VE-2016/VE-2016
        public void ChangeNode(ListViewItem v, string name)
        {
            Type type = GACForm.FindTypeFromAssemblies("." + name);

            if (type == null)
            {
                type = CSParsers.GetTypeForName(name);
            }

            Tuple <int, object, object, TreeNode, Image> TT = v.Tag as Tuple <int, object, object, TreeNode, Image>;

            if (type != null)
            {
                Tuple <int, object, object, TreeNode, Image> T = new Tuple <int, object, object, TreeNode, Image>(TT.Item1, type, type, TT.Item4, ve_resource.Class_yellow_16x);
                T.Item4.Nodes.Add(new TreeNode("placeholder"));
                T.Item4.Tag  = v;
                T.Item4.Text = "f";
                v.Tag        = T;

                v.SubItems[3].Text = type.FullName;
            }
            else
            {
                Tuple <int, object, object, TreeNode, Image> T = new Tuple <int, object, object, TreeNode, Image>(TT.Item1, TT.Item2, TT.Item3, TT.Item4, ve_resource.Cancel_16x);
                T.Item4.Nodes.Add(new TreeNode("placeholder"));
                T.Item4.Tag  = v;
                T.Item4.Text = "f";
                v.Tag        = T;
            }
        }
コード例 #2
0
ファイル: MarginExtended.cs プロジェクト: VE-2016/VE-2016
        public Tuple <string, string, ISymbol> GetType(TextEditor textEditor)
        {
            int position = textEditor.TextArea.Caret.Offset;

            string word = GetWordUnderMouse(textEditor.Document, textEditor.TextArea.Caret.Position);

            if (string.IsNullOrEmpty(word))
            {
                return(new Tuple <string, string, ISymbol>(null, null, null));
            }

            string FileName = SolutionToLoad; // "C:\\MSBuildProjects-beta\\VSExplorer\\VSExplorer.csproj";

            string filename = FileToLoad;     // "C:\\MSBuildProjects-beta\\VSExplorer\\ExplorerForms.cs";

            string content = StringReplace.Replace(textEditor.Document.Text);

            vp = vs.GetProjectbyCompileItem(FileToLoad);

            string file = null;

            if (vp != null)
            {
                file = vp.FileName;
            }

            ISymbol r = vs.GetSymbolAtLocation(vp, FileToLoad, position, content);

            if (word.Contains("."))
            {
                if (r != null)
                {
                    if (r.Kind == SymbolKind.Method)
                    {
                        return(new Tuple <string, string, ISymbol>(CSParsers.TypeToString(r.ContainingType), "", r));
                    }
                    else if (r.Kind == SymbolKind.Property)
                    {
                        IPropertySymbol ps = r as IPropertySymbol;
                        return(new Tuple <string, string, ISymbol>(CSParsers.TypeToString(ps.Type), "", r));
                    }
                    else if (r.Kind == SymbolKind.NamedType)
                    {
                        INamedTypeSymbol ps = r as INamedTypeSymbol;
                        return(new Tuple <string, string, ISymbol>(CSParsers.TypeToString(ps), "", r));
                    }
                }
            }
            else
            {
                if (r != null)
                {
                    if (r.Kind == SymbolKind.Method)
                    {
                        ISymbol containigType = r.ContainingType;

                        if (containigType != null)
                        {
                            if (containigType.Locations != null)
                            {
                                if (containigType.Locations[0] != null)
                                {
                                    if (containigType.Locations[0].IsInSource)
                                    {
                                        return(new Tuple <string, string, ISymbol>("", containigType.Locations[0].SourceTree.FilePath, r));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            List <INamespaceOrTypeSymbol> s = /*vp.*/ vs.GetAllTypes(file);

            word = word.ToLower();

            // var data = s.Select(bc => bc).Where(cd => cd.Name.ToLower().Contains(word)).ToList();

            foreach (INamespaceOrTypeSymbol b in s)
            {
                if (word.Contains("."))
                {
                }
                else if (b.Name.ToLower() == word)
                {
                    if (b.IsType)
                    {
                        if (b.Locations != null)
                        {
                            if (b.Locations[0] != null)
                            {
                                if (b.Locations[0].IsInSource)
                                {
                                    return(new Tuple <string, string, ISymbol>("", b.Locations[0].SourceTree.FilePath, b));
                                }
                            }
                        }
                        return(new Tuple <string, string, ISymbol>(CSParsers.TypeToString(b), "", b));
                    }
                }
            }
            return(new Tuple <string, string, ISymbol>("", "", null));
        }