Search in sources :

Example 1 with MacroName

use of ool.intellij.plugin.psi.MacroName in project oxy-template-support-plugin by mutant-industries.

the class OxyTemplatePsiUtil method isClosingTagMacroName.

public static boolean isClosingTagMacroName(@NotNull final MacroName macroName) {
    if (PsiTreeUtil.getParentOfType(macroName, MacroEmptyTag.class) != null) {
        return false;
    }
    MacroCall tag = PsiTreeUtil.getParentOfType(macroName, MacroCall.class);
    MacroName openingTagMacroName;
    return tag != null && (openingTagMacroName = tag.getMacroName()) != null && !openingTagMacroName.isEquivalentTo(macroName);
}
Also used : MacroEmptyTag(ool.intellij.plugin.psi.MacroEmptyTag) MacroCall(ool.intellij.plugin.psi.MacroCall) MacroName(ool.intellij.plugin.psi.MacroName)

Example 2 with MacroName

use of ool.intellij.plugin.psi.MacroName in project oxy-template-support-plugin by mutant-industries.

the class UnclosedMacroTag method fillCompletionVariants.

@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
    MacroName elementAt;
    if (parameters.getPosition().getNode().getElementType() != OxyTemplateTypes.T_MACRO_NAME || (elementAt = PsiTreeUtil.getParentOfType(parameters.getPosition(), MacroName.class)) == null || elementAt.getPrevSibling().getPrevSibling().getNode().getElementType() != OxyTemplateTypes.T_XML_CLOSE_TAG_START) {
        return;
    }
    String macroTagToBeClosedName = OxyTemplateHelper.getPreviousUnclosedMacroTagName(elementAt.getPrevSibling());
    if (macroTagToBeClosedName != null) {
        result.withPrefixMatcher(new CamelHumpMatcher(elementAt.getText().replace(CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED, ""))).consume(LookupElementBuilder.create(macroTagToBeClosedName + ">").withPresentableText("m:" + macroTagToBeClosedName).withInsertHandler(new TrailingPatternConsumer(INSERT_CONSUME)).withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
    }
}
Also used : TrailingPatternConsumer(ool.intellij.plugin.editor.completion.handler.TrailingPatternConsumer) MacroName(ool.intellij.plugin.psi.MacroName) CamelHumpMatcher(com.intellij.codeInsight.completion.impl.CamelHumpMatcher)

Aggregations

MacroName (ool.intellij.plugin.psi.MacroName)2 CamelHumpMatcher (com.intellij.codeInsight.completion.impl.CamelHumpMatcher)1 TrailingPatternConsumer (ool.intellij.plugin.editor.completion.handler.TrailingPatternConsumer)1 MacroCall (ool.intellij.plugin.psi.MacroCall)1 MacroEmptyTag (ool.intellij.plugin.psi.MacroEmptyTag)1