Browse Source

removed unnecessary function

cl-refactor
Liana Husikyan 10 years ago
parent
commit
04702b1fa5
  1. 18
      libsolidity/CompilerStack.cpp
  2. 3
      libsolidity/CompilerStack.h
  3. 2
      libsolidity/InterfaceHandler.h
  4. 5
      test/libsolidity/SolidityNatspecJSON.cpp

18
libsolidity/CompilerStack.cpp

@ -116,6 +116,7 @@ void CompilerStack::parse()
resolver.resolveNamesAndTypes(*contract); resolver.resolveNamesAndTypes(*contract);
m_contracts[contract->getName()].contract = contract; m_contracts[contract->getName()].contract = contract;
} }
InterfaceHandler interfaceHandler;
for (Source const* source: m_sourceOrder) for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->getNodes()) for (ASTPointer<ASTNode> const& node: source->ast->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
@ -123,20 +124,13 @@ void CompilerStack::parse()
m_globalContext->setCurrentContract(*contract); m_globalContext->setCurrentContract(*contract);
resolver.updateDeclaration(*m_globalContext->getCurrentThis()); resolver.updateDeclaration(*m_globalContext->getCurrentThis());
resolver.checkTypeRequirements(*contract); resolver.checkTypeRequirements(*contract);
contract->setDevDocumentation(interfaceHandler.devDocumentation(*contract));
contract->setUserDocumentation(interfaceHandler.userDocumentation(*contract));
m_contracts[contract->getName()].contract = contract; m_contracts[contract->getName()].contract = contract;
parseNatspecDocumentation(*contract);
} }
m_parseSuccessful = true; m_parseSuccessful = true;
} }
void CompilerStack::parseNatspecDocumentation(ContractDefinition const& _contract)
{
InterfaceHandler interfaceHandler;
string devDoc =_contract.devDocumentation();
devDoc = interfaceHandler.devDocumentation(_contract);
//interfaceHandler.generateUserDocumentation(_contract);
}
void CompilerStack::parse(string const& _sourceCode) void CompilerStack::parse(string const& _sourceCode)
{ {
setSource(_sourceCode); setSource(_sourceCode);
@ -240,6 +234,8 @@ string const& CompilerStack::getMetadata(string const& _contractName, Documentat
Contract const& contract = getContract(_contractName); Contract const& contract = getContract(_contractName);
std::unique_ptr<string const>* doc; std::unique_ptr<string const>* doc;
// checks wheather we already have the documentation
switch (_type) switch (_type)
{ {
case DocumentationType::NatspecUser: case DocumentationType::NatspecUser:
@ -257,10 +253,10 @@ string const& CompilerStack::getMetadata(string const& _contractName, Documentat
default: default:
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type.")); BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type."));
} }
auto resPtr = ((*doc) ? *(*doc) : contract.interfaceHandler->getDocumentation(*contract.contract, _type));
// caches the result
if (!*doc) if (!*doc)
*doc = (unique_ptr<string>(new string(contract.interfaceHandler->getDocumentation(*contract.contract, _type)))); doc->reset(new string(contract.interfaceHandler->getDocumentation(*contract.contract, _type)));
return *(*doc); return *(*doc);
} }

3
libsolidity/CompilerStack.h

@ -148,9 +148,6 @@ public:
/// start line, start column, end line, end column /// start line, start column, end line, end column
std::tuple<int, int, int, int> positionFromSourceLocation(SourceLocation const& _sourceLocation) const; std::tuple<int, int, int, int> positionFromSourceLocation(SourceLocation const& _sourceLocation) const;
/// Parses Natspec documentations. Throws exceptions in case of wrong documented contract
void parseNatspecDocumentation(dev::solidity::ContractDefinition const& _contract);
private: private:
/** /**
* Information pertaining to one source unit, filled gradually during parsing and compilation. * Information pertaining to one source unit, filled gradually during parsing and compilation.

2
libsolidity/InterfaceHandler.h

@ -82,7 +82,7 @@ public:
/// Genereates the Developer's documentation of the contract /// Genereates the Developer's documentation of the contract
/// @param _contractDef The contract definition /// @param _contractDef The contract definition
/// @return A string with the json representation /// @return A string with the json representation
/// of the contract's developer documentation /// of the contract's developer documentation
std::string devDocumentation(ContractDefinition const& _contractDef); std::string devDocumentation(ContractDefinition const& _contractDef);
private: private:

5
test/libsolidity/SolidityNatspecJSON.cpp

@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(natspec_notice_without_tag)
{ {
"methods" : { "methods" : {
"mul(uint256)" : { "mul(uint256)" : {
"notice" : " I do something awesome" "notice" : "I do something awesome"
} }
} }
} }
@ -518,11 +518,10 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag)
{ {
"methods" : { "methods" : {
"mul(uint256)" : { "mul(uint256)" : {
"notice" : " I do something awesome which requires two lines to explain" "notice" : "I do something awesome which requires two lines to explain"
} }
} }
} }
)ABCDEF"; )ABCDEF";
checkNatspec(sourceCode, natspec, true); checkNatspec(sourceCode, natspec, true);

Loading…
Cancel
Save