Exemple #1
0
        public void Run(ILexer <int> lexer, ShaderLabParser parser, SeldomInterruptChecker interruptChecker)
        {
            for (var tokenType = lexer.TokenType; tokenType != null; tokenType = lexer.TokenType)
            {
                interruptChecker.CheckForInterrupt();

                if (tokenType == ShaderLabTokenType.PP_ERROR ||
                    tokenType == ShaderLabTokenType.PP_WARNING ||
                    tokenType == ShaderLabTokenType.PP_LINE)
                {
                    var startOffset = lexer.TokenStart;
                    var directive   = parser.ParsePreprocessorDirective();
                    myPpDirectivesByOffset[startOffset] = directive;
                    myRanges.Add(new TextRange(startOffset, lexer.TokenStart));
                }
                else if (tokenType == ShaderLabTokenType.CG_INCLUDE ||
                         tokenType == ShaderLabTokenType.GLSL_INCLUDE ||
                         tokenType == ShaderLabTokenType.HLSL_INCLUDE)
                {
                    var startOffset = lexer.TokenStart;
                    var include     = parser.ParseIncludeBlock();
                    myPpDirectivesByOffset[startOffset] = include;
                    myRanges.Add(new TextRange(startOffset, lexer.TokenStart));
                }
                else
                {
                    lexer.Advance();
                }
            }
        }
        private void HighlightUses(Action <DaemonStageResult> committer, IEnumerable <FSharpResolvedSymbolUse> symbols, int allSymbolsCount)
        {
            var highlightings = new List <HighlightingInfo>(allSymbolsCount);

            foreach (var resolvedSymbolUse in symbols)
            {
                var symbolUse = resolvedSymbolUse.SymbolUse;
                var symbol    = symbolUse.Symbol;

                var highlightingId =
                    symbolUse.IsFromComputationExpression
            ? HighlightingAttributeIds.KEYWORD
            : symbol.GetHighlightingAttributeId();

                if (symbolUse.IsFromDefinition && symbol is FSharpMemberOrFunctionOrValue mfv)
                {
                    if (myDocument.Buffer.GetText(resolvedSymbolUse.Range).Equals("new", StringComparison.Ordinal) &&
                        mfv.LogicalName.Equals(".ctor", StringComparison.Ordinal))
                    {
                        continue;
                    }
                }

                var documentRange = new DocumentRange(myDocument, resolvedSymbolUse.Range);
                var highlighting  = new FSharpIdentifierHighlighting(highlightingId, documentRange);
                highlightings.Add(new HighlightingInfo(documentRange, highlighting));

                SeldomInterruptChecker.CheckForInterrupt();
            }
            committer(new DaemonStageResult(highlightings));
        }
            public override bool InteriorShouldBeProcessed(ITreeNode element)
            {
                SeldomInterruptChecker.CheckForInterrupt();

                if (element == StartTreeNode)
                {
                    return(true);
                }

                return(!UnityCallGraphUtil.IsFunctionNode(element) && !IsBurstProhibitedNode(element));
            }
Exemple #4
0
        public virtual bool InteriorShouldBeProcessed(ITreeNode element)
        {
            SeldomInterruptChecker.CheckForInterrupt();

            if (element == StartTreeNode)
            {
                return(true);
            }

            return(!UnityCallGraphUtil.IsFunctionNode(element));
        }
        private FindExecution RunForNamedReferences(ITreeNode scope)
        {
            var suspiciousRefs = new List <IReference>();

            var interruptChecker = new SeldomInterruptChecker();

            for (var descendants = new FixedThisAndDescendantsEnumerator(myRoot); descendants.MoveNext();)
            {
                var element = descendants.Current;

                foreach (var reference in GetReferences(element))
                {
                    suspiciousRefs.Add(reference);
                }

                if (!ShouldVisitScope(element))
                {
                    descendants.SkipThisNode();
                }

                interruptChecker.CheckForInterrupt();
            }

            if (suspiciousRefs.Count > 0)
            {
                MultipleReferencesResolver.ResolveReferences(scope, suspiciousRefs);
            }

            foreach (var reference in suspiciousRefs)
            {
                var execution = ProcessReference(reference);
                if (execution == FindExecution.Stop)
                {
                    return(FindExecution.Stop);
                }
                interruptChecker.CheckForInterrupt();
            }

            return(FindExecution.Continue);
        }
Exemple #6
0
            public bool InteriorShouldBeProcessed(ITreeNode element)
            {
                myInterruptChecker.CheckForInterrupt();
                switch (element)
                {
                case IFunctionDeclaration _:
                case ICSharpClosure _:
                    return(false);

                default:
                    return(true);
                }
            }
        public override void Execute(Action <DaemonStageResult> committer)
        {
            // todo: add more cases to GetSemanticClassification (e.g. methods, values, namespaces) and use it instead?
            var checkResults = DaemonProcess.CustomData.GetData(FSharpDaemonStageBase.TypeCheckResults);
            var declarations = myFsFile.GetAllDeclaredSymbols(checkResults?.Value);

            SeldomInterruptChecker.CheckForInterrupt();

            var usages = myFsFile.GetAllResolvedSymbols();

            SeldomInterruptChecker.CheckForInterrupt();

            HighlightUses(committer, declarations.Concat(usages), declarations.Length + usages.Length);
        }
        public void Run(ILexer <int> lexer, CgParser parser, SeldomInterruptChecker interruptChecker)
        {
            for (var tokenType = lexer.TokenType; tokenType != null; tokenType = lexer.TokenType)
            {
                interruptChecker.CheckForInterrupt();

                if (tokenType == CgTokenNodeTypes.DIRECTIVE)
                {
                    var startOffset      = lexer.TokenStart;
                    var directiveElement = parser.ParseDirective();
                    myPpDirectivesByOffset[startOffset] = directiveElement;
                    myRanges.Add(new TextRange(startOffset, lexer.TokenStart));
                }
                else
                {
                    lexer.Advance();
                }
            }
        }
Exemple #9
0
        public static UnitySceneData Build(IUnityYamlFile file)
        {
            Assertion.Assert(file.IsValid(), "file.IsValid()");
            Assertion.Assert(file.GetSolution().Locks.IsReadAccessAllowed(), "ReadLock is required");

            var interruptChecker            = new SeldomInterruptChecker();
            var unityPropertyValueCacheItem = new OneToListMap <MonoBehaviourProperty, MonoBehaviourPropertyValue>();
            var sceneHierarchy = new SceneHierarchy();

            var anchorToEventHandler       = new OneToSetMap <string, string>();
            var scriptMapping              = new OneToSetMap <string, string>();
            var eventHandlerToScriptTarget = new OneToSetMap <string, FileID>();

            foreach (var document in file.DocumentsEnumerable)
            {
                interruptChecker.CheckForInterrupt();
                var buffer = document.GetTextAsBuffer();
                if (ourPrefabModificationSearcher.Find(buffer, 0, Math.Min(buffer.Length, 100)) > 0)
                {
                    sceneHierarchy.AddPrefabModification(buffer);
                }
                else
                {
                    var simpleValues    = new Dictionary <string, string>();
                    var referenceValues = new Dictionary <string, FileID>();
                    UnitySceneDataUtil.ExtractSimpleAndReferenceValues(buffer, simpleValues, referenceValues, eventHandlerToScriptTarget);

                    FillProperties(simpleValues, referenceValues, unityPropertyValueCacheItem);
                    FillScriptMapping(simpleValues, referenceValues, scriptMapping);

                    sceneHierarchy.AddSceneHierarchyElement(simpleValues, referenceValues);
                }
            }

            if (unityPropertyValueCacheItem.Count == 0 && sceneHierarchy.Elements.Count == 0)
            {
                return(null);
            }

            return(new UnitySceneData(unityPropertyValueCacheItem, eventHandlerToScriptTarget, scriptMapping, sceneHierarchy));
        }
 public bool InteriorShouldBeProcessed(ITreeNode element)
 {
     myInterruptChecker.CheckForInterrupt();
     return(!IsFunctionNode(element) && !IsBurstContextBannedNode(element));
 }