/** Report an operator lookup error. */ private Symbol reportErrorIfNeeded(DiagnosticPosition pos, Tag tag, Type... args) { if (Stream.of(args).noneMatch(Type::isErroneous)) { Name opName = operatorName(tag); JCDiagnostic.Error opError = (args.length) == 1 ? Errors.OperatorCantBeApplied(opName, args[0]) : Errors.OperatorCantBeApplied1(opName, args[0], args[1]); log.error(pos, opError); } return syms.noSymbol; }
private List<ModuleSymbol> scanModulePath(ModuleSymbol toFind) { ListBuffer<ModuleSymbol> results = new ListBuffer<>(); Map<Name, Location> namesInSet = new HashMap<>(); while (moduleLocationIterator.hasNext()) { Set<Location> locns = (moduleLocationIterator.next()); namesInSet.clear(); for (Location l : locns) { try { Name n = names.fromString(fileManager.inferModuleName(l)); if (namesInSet.put(n, l) == null) { ModuleSymbol msym = syms.enterModule(n); if (msym.sourceLocation != null || msym.classLocation != null) { // module has already been found, so ignore this instance continue; } if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) { msym.sourceLocation = l; if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { msym.classLocation = fileManager.getLocationForModule( StandardLocation.CLASS_OUTPUT, msym.name.toString()); } } else { msym.classLocation = l; } if (moduleLocationIterator.outer == StandardLocation.SYSTEM_MODULES || moduleLocationIterator.outer == StandardLocation.UPGRADE_MODULE_PATH) { msym.flags_field |= Flags.SYSTEM_MODULE; } if (toFind == msym || toFind == null) { // Note: cannot return msym directly, because we must finish // processing this set first results.add(msym); } } else { log.error( Errors.DuplicateModuleOnPath(getDescription(moduleLocationIterator.outer), n)); } } catch (IOException e) { // skip location for now? log error? } } if (toFind != null && results.nonEmpty()) return results.toList(); } return results.toList(); }