Search in sources :

Example 1 with GroovyCodeStyleSettingsFacade

use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyCodeStyleSettingsFacade in project intellij-community by JetBrains.

the class GrReferenceAdjuster method shortenReference.

public static <T extends PsiElement> boolean shortenReference(@NotNull GrQualifiedReference<T> ref) {
    GroovyCodeStyleSettingsFacade facade = GroovyCodeStyleSettingsFacade.getInstance(ref.getProject());
    boolean result = shortenReferenceInner(ref, true, false, facade.useFqClassNamesInJavadoc(), facade.useFqClassNames());
    final TextRange range = ref.getTextRange();
    result |= process(ref, range.getStartOffset(), range.getEndOffset(), true, false, facade.useFqClassNamesInJavadoc(), facade.useFqClassNames());
    return result;
}
Also used : GroovyCodeStyleSettingsFacade(org.jetbrains.plugins.groovy.lang.psi.impl.GroovyCodeStyleSettingsFacade) TextRange(com.intellij.openapi.util.TextRange)

Example 2 with GroovyCodeStyleSettingsFacade

use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyCodeStyleSettingsFacade in project intellij-community by JetBrains.

the class GrTypeDefinitionImpl method getDefaultAnchor.

@Nullable
private PsiElement getDefaultAnchor(GrTypeDefinitionBody body, PsiMember member) {
    GroovyCodeStyleSettingsFacade settings = GroovyCodeStyleSettingsFacade.getInstance(getProject());
    int order = getMemberOrderWeight(member, settings);
    if (order < 0)
        return null;
    PsiElement lastMember = null;
    for (PsiElement child = body.getFirstChild(); child != null; child = child.getNextSibling()) {
        int order1 = getMemberOrderWeight(getAnyMember(child), settings);
        if (order1 < 0)
            continue;
        if (order1 > order) {
            final PsiElement lBrace = body.getLBrace();
            if (lastMember != null) {
                PsiElement nextSibling = lastMember.getNextSibling();
                while (nextSibling instanceof LeafPsiElement && (nextSibling.getText().equals(",") || nextSibling.getText().equals(";"))) {
                    nextSibling = nextSibling.getNextSibling();
                }
                return nextSibling == null && lBrace != null ? PsiUtil.skipWhitespacesAndComments(lBrace.getNextSibling(), true) : nextSibling;
            } else if (lBrace != null) {
                return PsiUtil.skipWhitespacesAndComments(lBrace.getNextSibling(), true);
            }
        }
        lastMember = child;
    }
    return body.getRBrace();
}
Also used : LeafPsiElement(com.intellij.psi.impl.source.tree.LeafPsiElement) GroovyCodeStyleSettingsFacade(org.jetbrains.plugins.groovy.lang.psi.impl.GroovyCodeStyleSettingsFacade) LeafPsiElement(com.intellij.psi.impl.source.tree.LeafPsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with GroovyCodeStyleSettingsFacade

use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyCodeStyleSettingsFacade in project intellij-community by JetBrains.

the class GrReferenceAdjuster method processRange.

@Override
public void processRange(@NotNull ASTNode element, int startOffset, int endOffset, Project project) {
    GroovyCodeStyleSettingsFacade facade = GroovyCodeStyleSettingsFacade.getInstance(project);
    processRange(element, startOffset, endOffset, facade.useFqClassNamesInJavadoc(), facade.useFqClassNames());
}
Also used : GroovyCodeStyleSettingsFacade(org.jetbrains.plugins.groovy.lang.psi.impl.GroovyCodeStyleSettingsFacade)

Aggregations

GroovyCodeStyleSettingsFacade (org.jetbrains.plugins.groovy.lang.psi.impl.GroovyCodeStyleSettingsFacade)3 TextRange (com.intellij.openapi.util.TextRange)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 Nullable (org.jetbrains.annotations.Nullable)1