mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move copyright classes to the base impl (WEB-41499)
GitOrigin-RevId: 36d74086f200c9b974c206ecd9a2c59bcd9dfb61
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a048824585
commit
8cb76ec6cc
@@ -10,7 +10,6 @@
|
||||
<orderEntry type="module" module-name="intellij.java" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util" />
|
||||
<orderEntry type="module" module-name="intellij.jsp.base" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.copyright" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.copyright;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.impl.source.jsp.jspXml.JspDirective;
|
||||
import com.intellij.psi.jsp.JspFile;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.maddyhome.idea.copyright.CopyrightProfile;
|
||||
import com.maddyhome.idea.copyright.options.LanguageOptions;
|
||||
import com.maddyhome.idea.copyright.options.XmlOptions;
|
||||
import com.maddyhome.idea.copyright.psi.UpdateCopyright;
|
||||
import com.maddyhome.idea.copyright.psi.UpdateCopyrightsProvider;
|
||||
import com.maddyhome.idea.copyright.psi.UpdatePsiFileCopyright;
|
||||
|
||||
public class UpdateJspFileCopyright extends UpdatePsiFileCopyright
|
||||
{
|
||||
public UpdateJspFileCopyright(Project project, Module module, VirtualFile root, CopyrightProfile options)
|
||||
{
|
||||
super(project, module, root, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean accept()
|
||||
{
|
||||
return getFile() instanceof JspFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scanFile()
|
||||
{
|
||||
logger.debug("updating " + getFile().getVirtualFile());
|
||||
|
||||
XmlDocument doc = ((XmlFile)getFile()).getDocument();
|
||||
XmlTag root = doc.getRootTag();
|
||||
if (root == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PsiElement elem = root.getFirstChild();
|
||||
PsiElement docTypeStart = null;
|
||||
PsiElement docTypeEnd = null;
|
||||
PsiElement firstTag = null;
|
||||
while (elem != null)
|
||||
{
|
||||
if (elem instanceof XmlToken)
|
||||
{
|
||||
if ("<!DOCTYPE".equals(elem.getText()))
|
||||
{
|
||||
docTypeStart = elem;
|
||||
while ((elem = getNextSibling(elem)) != null)
|
||||
{
|
||||
if (elem instanceof PsiWhiteSpace) continue;
|
||||
if (elem instanceof XmlToken)
|
||||
{
|
||||
if (elem.getText().endsWith(">"))
|
||||
{
|
||||
elem = getNextSibling(elem);
|
||||
docTypeEnd = elem;
|
||||
break;
|
||||
}
|
||||
else if (elem.getText().startsWith("<"))
|
||||
{
|
||||
docTypeEnd = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstTag = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (elem instanceof XmlTag && !(elem instanceof JspDirective))
|
||||
{
|
||||
firstTag = elem;
|
||||
break;
|
||||
}
|
||||
elem = getNextSibling(elem);
|
||||
}
|
||||
|
||||
PsiElement first = root.getFirstChild();
|
||||
|
||||
int location = getLanguageOptions().getFileLocation();
|
||||
if (docTypeStart != null)
|
||||
{
|
||||
checkComments(first, docTypeStart, location == XmlOptions.LOCATION_BEFORE_DOCTYPE);
|
||||
first = docTypeEnd;
|
||||
}
|
||||
else if (location == XmlOptions.LOCATION_BEFORE_DOCTYPE)
|
||||
{
|
||||
location = XmlOptions.LOCATION_BEFORE_ROOTTAG;
|
||||
}
|
||||
|
||||
if (firstTag != null)
|
||||
{
|
||||
checkComments(first, firstTag, location == XmlOptions.LOCATION_BEFORE_ROOTTAG);
|
||||
}
|
||||
else if (location == XmlOptions.LOCATION_BEFORE_ROOTTAG)
|
||||
{
|
||||
// If we get here we have an empty file
|
||||
checkComments(first, first, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement getPreviousSibling(PsiElement element)
|
||||
{
|
||||
if (element == null) return null;
|
||||
|
||||
PsiElement res = element.getPrevSibling();
|
||||
if (res == null)
|
||||
{
|
||||
if (element.getParent() instanceof XmlText)
|
||||
{
|
||||
res = element.getParent().getPrevSibling();
|
||||
}
|
||||
}
|
||||
|
||||
if (res instanceof XmlText)
|
||||
{
|
||||
XmlText text = (XmlText)res;
|
||||
if (text.getLastChild() != null)
|
||||
{
|
||||
res = text.getLastChild();
|
||||
}
|
||||
else
|
||||
{
|
||||
res = text.getPrevSibling();
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement getNextSibling(PsiElement element)
|
||||
{
|
||||
if (element == null) return null;
|
||||
|
||||
PsiElement res = element instanceof XmlText ? element.getFirstChild() : element.getNextSibling();
|
||||
if (res instanceof XmlText)
|
||||
{
|
||||
if (res.getFirstChild() != null)
|
||||
{
|
||||
res = res.getFirstChild();
|
||||
}
|
||||
else
|
||||
{
|
||||
res = res.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
if (res == null)
|
||||
{
|
||||
if (element.getParent() instanceof XmlText)
|
||||
{
|
||||
res = element.getParent().getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static final Logger logger = Logger.getInstance(UpdateJspFileCopyright.class.getName());
|
||||
public static class UpdateJspCopyrightsProvider extends UpdateCopyrightsProvider {
|
||||
|
||||
@Override
|
||||
public UpdateCopyright createInstance(Project project, Module module, VirtualFile file, FileType base, CopyrightProfile options) {
|
||||
return new UpdateJspFileCopyright(project, module, file, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LanguageOptions getDefaultOptions() {
|
||||
return UpdateCopyrightsProvider.createDefaultOptions(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.copyright;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.xml.XmlDoctype;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlProlog;
|
||||
import com.maddyhome.idea.copyright.CopyrightProfile;
|
||||
import com.maddyhome.idea.copyright.options.LanguageOptions;
|
||||
import com.maddyhome.idea.copyright.options.XmlOptions;
|
||||
import com.maddyhome.idea.copyright.psi.UpdateCopyright;
|
||||
import com.maddyhome.idea.copyright.psi.UpdateCopyrightsProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UpdateJspxFileCopyright extends UpdateJspFileCopyright {
|
||||
public UpdateJspxFileCopyright(Project project, Module module, VirtualFile root, CopyrightProfile options) {
|
||||
super(project, module, root, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scanFile() {
|
||||
logger.debug("updating " + getFile().getVirtualFile());
|
||||
|
||||
XmlDocument doc = ((XmlFile)getFile()).getDocument();
|
||||
XmlProlog xmlProlog = doc.getProlog();
|
||||
if (xmlProlog == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiElement elem = xmlProlog.getFirstChild();
|
||||
PsiElement docTypeStart = null;
|
||||
while (elem != null) {
|
||||
if (elem instanceof XmlDoctype) {
|
||||
docTypeStart = elem;
|
||||
break;
|
||||
}
|
||||
elem = getNextSibling(elem);
|
||||
}
|
||||
|
||||
PsiElement first = xmlProlog.getFirstChild();
|
||||
|
||||
int location = getLanguageOptions().getFileLocation();
|
||||
|
||||
if (docTypeStart != null) {
|
||||
final ArrayList<PsiComment> comments = new ArrayList<>();
|
||||
collectComments(doc.getFirstChild(), xmlProlog, comments);
|
||||
collectComments(first, docTypeStart, comments);
|
||||
checkComments(first, location == XmlOptions.LOCATION_BEFORE_DOCTYPE, comments);
|
||||
checkComments(docTypeStart, doc.getRootTag(), location == XmlOptions.LOCATION_BEFORE_ROOTTAG);
|
||||
return;
|
||||
}
|
||||
else if (location == XmlOptions.LOCATION_BEFORE_DOCTYPE) {
|
||||
location = XmlOptions.LOCATION_BEFORE_ROOTTAG;
|
||||
}
|
||||
final ArrayList<PsiComment> comments = new ArrayList<>();
|
||||
collectComments(doc.getFirstChild(), xmlProlog, comments);
|
||||
collectComments(first, doc.getRootTag(), comments);
|
||||
checkComments(doc.getRootTag(), location == XmlOptions.LOCATION_BEFORE_ROOTTAG, comments);
|
||||
}
|
||||
|
||||
private static final Logger logger = Logger.getInstance(UpdateJspxFileCopyright.class.getName());
|
||||
|
||||
public static class UpdateJspxCopyrightsProvider extends UpdateCopyrightsProvider {
|
||||
|
||||
@Override
|
||||
public UpdateCopyright createInstance(Project project, Module module, VirtualFile file, FileType base, CopyrightProfile options) {
|
||||
return new UpdateJspxFileCopyright(project, module, file, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LanguageOptions getDefaultOptions() {
|
||||
return createDefaultOptions(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user