Ejemplo n.º 1
0
  // FIXME: redo this method better: https://github.com/ceylon/ceylon-spec/issues/90
  @Override
  public Declaration getDirectMember(String name, List<ProducedType> signature) {
    synchronized (modelLoader) {
      String pkgName = getQualifiedNameString();

      // we need its package ready first
      modelLoader.loadPackage(pkgName, false);

      // make sure we iterate over a copy of compiledDeclarations, to avoid lazy loading to modify
      // it and
      // cause a ConcurrentModificationException:
      // https://github.com/ceylon/ceylon-compiler/issues/399
      Declaration d = lookupMember(copy(compiledDeclarations), name, signature, false);
      if (d != null) {
        return d;
      }

      String className = getQualifiedName(pkgName, name);
      ClassMirror classSymbol = modelLoader.lookupClassMirror(className);

      // only get it from the classpath if we're not compiling it, unless
      // it happens to be a java source
      if (classSymbol != null
          && (!classSymbol.isLoadedFromSource() || classSymbol.isJavaSource())) {
        d = modelLoader.convertToDeclaration(className, DeclarationType.VALUE);
        if (d instanceof Class) {
          if (((Class) d).isAbstraction()) {
            // make sure we iterate over a copy of compiledDeclarations, to avoid lazy loading to
            // modify it and
            // cause a ConcurrentModificationException:
            // https://github.com/ceylon/ceylon-compiler/issues/399
            return lookupMember(copy(compiledDeclarations), name, signature, false);
          }
        }
        return d;
      }
      return getDirectMemberFromSource(name);
    }
  }