tdf#80731: Only check closing parenthesis when in IDE

This reinstates the fix by Pierre Lepage, which was reverted in
351dead74b, and makes sure it only
has effect when the compilation is started from IDE.

The idea is that the IDE is used primarily for development, and
that's a good opportunity to detect any error in the code. When
the code is compiled from outside of the IDE (like running an
extension), the error is tolerated to allow users run the legacy
code having this error. Hopefully this is enough for tdf#106529.

This re-uses comphelper's NoEnableJavaInteractionContext class,
which is converted into general-purpose SetFlagContext class to
avoid code duplication.

Change-Id: Ie290019cb190b8d1d590699ec13bd63eac478d09
Reviewed-on: https://gerrit.libreoffice.org/81616
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2019-10-28 18:59:57 +03:00
parent 7e7e97fc0b
commit d628258f27
7 changed files with 91 additions and 62 deletions

View File

@@ -22,6 +22,7 @@
#include <parser.hxx>
#include <basic/sbx.hxx>
#include <expr.hxx>
#include <uno/current_context.hxx>
SbiExpression::SbiExpression( SbiParser* p, SbiExprType t,
SbiExprMode eMode, const KeywordSymbolInfo* pKeywordSymbolInfo )
@@ -1033,6 +1034,21 @@ SbiExprListPtr SbiExprList::ParseParameters( SbiParser* pParser, bool bStandalon
{
if( ( pExprList->bBracket && eTok == RPAREN ) || SbiTokenizer::IsEoln( eTok ) )
{
// tdf#80731
if (SbiTokenizer::IsEoln(eTok) && pExprList->bBracket)
{
// tdf#106529: only fail here in strict mode (i.e. when compiled from IDE), and
// allow legacy code with missing closing parenthesis when started e.g. from
// extensions and event handlers
bool bCheckStrict = false;
if (auto xContext = css::uno::getCurrentContext())
xContext->getValueByName("BasicStrict") >>= bCheckStrict;
if (bCheckStrict)
{
pParser->Error(ERRCODE_BASIC_EXPECTED, RPAREN);
pExprList->bError = true;
}
}
break;
}
pParser->Error( pExprList->bBracket ? ERRCODE_BASIC_BAD_BRACKETS : ERRCODE_BASIC_EXPECTED, COMMA );