logic: add type information of variable decl to name hierarchy

* implemented this feature for both, CXX and Java
* adjusted tests to reflect these changes
* added NameElement and NameHierarchy to Java code
* created more specialized JavaDeclName classes: JavaFunctionDeclName and JavaVariableDeclName
* implemented recording static modifier for Java methods and variables

fortune cookie message = You will enjoy true success in whatever you do.
This commit is contained in:
malte_langkabel
2017-07-28 09:12:32 +02:00
parent 2e117c4b6d
commit 01b1e0d6f1
21 changed files with 526 additions and 135 deletions
@@ -0,0 +1,69 @@
package com.sourcetrail.name;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class NameHierarchy
{
private List<NameElement> m_elements = new ArrayList<>();
public NameHierarchy()
{
}
public NameHierarchy(String name)
{
m_elements.add(new NameElement(name));
}
public NameHierarchy(NameElement name)
{
m_elements.add(name);
}
public NameHierarchy(List<NameElement> names)
{
m_elements.addAll(names);
}
public void push(NameElement element)
{
m_elements.add(element);
}
public void pop()
{
if (!m_elements.isEmpty())
{
m_elements.remove(m_elements.size() - 1);
}
}
public Optional<NameElement> peek()
{
if (!m_elements.isEmpty())
{
return Optional.of(m_elements.get(m_elements.size() - 1));
}
return Optional.empty();
}
public String serialize()
{
String serialized = ".\tm";
for (int i = 0; i < m_elements.size(); i++)
{
if (i != 0)
{
serialized += "\tn";
}
serialized += m_elements.get(i).serialize();
}
return serialized;
}
}