cleanup - sort modifiers, final

GitOrigin-RevId: bb0609b4dbd9403e3aaacbb8a84da46d6f193481
This commit is contained in:
Vladimir Krivosheev
2023-09-30 19:06:19 +02:00
committed by intellij-monorepo-bot
parent e96068bebd
commit 492a547788
41 changed files with 187 additions and 266 deletions

View File

@@ -11,11 +11,11 @@ import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class HtmlHttpEquivEncodingReferenceProvider extends XmlEncodingReferenceProvider {
public final class HtmlHttpEquivEncodingReferenceProvider extends XmlEncodingReferenceProvider {
private static final Logger LOG = Logger.getInstance(XmlEncodingReferenceProvider.class);
@Override
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) {
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, final @NotNull ProcessingContext context) {
LOG.assertTrue(element instanceof XmlAttributeValue);
XmlAttributeValue value = (XmlAttributeValue)element;
PsiElement parent = value.getParent();

View File

@@ -10,24 +10,22 @@ import com.intellij.psi.xml.XmlTag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class CreateRequiredSubElement extends LocalQuickFixAndIntentionActionOnPsiElement {
public final class CreateRequiredSubElement extends LocalQuickFixAndIntentionActionOnPsiElement {
private final String myName;
protected CreateRequiredSubElement(@Nullable PsiElement element, String name) {
CreateRequiredSubElement(@Nullable PsiElement element, String name) {
super(element);
myName = name;
}
@NotNull
@Override
public String getText() {
public @NotNull String getText() {
return HtmlToolsBundle.message("html.intention.create.sub.element.text", myName);
}
@NotNull
@Override
public String getFamilyName() {
public @NotNull String getFamilyName() {
return HtmlToolsBundle.message("html.intention.create.sub.element.family", myName);
}

View File

@@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull;
import static com.intellij.documentation.mdn.MdnDocumentationKt.getHtmlMdnDocumentation;
import static com.intellij.webSymbols.WebSymbolApiStatus.isDeprecatedOrObsolete;
public class HtmlDeprecatedAttributeInspection extends HtmlLocalInspectionTool {
public final class HtmlDeprecatedAttributeInspection extends HtmlLocalInspectionTool {
@Override
protected void checkAttribute(@NotNull XmlAttribute attribute, @NotNull ProblemsHolder holder, boolean isOnTheFly) {

View File

@@ -30,9 +30,9 @@ import java.util.Set;
import static com.intellij.documentation.mdn.MdnDocumentationKt.getHtmlMdnDocumentation;
import static com.intellij.webSymbols.WebSymbolApiStatus.isDeprecatedOrObsolete;
public class HtmlDeprecatedTagInspection extends HtmlLocalInspectionTool {
@NonNls private static final Set<String> ourHtmlReplaceableTags;
@NonNls private static final Set<String> ourCssReplaceableTags;
public final class HtmlDeprecatedTagInspection extends HtmlLocalInspectionTool {
private static final @NonNls Set<String> ourHtmlReplaceableTags;
private static final @NonNls Set<String> ourCssReplaceableTags;
static {
ourHtmlReplaceableTags = new HashSet<>();
@@ -61,7 +61,7 @@ public class HtmlDeprecatedTagInspection extends HtmlLocalInspectionTool {
}
@Override
protected void checkTag(@NotNull final XmlTag tag, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
protected void checkTag(final @NotNull XmlTag tag, final @NotNull ProblemsHolder holder, final boolean isOnTheFly) {
if (HtmlUtil.isHtmlTagContainingFile(tag)) {
XmlElementDescriptor descriptor = tag.getDescriptor();
if (!(descriptor instanceof HtmlElementDescriptorImpl) || !((HtmlElementDescriptorImpl)descriptor).isDeprecated()) {

View File

@@ -36,8 +36,7 @@ public final class HtmlFormInputWithoutLabelInspection extends HtmlLocalInspecti
@Override
@NotNull
public String getShortName() {
public @NotNull String getShortName() {
return "HtmlFormInputWithoutLabel";
}
@@ -143,7 +142,7 @@ public final class HtmlFormInputWithoutLabelInspection extends HtmlLocalInspecti
PsiElement getFirstChild(@NotNull PsiElement element);
}
public static class ForwardIterator implements ElementIterator {
public static final class ForwardIterator implements ElementIterator {
@Override
public PsiElement getNext(PsiElement element) {
return element.getNextSibling();
@@ -155,13 +154,12 @@ public final class HtmlFormInputWithoutLabelInspection extends HtmlLocalInspecti
}
@Override
@Nullable
public PsiElement getFirstChild(@NotNull PsiElement element) {
public @Nullable PsiElement getFirstChild(@NotNull PsiElement element) {
return element.getFirstChild();
}
}
public static class BackwardIterator implements ElementIterator {
public static final class BackwardIterator implements ElementIterator {
@Override
public PsiElement getNext(PsiElement element) {
return element.getPrevSibling();
@@ -173,14 +171,12 @@ public final class HtmlFormInputWithoutLabelInspection extends HtmlLocalInspecti
}
@Override
@Nullable
public PsiElement getFirstChild(@NotNull PsiElement element) {
public @Nullable PsiElement getFirstChild(@NotNull PsiElement element) {
return element.getLastChild();
}
}
@Nullable
public static Pair<PsiElement, PsiElement> getNearestText(PsiElement element, ElementIterator iterator) {
public static @Nullable Pair<PsiElement, PsiElement> getNearestText(PsiElement element, ElementIterator iterator) {
element = iterator.getNext(element);
if (!(element instanceof XmlText) || element.getChildren().length == 0) {
return null;

View File

@@ -17,11 +17,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class HtmlLabelsHolder {
public final class HtmlLabelsHolder {
private static final Key<CachedValue<HtmlLabelsHolder>> htmlLabelsHolderKey = Key.create("html labels holder");
private final Set<String> myForValuesOfLabels = new HashSet<>();
private final static UserDataCache<CachedValue<HtmlLabelsHolder>, XmlFile, Object> CACHE =
private static final UserDataCache<CachedValue<HtmlLabelsHolder>, XmlFile, Object> CACHE =
new UserDataCache<>() {
@Override
protected CachedValue<HtmlLabelsHolder> compute(final XmlFile file, final Object p) {

View File

@@ -9,12 +9,11 @@ import org.jetbrains.annotations.NotNull;
* This inspections is used to enable/disable checking internet links by external annotator
* @see HtmlNonExistentInternetResourcesAnnotator
*/
public class HtmlNonExistentInternetResourceInspection extends LocalInspectionTool {
@NonNls public static final String SHORT_NAME = "HtmlNonExistentInternetResource";
public final class HtmlNonExistentInternetResourceInspection extends LocalInspectionTool {
public static final @NonNls String SHORT_NAME = "HtmlNonExistentInternetResource";
@NotNull
@Override
public String getShortName() {
public @NotNull String getShortName() {
return SHORT_NAME;
}
}

View File

@@ -14,10 +14,10 @@ import org.jetbrains.annotations.NotNull;
import java.util.Set;
public class HtmlPresentationalElementInspection extends HtmlLocalInspectionTool {
@NonNls private static final Set<String> ourCssReplaceableTags;
@NonNls private static final Set<String> ourHtmlReplaceableTagsHtml4;
@NonNls private static final Set<String> ourHtmlReplaceableTagsHtml5;
public final class HtmlPresentationalElementInspection extends HtmlLocalInspectionTool {
private static final @NonNls Set<String> ourCssReplaceableTags;
private static final @NonNls Set<String> ourHtmlReplaceableTagsHtml4;
private static final @NonNls Set<String> ourHtmlReplaceableTagsHtml5;
static {
ourHtmlReplaceableTagsHtml4 = Set.of("i", "b", "tt");
@@ -26,13 +26,12 @@ public class HtmlPresentationalElementInspection extends HtmlLocalInspectionTool
}
@Override
@NotNull
public String getShortName() {
public @NotNull String getShortName() {
return "HtmlPresentationalElement";
}
@Override
protected void checkTag(@NotNull final XmlTag tag, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
protected void checkTag(final @NotNull XmlTag tag, final @NotNull ProblemsHolder holder, final boolean isOnTheFly) {
final String name = StringUtil.toLowerCase(tag.getName());
if (HtmlUtil.isHtmlTagContainingFile(tag)) {
if (HtmlUtil.isHtml5Context(tag) && !ourHtmlReplaceableTagsHtml5.contains(tag.getName())) {

View File

@@ -18,8 +18,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class HtmlRequiredAltAttributeInspection extends HtmlLocalInspectionTool {
@NonNls private static final Set<String> htmlTagsWithRequiredAltAttribute;
public final class HtmlRequiredAltAttributeInspection extends HtmlLocalInspectionTool {
private static final @NonNls Set<String> htmlTagsWithRequiredAltAttribute;
private static final String ALT = "alt";
static {
@@ -50,9 +50,8 @@ public class HtmlRequiredAltAttributeInspection extends HtmlLocalInspectionTool
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
@NotNull
@Override
public String getShortName() {
public @NotNull String getShortName() {
return "HtmlRequiredAltAttribute";
}
}

View File

@@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class HtmlRequiredLangAttributeInspection extends HtmlLocalInspectionTool {
public final class HtmlRequiredLangAttributeInspection extends HtmlLocalInspectionTool {
private static final String LANG = "lang";
private static final String HTML = "html";
@@ -60,9 +60,8 @@ public class HtmlRequiredLangAttributeInspection extends HtmlLocalInspectionTool
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
@NotNull
@Override
public String getShortName() {
public @NotNull String getShortName() {
return "HtmlRequiredLangAttribute";
}
}

View File

@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class HtmlRequiredSummaryAttributeInspection extends HtmlLocalInspectionTool {
public final class HtmlRequiredSummaryAttributeInspection extends HtmlLocalInspectionTool {
private static final String TABLE = "table";
private static final String SUMMARY = "summary";
@@ -36,9 +36,8 @@ public class HtmlRequiredSummaryAttributeInspection extends HtmlLocalInspectionT
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
@NotNull
@Override
public String getShortName() {
public @NotNull String getShortName() {
return super.getShortName();
}
}

View File

@@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class HtmlRequiredTitleAttributeInspection extends HtmlLocalInspectionTool {
public final class HtmlRequiredTitleAttributeInspection extends HtmlLocalInspectionTool {
private static final Set<String>
ourElementsWithoutTitle = Set.of("frame", "iframe", "dl", "a", "router-link");
private static final String TITLE = "title";
@@ -40,9 +40,8 @@ public class HtmlRequiredTitleAttributeInspection extends HtmlLocalInspectionToo
}
if (holder.isOnTheFly()) {
fixes.add(new InsertRequiredAttributeFix(tag, TITLE) {
@NotNull
@Override
public String getText() {
public @NotNull String getText() {
return HtmlToolsBundle.message("html.intention.insert.attribute", TITLE);
}
});
@@ -52,9 +51,8 @@ public class HtmlRequiredTitleAttributeInspection extends HtmlLocalInspectionToo
}
}
@NotNull
@Override
public String getShortName() {
public @NotNull String getShortName() {
return "HtmlRequiredTitleAttribute";
}
}

View File

@@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class HtmlRequiredTitleElementInspection extends HtmlLocalInspectionTool {
public final class HtmlRequiredTitleElementInspection extends HtmlLocalInspectionTool {
private static final String TITLE = "title";
private static final String HEAD = "head";
@@ -33,9 +33,8 @@ public class HtmlRequiredTitleElementInspection extends HtmlLocalInspectionTool
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
@NotNull
@Override
public String getShortName() {
public @NotNull String getShortName() {
return "HtmlRequiredTitleElement";
}
}

View File

@@ -16,7 +16,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
public class CreateLabelFromTextAction implements LocalQuickFix, HighPriorityAction {
public final class CreateLabelFromTextAction implements LocalQuickFix, HighPriorityAction {
private final String myBundleKey;
private final boolean myTextBeforeTag;
private final String myName;
@@ -29,8 +29,7 @@ public class CreateLabelFromTextAction implements LocalQuickFix, HighPriorityAct
}
@Override
@NotNull
public String getFamilyName() {
public @NotNull String getFamilyName() {
return HtmlToolsBundle.message(myBundleKey, myName);
}

View File

@@ -15,7 +15,7 @@ import com.intellij.xml.util.XmlUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class CreateNewLabelAction implements LocalQuickFix, HighPriorityAction {
public final class CreateNewLabelAction implements LocalQuickFix, HighPriorityAction {
private final String myName;
public CreateNewLabelAction(String name) {
@@ -23,8 +23,7 @@ public class CreateNewLabelAction implements LocalQuickFix, HighPriorityAction {
}
@Override
@NotNull
public String getFamilyName() {
public @NotNull String getFamilyName() {
return HtmlToolsBundle.message("html.inspections.create.new.label", myName);
}
@@ -52,8 +51,7 @@ public class CreateNewLabelAction implements LocalQuickFix, HighPriorityAction {
}
}
@NotNull
private static XmlTag createLabelFor(@NotNull XmlTag place, @NotNull XmlAttributeValue id) {
private static @NotNull XmlTag createLabelFor(@NotNull XmlTag place, @NotNull XmlAttributeValue id) {
XmlTag tag = createElementFromText(place.getProject(), place, "<label for=\"x\"></label>");
//noinspection ConstantConditions
tag.getAttribute("for").getValueElement().replace(id);
@@ -64,14 +62,12 @@ public class CreateNewLabelAction implements LocalQuickFix, HighPriorityAction {
return XmlElementFactory.getInstance(project).createTagFromText("<a>\n</a>").getValue().getTextElements()[0];
}
@Nullable
static String getId(XmlTag tag) {
static @Nullable String getId(XmlTag tag) {
XmlAttributeValue value = findIdValue(tag);
return value == null ? null : value.getValue();
}
@Nullable
private static XmlAttributeValue findIdValue(XmlTag tag) {
private static @Nullable XmlAttributeValue findIdValue(XmlTag tag) {
for (XmlAttribute attribute : tag.getAttributes()) {
if (attribute.getName().equalsIgnoreCase("id")) {
return attribute.getValueElement();
@@ -80,8 +76,7 @@ public class CreateNewLabelAction implements LocalQuickFix, HighPriorityAction {
return null;
}
@NotNull
static XmlTag createElementFromText(Project project, XmlTag myTag, String text) {
static @NotNull XmlTag createElementFromText(Project project, XmlTag myTag, String text) {
return myTag instanceof HtmlTag ?
XmlElementFactory.getInstance(project).createHTMLTagFromText(text) :
XmlElementFactory.getInstance(project).createXHTMLTagFromText(text);

View File

@@ -15,9 +15,9 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class ReplaceAppletTagAction implements LocalQuickFix {
private static class Holder {
@NonNls private static final Set<String> ourObjectAttributes = new HashSet<>();
public final class ReplaceAppletTagAction implements LocalQuickFix {
private static final class Holder {
private static final @NonNls Set<String> ourObjectAttributes = new HashSet<>();
static {
ourObjectAttributes.addAll(Arrays.asList("align", "height", "hspace", "title", "vspace", "width"));
@@ -25,15 +25,12 @@ public class ReplaceAppletTagAction implements LocalQuickFix {
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return HtmlToolsBundle.message("html.replace.tag.with.another.quickfix.text", "applet", "object");
}
@Override
@NonNls
@NotNull
public String getFamilyName() {
public @NonNls @NotNull String getFamilyName() {
return "ReplaceDeprecatedTag";
}
@@ -44,7 +41,7 @@ public class ReplaceAppletTagAction implements LocalQuickFix {
}
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
public void applyFix(final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) {
PsiElement parent = descriptor.getPsiElement();
while (parent != null) {
if (parent instanceof XmlTag && "applet".equals(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) {

View File

@@ -15,9 +15,9 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class ReplaceFontTagAction implements LocalQuickFix {
private static class Holder {
@NonNls private static final Map<String, String> ourSizesMap = new HashMap<>();
public final class ReplaceFontTagAction implements LocalQuickFix {
private static final class Holder {
private static final @NonNls Map<String, String> ourSizesMap = new HashMap<>();
static {
ourSizesMap.put("-3", "59%");
@@ -38,15 +38,12 @@ public class ReplaceFontTagAction implements LocalQuickFix {
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return HtmlToolsBundle.message("html.replace.tag.with.css.quickfix.text", "font");
}
@Override
@NonNls
@NotNull
public String getFamilyName() {
public @NonNls @NotNull String getFamilyName() {
return "ReplaceDepracatedTag";
}
@@ -57,7 +54,7 @@ public class ReplaceFontTagAction implements LocalQuickFix {
}
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
public void applyFix(final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) {
PsiElement parent = descriptor.getPsiElement();
while (parent != null) {
if (parent instanceof XmlTag && "font".equals(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) {

View File

@@ -17,14 +17,14 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class ReplaceHtmlTagWithAnotherAction implements LocalQuickFix {
@NonNls private final String myName;
public final class ReplaceHtmlTagWithAnotherAction implements LocalQuickFix {
private final @NonNls String myName;
public ReplaceHtmlTagWithAnotherAction(String name) {
myName = name;
}
private static class Holder {
@NonNls private static final Map<String, String> ourTagToNewTagMap = new HashMap<>();
private static final class Holder {
private static final @NonNls Map<String, String> ourTagToNewTagMap = new HashMap<>();
static {
ourTagToNewTagMap.put("i", "em");
@@ -39,15 +39,12 @@ public class ReplaceHtmlTagWithAnotherAction implements LocalQuickFix {
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return HtmlToolsBundle.message("html.replace.tag.with.another.quickfix.text", myName, Holder.ourTagToNewTagMap.get(myName));
}
@Override
@NonNls
@NotNull
public String getFamilyName() {
public @NonNls @NotNull String getFamilyName() {
return HtmlToolsBundle.message("html.replace.tag.with.another.quickfix.family.name");
}
@@ -58,7 +55,7 @@ public class ReplaceHtmlTagWithAnotherAction implements LocalQuickFix {
}
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
public void applyFix(final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) {
PsiElement parent = descriptor.getPsiElement();
while (parent != null) {
if (parent instanceof XmlTag && myName.equals(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) {

View File

@@ -16,15 +16,15 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class ReplaceHtmlTagWithCssAction implements LocalQuickFix {
@NonNls private final String myName;
public final class ReplaceHtmlTagWithCssAction implements LocalQuickFix {
private final @NonNls String myName;
@NonNls private static final String BODY = "body";
@NonNls private static final String HTML = "html";
@NonNls private static final String HEAD = "head";
private static final @NonNls String BODY = "body";
private static final @NonNls String HTML = "html";
private static final @NonNls String HEAD = "head";
private static class Holder {
@NonNls private static final Map<String, String> ourTagToCssMap = new HashMap<>();
private static final class Holder {
private static final @NonNls Map<String, String> ourTagToCssMap = new HashMap<>();
static {
ourTagToCssMap.put("center", "text-align: center;");
@@ -45,20 +45,16 @@ public class ReplaceHtmlTagWithCssAction implements LocalQuickFix {
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return HtmlToolsBundle.message("html.replace.tag.with.css.quickfix.text", myName);
}
@NotNull
public String getText() {
public @NotNull String getText() {
return getName();
}
@Override
@NonNls
@NotNull
public String getFamilyName() {
public @NonNls @NotNull String getFamilyName() {
return HtmlToolsBundle.message("html.replace.tag.with.css.quickfix.family.name");
}
@@ -90,7 +86,7 @@ public class ReplaceHtmlTagWithCssAction implements LocalQuickFix {
}
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
public void applyFix(final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) {
PsiElement parent = descriptor.getPsiElement();
while (parent != null) {
if (parent instanceof XmlTag && Holder.ourTagToCssMap.containsKey(StringUtil.toLowerCase(((XmlTag)parent).getLocalName()))) {

View File

@@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Objects;
public class HtmlGotoSymbolProvider implements ChooseByNameContributorEx {
public final class HtmlGotoSymbolProvider implements ChooseByNameContributorEx {
@Override
public void processNames(@NotNull Processor<? super String> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) {
FileBasedIndex.getInstance().processAllKeys(HtmlTagIdIndex.INDEX, (name) -> processor.process(name) && processor.process("#" + name),
@@ -79,9 +79,8 @@ public class HtmlGotoSymbolProvider implements ChooseByNameContributorEx {
return myName;
}
@Nullable
@Override
public String getLocationString() {
public @Nullable String getLocationString() {
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(myFile);
return psiFile != null ? "(" + SymbolPresentationUtil.getFilePathPresentation(psiFile) + ")" : null;
}

View File

@@ -26,18 +26,16 @@ import java.util.Map;
import static com.intellij.util.indexing.hints.FileTypeSubstitutionStrategy.BEFORE_SUBSTITUTION;
public class HtmlTagIdIndex extends XmlIndex<Integer> {
public final class HtmlTagIdIndex extends XmlIndex<Integer> {
public static final ID<String, Integer> INDEX = ID.create("HtmlTagIdIndex");
@NotNull
@Override
public ID<String, Integer> getName() {
public @NotNull ID<String, Integer> getName() {
return INDEX;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
public @NotNull FileBasedIndex.InputFilter getInputFilter() {
return new BaseFileTypeInputFilter(BEFORE_SUBSTITUTION) {
@Override
public boolean slowPathIfFileTypeHintUnsure(@NotNull IndexedFile file) {
@@ -57,13 +55,11 @@ public class HtmlTagIdIndex extends XmlIndex<Integer> {
};
}
@NotNull
@Override
public DataIndexer<String, Integer, FileContent> getIndexer() {
public @NotNull DataIndexer<String, Integer, FileContent> getIndexer() {
return new DataIndexer<>() {
@NotNull
@Override
public Map<String, Integer> map(@NotNull FileContent inputData) {
public @NotNull Map<String, Integer> map(@NotNull FileContent inputData) {
Map<String, Integer> result = new HashMap<>();
inputData
.getPsiFile()
@@ -98,9 +94,8 @@ public class HtmlTagIdIndex extends XmlIndex<Integer> {
return 3;
}
@NotNull
@Override
public DataExternalizer<Integer> getValueExternalizer() {
public @NotNull DataExternalizer<Integer> getValueExternalizer() {
return new DataExternalizer<>() {
@Override
public void save(@NotNull DataOutput out, Integer value) throws IOException {

View File

@@ -28,7 +28,7 @@ public final class TableCellNavigator {
return row >= 0 && row < table.size() && column >= 0 && column < table.get(row).size();
}
public static void moveCaret(@NotNull final Project project,@NotNull final Editor editor, final PsiFile file, int[] direction) {
public static void moveCaret(final @NotNull Project project, final @NotNull Editor editor, final PsiFile file, int[] direction) {
PsiElement element = getCurrentPsiElement(editor, file);
element = getParentWithName(element, new String[]{TD, TH});
assert element != null;

View File

@@ -34,7 +34,7 @@ public final class TableColumnAdder {
}
}
private static void addColumnToTable(@NotNull final Project project, List<TableRow> table, int columnNumber) {
private static void addColumnToTable(final @NotNull Project project, List<TableRow> table, int columnNumber) {
for (int i = 0; i < table.size(); i++) {
TableRow row = table.get(i);
if (row.isEmpty()) {
@@ -111,7 +111,7 @@ public final class TableColumnAdder {
return false;
}
public static void addColumn(@NotNull final Project project, final Editor editor, final PsiFile file, boolean toInsertBefore)
public static void addColumn(final @NotNull Project project, final Editor editor, final PsiFile file, boolean toInsertBefore)
throws IncorrectOperationException {
PsiElement element = getCurrentPsiElement(editor, file);
element = getParentWithName(element, new String[]{TD, TH});

View File

@@ -19,16 +19,15 @@ import java.util.ArrayList;
import java.util.List;
public final class TableUtil {
@NonNls static final String TD = "td";
@NonNls static final String TH = "th";
@NonNls static final String TR = "tr";
@NonNls static final String TABLE = "table";
@NonNls static final String COLSPAN = "colspan";
@NonNls static final String ROWSPAN = "rowspan";
@NonNls static final String THEAD = "thead";
static final @NonNls String TD = "td";
static final @NonNls String TH = "th";
static final @NonNls String TR = "tr";
static final @NonNls String TABLE = "table";
static final @NonNls String COLSPAN = "colspan";
static final @NonNls String ROWSPAN = "rowspan";
static final @NonNls String THEAD = "thead";
@Nullable
static PsiElement getParentWithName(PsiElement element, String[] tagNames) {
static @Nullable PsiElement getParentWithName(PsiElement element, String[] tagNames) {
while (element != null) {
if (element instanceof XmlTag) {
if (tagNames != null) {
@@ -196,23 +195,20 @@ public final class TableUtil {
return Pair.create(table, cell);
}
@Nullable
static PsiElement getCurrentPsiElement(final Editor editor, final PsiFile file) {
static @Nullable PsiElement getCurrentPsiElement(final Editor editor, final PsiFile file) {
final int offset = editor.getCaretModel().getOffset();
final PsiElement psiElement = file.findElementAt(offset);
return PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
}
@Nullable
static PsiElement getTablePsiElement(PsiElement root) {
static @Nullable PsiElement getTablePsiElement(PsiElement root) {
while (root != null && !(root instanceof XmlTag && TABLE.equals(StringUtil.toLowerCase(((XmlTag)root).getName())))) {
root = root.getParent();
}
return root;
}
@Nullable
static PsiElement findClosingToken(XmlTag tag) {
static @Nullable PsiElement findClosingToken(XmlTag tag) {
PsiElement[] children = tag.getChildren();
for (int i = 0; i < children.length; i++) {
PsiElement element = children[i];
@@ -226,7 +222,7 @@ public final class TableUtil {
return null;
}
static void moveCaretTo(@NotNull final Editor editor, final PsiElement element) {
static void moveCaretTo(final @NotNull Editor editor, final PsiElement element) {
editor.getCaretModel().moveToOffset(element.getTextOffset());
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
}
@@ -240,7 +236,7 @@ public final class TableUtil {
return HtmlUtil.isHtmlTagContainingFile(element);
}
static class TableCell {
static final class TableCell {
final int startColumn;
final int startRow;
final int cols;
@@ -264,7 +260,7 @@ public final class TableUtil {
}
}
static class TableRow {
static final class TableRow {
final XmlTag rowTag;
final List<TableCell> list;
final boolean insideHeader;

View File

@@ -14,10 +14,9 @@ import com.intellij.util.indexing.FileContent;
import com.intellij.xml.util.HtmlUtil;
import org.jetbrains.annotations.NotNull;
public class HtmlFileIncludeProvider extends FileIncludeProvider {
@NotNull
public final class HtmlFileIncludeProvider extends FileIncludeProvider {
@Override
public String getId() {
public @NotNull String getId() {
return "html";
}

View File

@@ -57,7 +57,7 @@ import java.util.List;
/**
* @author Dennis.Ushakov
*/
public class HtmlFileDropHandler extends CustomFileDropHandler {
public final class HtmlFileDropHandler extends CustomFileDropHandler {
@Override
public boolean canHandle(@NotNull Transferable t, @Nullable Editor editor) {
if (editor == null) return false;
@@ -190,8 +190,7 @@ public class HtmlFileDropHandler extends CustomFileDropHandler {
return true;
}
@Nullable
private static String prepareTagText(HtmlFileImpl target, String tagTemplate, String path) {
private static @Nullable String prepareTagText(HtmlFileImpl target, String tagTemplate, String path) {
return path != null ? MessageFormat.format(tagTemplate, XmlEditUtil.getAttributeQuote(target), path) : null;
}
@@ -200,8 +199,7 @@ public class HtmlFileDropHandler extends CustomFileDropHandler {
return FileUtil.getRelativePath(targetFile.getParent().getPath(), droppedFile.getPath(), '/');
}
@Nullable
private static VirtualFile getDroppedFile(@NotNull Transferable t) {
private static @Nullable VirtualFile getDroppedFile(@NotNull Transferable t) {
List<File> list = FileCopyPasteUtil.getFileList(t);
final File io = list != null && list.size() == 1 ? ContainerUtil.getFirstItem(list) : null;
return io != null ? VfsUtil.findFileByIoFile(io, true) : null;

View File

@@ -11,7 +11,7 @@ import com.intellij.ui.popup.PopupFactoryImpl;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
public class WebOpenInAction extends DumbAwareAction {
public final class WebOpenInAction extends DumbAwareAction {
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
@@ -19,7 +19,7 @@ public class WebOpenInAction extends DumbAwareAction {
}
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
public void actionPerformed(final @NotNull AnActionEvent e) {
DataContext dataContext = e.getDataContext();
ActionGroup group = getGroup();
ListPopup popup = JBPopupFactory.getInstance()

View File

@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class HtmlNonExistentInternetResourcesAnnotator extends WebReferencesAnnotatorBase {
public final class HtmlNonExistentInternetResourcesAnnotator extends WebReferencesAnnotatorBase {
public static boolean ourEnableInTestMode = false;
@Override
@@ -58,8 +58,7 @@ public class HtmlNonExistentInternetResourcesAnnotator extends WebReferencesAnno
return result.toArray(new WebReference[0]);
}
@Nullable
public static HtmlNonExistentInternetResourceInspection getInspection(@NotNull PsiElement context) {
public static @Nullable HtmlNonExistentInternetResourceInspection getInspection(@NotNull PsiElement context) {
final String shortName = HtmlNonExistentInternetResourceInspection.SHORT_NAME;
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
@@ -79,18 +78,16 @@ public class HtmlNonExistentInternetResourcesAnnotator extends WebReferencesAnno
return new IntentionAction[] {new MyDisableInspectionFix()};
}
@NotNull
@Override
protected HighlightDisplayLevel getHighlightDisplayLevel(@NotNull PsiElement context) {
protected @NotNull HighlightDisplayLevel getHighlightDisplayLevel(@NotNull PsiElement context) {
final InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(context.getProject()).getCurrentProfile();
final HighlightDisplayKey displayKey = HighlightDisplayKey.find(HtmlNonExistentInternetResourceInspection.SHORT_NAME);
return inspectionProfile.getErrorLevel(displayKey, context);
}
@NotNull
@Override
protected String getErrorMessage(@NotNull String url) {
protected @NotNull String getErrorMessage(@NotNull String url) {
return HtmlToolsBundle.message("html.inspections.non.existent.internet.resource.message", url);
}
@@ -103,15 +100,13 @@ public class HtmlNonExistentInternetResourcesAnnotator extends WebReferencesAnno
myDisableInspectionToolAction = new DisableInspectionToolAction(key);
}
@NotNull
@Override
public String getText() {
public @NotNull String getText() {
return HtmlToolsBundle.message("html.intention.disable.validation.web.links");
}
@NotNull
@Override
public String getFamilyName() {
public @NotNull String getFamilyName() {
return getText();
}
@@ -125,9 +120,8 @@ public class HtmlNonExistentInternetResourcesAnnotator extends WebReferencesAnno
myDisableInspectionToolAction.invoke(project, editor, file);
}
@Nullable
@Override
public PsiElement getElementToMakeWritable(@NotNull PsiFile file) {
public @Nullable PsiElement getElementToMakeWritable(@NotNull PsiFile file) {
return myDisableInspectionToolAction.getElementToMakeWritable(file);
}

View File

@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ExtractIncludeFromHTMLHandler extends ExtractIncludeFileBase<XmlTagChild> {
public final class ExtractIncludeFromHTMLHandler extends ExtractIncludeFileBase<XmlTagChild> {
private static final Logger LOG = Logger.getInstance(ExtractIncludeFromHTMLHandler.class);
@Override
@@ -36,7 +36,7 @@ public class ExtractIncludeFromHTMLHandler extends ExtractIncludeFileBase<XmlTag
try {
final XmlElementDescriptor descriptor = parentTag.getDescriptor();
LOG.assertTrue(descriptor != null);
@NonNls final String name = descriptor.getName();
final @NonNls String name = descriptor.getName();
if (HtmlUtil.SCRIPT_TAG_NAME.equals(name)) {
parentTag.setAttribute("src", includePath);
LOG.assertTrue(first.getParent() == parentTag);
@@ -79,8 +79,7 @@ public class ExtractIncludeFromHTMLHandler extends ExtractIncludeFileBase<XmlTag
}
@Override
@Nullable
protected Pair<XmlTagChild, XmlTagChild> findPairToExtract(final int start, final int end) {
protected @Nullable Pair<XmlTagChild, XmlTagChild> findPairToExtract(final int start, final int end) {
Pair<XmlTagChild, XmlTagChild> range = XmlUtil.findTagChildrenInRange(myIncludingFile, start, end);
if (range != null) {
if (range.first == range.second && range.first instanceof XmlTag) {

View File

@@ -8,25 +8,24 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class HtmlAddTableColumnAfterAction extends CodeInsightAction {
public final class HtmlAddTableColumnAfterAction extends CodeInsightAction {
private final CodeInsightActionHandler myHandler;
public HtmlAddTableColumnAfterAction() {
myHandler = new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public void invoke(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
TableColumnAdder.addColumn(project, editor, file, false);
}
};
}
@Override
@NotNull
protected final CodeInsightActionHandler getHandler() {
protected final @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}
@Override
public boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public boolean isValidForFile(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
return TableColumnAdder.isActionAvailable(editor, file);
}
}

View File

@@ -8,26 +8,25 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class HtmlAddTableColumnBeforeAction extends CodeInsightAction {
public final class HtmlAddTableColumnBeforeAction extends CodeInsightAction {
private final CodeInsightActionHandler myHandler;
public HtmlAddTableColumnBeforeAction() {
myHandler = new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public void invoke(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
TableColumnAdder.addColumn(project, editor, file, true);
}
};
}
@Override
@NotNull
protected final CodeInsightActionHandler getHandler() {
protected final @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}
@Override
protected boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
protected boolean isValidForFile(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
return TableColumnAdder.isActionAvailable(editor, file);
}
}

View File

@@ -8,13 +8,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class HtmlTableCellNavigateDownAction extends CodeInsightAction {
public final class HtmlTableCellNavigateDownAction extends CodeInsightAction {
private final CodeInsightActionHandler myHandler;
public HtmlTableCellNavigateDownAction() {
myHandler = new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public void invoke(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.DOWN);
}
@@ -25,13 +25,12 @@ public class HtmlTableCellNavigateDownAction extends CodeInsightAction {
};
}
@Override
@NotNull
protected final CodeInsightActionHandler getHandler() {
protected final @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}
@Override
protected boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
protected boolean isValidForFile(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
return TableCellNavigator.isActionAvailable(editor, file);
}
}

View File

@@ -8,13 +8,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class HtmlTableCellNavigateLeftAction extends CodeInsightAction {
public final class HtmlTableCellNavigateLeftAction extends CodeInsightAction {
private final CodeInsightActionHandler myHandler;
public HtmlTableCellNavigateLeftAction() {
myHandler = new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public void invoke(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.LEFT);
}
@@ -25,13 +25,12 @@ public class HtmlTableCellNavigateLeftAction extends CodeInsightAction {
};
}
@Override
@NotNull
protected final CodeInsightActionHandler getHandler() {
protected final @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}
@Override
protected boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
protected boolean isValidForFile(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
return TableCellNavigator.isActionAvailable(editor, file);
}
}

View File

@@ -8,13 +8,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class HtmlTableCellNavigateRightAction extends CodeInsightAction {
public final class HtmlTableCellNavigateRightAction extends CodeInsightAction {
private final CodeInsightActionHandler myHandler;
public HtmlTableCellNavigateRightAction() {
myHandler = new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public void invoke(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.RIGHT);
}
@@ -25,13 +25,12 @@ public class HtmlTableCellNavigateRightAction extends CodeInsightAction {
};
}
@Override
@NotNull
protected final CodeInsightActionHandler getHandler() {
protected final @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}
@Override
protected boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
protected boolean isValidForFile(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
return TableCellNavigator.isActionAvailable(editor, file);
}
}

View File

@@ -8,13 +8,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class HtmlTableCellNavigateUpAction extends CodeInsightAction {
public final class HtmlTableCellNavigateUpAction extends CodeInsightAction {
private final CodeInsightActionHandler myHandler;
public HtmlTableCellNavigateUpAction() {
myHandler = new CodeInsightActionHandler() {
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public void invoke(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
TableCellNavigator.moveCaret(project, editor, file, TableCellNavigator.Directions.UP);
}
@@ -25,13 +25,12 @@ public class HtmlTableCellNavigateUpAction extends CodeInsightAction {
};
}
@Override
@NotNull
protected final CodeInsightActionHandler getHandler() {
protected final @NotNull CodeInsightActionHandler getHandler() {
return myHandler;
}
@Override
public boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public boolean isValidForFile(final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) {
return TableCellNavigator.isActionAvailable(editor, file);
}
}

View File

@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
/**
* @author Maxim Mossienko
*/
public class CheckImageSizeInspection extends XmlSuppressableInspectionTool {
public final class CheckImageSizeInspection extends XmlSuppressableInspectionTool {
private static final Logger LOG = Logger.getInstance(CheckImageSizeInspection.class);
@Override
@@ -50,8 +50,7 @@ public class CheckImageSizeInspection extends XmlSuppressableInspectionTool {
}
@Override
@NotNull
public String getFamilyName() {
public @NotNull String getFamilyName() {
return myFamilyName;
}
@@ -71,8 +70,7 @@ public class CheckImageSizeInspection extends XmlSuppressableInspectionTool {
}
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
public @NotNull PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
return new XmlElementVisitor() {
@Override public void visitXmlAttribute(@NotNull XmlAttribute attribute) {
XmlTag parent = attribute.getParent();
@@ -121,9 +119,7 @@ public class CheckImageSizeInspection extends XmlSuppressableInspectionTool {
}
@Override
@NotNull
@NonNls
public String getShortName() {
public @NotNull @NonNls String getShortName() {
return "CheckImageSize";
}
}

View File

@@ -13,34 +13,26 @@ import org.jetbrains.annotations.Nullable;
import java.util.Set;
public final class ColorReference extends BasicAttributeValueReference {
@NonNls
static final Set<String> ourBgColorTagNames = Set.of("body", "td", "tr", "table", "th");
static final @NonNls Set<String> ourBgColorTagNames = Set.of("body", "td", "tr", "table", "th");
@NonNls
static final String BG_COLOR_ATTR_NAME = "bgcolor";
static final @NonNls String BG_COLOR_ATTR_NAME = "bgcolor";
@NonNls
static final String COLOR_ATTR_NAME = "color";
static final @NonNls String COLOR_ATTR_NAME = "color";
@NonNls
static final String ALINK_ATTR_NAME = "alink";
static final @NonNls String ALINK_ATTR_NAME = "alink";
@NonNls
static final String LINK_ATTR_NAME = "link";
static final @NonNls String LINK_ATTR_NAME = "link";
@NonNls
static final String VLINK_ATTR_NAME = "vlink";
static final @NonNls String VLINK_ATTR_NAME = "vlink";
@NonNls
static final String TEXT_ATTR_NAME = "text";
static final @NonNls String TEXT_ATTR_NAME = "text";
public ColorReference(final PsiElement element,int offset) {
super(element, offset);
}
@Override
@Nullable
public PsiElement resolve() {
public @Nullable PsiElement resolve() {
return myElement; // important for color doc
}

View File

@@ -48,13 +48,13 @@ import java.util.*;
import static com.intellij.util.ObjectUtils.doIfNotNull;
public class HtmlReferenceProvider extends PsiReferenceProvider {
@NonNls private static final String NAME_ATTR_LOCAL_NAME = "name";
@NonNls private static final String USEMAP_ATTR_NAME = "usemap";
@NonNls private static final String FOR_ATTR_NAME = "for";
@NonNls private static final String HREF_ATTRIBUTE_NAME = "href";
@NonNls private static final String SRC_ATTR_NAME = "src";
@NonNls private static final String JAVASCRIPT_PREFIX = "javascript:";
public final class HtmlReferenceProvider extends PsiReferenceProvider {
private static final @NonNls String NAME_ATTR_LOCAL_NAME = "name";
private static final @NonNls String USEMAP_ATTR_NAME = "usemap";
private static final @NonNls String FOR_ATTR_NAME = "for";
private static final @NonNls String HREF_ATTRIBUTE_NAME = "href";
private static final @NonNls String SRC_ATTR_NAME = "src";
private static final @NonNls String JAVASCRIPT_PREFIX = "javascript:";
public static final FileType[] IMAGE_FILE_TYPES = new FileType[]{ImageFileTypeManager.getInstance().getImageFileType()};
public static final String LABELLEDBY = "aria-labelledby";
@@ -77,15 +77,15 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
};
}
protected static boolean isAcceptableAttributeValue(PsiElement element) {
private static boolean isAcceptableAttributeValue(PsiElement element) {
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute xmlAttribute) {
@NonNls final String attrName = xmlAttribute.getName();
final @NonNls String attrName = xmlAttribute.getName();
XmlTag tag = xmlAttribute.getParent();
if (tag == null) return false;
@NonNls final String tagName = tag.getName();
final @NonNls String tagName = tag.getName();
return
( attrName.equalsIgnoreCase(SRC_ATTR_NAME) &&
@@ -170,7 +170,7 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
}
@Override
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) {
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, final @NotNull ProcessingContext context) {
final PsiElement parent = element.getParent();
if (!(parent instanceof XmlAttribute attribute)) return PsiReference.EMPTY_ARRAY;
final String localName = attribute.getLocalName();
@@ -295,18 +295,17 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
};
}
static class ContentTypeReference extends BasicAttributeValueReference {
private static @NonNls final String ourStyleContentType = "text/css";
static final class ContentTypeReference extends BasicAttributeValueReference {
private static final @NonNls String ourStyleContentType = "text/css";
@NonNls static final String TYPE_ATTR_NAME = "type";
static final @NonNls String TYPE_ATTR_NAME = "type";
ContentTypeReference(final PsiElement element) {
super(element);
}
@Override
@Nullable
public PsiElement resolve() {
public @Nullable PsiElement resolve() {
return null;
}
@@ -338,10 +337,10 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
}
}
public static class SizeReference extends BasicAttributeValueReference {
@NonNls static final String WIDTH_ATTR_NAME = "width";
@NonNls static final String HEIGHT_ATTR_NAME = "height";
@NonNls static final String IMAGE_TAG_NAME = "img";
public static final class SizeReference extends BasicAttributeValueReference {
static final @NonNls String WIDTH_ATTR_NAME = "width";
static final @NonNls String HEIGHT_ATTR_NAME = "height";
static final @NonNls String IMAGE_TAG_NAME = "img";
private final boolean myIsWidth;
@@ -354,8 +353,7 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
}
@Override
@Nullable
public PsiElement resolve() {
public @Nullable PsiElement resolve() {
final ImageInfoReader.Info info = getImageInfo();
if (info != null && info.width != 0 && info.height != 0) {
String text = getCanonicalText();
@@ -388,8 +386,7 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
return tag != null ? getImageInfo(tag) : null;
}
@Nullable
public static ImageInfoReader.Info getImageInfo(@NotNull final XmlTag tag) {
public static @Nullable ImageInfoReader.Info getImageInfo(final @NotNull XmlTag tag) {
return CachedValuesManager.getCachedValue(tag, () -> {
PsiElement srcValue = JBIterable.from(HtmlAttributeValueProvider.EP_NAME.getExtensionList())
.filterMap(it -> it.getCustomAttributeValue(tag, SRC_ATTR_NAME))
@@ -453,7 +450,7 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
}
}
private static class HtmlIdSelfReference extends AttributeValueSelfReference {
private static final class HtmlIdSelfReference extends AttributeValueSelfReference {
HtmlIdSelfReference(final PsiElement element, int offset) {
super(element, offset);
}
@@ -464,7 +461,7 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
IdRefReference.process(new PsiElementProcessor<>() {
@Override
public boolean execute(@NotNull final PsiElement element) {
public boolean execute(final @NotNull PsiElement element) {
if (element instanceof XmlTag) {
String forValue = ((XmlTag)element).getAttributeValue(IdReferenceProvider.FOR_ATTR_NAME);
if (forValue != null) {
@@ -479,7 +476,7 @@ public class HtmlReferenceProvider extends PsiReferenceProvider {
}
}
public static class HtmlIdRefReference extends IdRefReference {
public static final class HtmlIdRefReference extends IdRefReference {
public HtmlIdRefReference(PsiElement element, int offset) {
super(element, offset, true);
}

View File

@@ -16,13 +16,11 @@ import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class HtmlUpdateImageSizeIntention extends BaseIntentionAction {
public final class HtmlUpdateImageSizeIntention extends BaseIntentionAction {
private boolean myUseElementToTheLeft = false;
@Nls
@NotNull
@Override
public String getFamilyName() {
public @Nls @NotNull String getFamilyName() {
return HtmlToolsBundle.message("html.intention.update.image.size");
}
@@ -74,8 +72,7 @@ public class HtmlUpdateImageSizeIntention extends BaseIntentionAction {
}
}
@Nullable
private static ImageInfo getImageInfo(@NotNull XmlTag xmlTag) {
private static @Nullable ImageInfo getImageInfo(@NotNull XmlTag xmlTag) {
if (HtmlReferenceProvider.SizeReference.IMAGE_TAG_NAME.equalsIgnoreCase(xmlTag.getName())) {
return HtmlReferenceProvider.SizeReference.getImageInfo(xmlTag);
}
@@ -83,8 +80,7 @@ public class HtmlUpdateImageSizeIntention extends BaseIntentionAction {
}
@Nullable
private static XmlTag getTag(@NotNull PsiFile file, int offset) {
private static @Nullable XmlTag getTag(@NotNull PsiFile file, int offset) {
if (!HtmlUtil.hasHtml(file)) {
return null;
}

View File

@@ -8,7 +8,7 @@ import com.intellij.psi.PsiErrorElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class XHtmlErrorFilter extends HighlightErrorFilter {
public final class XHtmlErrorFilter extends HighlightErrorFilter {
@Override
public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement element) {
PsiFile containingFile = element.getContainingFile();