Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Ccontents of wrong file displayed in CContentOutlinePage, if two editors with the same name are opened

Hi Sadik,

The place to enter a bug is https://bugs.eclipse.org/bugs/enter_bug.cgi?product=CDT

Off the top of my head I thought that the parent of a translation until was its container, e.g. the folder or the project. If the files are in different folders, but in the same project then there should be an intermediary folder between the file and project which shows as different. Hopefully you can provide a reproducible test case with standard CDT so that others can reproduce the problem.

Thanks,
Jonah


~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com


On Wed, 10 Apr 2019 at 09:22, Sadik <soezoguz@xxxxxxxxxxx> wrote:
Hi Jonah,

You're absolutely right. It has nothing to do with the hash, it has to be
the equals method.

This is the code from CElement's equals method. The key point here is the
check for lhs.getParent() == rhs.getParent()

    public static boolean equals(ICElement lhs, ICElement rhs) {
                if (lhs == rhs) {
                        return true;
                }
                if (lhs.getElementType() != rhs.getElementType()) {
                        return false;
                }
                String lhsName = lhs.getElementName();
                String rhsName = rhs.getElementName();
                if (lhsName == null || rhsName == null || lhsName.length() !=
rhsName.length() || !lhsName.equals(rhsName)) {
                        return false;
                }

                if (lhs instanceof ISourceReference && rhs instanceof ISourceReference) {
                        if (((ISourceReference) lhs).getIndex() != ((ISourceReference)
rhs).getIndex()) {
                                return false;
                        }
                }

                ICElement lhsParent = lhs.getParent();
                ICElement rhsParent = rhs.getParent();
                if (lhsParent == rhsParent) {
                        return true;
                }

                return lhsParent != null && lhsParent.equals(rhsParent);
        }


Since lhs.getElementName() and rhs.getElementName() return the same name,
the method doesn't return false before checking the parent. The parent
folder is different for the two files, but getParent() returns the project,
which is the same. I can reproduce that this problem doesn't occur with two
files from different projects.

I would expect a check like lhs.getResource().equals(rhs.getResource())
before the parent check.

Jonah, sadly I don't know how and where to fill a bug report.



--
Sent from: http://eclipse.1072660.n5.nabble.com/Eclipse-CDT-Development-f46177.html
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev

Back to the top