Loading live templates in 8.0
The 8.0 broke my live template loader class.
I had these imports:
import com.intellij.codeInsight.template.Template;
import com.intellij.codeInsight.template.impl.TemplateContext;
import com.intellij.codeInsight.template.impl.TemplateImpl;
import com.intellij.codeInsight.template.impl.TemplateSettings;
But they don't seem to work anymore.
How are live templates treated in 8.0?
Best regards
Johan Lund
Bindows Team
Please sign in to leave a comment.
The only change I see is that specific context type now can be
specified, like following:
for(TemplateContextType contextType:
Extensions.getExtensions(TemplateContextType.EP_NAME)) {
if (contextType.isInContext(]]>)) {
contextType.setEnabled(templateContext, true);
}
}
Do the templates just not run or there are code compilation problem?
Johan Lund wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Compilation problems. It says that it can't resolve symbol "Template" and "impl" for my imports:
import com.intellij.codeInsight.template.Template
import com.intellij.codeInsight.template.impl
This in turn creates a lot of red stuff throughout the code like e.g.:
/**
* Loads live templates from xml
* @param inputStream data source
*/
public static void loadTemplates(@NotNull final InputStream inputStream) {
final SAXBuilder parser = new SAXBuilder();
try {
final TemplateSettings templateSettings = TemplateSettings.getInstance(); // Does not work for v.6
if(templateSettings == null) return;
final Document doc = parser.build(inputStream);
final Element root = doc.getRootElement();
final String groupName = root.getAttributeValue("group");
for (final Object o : root.getChildren()) {
if (o instanceof Element) {
final Template t = readExternal((Element)o, groupName);
templateSettings.addTemplate(t);
}
}
} catch (JDOMException e) {
System.err.println(e);
} catch (IOException e) {
System.err.println(e);
}
}
It can't resolve TemplateSettings for example.
You have to add idea.jar to your IDEA SDK classpath.
Johan Lund wrote:
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com
soemthing that might help you spot changes is the APIComparator plugin, comparing openapi.jar from 7.0 and 8.0 will show you all changes between the two, which proves very useful to me !
see http://plugins.intellij.net/plugin/?id=85
Thanks that did the trick.