Can not capture *.cshtml file

12 views
Skip to first unread message

taodongl

unread,
Jul 4, 2017, 4:19:31 AM7/4/17
to resharper-plugins
I implement DaemonStage to analyze *.cshtml file.
But I find it doesn't work. (I set breakpoint in `return ...` but nothing occurs) 

    [DaemonStage(StagesAfter = new[] { typeof(LanguageSpecificDaemonStage) })]
    public class RazorFileDaeMonStage : DaemonStageBase<IRazorFile>
    {
        protected override IDaemonStageProcess CreateDaemonProcess(IDaemonProcess process, DaemonProcessKind processKind, IRazorFile file,
            IContextBoundSettingsStore settingsStore)
        {
            return new Process(process, file, settingsStore);
        }
        ... ...
    }


Matt Ellis

unread,
Jul 4, 2017, 7:03:12 AM7/4/17
to resharper-plugins
What's your implementation of GetPsiFiles? If that returns nothing, then CreateDaemonProcess won't get called.

taodongl

unread,
Jul 4, 2017, 9:35:20 PM7/4/17
to resharper-plugins

Oh, there was a typo in GetPsiFiles function. now I can capture RazorFile.

       

        protected override IEnumerable<IRazorFile> GetPsiFiles(IPsiSourceFile sourceFile)       
        {
            if (sourceFile != null && sourceFile.PrimaryPsiLanguage.Is<RazorLanguage>())
                return sourceFile.GetPsiFiles<RazorLanguage>().Cast<IRazorFile>();
            return EmptyList<IRazorFile>.Instance;
        }


But another issue is:

I want to get string: "Use this area to provide additional information." which defined in *.cshtml.(please see the snapshot in below)

But I cannot get HTMLTOKEN whose nodetype is TEXT. 


                        public override void ProcessBeforeInterior(ITreeNode element)
            {
                switch (element)
                {
                    case IHtmlToken htmlToken:
                        if (htmlToken.NodeType == LanguageManager.Instance.GetService<RazorTokenNodeTypes, RazorLanguage>().TEXT)
                        {
                            ... ...
                        }
                        break;
                }
                ... ...
            }






在 2017年7月4日星期二 UTC+8下午7:03:12,Matt Ellis写道:

Matt Ellis

unread,
Jul 7, 2017, 9:10:26 AM7/7/17
to resharper-plugins
I would have expected that to work. I can only really suggest looking in the debugger to see what's happening - are you being passed all IHtmlToken instances, and if you are, and you're getting the HtmlToken, what is the node type? What class is it?
Reply all
Reply to author
Forward
0 new messages