コード例 #1
0
 public static IRegion getValueRegion(IDOMAttr attr) {
   int regOffset = attr.getValueRegionStartOffset();
   int regLength = attr.getValueRegionText().length();
   String attValue = attr.getValueRegionText();
   if (StringUtils.isQuoted(attValue)) {
     regOffset++;
     regLength -= 2;
   }
   return new Region(regOffset, regLength);
 }
コード例 #2
0
  @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);
  }
コード例 #3
0
 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);
         }
       }
     }
   }
 }
コード例 #4
0
ファイル: JSNode.java プロジェクト: orlandoibm/tern.java
 public String getName() {
   return StringUtils.isEmpty(file) ? name : file;
 }
コード例 #5
0
ファイル: JSNode.java プロジェクト: orlandoibm/tern.java
 public boolean isFile() {
   return !StringUtils.isEmpty(file);
 }