| 1137 | } |
| 1138 | |
| 1139 | ProgramPtr reportPrerequisitesErrors ( |
| 1140 | string fileName, |
| 1141 | vector<MissingRecord> & missing, |
| 1142 | vector<RequireRecord> & circular, |
| 1143 | vector<RequireRecord> & notAllowed, |
| 1144 | vector<ModuleInfo> & req, |
| 1145 | das_set<string> & dependencies, |
| 1146 | das_hash_map<string, NamelessModuleReq> & namelessReq, |
| 1147 | vector<NamelessMismatch> & namelessMismatches, |
| 1148 | const FileAccessPtr & access, |
| 1149 | ModuleGroup & libGroup, |
| 1150 | CodeOfPolicies policies ) { |
| 1151 | TextWriter tw; |
| 1152 | req.clear(); |
| 1153 | missing.clear(); |
| 1154 | circular.clear(); |
| 1155 | dependencies.clear(); |
| 1156 | notAllowed.clear(); |
| 1157 | vector<FileInfo *> chain; |
| 1158 | string modName; |
| 1159 | getPrerequisits(fileName, access, modName, req, missing, circular, notAllowed, chain, dependencies, namelessReq, namelessMismatches, libGroup, &tw, 1, false); |
| 1160 | auto program = make_smart<Program>(); |
| 1161 | program->policies = policies; |
| 1162 | program->thisModuleGroup = &libGroup; |
| 1163 | TextWriter err; |
| 1164 | LineInfo at; |
| 1165 | bool first = true; |
| 1166 | for ( auto & mis : missing ) { |
| 1167 | if ( first && !mis.chain.empty() ) { |
| 1168 | at.fileInfo = mis.chain.back(); |
| 1169 | at.line = at.last_line = mis.line; |
| 1170 | at.column = 8; |
| 1171 | at.last_column = at.column + (int)mis.name.size(); |
| 1172 | first = false; |
| 1173 | } |
| 1174 | switch ( mis.hintType ) { |
| 1175 | case MissingHint::FileNotFound: { |
| 1176 | err << "missing prerequisite '" << mis.name << "'; file not found\n"; |
| 1177 | break; |
| 1178 | } |
| 1179 | case MissingHint::WrongModuleName: { |
| 1180 | err << "wrong module name '" << mis.hintName << "'; did you mean '" << mis.hintName2 << "'?\n"; |
| 1181 | break; |
| 1182 | } |
| 1183 | case MissingHint::ModuleInfoNotFound: { |
| 1184 | err << "missing prerequisite '" << mis.name << "'; module info not found"; |
| 1185 | if ( !mis.hintName.empty() ) { |
| 1186 | err << ", did you mean '" << mis.hintName << "'?\n"; |
| 1187 | } else { |
| 1188 | err << "'\n"; |
| 1189 | } |
| 1190 | break; |
| 1191 | } |
| 1192 | case MissingHint::DuplicateModule: { |
| 1193 | err << "several modules with the same name '" << mis.name << "'\nnamely '" << mis.hintName << "' and '" << mis.hintName2 << "'\n"; |
| 1194 | break; |
| 1195 | } |
| 1196 | default: { |
no test coverage detected