private static bool MatchesLocalVariable(SrcMLDataContext db, VariableDeclaration def, XElement use)
        {
            if (def.IsGlobal ?? false)
                return false;

            if (def.DeclarationName != use.Value)
                return false;
            
            var useXPath = use.GetXPath(false);
            var validScopes = from scope in db.ValidScopes
                              where scope.DefinitionId == def.Id
                              select scope;
            foreach (var scope in validScopes)
            {
                if (useXPath.StartsWith(scope.XPath))
                    return true;
            }

            var method = (from ancestor in use.Ancestors()
                          where ContainerNames.MethodDefinitions.Any(mn => mn == ancestor.Name)
                          select ancestor).FirstOrDefault();
            var classNameFromMethod = SrcMLHelper.GetClassNameForMethod(method);

            if (null == classNameFromMethod)
            {
                return false;
            }

            var classDef = from scope in def.ValidScopes.OfType<TypeDefinition>()
                           where scope.TypeName == classNameFromMethod.Value
                           select scope;
            if (classDef.Any())
            {
                return true;
            }

            return false;
        }
 private static bool MatchesGlobalVariable(SrcMLDataContext db, VariableDeclaration def, XElement use)
 {
     return def.DeclarationName == use.Value && (def.IsGlobal ?? false);
 }
Example #3
0
 private static bool Verify(SrcMLDataContext db, TypeDefinition def, XElement use)
 {
     return def.TypeName == use.Elements(SRC.Name).Last().Value;
 }
 private static IEnumerable<VariableDeclaration> FindDefinitionsForVariable(SrcMLDataContext db, Archive archive, XElement element)
 {
     return archive.GetDeclarationForVariable(db, element);
 }
Example #5
0
 private static IEnumerable<TypeDefinition> FindDefinitionsFromArchive(SrcMLDataContext db, Archive archive, XElement element)
 {
     return archive.GetTypeForVariableName(db, element);
 }