コード例 #1
0
ファイル: ApiContentsModel.java プロジェクト: nodrogttam/aura
  @SuppressWarnings("unchecked")
  public static synchronized void refreshSymbols() {
    Reader reader = null;
    try {
      try {

        reader = new InputStreamReader(resourceLoader.getResourceAsStream("jsdoc/symbolSet.json"));
        JsonStreamReader jsonReader = new JsonStreamReader(reader);
        jsonReader
            .disableLengthLimitsBecauseIAmStreamingAndMyMemoryUseIsNotProportionalToTheStreamLength();
        jsonReader.next();
        List<Object> readSymbols = jsonReader.getList();
        symbols = Maps.newTreeMap();
        List<Map<String, Object>> classes = new ArrayList<>();
        for (Object symbol : readSymbols) {
          Map<String, Object> map = (Map<String, Object>) symbol;
          if (!map.containsKey("access")) {
            map.put("access", "public");
          }
          if ("class".equalsIgnoreCase((String) map.get("kind"))) {
            classes.add(map);
            map.put("methods", new ArrayList<Map<String, Object>>());
            if (!map.containsKey("properties")) {
              map.put("properties", new ArrayList<Map<String, Object>>());
            }
          } else if ("function".equalsIgnoreCase((String) map.get("kind"))) {
            for (Map<String, Object> aClass : classes) {
              if (map.get("memberof") != null
                  && map.get("memberof").equals(aClass.get("longname"))) {
                ((List<Map<String, Object>>) aClass.get("methods")).add(map);
              }
            }
          } else if ("member".equalsIgnoreCase((String) map.get("kind"))
              && !map.containsKey("undocumented")
              && map.get("access").equals("public")) {
            for (Map<String, Object> aClass : classes) {
              if (map.get("memberof") != null
                  && map.get("memberof").equals(aClass.get("longname"))) {
                ((List<Map<String, Object>>) aClass.get("properties")).add(map);
              }
            }
          }
        }
        for (Object symbol : readSymbols) {
          Map<String, Object> map = (Map<String, Object>) symbol;
          List<Map<String, Object>> l = (List<Map<String, Object>>) map.get("methods");
          if (l != null) {
            Collections.sort(l, SYMBOL_COMPARATOR);
          }
          l = (List<Map<String, Object>>) map.get("properties");
          if (l != null) {
            Collections.sort(l, SYMBOL_COMPARATOR);
          }
          String name = (String) map.get("name");
          if (name != null && !map.containsKey("undocumented")) {
            symbols.put(name, map);
          }
        }
      } finally {
        if (reader != null) {
          reader.close();
        }
      }
    } catch (IOException e) {
      throw new AuraRuntimeException(e);
    }
  }