private void updateSentFiles(TernDoc doc) {
   for (JsonValue value : doc.getFiles()) {
     if (value instanceof TernFile) {
       TernFile file = (TernFile) value;
       if (file.isType(FileType.full)) {
         String contents = file.getText();
         if (StringUtils.isEmpty(contents)) {
           // treat file with empty contents as removed
           sentFiles.remove(file.getName());
         } else {
           sentFiles.put(file.getName(), contents);
         }
       }
     }
   }
 }
  @Override
  public void startElement(String uri, String localName, String name, Attributes attributes)
      throws SAXException {
    if ("module".equals(name)) {
      String moduleName = attributes.getValue("name");
      module = new Module(moduleName);
    } else if ("directive".equals(name)) {

      String directiveName = attributes.getValue("name");
      String url = attributes.getValue("url");
      AngularType directiveType = AngularType.get(attributes.getValue("type"));
      // tags name
      List<String> tagsName = new ArrayList<String>();
      String tags = attributes.getValue("tags");
      if (!StringUtils.isEmpty(tags)) {
        String[] names = tags.split(",");
        String tagName = null;

        for (int i = 0; i < names.length; i++) {
          tagName = names[i].trim();
          if (tagName.length() > 0) {
            tagsName.add(tagName);
          }
        }
      }
      // restrict
      String restrict = attributes.getValue("restrict");
      // value : required|optional|none
      DirectiveValue directiveValue = DirectiveValue.get(attributes.getValue("value"));
      this.directive =
          new Directive(
              directiveName, directiveType, url, tagsName, restrict, directiveValue, module, false);
    } else if ("description".equals(name)) {
      this.description = new StringBuilder();
    } else if ("parameter".equals(name)) {
      String parameterName = attributes.getValue("name");
      boolean optional = StringUtils.asBoolean(attributes.getValue("optional"), false);
      this.directiveParameter = new DirectiveParameter(parameterName, optional, directive);
      directive.addParameter(directiveParameter);
      this.description = new StringBuilder();
    }
    super.startElement(uri, localName, name, attributes);
  }
Exemple #3
0
 public String getName() {
   return StringUtils.isEmpty(file) ? name : file;
 }
Exemple #4
0
 public boolean isFile() {
   return !StringUtils.isEmpty(file);
 }