ui: snippet sizes

* added SnippetMerger class that conducts the merging and snapping of TokenLocations to create snippets.
* added parameters for snippet snapping and merging to ApplicationSettings.
* added forEachStartTokenLocation() and forEachEndTokenLocation() to TokenLocationLine and TokenLocationFile.
* added < and > operators to TokenLocation that compare the location part (not the id).
This commit is contained in:
malte_langkabel
2015-05-04 15:00:18 +02:00
parent 4ec3dfd372
commit fd73abde64
19 changed files with 345 additions and 35 deletions
+44
View File
@@ -39,6 +39,26 @@ TokenLocation::~TokenLocation()
{
}
bool TokenLocation::operator<(const TokenLocation& rhs) const
{
return (
getLineNumber() < rhs.getLineNumber() || (
getLineNumber() == rhs.getLineNumber() &&
getColumnNumber() < rhs.getColumnNumber()
)
);
}
bool TokenLocation::operator>(const TokenLocation& rhs) const
{
return (
getLineNumber() > rhs.getLineNumber() || (
getLineNumber() == rhs.getLineNumber() &&
getColumnNumber() > rhs.getColumnNumber()
)
);
}
Id TokenLocation::getId() const
{
return m_id;
@@ -123,6 +143,30 @@ TokenLocation* TokenLocation::getEndTokenLocation()
}
}
const TokenLocation* TokenLocation::getStartTokenLocation() const
{
if (m_isStart)
{
return this;
}
else
{
return m_other;
}
}
const TokenLocation* TokenLocation::getEndTokenLocation() const
{
if (!m_isStart)
{
return this;
}
else
{
return m_other;
}
}
bool TokenLocation::isStartTokenLocation() const
{
return m_isStart;