symbolLinkingName :: TypeNode -> [[String]] -> SemanticUnit -> Name -> [Symbol]
symbolLinkingName db imps su (Name cname@(nm:remain)) = case syms'' of
                                                        [] -> case symsInheritance''' of
                                                                --[] -> if cname == ["Arrays", "equals"] then error (show $ lookUpDBSymbol db imps su cname) else lookUpDBSymbol db imps su cname
                                                                [] -> lookUpDBSymbol db imps su cname
                                                                _ -> symsInheritance''
                                                        _ -> syms''
    where
                baseName = (typeToName . lookUpThis) su
                syms = [sym | sym <- lookUpSymbolTable su nm, not $ elem "cons" (symbolModifiers sym)]
                symsLocal = [sym | sym@(SYM mds scope _ _) <- syms, (scope /= baseName)]
                symsStatic = symsLocal ++ [sym | sym@(SYM mds scope _ _) <- syms, elem "static" mds] ++ [func | func@(FUNC mds _ _ _ _) <- syms, elem "static" mds, (length cname) > 1]
                symsNStatic = symsLocal ++ [sym | sym <- syms, not $ elem sym symsStatic]
                syms' = if scopeStatic su then symsStatic else symsNStatic
                syms'' = if remain == []
                            then syms'
                            else map symbol $ concat $ map (traverseInstanceEntryAccessible db baseName db) [((typeToName . localType) sym) ++ remain | sym@(SYM mds _ _ _) <- syms']
                
                Just thisNode = getTypeEntry db baseName
                symsInheritance = [sym | sym <- map symbol (traverseInstanceEntryAccessible db baseName thisNode [nm]), not $ elem "cons" (symbolModifiers sym)]
                symsInheritanceStatic = [sym | sym@(SYM mds _ _ _) <- symsInheritance, elem "static" mds] ++ [func | func@(FUNC mds _ _ _ _) <- symsInheritance, elem "static" mds]
                symsInheritanceNStatic = [sym | sym <- symsInheritance, not $ elem sym symsInheritanceStatic]
                symsInheritance' = if scopeStatic su then symsInheritanceStatic else symsInheritanceNStatic
                symsInheritance'' = if remain == []
                                    then symsInheritance'
                                    else map symbol $ concat $ map (traverseInstanceEntryAccessible db baseName db) [((typeToName . localType) sym) ++ remain | sym@(SYM mds _ _ _) <- symsInheritance']
                symsInheritance''' = if scopeLocal su then symsInheritance'' else []


---------------------------------------------------------------------------------------------------------
symbolLinkingName :: TypeNode -> [[String]] -> SemanticUnit -> Name -> [Symbol]
symbolLinkingName db imps su (Name cname@(nm:remain)) = case syms'' of
                                                        [] -> case symsInheritance''' of
                                                                --[] -> if cname == ["Arrays", "equals"] then error (show $ lookUpDBSymbol db imps su cname) else lookUpDBSymbol db imps su cname
                                                                [] -> lookUpDBSymbol db imps su cname
                                                                _ -> symsInheritance''
                                                        _ -> syms''
    where
                baseName = (typeToName . lookUpThis) su
                syms = [sym | sym <- lookUpSymbolTable su nm, not $ elem "cons" (symbolModifiers sym)]
                symsLocal = [sym | sym@(SYM mds scope _ _) <- syms, (scope /= baseName)]
                symsStatic = symsLocal ++ [sym | sym@(SYM mds scope _ _) <- syms, elem "static" mds] ++ [func | func@(FUNC mds _ _ _ _) <- syms, elem "static" mds, (length cname) > 1]
                symsNStatic = symsLocal ++ [sym | sym <- syms, not $ elem sym symsStatic]
                syms' = if scopeStatic su then symsStatic else symsNStatic
                syms'' = if remain == []
                            then syms'
                            else map symbol $ concat $ map (traverseInstanceEntryAccessible db baseName db) [((typeToName . localType) sym) ++ remain | sym@(SYM mds _ _ _) <- syms']
                
                Just thisNode = getTypeEntry db baseName
                symsInheritance = [sym | sym <- map symbol (traverseInstanceEntryAccessible db baseName thisNode [nm]), not $ elem "cons" (symbolModifiers sym)]
                symsInheritanceStatic = [sym | sym@(SYM mds _ _ _) <- symsInheritance, elem "static" mds] ++ [func | func@(FUNC mds _ _ _ _) <- symsInheritance, elem "static" mds]
                symsInheritanceNStatic = [sym | sym <- symsInheritance, not $ elem sym symsInheritanceStatic]
                symsInheritance' = if scopeStatic su then symsInheritanceStatic else symsInheritanceNStatic
                symsInheritance'' = if remain == []
                                    then symsInheritance'
                                    else map symbol $ concat $ map (traverseInstanceEntryAccessible db baseName db) [((typeToName . localType) sym) ++ remain | sym@(SYM mds _ _ _) <- symsInheritance']
                symsInheritance''' = if scopeLocal su then symsInheritance'' else []


---------------------------------------------------------------------------------------------------------
symbolLinkingName db imps su (Name cname@(nm:remain)) = case syms'' of
                                                        [] -> case symsInheritance''' of
                                                                --[] -> if cname == ["Arrays", "equals"] then error (show $ lookUpDBSymbol db imps su cname) else lookUpDBSymbol db imps su cname
                                                                [] -> lookUpDBSymbol db imps su cname
                                                                _ -> symsInheritance''
                                                        _ -> syms''
    where
                baseName = (typeToName . lookUpThis) su
                syms = [sym | sym <- lookUpSymbolTable su nm, not $ elem "cons" (symbolModifiers sym)]
                symsLocal = [sym | sym@(SYM mds scope _ _) <- syms, (scope /= baseName)]
                symsStatic = symsLocal ++ [sym | sym@(SYM mds scope _ _) <- syms, elem "static" mds] ++ [func | func@(FUNC mds _ _ _ _) <- syms, elem "static" mds, (length cname) > 1]
                symsNStatic = symsLocal ++ [sym | sym <- syms, not $ elem sym symsStatic]
                syms' = if scopeStatic su then symsStatic else symsNStatic
                syms'' = if remain == []
                            then syms'
                            else map symbol $ concat $ map (traverseInstanceEntryAccessible db baseName db) [((typeToName . localType) sym) ++ remain | sym@(SYM mds _ _ _) <- syms']
                
                Just thisNode = getTypeEntry db baseName
                symsInheritance = [sym | sym <- map symbol (traverseInstanceEntryAccessible db baseName thisNode [nm]), not $ elem "cons" (symbolModifiers sym)]
                symsInheritanceStatic = [sym | sym@(SYM mds _ _ _) <- symsInheritance, elem "static" mds] ++ [func | func@(FUNC mds _ _ _ _) <- symsInheritance, elem "static" mds]
                symsInheritanceNStatic = [sym | sym <- symsInheritance, not $ elem sym symsInheritanceStatic]
                symsInheritance' = if scopeStatic su then symsInheritanceStatic else symsInheritanceNStatic
                symsInheritance'' = if remain == []
                                    then symsInheritance'
                                    else map symbol $ concat $ map (traverseInstanceEntryAccessible db baseName db) [((typeToName . localType) sym) ++ remain | sym@(SYM mds _ _ _) <- symsInheritance']
                symsInheritance''' = if scopeLocal su then symsInheritance'' else []


---------------------------------------------------------------------------------------------------------