Untangle headers and namespaces in TestFileParser

This commit is contained in:
Alex Beregszaszi 2020-11-03 23:39:29 +00:00 committed by chriseth
parent 41f5036507
commit c002fcc39f
7 changed files with 10 additions and 22 deletions

View File

@ -36,11 +36,9 @@
using namespace solidity; using namespace solidity;
using namespace solidity::util; using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::frontend; using namespace solidity::frontend;
using namespace solidity::frontend::test; using namespace solidity::frontend::test;
using namespace std; using namespace std;
using namespace soltest;
bytes BytesUtils::alignLeft(bytes _bytes) bytes BytesUtils::alignLeft(bytes _bytes)
{ {

View File

@ -41,7 +41,6 @@ using namespace solidity::util;
using namespace solidity::langutil; using namespace solidity::langutil;
using namespace solidity::frontend::test; using namespace solidity::frontend::test;
using namespace std; using namespace std;
using namespace soltest;
namespace namespace
{ {

View File

@ -16,7 +16,6 @@
#include <libsolutil/AnsiColorized.h> #include <libsolutil/AnsiColorized.h>
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <libsolidity/ast/Types.h>
namespace solidity::frontend::test namespace solidity::frontend::test
{ {

View File

@ -34,11 +34,11 @@
#include <stdexcept> #include <stdexcept>
using namespace solidity; using namespace solidity;
using namespace solidity::langutil;
using namespace solidity::frontend; using namespace solidity::frontend;
using namespace solidity::frontend::test; using namespace solidity::frontend::test;
using namespace std; using namespace std;
using namespace soltest;
using Token = soltest::Token;
char TestFileParser::Scanner::peek() const noexcept char TestFileParser::Scanner::peek() const noexcept
{ {
@ -158,7 +158,7 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
return calls; return calls;
} }
bool TestFileParser::accept(soltest::Token _token, bool const _expect) bool TestFileParser::accept(Token _token, bool const _expect)
{ {
if (m_scanner.currentToken() != _token) if (m_scanner.currentToken() != _token)
return false; return false;
@ -167,7 +167,7 @@ bool TestFileParser::accept(soltest::Token _token, bool const _expect)
return true; return true;
} }
bool TestFileParser::expect(soltest::Token _token, bool const _advance) bool TestFileParser::expect(Token _token, bool const _advance)
{ {
if (m_scanner.currentToken() != _token || m_scanner.currentToken() == Token::Invalid) if (m_scanner.currentToken() != _token || m_scanner.currentToken() == Token::Invalid)
throw TestParserError( throw TestParserError(
@ -484,8 +484,6 @@ void TestFileParser::Scanner::readStream(istream& _stream)
void TestFileParser::Scanner::scanNextToken() void TestFileParser::Scanner::scanNextToken()
{ {
using namespace langutil;
// Make code coverage happy. // Make code coverage happy.
assert(formatToken(Token::NUM_TOKENS) == ""); assert(formatToken(Token::NUM_TOKENS) == "");
@ -554,12 +552,12 @@ void TestFileParser::Scanner::scanNextToken()
token = selectToken(Token::String, scanString()); token = selectToken(Token::String, scanString());
break; break;
default: default:
if (isIdentifierStart(current())) if (langutil::isIdentifierStart(current()))
{ {
TokenDesc detectedToken = detectKeyword(scanIdentifierOrKeyword()); TokenDesc detectedToken = detectKeyword(scanIdentifierOrKeyword());
token = selectToken(detectedToken.first, detectedToken.second); token = selectToken(detectedToken.first, detectedToken.second);
} }
else if (isDecimalDigit(current())) else if (langutil::isDecimalDigit(current()))
{ {
if (current() == '0' && peek() == 'x') if (current() == '0' && peek() == 'x')
{ {
@ -570,7 +568,7 @@ void TestFileParser::Scanner::scanNextToken()
else else
token = selectToken(Token::Number, scanDecimalNumber()); token = selectToken(Token::Number, scanDecimalNumber());
} }
else if (isWhiteSpace(current())) else if (langutil::isWhiteSpace(current()))
token = selectToken(Token::Whitespace); token = selectToken(Token::Whitespace);
else if (isEndOfLine()) else if (isEndOfLine())
token = make_pair(Token::EOS, "EOS"); token = make_pair(Token::EOS, "EOS");

View File

@ -15,7 +15,6 @@
#pragma once #pragma once
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <libsolidity/ast/Types.h>
#include <liblangutil/Exceptions.h> #include <liblangutil/Exceptions.h>
#include <test/libsolidity/util/SoltestTypes.h> #include <test/libsolidity/util/SoltestTypes.h>
@ -64,7 +63,6 @@ public:
std::vector<FunctionCall> parseFunctionCalls(std::size_t _lineOffset); std::vector<FunctionCall> parseFunctionCalls(std::size_t _lineOffset);
private: private:
using Token = soltest::Token;
/** /**
* Token scanner that is used internally to abstract away character traversal. * Token scanner that is used internally to abstract away character traversal.
*/ */
@ -92,7 +90,7 @@ private:
char scanHexPart(); char scanHexPart();
private: private:
using TokenDesc = std::pair<Token, std::string>; using TokenDesc = std::pair<soltest::Token, std::string>;
/// Advances current position in the input stream. /// Advances current position in the input stream.
void advance(unsigned n = 1) void advance(unsigned n = 1)

View File

@ -30,6 +30,8 @@ using namespace solidity::util;
using namespace solidity::frontend::test; using namespace solidity::frontend::test;
using namespace std; using namespace std;
using Token = soltest::Token;
string TestFunctionCall::format( string TestFunctionCall::format(
ErrorReporter& _errorReporter, ErrorReporter& _errorReporter,
string const& _linePrefix, string const& _linePrefix,
@ -37,9 +39,6 @@ string TestFunctionCall::format(
bool const _highlight bool const _highlight
) const ) const
{ {
using namespace soltest;
using Token = soltest::Token;
stringstream stream; stringstream stream;
bool highlight = !matchesExpectation() && _highlight; bool highlight = !matchesExpectation() && _highlight;
@ -279,8 +278,6 @@ string TestFunctionCall::formatFailure(
bool _highlight bool _highlight
) const ) const
{ {
using Token = soltest::Token;
stringstream os; stringstream os;
os << formatToken(Token::Failure); os << formatToken(Token::Failure);

View File

@ -17,7 +17,6 @@
#include <test/libsolidity/util/TestFileParser.h> #include <test/libsolidity/util/TestFileParser.h>
#include <test/libsolidity/util/SoltestErrors.h> #include <test/libsolidity/util/SoltestErrors.h>
#include <libsolidity/ast/Types.h>
#include <liblangutil/Exceptions.h> #include <liblangutil/Exceptions.h>
#include <libsolutil/AnsiColorized.h> #include <libsolutil/AnsiColorized.h>
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>