예제 #1
0
ItemReaderResult ItemReader::internalReadFile(const QString &filePath)
{
    ASTCacheValue &cacheValue = (*m_astCache)[filePath];
    if (cacheValue.isValid()) {
        if (Q_UNLIKELY(cacheValue.isProcessing()))
            throw ErrorInfo(Tr::tr("Loop detected when importing '%1'.").arg(filePath));
    } else {
        QFile file(filePath);
        if (Q_UNLIKELY(!file.open(QFile::ReadOnly)))
            throw ErrorInfo(Tr::tr("Cannot open '%1'.").arg(filePath));

        m_filesRead.insert(filePath);
        const QString code = QTextStream(&file).readAll();
        QbsQmlJS::Lexer lexer(cacheValue.engine());
        lexer.setCode(code, 1);
        QbsQmlJS::Parser parser(cacheValue.engine());

        file.close();
        if (!parser.parse()) {
            QList<QbsQmlJS::DiagnosticMessage> parserMessages = parser.diagnosticMessages();
            if (Q_UNLIKELY(!parserMessages.isEmpty())) {
                ErrorInfo err;
                foreach (const QbsQmlJS::DiagnosticMessage &msg, parserMessages)
                    err.append(msg.message, toCodeLocation(filePath, msg.loc));
                throw err;
            }
        }
예제 #2
0
void ClangCompilationDatabaseGenerator::generate()
{
    for (const Project &theProject : project().projects.values()) {
        QJsonArray database;
        const ProjectData projectData = theProject.projectData();
        const QString buildDir = projectData.buildDirectory();

        for (const ProductData &productData : projectData.allProducts()) {
            for (const GroupData &groupData : productData.groups()) {
                for (const ArtifactData &sourceArtifact : groupData.allSourceArtifacts()) {
                    if (!hasValidInputFileTag(sourceArtifact.fileTags()))
                        continue;

                    const QString filePath = sourceArtifact.filePath();
                    ErrorInfo errorInfo;
                    const RuleCommandList rules = theProject.ruleCommands(productData, filePath,
                                                                       QStringLiteral("obj"),
                                                                       &errorInfo);

                    if (errorInfo.hasError())
                        throw errorInfo;

                    for (const RuleCommand &rule : rules) {
                        if (rule.type() != RuleCommand::ProcessCommandType)
                            continue;
                        database.append(createEntry(filePath, buildDir, rule));
                    }
                }
            }
        }

        writeProjectDatabase(QDir(buildDir).filePath(DefaultDatabaseFileName), database);
    }
}
예제 #3
0
cpix_Error * CreateError(cpix_ErrorType    errorType,
                         const char      * msg)
{
    ErrorInfo
        * errorInfo = NULL;

    try
        {
            errorInfo = AcquireErrorInfo();
            errorInfo->setInfo(errorType,
                               msg);
        }
    catch (...)
        {
            logMsg(CPIX_LL_ERROR,
                   "!!! Failed to create error struct for type %d ...",
                   errorType);
            logMsg(CPIX_LL_ERROR,
                   "!!! ... (cont'd) msg: %s. Will report CPIX error.",
                   msg == NULL ? "(null)" : msg);

            errorInfo = & SyncErrorInfo;
            errorInfo->setInfo(ET_CPIX_EXC);
        }

    cpix_Error
        * rv = static_cast<cpix_Error*>(errorInfo);

    return rv;
}
예제 #4
0
void InternalSetupProjectJob::start()
{
    BuildGraphLocker *bgLocker = m_existingProject ? m_existingProject->bgLocker : 0;
    try {
        const ErrorInfo err = m_parameters.expandBuildConfiguration();
        if (err.hasError())
            throw err;
        const QString projectId = TopLevelProject::deriveId(m_parameters.topLevelProfile(),
                m_parameters.finalBuildConfigurationTree());
        const QString buildDir
                = TopLevelProject::deriveBuildDirectory(m_parameters.buildRoot(), projectId);
        if (m_existingProject && m_existingProject->buildDirectory != buildDir)
            m_existingProject.clear();
        if (!m_existingProject) {
            bgLocker = new BuildGraphLocker(ProjectBuildData::deriveBuildGraphFilePath(buildDir,
                                                                                       projectId),
                                            logger());
        }
        execute();
        if (m_existingProject)
            m_existingProject->bgLocker = 0;
        m_newProject->bgLocker = bgLocker;
    } catch (const ErrorInfo &error) {
        m_newProject.clear();
        setError(error);
        if (!m_existingProject)
            delete bgLocker;
    }
    emit finished(this);
}
예제 #5
0
파일: error.cpp 프로젝트: rstone/ld28
ErrorInfo ErrorInfoCreate(ErrorInfo::Error error, EModule module, int line) {
    ErrorInfo info;
    info.set_error(error);
    info.set_module(module);
    info.set_line(line);
    return info;
}
예제 #6
0
void testCallingSequence1(uima::util::ConsoleUI& rclConsole, const TCHAR* cpszConfigFilename)
/* ----------------------------------------------------------------------- */
{
    ErrorInfo errInfo;
    uima::TextAnalysisEngine* pEngine = TextAnalysisEngine::createTextAnalysisEngine(cpszConfigFilename, errInfo);

    failIfNotTrue(errInfo.getErrorId() == UIMA_ERR_NONE);
    failIfNotTrue(pEngine != NULL);
    CAS* cas = pEngine->newCAS();
    failIfNotTrue(cas != NULL);

    uima::UnicodeStringRef us(UnicodeString("a"));
//   UnicodeStringRef uRef(us);
    rclConsole.formatHeader(_TEXT("testing Engine CallingSequence1"));

    cas->setDocumentText(us.getBuffer(), us.length());
    cas->getDocumentAnnotation().setLanguage("en");
    failIfNotTrue(pEngine->process(*cas) == UIMA_ERR_NONE);
    failIfNotTrue(cas->reset() == UIMA_ERR_NONE);
    failIfNotTrue(pEngine->destroy() == UIMA_ERR_NONE);

    cas->setDocumentText(us.getBuffer(), us.length());
    cas->getDocumentAnnotation().setLanguage("en");
    failIfNotTrue(pEngine->process(*cas) == UIMA_ERR_ENGINE_INVALID_CALLING_SEQUENCE);

    TyErrorId deInitRC = pEngine->destroy();
    rclConsole.format("RC of deInit()", deInitRC);
    failIfNotTrue(deInitRC == UIMA_ERR_ENGINE_INVALID_CALLING_SEQUENCE);
    rclConsole.formatBool(_TEXT("testing Engine CallingSequence1 OK"),
                          true);  //lint !e944: argument for operator '!' always evaluates to False
    delete cas;
    delete pEngine;
}  //lint !e715: cpszConfigFilename (line 99) not referenced
예제 #7
0
static void PNGWarning(png_structp png, png_const_charp message)
{
	ErrorInfo *errorInfo = png_get_error_ptr(png);
	if (errorInfo != NULL && errorInfo->errorCB != NULL)
	{
		errorInfo->errorCB(message, false, errorInfo->errorCBContext);
	}
}
예제 #8
0
void CommandLineFrontend::dumpNodesTree()
{
    QFile stdOut;
    stdOut.open(stdout, QIODevice::WriteOnly);
    const ErrorInfo error = m_projects.front().dumpNodesTree(stdOut, productsToUse()
                                                             .value(m_projects.front()));
    if (error.hasError())
        throw error;
}
예제 #9
0
/* Similar routine as above just with error info objects instead of err-ids.
This routine just does a hard program exit for any failure!
*/
static void CheckError(ErrorInfo const &errInfo) {
    if (errInfo.getErrorId() != UIMA_ERR_NONE) {
        cerr << endl << "   *** ExampleApplication - Error info:" << endl
        << "Error string  : "
        << AnalysisEngine::getErrorIdAsCString(errInfo.getErrorId())
        << errInfo << endl;                      /* (errInfo starts with a newline) */
        exit((int) errInfo.getErrorId());
    }
}
예제 #10
0
void CommandLineFrontend::generate()
{
    QBS_CHECK(!!m_generator);
    const ErrorInfo error = m_generator->generate(m_projects,
                                                  m_parser.buildConfigurations(),
                                                  m_parser.installOptions(QString()),
                                                  m_parser.settingsDir(),
                                                  ConsoleLogger::instance(m_settings));
    if (error.hasError())
        throw error;
}
예제 #11
0
void testDescriptorNotFound(uima::util::ConsoleUI& rclConsole)
/* ----------------------------------------------------------------------- */
{
    rclConsole.info("testDescriptorNotFound start.");
    uima::TextAnalysisEngine* pEngine;

    ErrorInfo errInfo;
    pEngine = TextAnalysisEngine::createTextAnalysisEngine(_TEXT("DUMMY"), errInfo);
    failIfNotTrue(errInfo.getErrorId() == UIMA_ERR_RESOURCE_CORRUPTED);
    failIfNotTrue(pEngine == NULL);
    rclConsole.info("testDescriptorNotFound finished.");
}
예제 #12
0
void testMissingResMgr(uima::util::ConsoleUI& rclConsole)
/* ----------------------------------------------------------------------- */
{
    rclConsole.info("testMissingResMgr start.");
    uima::TextAnalysisEngine* pEngine;

    failIfNotTrue(!ResourceManager::hasInstance());
    ErrorInfo errInfo;
    pEngine = TextAnalysisEngine::createTextAnalysisEngine(_TEXT("DUMMY"), errInfo);
    failIfNotTrue(!ResourceManager::hasInstance());
    failIfNotTrue(errInfo.getErrorId() == UIMA_ERR_ENGINE_RESMGR_NOT_INITIALIZED);
    failIfNotTrue(pEngine == NULL);
    rclConsole.info("testMissingResMgr finished.");
}
예제 #13
0
            static
            typename ErrorInfo::value_type *
            get( exception const & x )
                {
                if( exception_detail::error_info_container * c=x.data_.get() )
                    if( shared_ptr<exception_detail::error_info_base> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
                        {
#ifndef BOOST_NO_RTTI
                        BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo *>(eib.get()) );
#endif
                        ErrorInfo * w = static_cast<ErrorInfo *>(eib.get());
                        return &w->value();
                        }
                return 0;
                }
예제 #14
0
// [R]
void CompileSession::RecordErrorInfo(const ErrorInfo& templ) {
  DEBUG_FORMAT("%s", templ);

  static bool fContinue = false;
  if (!fContinue && ::IsDebuggerPresent()) {
    __debugbreak();
    fContinue = true;
  }

  if (error_set_.Contains(&templ)) {
    return;
  }

  auto& error_info = templ.Clone();

  error_set_.Add(&error_info);

  auto ref = errors_.GetLast();
  while (ref) {
    if (error_info.source_info() > ref->source_info()) {
      break;
    }
    ref = ref->GetPrev();
  }
  if (ref) {
    errors_.InsertAfter(&error_info, ref);
  } else {
    errors_.Prepend(&error_info);
  }
}
예제 #15
0
void testCallingSequence2(uima::util::ConsoleUI& rclConsole, const TCHAR* cpszConfigFilename)
/* ----------------------------------------------------------------------- */
{
    rclConsole.formatHeader(_TEXT("testing Engine CallingSequence2"));
    {

        uima::TextAnalysisEngine* pEngine = NULL;
        ErrorInfo errInfo;

        pEngine = TextAnalysisEngine::createTextAnalysisEngine(cpszConfigFilename, errInfo);
        failIfNotTrue(errInfo.getErrorId() == UIMA_ERR_NONE);
        failIfNotTrue(pEngine != NULL);
        delete pEngine;
    }
    rclConsole.formatBool(_TEXT("testing Engine CallingSequence2 OK"),
                          true);  //lint !e944: argument for operator '!' always evaluates to False
}
void WiFiAppNetworkConfiguratorView::handleChangePost()
{
  WiFiAppNetworkConfigurator::SwitchWiFiPayload payload;
  payload.ssid = ws()->arg("ssid");
  payload.password = ws()->arg("password");
  
  ErrorInfo ex;
  m_configurator->validateSwitchWiFiPayload(payload, ex);
  
  if (!ex) {
    ws()->send(200, "text/html", renderWaitForStatusView());
    delay(100);
    m_configurator->switchWiFi(payload, ex);
  } else {
    ws()->send(400, "text/plain", ex.message());
  }
}
예제 #17
0
void testCallingSequence3(uima::util::ConsoleUI& rclConsole, const TCHAR* cpszConfigFilename)
/* ----------------------------------------------------------------------- */
{
    uima::TextAnalysisEngine* pEngine = NULL;
    uima::Language clLanguage(MAIN_DEFAULT_LANG);
    const char* clCCSID = MAIN_DEFAULT_CCSID_STR;
    TyErrorId utErrorId;

    UnicodeString us("a");
    UnicodeStringRef uref(us);

    rclConsole.formatHeader(_TEXT("testing Engine CallingSequence3"));

    ErrorInfo errInfo;
    pEngine = TextAnalysisEngine::createTextAnalysisEngine(cpszConfigFilename, errInfo);
    failIfNotTrue(errInfo.getErrorId() == UIMA_ERR_NONE);
    failIfNotTrue(pEngine != NULL);
    CAS* cas = pEngine->newCAS();
    failIfNotTrue(cas != NULL);

    /* test for NULL ptrs */

    UnicodeStringRef uref2(NULL);
    cas->setDocumentText(uref2.getBuffer(), uref2.length());
    cas->getDocumentAnnotation().setLanguage("en");
    failIfNotTrue(pEngine->process(*cas) == UIMA_ERR_NONE);
    failIfNotTrue(cas->reset() == UIMA_ERR_NONE);


    /* test for subsequent processes */
    cas->setDocumentText(uref2.getBuffer(), uref2.length());
    cas->getDocumentAnnotation().setLanguage("en");

    failIfNotTrue(pEngine->process(*cas) == UIMA_ERR_NONE);

    failIfNotTrue(pEngine->process(*cas) == UIMA_ERR_NONE);


    utErrorId = pEngine->destroy();
    failIfNotTrue(utErrorId == UIMA_ERR_NONE);
    delete cas;
    delete pEngine;
    rclConsole.formatBool(_TEXT("testing Engine CallingSequence3 OK"),
                          true);  //lint !e944: argument for operator '!' always evaluates to False
}
예제 #18
0
bool testLoadData(uima::util::ConsoleUI& rclConsole,
                  const char* cpszCCSID,
                  const TCHAR* cpszConfigFilename,
                  const TCHAR* cpszLanguage,
                  size_t uiNumOfIterations)
/* ----------------------------------------------------------------------- */
{
    uima::TextAnalysisEngine* pEngine = NULL;
    ///uima::CCSID                 clCCSID(lCCSID);
    uima::Language clLanguage(cpszLanguage);
    ErrorInfo errInfo;

    rclConsole.formatHeader(_TEXT("testing UIMA Engine loading a document"));
    /* init engine */
    pEngine = TextAnalysisEngine::createTextAnalysisEngine(cpszConfigFilename, errInfo);
    uimaToolHandleErrorId(rclConsole, errInfo.getErrorId(), errInfo.asString().c_str(), _TEXT("uima::Engine::init()"),
                          gs_lExpectedInitRc);
    if (gs_lExpectedInitRc != UIMA_ERR_NONE) {
        return (false);
    }
    failIfNotTrue(pEngine != NULL);

    for (size_t ui = 0; ui < uiNumOfIterations; ui++) {
        const TCHAR* cpszInpTerm = 0;

        /* read in file */
        if (uiNumOfIterations > 1) {
            rclConsole.newline();
            rclConsole.format(_TEXT("Iteration"), (unsigned long) ui);
        }
        if (rclConsole.hasArgString(_TEXT("inpterm"), cpszInpTerm)) {
            testProcessTerm(rclConsole, *pEngine, cpszCCSID, clLanguage, cpszInpTerm);
        } else {
            testProcessDocu(rclConsole, *pEngine, cpszCCSID, clLanguage);
        }
    }
    TyErrorId utErrorId = pEngine->destroy();
    uimaToolHandleErrorId(rclConsole, utErrorId, pEngine->getAnnotatorContext().getLogger().getLastErrorAsCStr(),
                          _TEXT("uima::Engine::deInit"));
    delete pEngine;
    return (true);
}
static QVariantMap expandedBuildConfigurationInternal(const QString &settingsBaseDir,
        const QString &profileName, const QString &buildVariant)
{
    Settings settings(settingsBaseDir);
    QVariantMap buildConfig;

    // (1) Values from profile, if given.
    if (!profileName.isEmpty()) {
        ErrorInfo err;
        const Profile profile(profileName, &settings);
        const QStringList profileKeys = profile.allKeys(Profile::KeySelectionRecursive, &err);
        if (err.hasError())
            throw err;
        if (profileKeys.isEmpty())
            throw ErrorInfo(Internal::Tr::tr("Unknown or empty profile '%1'.").arg(profileName));
        foreach (const QString &profileKey, profileKeys) {
            buildConfig.insert(profileKey, profile.value(profileKey, QVariant(), &err));
            if (err.hasError())
                throw err;
        }
예제 #20
0
파일: error.hpp 프로젝트: detunized/oglplus
	void Cleanup(void) const
	{
#if !OGLPLUS_ERROR_INFO_NO_OBJECT_DESC
		if(_info._purge_archive != 0)
			_info._purge_archive();
		for(auto i=_propagation.begin(),e=_propagation.end();i!=e;++i)
		{
			if(i->_purge_archive != 0)
				i->_purge_archive();
		}
#endif
	}
예제 #21
0
void testCasMultiplier(uima::util::ConsoleUI& rclConsole)
/* ----------------------------------------------------------------------- */
{
    rclConsole.info("testCasMultiplier start.");
    uima::TextAnalysisEngine* pEngine;

    ErrorInfo errInfo;

    UnicodeString filename("SimpleTextSegmenter.xml");
    UnicodeString fn = ResourceManager::resolveFilename(filename, filename);
    pEngine = TextAnalysisEngine::createTextAnalysisEngine(UnicodeStringRef(fn).asUTF8().c_str(), errInfo);
    failIfNotTrue(errInfo.getErrorId() == UIMA_ERR_NONE);
    failIfNotTrue(pEngine != NULL);


    //test operational properties settings
    failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->getOutputsNewCASes() == true);
    failIfNotTrue(pEngine->getAnalysisEngineMetaData().getOperationalProperties()->getModifiesCas() == false);
    failIfNotTrue(
            pEngine->getAnalysisEngineMetaData().getOperationalProperties()->isMultipleDeploymentAllowed() == true);


    CAS* cas = pEngine->newCAS();
    cas->setDocumentText(
            UnicodeString("This is the first sentence. This is the second sentence. This is the third sentence."));

    CASIterator iter = pEngine->processAndOutputNewCASes(*cas);
    int num = 0;
    while (iter.hasNext()) {
        num++;
        CAS& seg = iter.next();
        failIfNotTrue(seg.getDocumentText().length() > 0);
        pEngine->getAnnotatorContext().releaseCAS(seg);
    }
    failIfNotTrue(num == 3);
    delete pEngine;
    delete cas;
    rclConsole.info("testCasMultiplier finished.");
}
예제 #22
0
void TestTools::testBuildConfigMerging()
{
    Settings settings((QString()));
    TemporaryProfile tp(QLatin1String("tst_tools_profile"), &settings);
    Profile profile = tp.p;
    profile.setValue(QLatin1String("topLevelKey"), QLatin1String("topLevelValue"));
    profile.setValue(QLatin1String("qbs.toolchain"), QLatin1String("gcc"));
    profile.setValue(QLatin1String("qbs.architecture"),
                     QLatin1String("Jean-Claude Pillemann"));
    profile.setValue(QLatin1String("cpp.treatWarningsAsErrors"), true);
    QVariantMap overrideMap;
    overrideMap.insert(QLatin1String("qbs.toolchain"), QLatin1String("clang"));
    overrideMap.insert(QLatin1String("qbs.installRoot"), QLatin1String("/blubb"));
    SetupProjectParameters params;
    params.setTopLevelProfile(profile.name());
    params.setConfigurationName(QLatin1String("debug"));
    params.setOverriddenValues(overrideMap);
    const ErrorInfo error = params.expandBuildConfiguration();
    QVERIFY2(!error.hasError(), qPrintable(error.toString()));
    const QVariantMap finalMap = params.finalBuildConfigurationTree();
    QCOMPARE(finalMap.count(), 3);
    QCOMPARE(finalMap.value(QLatin1String("topLevelKey")).toString(),
             QString::fromLatin1("topLevelValue"));
    const QVariantMap finalQbsMap = finalMap.value(QLatin1String("qbs")).toMap();
    QCOMPARE(finalQbsMap.count(), 4);
    QCOMPARE(finalQbsMap.value(QLatin1String("toolchain")).toString(),
             QString::fromLatin1("clang"));
    QCOMPARE(finalQbsMap.value(QLatin1String("configurationName")).toString(),
             QString::fromLatin1("debug"));
    QCOMPARE(finalQbsMap.value(QLatin1String("architecture")).toString(),
             QString::fromLatin1("Jean-Claude Pillemann"));
    QCOMPARE(finalQbsMap.value(QLatin1String("installRoot")).toString(), QLatin1String("/blubb"));
    const QVariantMap finalCppMap = finalMap.value(QLatin1String("cpp")).toMap();
    QCOMPARE(finalCppMap.count(), 1);
    QCOMPARE(finalCppMap.value(QLatin1String("treatWarningsAsErrors")).toBool(), true);
}
예제 #23
0
void TestTools::testProfiles()
{
    TemporaryProfile tpp("parent", m_settings);
    Profile parentProfile = tpp.p;
    TemporaryProfile tpc("child", m_settings);
    Profile childProfile = tpc.p;
    parentProfile.removeBaseProfile();
    parentProfile.remove("testKey");
    QCOMPARE(parentProfile.value("testKey", "none").toString(), QLatin1String("none"));
    parentProfile.setValue("testKey", "testValue");
    QCOMPARE(parentProfile.value("testKey").toString(), QLatin1String("testValue"));

    childProfile.remove("testKey");
    childProfile.removeBaseProfile();
    QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("none"));
    childProfile.setBaseProfile("parent");
    QCOMPARE(childProfile.value("testKey").toString(), QLatin1String("testValue"));

    // Change base profile and check if the inherited value also changes.
    TemporaryProfile tpf("foo", m_settings);
    Profile fooProfile = tpf.p;
    fooProfile.setValue("testKey", "gnampf");
    childProfile.setBaseProfile("foo");
    QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("gnampf"));

    ErrorInfo errorInfo;
    childProfile.setBaseProfile("SmurfAlongWithMe");
    childProfile.value("blubb", QString(), &errorInfo);
    QVERIFY(errorInfo.hasError());

    errorInfo.clear();
    childProfile.setBaseProfile("parent");
    parentProfile.setBaseProfile("child");
    QVERIFY(!childProfile.value("blubb", QString(), &errorInfo).isValid());
    QVERIFY(errorInfo.hasError());

    QVERIFY(!childProfile.allKeys(Profile::KeySelectionNonRecursive).isEmpty());

    errorInfo.clear();
    QVERIFY(childProfile.allKeys(Profile::KeySelectionRecursive, &errorInfo).isEmpty());
    QVERIFY(errorInfo.hasError());
}
예제 #24
0
void CompileSession::RecordWarningInfo(const ErrorInfo& error_info) {
  warnings_.Append(&error_info.Clone());
}
예제 #25
0
static void makeTypeError(const ErrorInfo &error, QScriptValue &v)
{
    v = v.engine()->currentContext()->throwError(QScriptContext::TypeError,
                                                 error.toString());
}
예제 #26
0
void CompileSession::AddErrorInfo(const ErrorInfo& error_info) {
  RecordErrorInfo(error_info.Clone());
}
예제 #27
0
void TestUpgradeEnv::exceptionHandler(ErrorInfo error)
{
   qDebug() << error.toString();
}