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());
}
}
Aggregations