use of com.intellij.codeInsight.intention.impl.config.TextDescriptor in project intellij-community by JetBrains.
the class IntentionDump method main.
@Override
public void main(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element intentions = document.createElement("Intentions");
document.appendChild(intentions);
while (((IntentionManagerImpl) IntentionManager.getInstance()).hasActiveRequests()) {
TimeoutUtil.sleep(100);
}
for (IntentionActionMetaData actionMetaData : IntentionManagerSettings.getInstance().getMetaData()) {
Element intention = document.createElement("Intention");
intention.setAttribute("categories", StringUtil.join(actionMetaData.myCategory, ","));
intention.setAttribute("name", actionMetaData.getFamily());
Element description = document.createElement("description");
CDATASection descriptionSection = document.createCDATASection(escapeCDATA(actionMetaData.getDescription().getText()));
description.appendChild(descriptionSection);
intention.appendChild(description);
TextDescriptor[] beforeDescriptors = actionMetaData.getExampleUsagesBefore();
if (beforeDescriptors.length > 0) {
Element before = document.createElement("before");
CDATASection beforeSection = document.createCDATASection(escapeCDATA(beforeDescriptors[0].getText()));
before.appendChild(beforeSection);
intention.appendChild(before);
}
TextDescriptor[] afterDescriptors = actionMetaData.getExampleUsagesAfter();
if (afterDescriptors.length > 0) {
Element after = document.createElement("after");
CDATASection afterSection = document.createCDATASection(escapeCDATA(afterDescriptors[0].getText()));
after.appendChild(afterSection);
intention.appendChild(after);
}
intentions.appendChild(intention);
}
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
DOMSource source = new DOMSource(document);
final String path = args.length == 2 ? args[1] : PathManager.getHomePath() + File.separator + "AllIntentions.xml";
StreamResult console = new StreamResult(new File(path));
transformer.transform(source, console);
System.exit(0);
} catch (ParserConfigurationException | IOException | TransformerException e) {
// noinspection CallToPrintStackTrace
e.printStackTrace();
System.exit(1);
}
}
Aggregations