[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [cdt-dev] Confusion again. | 
- From: Nathan Ridge <zeratul976@xxxxxxxxxxx>
- Date: Wed, 4 Mar 2020 02:02:13 +0000
- Accept-language: en-CA, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;	dkim=none; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 	s=arcselector9901;	h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;	bh=58JgVw4o0VPBO5dwW1ddN1y9TIMNyk0j6m2QNfP0C1E=;	b=DOgWo8tUEpOf7mHmJhK798bTMmAmzeD8HsNwATg/gG06DNpqzitvVRbUpfWtA9cT0vBhUhUkJOD9EEITqfVRWkFpcB22gnZEf1Kg58zo9TkBnTHweH5Dp9XIPMm49W/gN2qJt5I0Ruv1LgA8xPAiwPJ7qWcNu/SKs8B3d/+i/QCk0MvdyY6DvkW/vv4Q0rjyvBCizXdsy/WkxEUvil4YNjXTvbMMbOYLcKfk2xvcDbszMArc5UoSSjRlqCsEXNDmxZLKepMpm3ckQZNEP9YpCDr6SL6ijgczBdk5Rb7h15epROvCJwdEiNa591NXZF5NiB+OB3Qfm9t77sVPtiA+2g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;	b=Fe79BQXhrBLA4hWi22gTCOAWuLWGFV88nuPXIeGcnVUY1Phg5ULVo0hQ0T7T3pOMSCKJxTFVhdccYPYC+R9i8KWlb/kW/0qoNLl/kBcJ3NwWb5SeX4CGvLnIqAeu3cBCUOnbCWj7mAmYmEZdkgaBK95d6WNOHwvPGbpZaRrdoimiKBWS0mkkggzEZRudqlscAZMYZFUCVxCWI09HVeWM8gJv1AVH5iGfb41HrQtzgyJj2h9cZstoelx04QiRmjhLvwuRUffg5oM58dMYK3lYHk5r7YZdrC3HqAzDe4+fzkfEXbf4XmL/0UU60ugbPc+xJ5DYAxzTteEahcqtkULNtg==
- Delivered-to: cdt-dev@xxxxxxxxxxx
- List-archive: <https://www.eclipse.org/mailman/private/cdt-dev>
- List-help: <mailto:cdt-dev-request@eclipse.org?subject=help>
- List-subscribe: <https://www.eclipse.org/mailman/listinfo/cdt-dev>,	<mailto:cdt-dev-request@eclipse.org?subject=subscribe>
- List-unsubscribe: <https://www.eclipse.org/mailman/options/cdt-dev>,	<mailto:cdt-dev-request@eclipse.org?subject=unsubscribe>
- Thread-index: AQHV8H2NHtXLElb12U+Hd2ShrTFmAqg3qbPOgAAGmIo=
- Thread-topic: Confusion again.
There are two interfaces named IFunction in the CDT code:
1. org.eclipse.cdt.core.dom.ast.IFunction
2. org.eclipse.cdt.core.model.IFunction
IBindings are of the first kind (dom.ast), is that the one you're checking for?
Also, there is a public API to get the binding for a name:
  cppFunctionDeclarator.getName().resolveBinding()
(i.e. there is no need to use the private class CPPVisitor).
Hope that helps,
Nate
________________________________________
From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Ming Cheng <chengm349@xxxxxxxxxxx>
Sent: March 4, 2020 1:42 AM
To: cdt-dev@xxxxxxxxxxx
Subject: Re: [cdt-dev] Confusion again.
I know when my program parses my C++ src, it came to my function:
private static int visit(IIndex index, ICPPASTFunctionDeclarator cppFunctionDeclarator) {
        display("Visiting ICPPASTFunctionDeclarator: " + cppFunctionDeclarator.getRawSignature());
        //display(cppName.getBinding().getName());
        IBinding b = CPPVisitor.createBinding(cppFunctionDeclarator.getName());
        if (b != null)
            processFuncName(index, b);
        else {
            display("failed to find IBinding");
        }
        return PROCESS_CONTINUE;
    }
[cid:b54bb5c2-64d7-478f-b883-35d44a5e5d17]
However processFuncName() prompts "non IFunction":
private static void processFuncName(IIndex index, IBinding b) {
        try {
                    if (b instanceof IFunction) {
                        outputReferences(index, b);
                    } else if (b instanceof IProblemBinding) {
                        display("IProblemBinding");
                    } else if (b instanceof ICPPUnknownBinding) {
                        display("ICPPUnknownBinding");
                    }  else {
                        display("non IFunction");
                    }
        } catch (CoreException e) {
            log.error(e.getMessage());
        }
    }
Where did it go wrong?
Thanks.
________________________________
From: Ming Cheng
Sent: Monday, March 2, 2020 10:32 AM
To: cdt-dev@xxxxxxxxxxx <cdt-dev@xxxxxxxxxxx>
Subject: Confusion again.
My C++ source code:
void initPluginAgentMsgCopy(PFO_PluginAgent& );
class CPlImplMsgCopy : public QFIXFLEX_NMSP::CPluginImplBase<CPlImplMsgCopy>
{
public:
    CPlImplMsgCopy() : m_pMgr(NULL), m_bDoRecovery(false)
    {
    }
    ~CPlImplMsgCopy()
    {
        if (NULL != m_pMgr)
        {
            delete m_pMgr;
            m_pMgr = NULL;
        }
    }
    static const std::string& name()
    {
        static const std::string s_name("MSGCOPY");
        return s_name;
    }
}
My Java processing code:
private static void processFuncName(IIndex index, IASTName funcName) {
        // find bindings for name
        try {
            index.acquireReadLock();
            IBinding binding = funcName.resolveBinding();
            if (binding != null) {
                display(binding.getName());
                IIndexBinding[] bindings= index.findBindings(binding.getName().toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
                display("bindings=" + bindings.length);
                for (IIndexBinding b : bindings) {
                    if (binding instanceof IFunction) {
                        outputReferences(index, binding);
                    } else {
                        display("non IFunction");
                    }
                }
            }
        } catch (CoreException e) {
            log.error(e.getMessage());
        } catch (InterruptedException e) {
            log.error(e.getMessage());
        } finally {
            index.releaseReadLock();
        }
    }
initPluginAgentMsgCopy() will come to outputReferences() but CPlImplMsgCopy() /name().
display("bindings=" + bindings.length); does show these 3 (initPluginAgentMsgCopy() /CPlImplMsgCopy() /name() binding size are 1.
Thanks.
