final List<Tag> tags = new ArrayList<Tag>();
final JSONParser parser = new JSONParser();
engine.search(ITwigModelElement.START_TAG, null, null, 0, 0, 200,
SearchFor.REFERENCES, MatchRule.PREFIX, scope,
new ISearchRequestor()
{
@Override
public void match(int elementType, int flags, int offset,
int length, int nameOffset, int nameLength,
String elementName, String metadata, String doc,
String qualifier, String parent,
ISourceModule sourceModule, boolean isReference)
{
try {
Tag tag = new Tag(elementName);
if (metadata != null) {
JSONObject data = (JSONObject) parser
.parse(new StringReader(metadata));
if (data.size() > 0)
tag.setPhpClass((String) data
.get(TwigType.PHPCLASS));
if (data.size() > 1)
tag.setDescription((String) data
.get(TwigType.DOC));
}
tags.add(tag);
} catch (Exception e) {
e.printStackTrace();
}
}
}, null);
engine.search(ITwigModelElement.END_TAG, null, null, 0, 0, 200,
SearchFor.REFERENCES, MatchRule.PREFIX, scope,
new ISearchRequestor()
{
@Override
public void match(int elementType, int flags, int offset,
int length, int nameOffset, int nameLength,