Skip to content

Commit

Permalink
TEIIDDES-1701 fixed file collector visit() logic to properly check an…
Browse files Browse the repository at this point in the history
…d return correct results
  • Loading branch information
blafond committed May 3, 2013
1 parent 98d2503 commit 64680e4
Showing 1 changed file with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static IFile findIResourceByPath( final IPath workspacePath ) {
FileResourceCollectorVisitor visitor = new FileResourceCollectorVisitor() {
@Override
public boolean visit(IResource resource) {
if (! resource.exists() || resource.getType() != IResource.FILE || getResourceFilter().accept(resource))
if (! resource.exists() || resource.getType() != IResource.FILE || !getResourceFilter().accept(resource))
return false;

IPath path = resource.getFullPath();
Expand Down Expand Up @@ -278,20 +278,35 @@ public boolean visit(IResource resource) {
public static IFile findIResourceByUUID( final String stringifiedUuid ) {
if (CoreStringUtil.isEmpty(stringifiedUuid) || !stringifiedUuid.startsWith(UUID.PROTOCOL) || getWorkspace() == null) return null;

// Visitor should only look for XMI files with UUIDs in them
// If the resource is a FOLDER or PROJECT we should return TRUE so that the resource's children will get visited
// If we encounter a XSD or XMI file, we return false so the visitation stops at the model

FileResourceCollectorVisitor visitor = new FileResourceCollectorVisitor() {
@Override
public boolean visit(IResource resource) {
if (! resource.exists() || resource.getType() != IResource.FILE || getResourceFilter().accept(resource))
return false;
if (resource.exists() && resource.getType() == IResource.FILE && getResourceFilter().accept(resource) ) {
if (ModelUtil.isXsdFile(resource))
return false;

if( ModelUtil.isModelFile(resource, true)) {
XMIHeader header = ModelUtil.getXmiHeader(resource);
if (header != null && stringifiedUuid.equals(header.getUUID())) {
addResource(resource);
}
return false;
}

if (ModelUtil.isXsdFile(resource))
if( resource.getType() == IResource.PROJECT ||
resource.getType() == IResource.FOLDER ) {
return true;
}

return false;

XMIHeader header = ModelUtil.getXmiHeader(resource);
if (header != null && stringifiedUuid.equals(header.getUUID()))
addResource(resource);

}

return true;

}
};

Expand Down

0 comments on commit 64680e4

Please sign in to comment.