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

5 comments
Comment actions Permalink

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:

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

---
Original message URL: http://www.jetbrains.net/devnet/message/5227701#5227701



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

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.

0
Comment actions Permalink

You have to add idea.jar to your IDEA SDK classpath.

Johan Lund wrote:

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.

---
Original message URL: http://www.jetbrains.net/devnet/message/5227708#5227708


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0
Comment actions Permalink

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

0
Comment actions Permalink

Thanks that did the trick.

0

Please sign in to leave a comment.