Automated Formal Static Analysis and Retrieval of Source Code - JKU
Automated Formal Static Analysis and Retrieval of Source Code - JKU
Automated Formal Static Analysis and Retrieval of Source Code - JKU
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
44CHAPTER 3. CODE SEARCH INTEGRATION FACILITY INTO MINDBREEZE ENTERPRISE SEARCH<br />
• private ContextMenu getMenu(Map metadata) – creates a context<br />
menu for the hit type specified by its metadata. For creating a suitable pattern action for<br />
a menu entry, the unique key <strong>of</strong> a hit type plays an important role. The way we approach the<br />
key construction turned out to be very fruitful because information like the category class,<br />
category instance, programming language needed for constructing pattern actions are easily<br />
identifiable in the key construction.<br />
I want to exemplify here with two types <strong>of</strong> re-query context actions; one type uses the key <strong>of</strong><br />
the hit-type <strong>and</strong> the a special construct for formulating re-queries, similar to the Mindbreeze<br />
Query Language.<br />
Example 3.4.<br />
[Sample Context Actions Implementation]<br />
//default context action<br />
ContextAction openAction = new ContextAction();<br />
openAction.setIcon(null);<br />
openAction.setName("Open");<br />
openAction.setPattern(getPathFromKey(metadata.get(MetadataKeys.DOCUMENT_KEY)));<br />
actions.add(openAction);<br />
String cc = metadata.get(getCategoryClass());<br />
if (cc.equals("callable")){<br />
ContextAction similarCallableinLang = new ContextAction();<br />
similarCallableinLang.setIcon(null);<br />
similarCallableinLang.setName("Similar Callable in the Same Language");<br />
similarCallableinLang.setPattern("tag:mindbreeze.com,2007/actions/query/<br />
signature:"+ metadata.get(getSignature())+ " AND language:"+<br />
metadata.get(getLanguage()));<br />
actions.add(similarCallableinLang);<br />
}<br />
...<br />
The methods getLanguage() <strong>and</strong> getSignature() use the method getRequiredMetadataKeys()<br />
in order to retrieve the respective metadata for the hit-type. We mention that they have to be written<br />
exactly in the same way as they are stored in the index.<br />
Example 3.5.<br />
[The metadata keys required by this context provider]<br />
public String[] getRequiredMetadataKeys() {<br />
return new String[] {<br />
MetadataKeys.HIT_GROUP_ID, MetadataKeys.CATEGORY_CLASS,<br />
MetadataKeys.DOCUMENT_KEY, "signature",<br />
"language", "categoryclass"<br />
} ;<br />
}