예제 #1
0
 public static void doFileCodeModel(EnvDTE.FileCodeModel fileCodeModel)
 {
     Debug.WriteLine("walking FileCodeModel...");
     if (fileCodeModel.CodeElements.Count <= 0)
     {
         Debug.WriteLine("no code elements in this FileCodeModel");
     }
 }
예제 #2
0
        private CommentType GetCommentType(Document doc)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (doc == null)
            {
                return(CommentType.Unknown);
            }
            var prjItem = doc.ProjectItem;

            if (prjItem == null)
            {
                return(CommentType.Unknown);
            }
            if (prjItem.FileCodeModel != null)
            {
                EnvDTE.FileCodeModel fileCodeModel = prjItem.FileCodeModel;
                switch (fileCodeModel.Language)
                {
                case EnvDTE.CodeModelLanguageConstants.vsCMLanguageCSharp:
                case EnvDTE.CodeModelLanguageConstants.vsCMLanguageMC:
                case EnvDTE.CodeModelLanguageConstants.vsCMLanguageVC:
                case EnvDTE.CodeModelLanguageConstants.vsCMLanguageIDL:
                    return(CommentType.TypeCs);

                case EnvDTE.CodeModelLanguageConstants.vsCMLanguageVB:
                    return(CommentType.TypeVb);
                }
            }
            if (doc.Language == "XML")
            {
                return(CommentType.TypeXml);
            }
            //	認識できない形式 == プレーンテキスト扱い
            Trace.WriteLine($"NonDetected Item. Name={prjItem.Name}, Kind={prjItem.Kind}, Language={doc.Language}");
            return(CommentType.Unknown);
        }
예제 #3
0
 public static void WalkFileCodeModel(EnvDTE.FileCodeModel fileCodeModel, string indent)
 {
     doFileCodeModel(fileCodeModel);
     WalkCodeElements(fileCodeModel.CodeElements, indent);
 }
예제 #4
0
 public CodeModel(EnvDTE.FileCodeModel codeModel)
 {
     code_model_ = codeModel;
     parse();
 }
 public NemerleCodeBehindEventBinder(EnvDTE.FileCodeModel fileCodeModel, ITypeResolutionService typeResolutionService)
 {
     _fileCodeModel = fileCodeModel;
     _typeResolutionService = typeResolutionService;
 }
예제 #6
0
 public NemerleCodeBehindEventBinder(EnvDTE.FileCodeModel fileCodeModel, ITypeResolutionService typeResolutionService)
 {
     _fileCodeModel         = fileCodeModel;
     _typeResolutionService = typeResolutionService;
 }
예제 #7
0
        /// <summary>
        /// Gets the code element.
        /// </summary>
        /// <param name="vs">The vs.</param>
        /// <param name="fileCodeModel">The file code model.</param>
        /// <param name="codeElementType">Type of the code element.</param>
        /// <returns></returns>
        public static object GetCodeElement(DTE vs, EnvDTE.FileCodeModel fileCodeModel, Type codeElementType)
        {
            TextSelection textSelection = (TextSelection)vs.ActiveDocument.Selection;
            TextPoint     point         = textSelection.ActivePoint;

            object element;

            if (codeElementType.IsAssignableFrom(typeof(CodeNamespace)))
            {
                try
                {
                    element = (CodeNamespace)fileCodeModel.CodeElementFromPoint(
                        point,
                        vsCMElement.vsCMElementNamespace);
                    return(element);
                }
                catch
                {
                    return(null);
                }
            }

            if (codeElementType.IsAssignableFrom(typeof(CodeAttribute)))
            {
                try
                {
                    element = (CodeAttribute)fileCodeModel.CodeElementFromPoint(
                        point,
                        vsCMElement.vsCMElementAttribute);
                    return(element);
                }
                catch
                {
                    return(null);
                }
            }

            if (codeElementType.IsAssignableFrom(typeof(CodeClass)))
            {
                try
                {
                    element = (CodeClass)fileCodeModel.CodeElementFromPoint(
                        point,
                        vsCMElement.vsCMElementClass);
                    return(element);
                }
                catch
                {
                    return(null);
                }
            }

            if (codeElementType.IsAssignableFrom(typeof(CodeProperty)))
            {
                try
                {
                    element = (CodeProperty)fileCodeModel.CodeElementFromPoint(
                        point,
                        vsCMElement.vsCMElementProperty);
                    return(element);
                }
                catch
                {
                    return(null);
                }
            }

            if (codeElementType.IsAssignableFrom(typeof(CodeFunction)))
            {
                try
                {
                    element = (CodeFunction)fileCodeModel.CodeElementFromPoint(
                        point,
                        vsCMElement.vsCMElementFunction);
                    return(element);
                }
                catch
                {
                    return(null);
                }
            }

            return(null);
        }