mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	AnalysisFramework.formatErrors(): Support colored output and error IDs
This commit is contained in:
		
							parent
							
								
									6f3a379557
								
							
						
					
					
						commit
						6c1bcb9a81
					
				@ -141,17 +141,30 @@ ErrorList AnalysisFramework::expectError(std::string const& _source, bool _warni
 | 
			
		||||
	return sourceAndErrors.second;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
string AnalysisFramework::formatErrors() const
 | 
			
		||||
string AnalysisFramework::formatErrors(
 | 
			
		||||
	bool _colored,
 | 
			
		||||
	bool _withErrorIds
 | 
			
		||||
) const
 | 
			
		||||
{
 | 
			
		||||
	string message;
 | 
			
		||||
	for (auto const& error: compiler().errors())
 | 
			
		||||
		message += formatError(*error);
 | 
			
		||||
		message += formatError(*error, _colored, _withErrorIds);
 | 
			
		||||
	return message;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
string AnalysisFramework::formatError(Error const& _error) const
 | 
			
		||||
string AnalysisFramework::formatError(
 | 
			
		||||
	Error const& _error,
 | 
			
		||||
	bool _colored,
 | 
			
		||||
	bool _withErrorIds
 | 
			
		||||
) const
 | 
			
		||||
{
 | 
			
		||||
	return SourceReferenceFormatter::formatErrorInformation(_error, *m_compiler);
 | 
			
		||||
	return SourceReferenceFormatter::formatExceptionInformation(
 | 
			
		||||
		_error,
 | 
			
		||||
		_error.type(),
 | 
			
		||||
		*m_compiler,
 | 
			
		||||
		_colored,
 | 
			
		||||
		_withErrorIds
 | 
			
		||||
	);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ContractDefinition const* AnalysisFramework::retrieveContractByName(SourceUnit const& _source, string const& _name)
 | 
			
		||||
 | 
			
		||||
@ -57,8 +57,15 @@ protected:
 | 
			
		||||
	bool success(std::string const& _source);
 | 
			
		||||
	langutil::ErrorList expectError(std::string const& _source, bool _warning = false, bool _allowMultiple = false);
 | 
			
		||||
 | 
			
		||||
	std::string formatErrors() const;
 | 
			
		||||
	std::string formatError(langutil::Error const& _error) const;
 | 
			
		||||
	std::string formatErrors(
 | 
			
		||||
		bool _colored = false,
 | 
			
		||||
		bool _withErrorIds = false
 | 
			
		||||
	) const;
 | 
			
		||||
	std::string formatError(
 | 
			
		||||
		langutil::Error const& _error,
 | 
			
		||||
		bool _colored = false,
 | 
			
		||||
		bool _withErrorIds = false
 | 
			
		||||
	) const;
 | 
			
		||||
 | 
			
		||||
	static ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name);
 | 
			
		||||
	static FunctionTypePointer retrieveFunctionBySignature(
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user