Permalink
Browse files

get full cabal description, use scion for library dependencies

  • Loading branch information...
1 parent 67eca47 commit 67ccc4ec1ee44b95d39ad1d2e72c3d3334fd0fb9 @JPMoresmau committed Jun 25, 2010
Showing with 2,302 additions and 65 deletions.
  1. +2 −2 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/cabalmodel/CabalModelTest.java
  2. +114 −0 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/cabalmodel/Haskell0.json
  3. +101 −0 ...efp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/cabalmodel/JSONDescriptionHelperTest.java
  4. +1,533 −0 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/cabalmodel/scion.json
  5. +96 −0 ...sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/cabalmodel/JSONDescriptionHelper.java
  6. +1 −0 .../INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/launch/HaskellLaunchDelegate.java
  7. +7 −0 net.sf.eclipsefp.haskell.scion.client.test/.classpath
  8. +28 −0 net.sf.eclipsefp.haskell.scion.client.test/.project
  9. +8 −0 net.sf.eclipsefp.haskell.scion.client.test/.settings/org.eclipse.jdt.core.prefs
  10. +11 −0 net.sf.eclipsefp.haskell.scion.client.test/META-INF/MANIFEST.MF
  11. BIN ....haskell.scion.client.test/bin/net/sf/eclipsefp/haskell/scion/client/test/JSONNavigatorTest.class
  12. +4 −0 net.sf.eclipsefp.haskell.scion.client.test/build.properties
  13. +62 −0 ...p.haskell.scion.client.test/src/net/sf/eclipsefp/haskell/scion/client/test/JSONNavigatorTest.java
  14. +53 −0 net.sf.eclipsefp.haskell.scion.client/lib/org/json/JSONNavigator.java
  15. +29 −0 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/ScionInstance.java
  16. +60 −0 ...l.scion.client/src/net/sf/eclipsefp/haskell/scion/internal/commands/CabalDependenciesCommand.java
  17. +44 −0 ....haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/internal/commands/ParseCabalCommand.java
  18. +56 −0 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/types/CabalPackage.java
  19. +2 −2 net.sf.eclipsefp.haskell.ui/plugin.xml
  20. +40 −20 ...skell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/model/GHCPackageConf.java
  21. +51 −41 ...ell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/model/GHCSystemLibrary.java
@@ -26,9 +26,9 @@ protected void setUp() throws Exception {
}
- private String getContent(final String fileName){
+ public static String getContent(final String fileName){
try {
- InputStream is=getClass().getResourceAsStream( fileName);
+ InputStream is=CabalModelTest.class.getResourceAsStream( fileName);
ByteArrayOutputStream baos=new ByteArrayOutputStream();
int c=-1;
while ((c=is.read())!=-1){
@@ -0,0 +1,114 @@
+{
+ "condExecutables": [[
+ "main",
+ {
+ "condTreeComponents": [],
+ "condTreeConstraints": [
+ [
+ "containers",
+ "AnyVersion"
+ ],
+ [
+ "base",
+ "AnyVersion"
+ ]
+ ],
+ "condTreeData": {
+ "buildInfo": {
+ "buildTools": [],
+ "buildable": true,
+ "cSources": [],
+ "ccOptions": [],
+ "cppOptions": [],
+ "customFieldsBI": [],
+ "extensions": [],
+ "extraLibDirs": [],
+ "extraLibs": [],
+ "frameworks": [],
+ "ghcProfOptions": [],
+ "ghcSharedOptions": [],
+ "hsSourceDirs": ["src"],
+ "includeDirs": [],
+ "includes": [],
+ "installIncludes": [],
+ "ldOptions": [],
+ "options": [[
+ "GHC",
+ ["-Wall"]
+ ]],
+ "otherModules": [
+ ["Test1"],
+ [
+ "Folder1",
+ "Module2"
+ ],
+ ["Test"],
+ [
+ "Folder1",
+ "Module1"
+ ],
+ ["Lit"],
+ ["QSort"]
+ ],
+ "pkgconfigDepends": [],
+ "targetBuildDepends": []
+ },
+ "exeName": "",
+ "modulePath": "Main.hs"
+ }
+ }
+ ]],
+ "condLibrary": "Nothing",
+ "genPackageFlags": [],
+ "packageDescription": {
+ "author": "Angela Author",
+ "bugReports": "",
+ "buildDepends": [],
+ "buildType": {"Just": "Simple"},
+ "category": "TEST",
+ "copyright": "Copyright2004",
+ "customFieldsPD": [],
+ "dataDir": "",
+ "dataFiles": [],
+ "descCabalVersion": {"UnionVersionRanges": [
+ {"ThisVersion": {
+ "versionBranch": [
+ 1,
+ 2
+ ],
+ "versionTags": []
+ }},
+ {"LaterVersion": {
+ "versionBranch": [
+ 1,
+ 2
+ ],
+ "versionTags": []
+ }}
+ ]},
+ "description": "Scion is a Haskell library that aims to implement those parts of a\nHaskell IDE which are independent of a particular front-end. Scion\nis based on the GHC API and Cabal. It provides both a Haskell API and\na server for non-Haskell clients such as Emacs and Vim.\n\nSee the homepage<http://code.google.com/p/scion-lib> and the README\n<http://github.com/nominolo/scion/blob/master/README.markdown> for\nmore information.\n\nAnother line.",
+ "executables": [],
+ "extraSrcFiles": [],
+ "extraTmpFiles": [],
+ "homepage": "http://eclipsefp.sourceforge.net",
+ "library": "Nothing",
+ "license": "BSD3",
+ "licenseFile": "LICENSE",
+ "maintainer": "JP2",
+ "package": {
+ "pkgName": "Haskell0",
+ "pkgVersion": {
+ "versionBranch": [
+ 0,
+ 2
+ ],
+ "versionTags": []
+ }
+ },
+ "pkgUrl": "",
+ "sourceRepos": [],
+ "stability": "",
+ "synopsis": "Package with library and two programs",
+ "testedWith": []
+ }
+}
@@ -0,0 +1,101 @@
+package net.sf.eclipsefp.haskell.core.cabalmodel;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.util.Set;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
+
+/**
+ *
+ * @author JP Moresmau
+ *
+ */
+public class JSONDescriptionHelperTest {
+
+ private JSONObject getJSONObject(final String file)throws IOException,JSONException{
+ return new JSONObject(CabalModelTest.getContent( file ));
+
+ }
+
+ @Test
+ public void executablesHaskell0() throws IOException,JSONException{
+ JSONObject obj=getJSONObject("Haskell0.json");
+ Set<String> exe=JSONDescriptionHelper.getNames(JSONDescriptionHelper.getExecutables( obj ));
+ assertNotNull(exe);
+ assertEquals(1,exe.size());
+ assertTrue(exe.contains("main"));
+ }
+
+ @Test
+ public void executablesScion() throws IOException,JSONException{
+ JSONObject obj=getJSONObject("scion.json");
+ Set<String> exe=JSONDescriptionHelper.getNames(JSONDescriptionHelper.getExecutables( obj ));
+ assertNotNull(exe);
+ assertEquals(1,exe.size());
+ assertTrue(exe.contains("scion-server"));
+ }
+
+ @Test
+ public void libraryHaskell0() throws IOException,JSONException{
+ JSONObject obj=getJSONObject("Haskell0.json");
+ assertFalse(JSONDescriptionHelper.hasLibrary( obj ));
+
+ }
+
+ @Test
+ public void libraryScion() throws IOException,JSONException{
+ JSONObject obj=getJSONObject("scion.json");
+ assertTrue(JSONDescriptionHelper.hasLibrary( obj ));
+ }
+
+ @Test
+ public void dependenciesHaskell0() throws IOException,JSONException{
+ JSONObject obj=getJSONObject("Haskell0.json");
+ Set<String> deps=JSONDescriptionHelper.getNames(JSONDescriptionHelper.getDependencies( obj ));
+ assertNotNull(deps);
+ assertEquals(2,deps.size());
+ assertTrue(deps.contains(("containers")));
+ assertTrue(deps.contains(("base")));
+ deps=JSONDescriptionHelper.getNames(JSONDescriptionHelper.getDependencies( JSONDescriptionHelper.getExecutables( obj ).get( 0 )));
+ assertNotNull(deps);
+ assertEquals(2,deps.size());
+ assertTrue(deps.contains(("containers")));
+ assertTrue(deps.contains(("base")));
+ }
+
+ @Test
+ public void dependenciesScion() throws IOException,JSONException{
+ JSONObject obj=getJSONObject("scion.json");
+ Set<String> deps=JSONDescriptionHelper.getNames(JSONDescriptionHelper.getDependencies( obj ));
+ assertNotNull(deps);
+ assertEquals(23,deps.size());
+ assertTrue(deps.contains(("containers")));
+ assertTrue(deps.contains(("base")));
+ assertTrue(deps.contains(("directory")));
+ assertTrue(deps.contains(("filepath")));
+ assertTrue(deps.contains(("ghc")));
+ assertTrue(deps.contains(("ghc-paths")));
+ assertTrue(deps.contains(("ghc-syb")));
+ assertTrue(deps.contains(("ghc-syb-utils")));
+ assertTrue(deps.contains(("hslogger")));
+ assertTrue(deps.contains(("json")));
+ assertTrue(deps.contains(("multiset")));
+ assertTrue(deps.contains(("time")));
+ assertTrue(deps.contains(("uniplate")));
+ assertTrue(deps.contains(("list-tries")));
+ assertTrue(deps.contains(("binary")));
+ assertTrue(deps.contains(("array")));
+ assertTrue(deps.contains(("old-time")));
+ assertTrue(deps.contains(("Cabal")));
+ assertTrue(deps.contains(("bytestring")));
+ assertTrue(deps.contains(("network")));
+ assertTrue(deps.contains(("network-bytestring")));
+ assertTrue(deps.contains(("utf8-string")));
+ assertTrue(deps.contains(("QuickCheck")));
+
+ }
+}
Oops, something went wrong.

0 comments on commit 67ccc4e

Please sign in to comment.