Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2016-01-07 18:03:58 +0000
committerJeff Johnston2016-01-07 19:36:35 +0000
commit61d1c4672203a9be17221b3dff79c68665a15a66 (patch)
treedbd21abcbcc4e78fb414f62f18b5c7e274de7386
parent35df9b23068fd118d5d39556745ff3ffb7b438b6 (diff)
downloadorg.eclipse.linuxtools-61d1c4672203a9be17221b3dff79c68665a15a66.tar.gz
org.eclipse.linuxtools-61d1c4672203a9be17221b3dff79c68665a15a66.tar.xz
org.eclipse.linuxtools-61d1c4672203a9be17221b3dff79c68665a15a66.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>
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java18
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 38143aac0d..68e0d8c594 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) {

Back to the top