felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r911023 - /felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
Date Wed, 17 Feb 2010 15:38:52 GMT
Author: dsavage
Date: Wed Feb 17 15:38:52 2010
New Revision: 911023

URL: http://svn.apache.org/viewvc?rev=911023&view=rev
Log:
Tidy up unused imports and implement hashCode algorithm

Modified:
    felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java

Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java?rev=911023&r1=911022&r2=911023&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
(original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
Wed Feb 17 15:38:52 2010
@@ -27,6 +27,7 @@
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.regex.Matcher;
 
 import org.apache.felix.sigil.config.BldFactory;
 import org.apache.felix.sigil.config.IBldProject;
@@ -48,6 +49,7 @@
 import org.apache.felix.sigil.repository.ResolutionConfig;
 import org.apache.felix.sigil.repository.ResolutionException;
 import org.apache.felix.sigil.repository.ResolutionMonitorAdapter;
+import org.apache.felix.sigil.utils.GlobCompiler;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -65,6 +67,7 @@
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaElement;
 import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
 import org.eclipse.jdt.core.IPackageFragmentRoot;
 import org.eclipse.jdt.core.IParent;
 import org.eclipse.jdt.core.JavaCore;
@@ -327,8 +330,12 @@
     @Override
     public int hashCode()
     {
-        // TODO Auto-generated method stub
-        return super.hashCode();
+        int hc = getSymbolicName().hashCode();
+        if ( getVersion() != null ) {
+            hc *= getVersion().hashCode();
+        }
+        hc *= 7;
+        return hc;
     }
 
 
@@ -570,9 +577,22 @@
     }
 
 
-    public boolean isInBundleClasspath( IPackageFragmentRoot root ) throws JavaModelException
+    public boolean isInBundleClasspath( IPackageFragment root ) throws JavaModelException
     {
-        String enc = getJavaModel().encodeClasspathEntry( root.getRawClasspathEntry() );
-        return getBundle().getClasspathEntrys().contains( enc.trim() );
+        if ( getBundle().getClasspathEntrys().isEmpty() ) {
+            for ( String p : getBundle().getPackages() ) {
+                SigilCore.log("Checking " + p + "->" + root.getElementName() );
+                Matcher m = GlobCompiler.compile(p).matcher(root.getElementName());
+                if ( m.matches() ) {
+                    return true;
+                }
+            }
+            return false;
+        }
+        else {
+            IPackageFragmentRoot parent = (IPackageFragmentRoot) root.getParent();
+            String enc = getJavaModel().encodeClasspathEntry( parent.getRawClasspathEntry()
);
+            return getBundle().getClasspathEntrys().contains( enc.trim() );
+        }
     }
 }



Mime
View raw message