public CfgInfo(Configuration cfg, final String title) {
   this.cfg = cfg;
   this.title = title;
   bundledInjections.addAll(cfg.getDefaultInjections());
   originalInjections =
       new ArrayList<BaseInjection>(
           ContainerUtil.concat(
               InjectorUtils.getActiveInjectionSupportIds(),
               new Function<String, Collection<? extends BaseInjection>>() {
                 public Collection<? extends BaseInjection> fun(final String s) {
                   List<BaseInjection> injections =
                       CfgInfo.this.cfg instanceof Configuration.Prj
                           ? ((Configuration.Prj) CfgInfo.this.cfg).getOwnInjections(s)
                           : CfgInfo.this.cfg.getInjections(s);
                   return ContainerUtil.findAll(
                       injections,
                       new Condition<BaseInjection>() {
                         public boolean value(final BaseInjection injection) {
                           String id = injection.getInjectedLanguageId();
                           return InjectedLanguage.findLanguageById(id) != null
                               || ReferenceInjector.findById(id) != null;
                         }
                       });
                 }
               }));
   sortInjections(originalInjections);
   reset();
 }
  public void init(PsiElement element) {
    myFile = (XmlFile) element.getContainingFile();

    if (element instanceof XmlTag) {
      myTag = (XmlTag) element;
    } else {
      final XmlDocument document = myFile.getDocument();

      if (document != null) {
        myTag = document.getRootTag();
      }
    }

    if (myTag != null) {
      myTargetNamespace = myTag.getAttributeValue("targetNamespace");
    }

    final THashSet<PsiFile> dependenciesSet = new THashSet<PsiFile>();
    final Set<PsiFile> redefineProcessingSet = myRedefinedDescriptorsInProcessing.get();
    if (redefineProcessingSet != null) {
      dependenciesSet.addAll(redefineProcessingSet);
    }
    collectDependencies(myTag, myFile, dependenciesSet);
    dependencies = ArrayUtil.toObjectArray(dependenciesSet);
  }
 @Override
 public Set<String> getAllLookupStrings() {
   final Set<String> strings = getDelegate().getAllLookupStrings();
   final THashSet<String> result = new THashSet<String>();
   result.addAll(strings);
   result.add(getLookupString());
   return result;
 }
 static {
   final THashSet<String> set = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
   set.addAll(Arrays.asList("jpg", "jpeg", "gif", "bmp", "png"));
   DEFAULT_FILTERING_EXCLUDED_EXTENSIONS = Collections.unmodifiableSet(set);
 }
예제 #5
0
  private List<JavaFileObject> findInside(
      Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean lookForFile)
      throws IOException {
    Iterable<? extends File> path = getLocation(location);
    if (path == null) return Collections.emptyList();

    String subdirectory = packageName.replace('.', '/');
    List<JavaFileObject> results = null;

    for (File directory : path) {
      VirtualFile dir = LocalFileSystem.getInstance().findFileByIoFile(directory);
      if (dir == null) continue;
      if (!dir.isDirectory()) {
        dir = JarFileSystem.getInstance().getJarRootForLocalFile(dir);
        if (dir == null) continue;
      }
      VirtualFile virtualFile =
          StringUtil.isEmptyOrSpaces(subdirectory) ? dir : dir.findFileByRelativePath(subdirectory);
      if (virtualFile == null) continue;

      VirtualFile[] children;
      if (lookForFile) {
        if (!virtualFile.isDirectory()) {
          children = new VirtualFile[] {virtualFile};
        } else continue;
      } else {
        children = virtualFile.getChildren();
      }
      for (VirtualFile child : children) {
        JavaFileObject.Kind kind = getKind("." + child.getExtension());
        if (kinds == null || kinds.contains(kind)) {
          if (results == null) results = new SmartList<JavaFileObject>();
          if (kind == JavaFileObject.Kind.SOURCE && child.getFileSystem() instanceof JarFileSystem)
            continue; // for some reasdon javac looks for java files inside jar

          // use VFS to read content inside .jar
          String childPath = child.getPath();
          JavaFileObject fileObject =
              !childPath.contains("!/")
                  ? new JavaIoFile(new File(childPath), kind, myEncoding)
                  : new JavaVirtualFile(child, kind);
          results.add(fileObject);
        }
      }
    }

    List<JavaFileObject> ret = results == null ? Collections.<JavaFileObject>emptyList() : results;

    if (LOG.isDebugEnabled()) {
      // for testing consistency
      Collection c = (Collection) myStandardFileManager.list(location, packageName, kinds, false);
      Collection<JavaFileObject> sup = new HashSet(c);
      assert sup.size() == c.size();
      assert new HashSet(c).equals(sup);

      THashSet<JavaFileObject> s =
          new THashSet<JavaFileObject>(
              new TObjectHashingStrategy<JavaFileObject>() {
                public int computeHashCode(JavaFileObject object) {
                  return object.getName().hashCode();
                }

                public boolean equals(JavaFileObject o1, JavaFileObject o2) {
                  return o1.getKind() == o2.getKind() && o1.toUri().equals(o2.toUri());
                }
              });
      s.addAll(ret);

      s.removeAll(sup);
      if (ret.size() != sup.size()) {
        assert false : "our implementation differs from javac'";
      }
    }

    return ret;
  }