Search in sources :

Example 1 with UpdateJavaFileCopyright

use of com.maddyhome.idea.copyright.psi.UpdateJavaFileCopyright in project intellij-community by JetBrains.

the class UpdateGroovyCopyrightsProvider method createInstance.

@Override
public UpdateCopyright createInstance(Project project, Module module, VirtualFile file, FileType base, CopyrightProfile options) {
    return new UpdateJavaFileCopyright(project, module, file, options) {

        @Override
        protected boolean accept() {
            return getFile() instanceof GroovyFile;
        }

        @Override
        protected PsiElement[] getImportsList() {
            return ((GroovyFile) getFile()).getImportStatements();
        }

        @Override
        protected PsiElement getPackageStatement() {
            return ((GroovyFile) getFile()).getPackageDefinition();
        }

        @Override
        protected void checkCommentsForTopClass(PsiClass topclass, int location, List<PsiComment> comments) {
            if (!(topclass instanceof GroovyScriptClass)) {
                super.checkCommentsForTopClass(topclass, location, comments);
                return;
            }
            final GroovyFile containingFile = (GroovyFile) topclass.getContainingFile();
            PsiElement last = containingFile.getFirstChild();
            while (last != null && !(last instanceof GrStatement)) {
                last = last.getNextSibling();
            }
            checkComments(last, location == JavaOptions.LOCATION_BEFORE_CLASS, comments);
        }
    };
}
Also used : GroovyScriptClass(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass) UpdateJavaFileCopyright(com.maddyhome.idea.copyright.psi.UpdateJavaFileCopyright) PsiClass(com.intellij.psi.PsiClass) List(java.util.List) GroovyFile(org.jetbrains.plugins.groovy.lang.psi.GroovyFile) PsiElement(com.intellij.psi.PsiElement) GrStatement(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement)

Aggregations

PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 UpdateJavaFileCopyright (com.maddyhome.idea.copyright.psi.UpdateJavaFileCopyright)1 List (java.util.List)1 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)1 GrStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement)1 GroovyScriptClass (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass)1