/**
  * Sets the definition of the ActionScript class to which this node refers, from its fully
  * qualified name.
  *
  * @param project An {@code ICompilerProject}, used for finding the class by name.
  * @param qname A fully qualified class name.
  */
 void setClassReference(FlexProject project, String qname) {
   ASProjectScope projectScope = (ASProjectScope) project.getScope();
   IDefinition definition = projectScope.findDefinitionByName(qname);
   // TODO This method is getting called by MXML tree-building
   // with an interface qname if there is a property whose type is an interface.
   // Until databinding is implemented, we need to protect against this.
   if (definition instanceof IClassDefinition)
     setClassReference(project, (IClassDefinition) definition);
 }
Ejemplo n.º 2
0
  private final Collection<ICompilationUnit> collectAssociatedCompilationUnits(
      IFileSpecification file) {
    String filename = file.getPath();
    Collection<WeakReference<ICompilationUnit>> relatedCompilationUnits =
        pathToCompilationUnitMapping.getVisibleAndInvisible(filename);

    // relatedCompilationUnits should never be null, but it is OK for it to be empty, as
    // we can be null, if someone passes us in a arbitrary file which has no compilation
    // units associated with it.
    assert (relatedCompilationUnits != null) : "relatedCompilationUnits should never be null";

    // add any compilation units which include the file, as they need to be recompiled also
    Collection<WeakReference<ICompilationUnit>> includingCompilationUnits =
        includeFilesToIncludingCompilationUnitMapping.get(filename);

    Collection<WeakReference<ICompilationUnit>> allRelatedCompilationUnits =
        new HashSet<WeakReference<ICompilationUnit>>();
    allRelatedCompilationUnits.addAll(relatedCompilationUnits);
    allRelatedCompilationUnits.addAll(includingCompilationUnits);

    HashSet<ICompilationUnit> associatedCompilationUnits = new HashSet<ICompilationUnit>();
    for (WeakReference<ICompilationUnit> relatedCURef : allRelatedCompilationUnits) {
      ICompilationUnit relatedCU = relatedCURef.get();
      if (relatedCU != null) {
        associatedCompilationUnits.add(relatedCU);
      }
    }

    final Set<ICompilationUnit> associatedCompilationUnitsAccountingForConflictingDefinitions =
        ASProjectScope.getCompilationUnitsWithConflictingDefinitions(
            this, associatedCompilationUnits);

    return associatedCompilationUnitsAccountingForConflictingDefinitions;
  }