Пример #1
0
 /**
  * get the range including all the versions that have the same minor components
  *
  * @param s1 the precise version we want to get the full range for
  * @return the range ins Cabal syntax
  */
 public static String getMinorRange(final String s1) {
   String[] ss1 = s1.split("\\."); // $NON-NLS-1$
   if (ss1.length > 2) {
     try {
       return ">="
           + ss1[0]
           + "."
           + ss1[1]
           + "."
           + ss1[2]
           + " && <"
           + ss1[0]
           + "."
           + ss1[1]
           + "."
           + (Integer.parseInt(ss1[2]) + 1);
     } catch (NumberFormatException nfe) {
       HaskellCorePlugin.log(nfe);
     }
   } else if (ss1.length > 1) {
     try {
       return ">=" + ss1[0] + "." + ss1[1] + " && <" + ss1[0] + "." + ss1[1] + ".1";
     } catch (NumberFormatException nfe) {
       HaskellCorePlugin.log(nfe);
     }
   }
   return "";
 }
Пример #2
0
 protected String getMainFileContent(final Map<String, String> vars) {
   /** get module header * */
   vars.put(TemplateVariables.MODULE_NAME, "Main"); // $NON-NLS-1$
   vars.put(TemplateVariables.IMPORTS, ""); // $NON-NLS-1$
   String mod = HaskellCorePlugin.populateTemplate(ICorePreferenceNames.TEMPLATE_MODULE, vars);
   /** get content * */
   vars.put(TemplateVariables.MODULE, mod);
   return HaskellCorePlugin.populateTemplate(ICorePreferenceNames.TEMPLATE_MAIN, vars);
   // return "module Main where"+PlatformUtil.NL+PlatformUtil.NL+"main::IO()"+PlatformUtil.NL+"main
   // = undefined"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 }
Пример #3
0
 /**
  * get the range including all the versions that have the same major components or above
  *
  * @param s1 the precise version we want to get the full range for
  * @return the range ins Cabal syntax
  */
 public static String getFromMajorRange(final String s1) {
   String[] ss1 = s1.split("\\."); // $NON-NLS-1$
   if (ss1.length > 1) {
     try {
       return ">=" + ss1[0] + "." + ss1[1];
     } catch (NumberFormatException nfe) {
       HaskellCorePlugin.log(nfe);
     }
   }
   return "";
 }
Пример #4
0
 private void createFile(
     final IProject project, final IPath fileName, final String content, final IProgressMonitor mo)
     throws CoreException {
   try {
     IFile file = project.getFile(fileName);
     // file may exist if project is created from source version control
     if (!file.exists()) {
       InputStream is = new ByteArrayInputStream(content.getBytes(FileUtil.UTF8));
       IProgressMonitor monitor = new SubProgressMonitor(mo, 1);
       file.create(is, true, monitor);
       file.setCharset(FileUtil.UTF8, mo);
     }
   } catch (UnsupportedEncodingException uex) {
     HaskellCorePlugin.log(uex);
   }
 }
Пример #5
0
 public IEclipsePreferences getCorePrefs() {
   return getPrefsScope().getNode(HaskellCorePlugin.getPluginId());
 }
Пример #6
0
 public TestCaseWithPreferences(final String name) {
   super(name);
   addQualifier(HaskellCorePlugin.getPluginId());
 }
Пример #7
0
 public TestCaseWithPreferences() {
   addQualifier(HaskellCorePlugin.getPluginId());
 }
Пример #8
0
  protected PackageDescription getCabalFile(final Map<String, String> vars) {

    /*String s=CabalSyntax.FIELD_NAME.getCabalName()+":           " + name + NL //$NON-NLS-1$
           + CabalSyntax.FIELD_VERSION.getCabalName()+":        0.1 "+ NL + NL //$NON-NLS-1$
           ;
    if (isLibrary()){
      s+= CabalSyntax.SECTION_LIBRARY.getCabalName() + NL
        + "  "+ CabalSyntax.FIELD_HS_SOURCE_DIRS.getCabalName()+": src" + NL + NL//$NON-NLS-1$ //$NON-NLS-2$
      ;
    }

    if (isExecutable()){
        s+= CabalSyntax.SECTION_EXECUTABLE.getCabalName()+" " + name + NL //$NON-NLS-1$
           + "  "+ CabalSyntax.FIELD_HS_SOURCE_DIRS.getCabalName()+": src" + NL //$NON-NLS-1$ //$NON-NLS-2$
           + "  "+ CabalSyntax.FIELD_MAIN_IS.getCabalName()+": Main.hs"+ NL + NL; //$NON-NLS-1$ //$NON-NLS-2$
    }


    return s;*/
    /*PackageDescription pd=new PackageDescription( name );
    pd.getStanzas().get( 0 ).update( CabalSyntax.FIELD_VERSION, "0.1" ); //$NON-NLS-1$
    pd.getStanzas().get( 0 ).update( CabalSyntax.FIELD_CABAL_VERSION, ">= 1.2" ); //$NON-NLS-1$
    pd.getStanzas().get( 0 ).update( CabalSyntax.FIELD_BUILD_TYPE, "Simple" ); //$NON-NLS-1$
    String userName=PlatformUtil.getCurrentUser();
    if (userName!=null){
      pd.getStanzas().get( 0 ).update( CabalSyntax.FIELD_AUTHOR, userName );
    }

    if (isLibrary()){
      PackageDescriptionStanza pds=pd.addStanza( CabalSyntax.SECTION_LIBRARY, null );
      pds.update( CabalSyntax.FIELD_HS_SOURCE_DIRS, src );
      pds.update( CabalSyntax.FIELD_BUILD_DEPENDS, "base >= 4" ); //$NON-NLS-1$
      pds.update( CabalSyntax.FIELD_GHC_OPTIONS, "-Wall" ); //$NON-NLS-1$
    }

    if (isExecutable()){
      PackageDescriptionStanza pds=pd.addStanza( CabalSyntax.SECTION_EXECUTABLE, name );
      pds.update( CabalSyntax.FIELD_HS_SOURCE_DIRS, src );
      pds.update( CabalSyntax.FIELD_MAIN_IS, "Main.hs" ); //$NON-NLS-1$
      pds.update( CabalSyntax.FIELD_BUILD_DEPENDS, "base >= 4" ); //$NON-NLS-1$
      pds.update( CabalSyntax.FIELD_GHC_OPTIONS, "-Wall" ); //$NON-NLS-1$
    }*/

    String library = ""; // $NON-NLS-1$

    if (isLibrary()) {
      library =
          HaskellCorePlugin.populateTemplate(ICorePreferenceNames.TEMPLATE_CABAL_LIBRARY, vars);
    }
    vars.put(TemplateVariables.LIBRARY, library);

    String exe = ""; // $NON-NLS-1$
    if (isExecutable()) {
      exe = HaskellCorePlugin.populateTemplate(ICorePreferenceNames.TEMPLATE_CABAL_EXE, vars);
    }
    vars.put(TemplateVariables.EXECUTABLE, exe);

    String content = HaskellCorePlugin.populateTemplate(ICorePreferenceNames.TEMPLATE_CABAL, vars);
    PackageDescription pd = PackageDescriptionLoader.load(content);

    for (ICabalContributor c : CabalContributorManager.getContributors()) {
      c.contributeOnNewProject(pd);
    }

    return pd;
  }
Пример #9
0
 private String getSetupFileContent(final Map<String, String> vars) {
   // return "import Distribution.Simple"+PlatformUtil.NL+"main = defaultMain"+PlatformUtil.NL;
   // //$NON-NLS-1$ //$NON-NLS-2$
   return HaskellCorePlugin.populateTemplate(ICorePreferenceNames.TEMPLATE_CABAL_SETUP, vars);
 }