src/edu/clemson/resolve/jetbrains/psi/impl/ResReference.java
/** Searches the specifications of any facility modules accessible from {@code file}. */
Searches the specifications of any facility modules accessible from  file.
Searches the specifications of any facility modules accessible from file .
public static boolean processFacilityImports(@NotNull ResFile file,
                                                 @NotNull ResScopeProcessor processor,
                                                 @NotNull ResolveState state) {
        List<ResModuleIdentifierSpec> usesItems = file.getModuleIdentifierSpecs();
        Set<ResModuleIdentifier> v = new LinkedHashSet<>();
        List<String> superModuleRefs = new ArrayList<>();
        if (file.getEnclosedModule() != null) {
            for (ResReferenceExp e : file.getEnclosedModule().getModuleHeaderReferences()) {
                superModuleRefs.add(e.getText());
            }
        }
        List<ResModuleDecl> superModuleDecls = new ArrayList<>();
        for (ResModuleIdentifierSpec usesItem : usesItems) {
            PsiElement resolve = usesItem.getModuleIdentifier().resolve();
            if (resolve != null && resolve instanceof ResFile) {
                ResModuleDecl moduleDecl = ((ResFile) resolve).getEnclosedModule();
                if (moduleDecl == null) continue;
                if (superModuleRefs.contains(usesItem.getName())) {
                    superModuleDecls.add(moduleDecl);
                }
                for (ResFacilityDecl f : moduleDecl.getFacilities()) {
                    if (f.getModuleIdentifierList().size() != 2) continue;
                    v.add(f.getModuleIdentifierList().get(0));
                }
            }
        }
        for (ResModuleDecl superModule : superModuleDecls) {
            for (ResModuleIdentifierSpec usesItem : superModule.getModuleIdentifierSpecs()) {
                PsiElement resolve = usesItem.getModuleIdentifier().resolve();
                if (resolve != null && resolve instanceof ResFile) {
                    ResModuleDecl moduleDecl = ((ResFile) resolve).getEnclosedModule();
                    if (moduleDecl == null) continue;
                    for (ResFacilityDecl f : moduleDecl.getFacilities()) {
                        if (f.getModuleIdentifierList().size() != 2) continue;
                        v.add(f.getModuleIdentifierList().get(0));
                    }
                }
            }
        }
        for (ResFacilityDecl facility : file.getFacilities()) {
            if (facility.getModuleIdentifierList().size() != 2) continue;
            v.add(facility.getModuleIdentifierList().get(0));
            if (!facility.getExtensionPairingList().isEmpty()) {
                for (ResExtensionPairing ext : facility.getExtensionPairingList()) {
                    if (ext.getModuleIdentifierList().size() == 2) {
                        v.add(ext.getModuleIdentifierList().get(0));
                    }
                }
            }
        }
        for (ResModuleIdentifier identifier : v) {
            PsiElement resolve = identifier.resolve();
            if (resolve == null || !(resolve instanceof ResFile)) continue;
            if (!processModuleLevelEntities((ResFile) resolve, processor, state, true)) return false;
        }
        return true;
    }
public static boolean processFacilityImports ( @ NotNull ResFile file , @ NotNull ResScopeProcessor processor , @ NotNull ResolveState state ) { List < ResModuleIdentifierSpec > usesItems = file . getModuleIdentifierSpecs ( ) ; Set < ResModuleIdentifier > v = new LinkedHashSet < > ( ) ; List < String > superModuleRefs = new ArrayList < > ( ) ; if ( file . getEnclosedModule ( ) != null ) { for ( ResReferenceExp e : file . getEnclosedModule ( ) . getModuleHeaderReferences ( ) ) { superModuleRefs . add ( e . getText ( ) ) ; } } List < ResModuleDecl > superModuleDecls = new ArrayList < > ( ) ; for ( ResModuleIdentifierSpec usesItem : usesItems ) { PsiElement resolve = usesItem . getModuleIdentifier ( ) . resolve ( ) ; if ( resolve != null && resolve instanceof ResFile ) { ResModuleDecl moduleDecl = ( ( ResFile ) resolve ) . getEnclosedModule ( ) ; if ( moduleDecl == null ) continue ; if ( superModuleRefs . contains ( usesItem . getName ( ) ) ) { superModuleDecls . add ( moduleDecl ) ; } for ( ResFacilityDecl f : moduleDecl . getFacilities ( ) ) { if ( f . getModuleIdentifierList ( ) . size ( ) != 2 ) continue ; v . add ( f . getModuleIdentifierList ( ) . get ( 0 ) ) ; } } } for ( ResModuleDecl superModule : superModuleDecls ) { for ( ResModuleIdentifierSpec usesItem : superModule . getModuleIdentifierSpecs ( ) ) { PsiElement resolve = usesItem . getModuleIdentifier ( ) . resolve ( ) ; if ( resolve != null && resolve instanceof ResFile ) { ResModuleDecl moduleDecl = ( ( ResFile ) resolve ) . getEnclosedModule ( ) ; if ( moduleDecl == null ) continue ; for ( ResFacilityDecl f : moduleDecl . getFacilities ( ) ) { if ( f . getModuleIdentifierList ( ) . size ( ) != 2 ) continue ; v . add ( f . getModuleIdentifierList ( ) . get ( 0 ) ) ; } } } } for ( ResFacilityDecl facility : file . getFacilities ( ) ) { if ( facility . getModuleIdentifierList ( ) . size ( ) != 2 ) continue ; v . add ( facility . getModuleIdentifierList ( ) . get ( 0 ) ) ; if ( ! facility . getExtensionPairingList ( ) . isEmpty ( ) ) { for ( ResExtensionPairing ext : facility . getExtensionPairingList ( ) ) { if ( ext . getModuleIdentifierList ( ) . size ( ) == 2 ) { v . add ( ext . getModuleIdentifierList ( ) . get ( 0 ) ) ; } } } } for ( ResModuleIdentifier identifier : v ) { PsiElement resolve = identifier . resolve ( ) ; if ( resolve == null || ! ( resolve instanceof ResFile ) ) continue ; if ( ! processModuleLevelEntities ( ( ResFile ) resolve , processor , state , true ) ) return false ; } return true ; }
Searches the specifications of any facility modules accessible from {@code file}.
Searches the specifications of any facility modules accessible from { @code file } .
//get ModuleIdentifiers from facilities visible through any named uses items (remember: uses items currently //explicitly include header modules) //resolve into the ModuleIdentifiers named in each of the super modules' useslists looking for facilities. //now get ModuleIdentifiers from any local facilities //skip this facility if for some reason it's malformed: i.e. missing the spec or impl; //size 2 implies both are present and accounted for //resolve through their specifications