Exemple #1
0
            public override string ToString()
            {
                if (Symbol == null)
                {
                    return("<empty import binding>");
                }

                if (Alias == null)
                {
                    return(Symbol.ToString());
                }
                return(Alias + " = " + Symbol);
            }
Exemple #2
0
        static ResolveResult[] HandleIdDeclaration(IdentifierDeclaration typeId,
			ResolverContext lastResCtxt,
			IAbstractSyntaxTree SyntaxTree,
			CodeScanResult csr, 
			Dictionary<string, ResolveResult> compDict)
        {
            var typeString = typeId.ToString();

            bool WasAlreadyResolved = false;
            ResolveResult[] allCurrentResults = null;
            ResolveResult rr = null;

            /*
             * string,wstring,dstring are highlighted by the editor's syntax definition automatically..
             * Anyway, allow to resolve e.g. "object.string"
             */
            if (typeString == "" || typeString == "string" || typeString == "wstring" || typeString == "dstring")
                return null;

            lastResCtxt.ScopedBlock = DResolver.SearchBlockAt(SyntaxTree, typeId.Location, out lastResCtxt.ScopedStatement);
            if (typeString == "th" && typeId.Location.Line == 114)
            {

            }
            if (!(WasAlreadyResolved = compDict.TryGetValue(typeString, out rr)))
            {
                allCurrentResults = DResolver.ResolveType(typeId, lastResCtxt);

                if (allCurrentResults != null && allCurrentResults.Length > 0)
                    rr = allCurrentResults[0];
            }

            if (rr == null)
            {
                if (typeId is IdentifierDeclaration)
                    csr.UnresolvedIdentifiers.Add(typeId as IdentifierDeclaration);
            }
            else
            {
                /*
                 * Note: It is of course possible to highlight more than one type in one type declaration!
                 * So, we scan down the result hierarchy for TypeResults and highlight all of them later.
                 */
                var curRes = rr;

                /*
                 * Note: Since we want to use results multiple times,
                 * we at least have to 'update' their type declarations
                 * to ensure that the second, third, fourth etc. occurence of this result
                 * are also highlit (and won't(!) cause an Already-Added-Exception of our finalDict-Array)
                 */
                var curTypeDeclBase = typeId as ITypeDeclaration;

                while (curRes != null)
                {
                    if (curRes is MemberResult)
                    {
                        var mr = curRes as MemberResult;

                        // If curRes is an alias or a template parameter, highlight it
                        if (mr.ResolvedMember is TemplateParameterNode ||
                            (mr.ResolvedMember is DVariable &&
                            (mr.ResolvedMember as DVariable).IsAlias))
                        {
                            try
                            {
                                csr.ResolvedIdentifiers.Add(curTypeDeclBase as IdentifierDeclaration, curRes);
                            }
                            catch { }

                            // See performance reasons
                            //if (curRes != rr && !WasAlreadyResolved && !) compDict.Add(curTypeDeclBase.ToString(), curRes);
                        }
                    }

                    else if (curRes is TypeResult)
                    {
                        // Yeah, in quite all cases we do identify a class via its name ;-)
                        if (curTypeDeclBase is IdentifierDeclaration &&
                            !(curTypeDeclBase is DTokenDeclaration) &&
                            !csr.ResolvedIdentifiers.ContainsKey(curTypeDeclBase as IdentifierDeclaration))
                        {
                            csr.ResolvedIdentifiers.Add(curTypeDeclBase as IdentifierDeclaration, curRes);

                            // See performance reasons
                            //if (curRes != rr && !WasAlreadyResolved) compDict.Add(curTypeDeclBase.ToString(), curRes);
                        }
                    }

                    else if (curRes is ModuleResult)
                    {
                        if (curTypeDeclBase is IdentifierDeclaration &&
                            !csr.ResolvedIdentifiers.ContainsKey(curTypeDeclBase as IdentifierDeclaration))
                            csr.ResolvedIdentifiers.Add(curTypeDeclBase as IdentifierDeclaration, curRes);
                    }

                    curRes = curRes.ResultBase;
                    curTypeDeclBase = curTypeDeclBase.InnerDeclaration;
                }
            }
            return allCurrentResults;
        }