コード例 #1
0
  public List<? extends Task> scan(FileObject fo) {
    List<Task> violations = new ArrayList<Task>();

    if (!fo.hasExt("php") && !fo.hasExt("php5") && !fo.hasExt("phtml")) {
      return violations;
    }

    if (codeSnifferBinary.exists() == true) {
      CodeSnifferXmlLogResult rs = getCodeSniffer().execute(fo);

      for (int i = 0; i < rs.getCsErrors().size(); i++) {
        violations.add(
            Task.create(
                fo,
                "error",
                rs.getCsErrors().get(i).getShortDescription(),
                rs.getCsErrors().get(i).getLineNum() + 1));
      }
      for (int i = 0; i < rs.getCsWarnings().size(); i++) {
        violations.add(
            Task.create(
                fo,
                "warning",
                rs.getCsWarnings().get(i).getShortDescription(),
                rs.getCsWarnings().get(i).getLineNum() + 1));
      }
    }

    return violations;
  }
コード例 #2
0
 private void replaceXmlFiles() {
   List<FileObject> newFiles = new ArrayList<FileObject>();
   for (Iterator<FileObject> it = assetList.iterator(); it.hasNext(); ) {
     FileObject fileObject = it.next();
     if (fileObject.hasExt("xml")) {
       FileObject binaryFile = fileObject.getParent().getFileObject(fileObject.getName());
       if (binaryFile != null) {
         newFiles.add(binaryFile);
         it.remove();
       }
     }
   }
   for (Iterator<FileObject> it = newFiles.iterator(); it.hasNext(); ) {
     FileObject fileObject = it.next();
     assetList.add(fileObject);
   }
 }
コード例 #3
0
 private void loadPresets() {
   FileObject folder = FileUtil.getConfigFile("layoutpresets");
   if (folder != null) {
     for (FileObject child : folder.getChildren()) {
       if (child.isValid() && child.hasExt("xml")) {
         try {
           InputStream stream = child.getInputStream();
           DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
           DocumentBuilder builder = factory.newDocumentBuilder();
           Document document = builder.parse(stream);
           Preset preset = new Preset(document);
           addPreset(preset);
         } catch (Exception ex) {
           ex.printStackTrace();
         }
       }
     }
   }
 }