public static IYamlDocument FindDocumentByAnchor([CanBeNull] this IYamlFile file, [CanBeNull] string anchor)
        {
            if (file == null || anchor == null)
            {
                return(null);
            }

            var searcher = new StringSearcher("&" + anchor, true);

            foreach (var document in file.DocumentsEnumerable)
            {
                // Don't open chameleons unless we have to
                // TODO: GetTextAsBuffer is not cheap - it will allocate a StringBuilder + string
                // But then, FindDocumentByAnchor is hopelessly naive
                if (searcher.Find(document.GetTextAsBuffer()) >= 0)
                {
                    // Note that this opens the Body chameleon
                    var properties = GetDocumentBlockNodeProperties(document.Body.BlockNode);
                    if (properties?.AnchorProperty?.Text?.CompareBufferText(anchor) == true)
                    {
                        return(document);
                    }
                }
            }

            return(null);
        }
 public IdentifierHighlightingProcess(IDaemonProcess process, IYamlFile file,
                                      ResolveHighlighterRegistrar resolveHighlighterRegistrar,
                                      bool allowOpeningChameleons)
     : base(process, file, allowOpeningChameleons)
 {
     myResolveProblemHighlighter = new ResolveProblemHighlighter(resolveHighlighterRegistrar);
     myReferenceProvider         = ((IFileImpl)file).ReferenceProvider;
 }
Esempio n. 3
0
            public YamlErrorStageProcess(IDaemonProcess process, DaemonProcessKind processKind,
                                         ElementProblemAnalyzerRegistrar elementProblemAnalyzerRegistrar,
                                         IContextBoundSettingsStore settings, IYamlFile file, bool allowOpeningChameleons)
                : base(process, file, allowOpeningChameleons)
            {
                var elementProblemAnalyzerData = new ElementProblemAnalyzerData(file, settings, ElementProblemAnalyzerRunKind.FullDaemon);

                elementProblemAnalyzerData.SetDaemonProcess(process, processKind);
                myElementAnalyzerDispatcher = elementProblemAnalyzerRegistrar.CreateDispatcher(elementProblemAnalyzerData);
            }
        protected virtual bool ShouldAllowOpeningChameleons(IYamlFile file, DaemonProcessKind processKind)
        {
            // By default, only process already open chameleons for files larger than 1Mb when doing background analysis
            // (SWEA). Opening chameleons for e.g. large Unity files is too expensive
            if (processKind != DaemonProcessKind.VISIBLE_DOCUMENT &&
                file.GetSourceFile().ToProjectFile() is ProjectFileImpl projectFileImpl &&
                projectFileImpl.CachedFileSystemData.FileLength > LargeFileThreshold)
            {
                return(false);
            }

            return(true);
        }
        public static INode GetCollection([CanBeNull] IYamlFile file, string documentName, string name)
        {
            var blockMappingNode = file?.Documents[0].Body.BlockNode as IBlockMappingNode;

            return(GetCollection(blockMappingNode, documentName, name));
        }
 public static INode GetSceneCollection([NotNull] IYamlFile file)
 {
     return(GetCollection(file, "EditorBuildSettings", "m_Scenes"));
 }
 protected YamlDaemonStageProcessBase(IDaemonProcess process, IYamlFile file)
 {
     DaemonProcess = process;
     myFile        = file;
 }
Esempio n. 8
0
 protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                      DaemonProcessKind processKind, IYamlFile file)
 {
     return(new YamlErrorStageProcess(process, processKind, myElementProblemAnalyzerRegistrar, settings, file));
 }
 protected abstract IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                      DaemonProcessKind processKind, IYamlFile file);
Esempio n. 10
0
 protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                      DaemonProcessKind processKind, IYamlFile file)
 {
     return(new IdentifierHighlightingProcess(process, file, myRegistrar));
 }
Esempio n. 11
0
 protected override IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings,
                                                      DaemonProcessKind processKind, IYamlFile file)
 {
     return(new IdentifierHighlightingProcess(process, file, processKind, myRegistrar,
                                              ShouldAllowOpeningChameleons(file, processKind), myInternalMode));
 }
 protected YamlDaemonStageProcessBase(IDaemonProcess process, IYamlFile file, bool allowOpeningChameleons)
 {
     DaemonProcess            = process;
     myFile                   = file;
     myAllowOpeningChameleons = allowOpeningChameleons;
 }