diff options
author | Jeff Johnston | 2016-01-07 18:03:58 +0000 |
---|---|---|
committer | Jeff Johnston | 2016-01-07 21:00:27 +0000 |
commit | 485410785e8facfcd7f80a4ac76d0263f0ad771e (patch) | |
tree | 8e1bb80cf6377d8d892ea274f671c5a3c55a715b /gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java | |
parent | d451684f655211bbeb99ffa749ddf034463a19dc (diff) | |
download | org.eclipse.linuxtools-485410785e8facfcd7f80a4ac76d0263f0ad771e.tar.gz org.eclipse.linuxtools-485410785e8facfcd7f80a4ac76d0263f0ad771e.tar.xz org.eclipse.linuxtools-485410785e8facfcd7f80a4ac76d0263f0ad771e.zip |
Bug 447554 - GCov not working for files linked from file system
- fix Visitor logic in GcovAnnotationModel.java so that it handles
the case where the link is actually a parent directory
- when the link is a parent directory, a file does not have the
isLinked attribute set on and so we must figure this out by
saving the last linked directory we found
Change-Id: I2a9dfeb769d4314ec0b905994c5a53216c3ea8a0
Reviewed-on: https://git.eclipse.org/r/63763
Tested-by: Hudson CI
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
Reviewed-on: https://git.eclipse.org/r/63775
Diffstat (limited to 'gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java')
-rw-r--r-- | gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java index c151327cd5..1211f8b58a 100644 --- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java +++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java @@ -174,6 +174,8 @@ public final class GcovAnnotationModel implements IAnnotationModel { final private ICElement element; private boolean keepSearching = true; private boolean found; + private IResource resource; + private String lastLinkPath; public FindLinkedResourceVisitor(ICElement element) { this.element = element; @@ -183,10 +185,21 @@ public final class GcovAnnotationModel implements IAnnotationModel { return found; } + public IResource getResource() { + return resource; + } + @Override public boolean visit(IResourceProxy proxy) { - if (proxy.isLinked() && proxy.requestResource().getLocationURI().equals(element.getLocationURI())) { + // To correctly find a file in a linked directory, we cannot just look at the isLinked() attribute + // which is not set for the file but is set for one of its parent directories. So, we keep track + // of linked directories and use them to determine if we should bother getting the resource to compare with. + if (proxy.isLinked()) { + lastLinkPath = proxy.requestFullPath().toString(); + } + if (lastLinkPath != null && proxy.requestFullPath().toString().startsWith(lastLinkPath) && proxy.requestResource().getLocationURI().equals(element.getLocationURI())) { found = true; + resource = proxy.requestResource(); keepSearching = false; } return keepSearching; @@ -197,6 +210,7 @@ public final class GcovAnnotationModel implements IAnnotationModel { private SourceFile findSourceCoverageForElement(ICElement element) { List<SourceFile> sources = new ArrayList<> (); ICProject cProject = element.getCProject(); + IResource elementResource = element.getResource(); IPath target = GcovAnnotationModelTracker.getInstance().getBinaryPath(cProject.getProject()); if (target == null) { // We cannot find a target for this element, using it's project. @@ -214,6 +228,7 @@ public final class GcovAnnotationModel implements IAnnotationModel { if (visitor.foundElement()) { target = GcovAnnotationModelTracker.getInstance().getBinaryPath(proj); cProject = CoreModel.getDefault().getCModel().getCProject(proj.getName()); + elementResource = visitor.getResource(); break; } } catch (CoreException e) { @@ -236,7 +251,6 @@ public final class GcovAnnotationModel implements IAnnotationModel { } catch (IOException|CoreException|InterruptedException e) { } - IResource elementResource = element.getResource(); if (elementResource != null) { IPath elementLocation = elementResource.getLocation(); if (elementLocation != null) { |