Esempio n. 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 "";
 }
Esempio n. 2
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 "";
 }
Esempio n. 3
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);
   }
 }