Search in sources :

Example 1 with RelativePathCalculator

use of ool.intellij.plugin.file.RelativePathCalculator in project oxy-template-support-plugin by mutant-industries.

the class IncludeAutoInsert method handleInsert.

@Override
public void handleInsert(InsertionContext context, LookupElementDecorator<LookupElement> item) {
    item.getDelegate().handleInsert(context);
    if (!(item.getObject() instanceof JSElement)) {
        return;
    }
    JSElement macroDefinition = (JSElement) item.getObject();
    if (OxyTemplateHelper.isJsMacroMissingInclude(context.getFile().getViewProvider().getPsi(OxyTemplate.INSTANCE), macroDefinition)) {
        RelativePathCalculator pathCalculator = new RelativePathCalculator(context.getFile().getVirtualFile().getPath(), macroDefinition.getContainingFile().getVirtualFile().getPath());
        pathCalculator.execute();
        DirectiveStatement includeDirective = OxyTemplateElementFactory.createDirectiveStatement(context.getProject(), IncludeOnceDirective.NAME, pathCalculator.getResult());
        OxyTemplateHelper.addDirective(includeDirective, context.getFile());
    }
}
Also used : JSElement(com.intellij.lang.javascript.psi.JSElement) RelativePathCalculator(ool.intellij.plugin.file.RelativePathCalculator) DirectiveStatement(ool.intellij.plugin.psi.DirectiveStatement)

Aggregations

JSElement (com.intellij.lang.javascript.psi.JSElement)1 RelativePathCalculator (ool.intellij.plugin.file.RelativePathCalculator)1 DirectiveStatement (ool.intellij.plugin.psi.DirectiveStatement)1