Пример #1
0
        internal IEnumerable <AnalysisVariable> ToVariables(IReferenceable referenceable)
        {
            LocatedVariableDef locatedDef = referenceable as LocatedVariableDef;

            if (locatedDef != null &&
                locatedDef.Entry.Tree != null &&    // null tree if there are errors in the file
                locatedDef.DeclaringVersion == locatedDef.Entry.AnalysisVersion)
            {
                var start = locatedDef.Node.GetStart(locatedDef.Entry.Tree);
                yield return(new AnalysisVariable(VariableType.Definition, new LocationInfo(locatedDef.Entry, start.Line, start.Column)));
            }

            VariableDef def = referenceable as VariableDef;

            if (def != null)
            {
                foreach (var location in def.TypesNoCopy.SelectMany(type => type.Locations))
                {
                    yield return(new AnalysisVariable(VariableType.Value, location));
                }
            }

            foreach (var reference in referenceable.Definitions)
            {
                yield return(new AnalysisVariable(VariableType.Definition, reference.Value.GetLocationInfo(reference.Key)));
            }

            foreach (var reference in referenceable.References)
            {
                yield return(new AnalysisVariable(VariableType.Reference, reference.Value.GetLocationInfo(reference.Key)));
            }
        }
Пример #2
0
        private IEnumerable <IAnalysisVariable> ToVariables(IReferenceable referenceable)
        {
            LocatedVariableDef locatedDef = referenceable as LocatedVariableDef;

            if (locatedDef != null)
            {
                yield return(new AnalysisVariable(VariableType.Definition, new LocationInfo(locatedDef.Entry, locatedDef.Node.Start.Line, locatedDef.Node.Start.Column)));
            }

            foreach (var reference in referenceable.Definitions)
            {
                yield return(new AnalysisVariable(VariableType.Definition, new LocationInfo(reference.Key, reference.Value.Line, reference.Value.Column)));
            }

            foreach (var reference in referenceable.References)
            {
                yield return(new AnalysisVariable(VariableType.Reference, new LocationInfo(reference.Key, reference.Value.Line, reference.Value.Column)));
            }
        }