IJPL-159596 cleanup - sort modifiers

GitOrigin-RevId: c0e6edefefbbfb738d74c96b26697a7e55e93ac1
This commit is contained in:
Vladimir Krivosheev
2024-08-05 08:26:54 +02:00
committed by intellij-monorepo-bot
parent f1568d84fb
commit 035d071d3c
20 changed files with 153 additions and 287 deletions

View File

@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInspection;
@@ -56,16 +54,14 @@ public class DefaultXmlSuppressionProvider extends XmlSuppressionProvider implem
suppress(element.getContainingFile(), findSuppressionLeaf(tag, null, 0), inspectionId, tag.getTextRange().getStartOffset());
}
@Nullable
protected PsiElement findSuppression(final PsiElement anchor, final String id, PsiElement originalElement) {
protected @Nullable PsiElement findSuppression(final PsiElement anchor, final String id, PsiElement originalElement) {
final PsiElement element = findSuppressionLeaf(anchor, id, 0);
if (element != null) return element;
return findFileSuppression(anchor, id, originalElement);
}
@Nullable
protected PsiElement findFileSuppression(PsiElement anchor, String id, PsiElement originalElement) {
protected @Nullable PsiElement findFileSuppression(PsiElement anchor, String id, PsiElement originalElement) {
final PsiFile file = anchor.getContainingFile();
if (file instanceof XmlFile) {
final XmlDocument document = ((XmlFile)file).getDocument();
@@ -76,8 +72,7 @@ public class DefaultXmlSuppressionProvider extends XmlSuppressionProvider implem
return null;
}
@Nullable
protected PsiElement findSuppressionLeaf(PsiElement leaf, @Nullable final String id, int offset) {
protected @Nullable PsiElement findSuppressionLeaf(PsiElement leaf, final @Nullable String id, int offset) {
while (leaf != null && leaf.getTextOffset() >= offset) {
if (isSuppressedInComment(leaf, id)) {
return leaf;
@@ -107,7 +102,7 @@ public class DefaultXmlSuppressionProvider extends XmlSuppressionProvider implem
if (id == null) {
return true;
}
@NonNls final HashSet<String> parts = new HashSet<>(StringUtil.getWordsIn(text));
final @NonNls HashSet<String> parts = new HashSet<>(StringUtil.getWordsIn(text));
return parts.contains(id) || parts.contains(XmlSuppressableInspectionTool.ALL);
}
@@ -140,15 +135,13 @@ public class DefaultXmlSuppressionProvider extends XmlSuppressionProvider implem
return StringUtil.replace(originalText, getSuffix(), ", " + inspectionId + getSuffix());
}
@NonNls
protected String getPrefix() {
protected @NonNls String getPrefix() {
return "<!--" +
SUPPRESS_MARK +
" ";
}
@NonNls
protected String getSuffix() {
protected @NonNls String getSuffix() {
return " -->";
}
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInspection;
@@ -27,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool implements BatchSuppressableTool {
@NonNls static final String ALL = "ALL";
static final @NonNls String ALL = "ALL";
public static SuppressQuickFix @NotNull [] getSuppressFixes(@NotNull String toolId) {
return getSuppressFixes(toolId, new DefaultXmlSuppressionProvider());
@@ -59,20 +45,17 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool
}
@Override
@NotNull
public String getFamilyName() {
public @NotNull String getFamilyName() {
return getName();
}
@Nullable
@Override
public PsiElement getContainer(@Nullable PsiElement context) {
public @Nullable PsiElement getContainer(@Nullable PsiElement context) {
return null;
}
@NotNull
@Override
public ThreeState isShouldBeAppliedToInjectionHost() {
public @NotNull ThreeState isShouldBeAppliedToInjectionHost() {
return myShouldBeAppliedToInjectionHost;
}
@@ -97,9 +80,8 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool
super(id);
}
@NotNull
@Override
public String getName() {
public @NotNull String getName() {
return XmlPsiBundle.message("xml.suppressable.for.tag.title");
}
@@ -110,9 +92,8 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool
myProvider.suppressForTag(element, myId);
}
@Nullable
@Override
public PsiElement getContainer(@Nullable PsiElement context) {
public @Nullable PsiElement getContainer(@Nullable PsiElement context) {
return PsiTreeUtil.getParentOfType(context, XmlTag.class);
}
}
@@ -127,9 +108,8 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool
super(id);
}
@NotNull
@Override
public String getName() {
public @NotNull String getName() {
return XmlPsiBundle.message("xml.suppressable.for.file.title");
}
@@ -139,9 +119,8 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool
myProvider.suppressForFile(element, myId);
}
@Nullable
@Override
public PsiElement getContainer(@Nullable PsiElement context) {
public @Nullable PsiElement getContainer(@Nullable PsiElement context) {
return context == null || !context.isValid() ? null : context.getContainingFile();
}
}
@@ -155,9 +134,8 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool
super(ALL);
}
@NotNull
@Override
public String getName() {
public @NotNull String getName() {
return XmlPsiBundle.message("xml.suppressable.all.for.file.title");
}
}

View File

@@ -33,8 +33,7 @@ public abstract class ExternalResourceManager extends SimpleModificationTracker
public abstract String getResourceLocation(@NotNull @NonNls String url, @NotNull Project project);
@Nullable
public abstract PsiFile getResourceLocation(@NotNull @NonNls String url, @NotNull PsiFile baseFile, @Nullable String version);
public abstract @Nullable PsiFile getResourceLocation(@NotNull @NonNls String url, @NotNull PsiFile baseFile, @Nullable String version);
public abstract String[] getResourceUrls(@Nullable FileType fileType, boolean includeStandard);

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.javaee;
import com.intellij.openapi.util.text.StringUtil;
@@ -15,21 +15,18 @@ public final class UriUtil {
* @deprecated use {@link #findRelative(String, PsiFileSystemItem)}
*/
@Deprecated(forRemoval = true)
@Nullable
public static VirtualFile findRelativeFile(String uri, VirtualFile base) {
public static @Nullable VirtualFile findRelativeFile(String uri, VirtualFile base) {
return VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(uri), base);
}
@Nullable
public static VirtualFile findRelative(String uri, @NotNull PsiFileSystemItem base) {
public static @Nullable VirtualFile findRelative(String uri, @NotNull PsiFileSystemItem base) {
String location = ExternalResourceManager.getInstance().getResourceLocation(uri, base.getProject());
VirtualFile file = base.getVirtualFile();
return VfsUtilCore.findRelativeFile(location, file != null && file.isValid() ? file : null);
}
// cannot use UriUtil.SLASH_MATCHER.trimFrom - we don't depend on guava
@NotNull
public static String trimSlashFrom(@NotNull String path) {
public static @NotNull String trimSlashFrom(@NotNull String path) {
return StringUtil.trimStart(StringUtil.trimEnd(path, "/"), "/");
}
}

View File

@@ -1,18 +1,18 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.patterns;
import com.intellij.psi.xml.*;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.*;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NonNls;
public class XmlAttributeValuePattern extends XmlElementPattern<XmlAttributeValue,XmlAttributeValuePattern>{
static final XmlAttributeValuePattern XML_ATTRIBUTE_VALUE_PATTERN = new XmlAttributeValuePattern(
new InitialPatternCondition<>(XmlAttributeValue.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
public boolean accepts(final @Nullable Object o, final ProcessingContext context) {
return o instanceof XmlAttributeValue;
}
});
@@ -35,7 +35,7 @@ public class XmlAttributeValuePattern extends XmlElementPattern<XmlAttributeValu
public XmlAttributeValuePattern withLocalName(ElementPattern<String> namePattern) {
return with(new PsiNamePatternCondition<>("withLocalName", namePattern) {
@Override
public String getPropertyValue(@NotNull final Object o) {
public String getPropertyValue(final @NotNull Object o) {
if (o instanceof XmlAttributeValue) {
return getLocalName((XmlAttributeValue)o);
}
@@ -44,8 +44,28 @@ public class XmlAttributeValuePattern extends XmlElementPattern<XmlAttributeValu
});
}
@Nullable
public static String getLocalName(@NotNull XmlAttributeValue value) {
public XmlAttributeValuePattern withNamespace(ElementPattern<String> namePattern) {
return with(new PsiNamePatternCondition<>("withNamespace", namePattern) {
@Override
public String getPropertyValue(final @NotNull Object o) {
if (o instanceof XmlAttributeValue) {
final PsiElement parent = ((XmlAttributeValue)o).getParent();
if (parent instanceof XmlAttribute) {
return ((XmlAttribute)parent).getNamespace();
}
}
return null;
}
});
}
public XmlAttributeValuePattern withNamespace(@NonNls String... names) {
return names.length == 1
? withNamespace(StandardPatterns.string().equalTo(names[0]))
: withNamespace(StandardPatterns.string().oneOf(names));
}
public static @Nullable String getLocalName(@NotNull XmlAttributeValue value) {
final PsiElement parent = value.getParent();
if (parent instanceof XmlAttribute) {
return ((XmlAttribute)parent).getLocalName();
@@ -62,28 +82,6 @@ public class XmlAttributeValuePattern extends XmlElementPattern<XmlAttributeValu
}
}
public XmlAttributeValuePattern withNamespace(@NonNls String... names) {
return names.length == 1
? withNamespace(StandardPatterns.string().equalTo(names[0]))
: withNamespace(StandardPatterns.string().oneOf(names));
}
public XmlAttributeValuePattern withNamespace(ElementPattern<String> namePattern) {
return with(new PsiNamePatternCondition<>("withNamespace", namePattern) {
@Override
public String getPropertyValue(@NotNull final Object o) {
if (o instanceof XmlAttributeValue) {
final PsiElement parent = ((XmlAttributeValue)o).getParent();
if (parent instanceof XmlAttribute) {
return ((XmlAttribute)parent).getNamespace();
}
}
return null;
}
});
}
public XmlAttributeValuePattern withValue(final StringPattern valuePattern) {
return with(new PatternCondition<>("withValue") {
@Override

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.patterns;
import com.intellij.psi.xml.XmlElement;
@@ -27,7 +13,7 @@ public class XmlElementPattern<T extends XmlElement,Self extends XmlElementPatte
super(aClass);
}
XmlElementPattern(@NotNull final InitialPatternCondition<T> condition) {
XmlElementPattern(final @NotNull InitialPatternCondition<T> condition) {
super(condition);
}
@@ -35,7 +21,7 @@ public class XmlElementPattern<T extends XmlElement,Self extends XmlElementPatte
Capture() {
super(new InitialPatternCondition<>(XmlElement.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
public boolean accepts(final @Nullable Object o, final ProcessingContext context) {
return o instanceof XmlElement;
}
});
@@ -46,7 +32,7 @@ public class XmlElementPattern<T extends XmlElement,Self extends XmlElementPatte
XmlTextPattern() {
super(new InitialPatternCondition<>(XmlText.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
public boolean accepts(final @Nullable Object o, final ProcessingContext context) {
return o instanceof XmlText;
}
});
@@ -57,7 +43,7 @@ public class XmlElementPattern<T extends XmlElement,Self extends XmlElementPatte
XmlEntityRefPattern() {
super(new InitialPatternCondition<>(XmlEntityRef.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
public boolean accepts(final @Nullable Object o, final ProcessingContext context) {
return o instanceof XmlEntityRef;
}
});

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.patterns;
import com.intellij.psi.xml.XmlDocument;
@@ -27,14 +13,14 @@ public class XmlFilePattern<Self extends XmlFilePattern<Self>> extends PsiFilePa
super(XmlFile.class);
}
protected XmlFilePattern(@NotNull final InitialPatternCondition<XmlFile> condition) {
protected XmlFilePattern(final @NotNull InitialPatternCondition<XmlFile> condition) {
super(condition);
}
public Self withRootTag(final ElementPattern<XmlTag> rootTag) {
return with(new PatternCondition<>("withRootTag") {
@Override
public boolean accepts(@NotNull final XmlFile xmlFile, final ProcessingContext context) {
public boolean accepts(final @NotNull XmlFile xmlFile, final ProcessingContext context) {
XmlDocument document = xmlFile.getDocument();
return document != null && rootTag.accepts(document.getRootTag(), context);
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.patterns;
import com.intellij.psi.PsiNamedElement;
@@ -26,7 +12,7 @@ import org.jetbrains.annotations.Nullable;
public abstract class XmlNamedElementPattern<T extends XmlElement & PsiNamedElement,Self extends XmlNamedElementPattern<T,Self>> extends XmlElementPattern<T,Self>{
public XmlNamedElementPattern(@NotNull final InitialPatternCondition<T> condition) {
public XmlNamedElementPattern(final @NotNull InitialPatternCondition<T> condition) {
super(condition);
}
@@ -44,17 +30,17 @@ public abstract class XmlNamedElementPattern<T extends XmlElement & PsiNamedElem
public Self withLocalName(final ElementPattern<String> localName) {
return with(new PsiNamePatternCondition<>("withLocalName", localName) {
@Override
public String getPropertyValue(@NotNull final Object o) {
public String getPropertyValue(final @NotNull Object o) {
return o instanceof XmlElement ? getLocalName((T)o) : null;
}
});
}
public Self withNamespace(@NonNls final String namespace) {
public Self withNamespace(final @NonNls String namespace) {
return withNamespace(StandardPatterns.string().equalTo(namespace));
}
public Self withNamespace(@NonNls final String... namespaces) {
public Self withNamespace(final @NonNls String... namespaces) {
return withNamespace(StandardPatterns.string().oneOf(namespaces));
}
@@ -73,7 +59,7 @@ public abstract class XmlNamedElementPattern<T extends XmlElement & PsiNamedElem
protected XmlAttributePattern() {
super(new InitialPatternCondition<>(XmlAttribute.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
public boolean accepts(final @Nullable Object o, final ProcessingContext context) {
return o instanceof XmlAttribute;
}
});

View File

@@ -1,27 +1,28 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.patterns;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ProcessingContext;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
public class XmlTagPattern<Self extends XmlTagPattern<Self>> extends XmlNamedElementPattern<XmlTag, Self> {
protected XmlTagPattern() {
super(new InitialPatternCondition<>(XmlTag.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
public boolean accepts(final @Nullable Object o, final ProcessingContext context) {
return o instanceof XmlTag;
}
});
}
protected XmlTagPattern(@NotNull final InitialPatternCondition<XmlTag> condition) {
protected XmlTagPattern(final @NotNull InitialPatternCondition<XmlTag> condition) {
super(condition);
}
@@ -35,19 +36,19 @@ public class XmlTagPattern<Self extends XmlTagPattern<Self>> extends XmlNamedEle
return tag.getNamespace();
}
public Self withAttributeValue(@NotNull @NonNls final String attributeName, @NotNull final String attributeValue) {
public Self withAttributeValue(final @NotNull @NonNls String attributeName, final @NotNull String attributeValue) {
return with(new PatternCondition<>("withAttributeValue") {
@Override
public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) {
public boolean accepts(final @NotNull XmlTag xmlTag, final ProcessingContext context) {
return Objects.equals(xmlTag.getAttributeValue(attributeName), attributeValue);
}
});
}
public Self withAnyAttribute(@NonNls final String @NotNull ... attributeNames) {
public Self withAnyAttribute(final @NonNls String @NotNull ... attributeNames) {
return with(new PatternCondition<>("withAnyAttribute") {
@Override
public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) {
public boolean accepts(final @NotNull XmlTag xmlTag, final ProcessingContext context) {
for (String attributeName : attributeNames) {
if (xmlTag.getAttribute(attributeName) != null) {
return true;
@@ -58,19 +59,19 @@ public class XmlTagPattern<Self extends XmlTagPattern<Self>> extends XmlNamedEle
});
}
public Self withDescriptor(@NotNull final ElementPattern<? extends PsiMetaData> metaDataPattern) {
public Self withDescriptor(final @NotNull ElementPattern<? extends PsiMetaData> metaDataPattern) {
return with(new PatternCondition<>("withDescriptor") {
@Override
public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) {
public boolean accepts(final @NotNull XmlTag xmlTag, final ProcessingContext context) {
return metaDataPattern.accepts(xmlTag.getDescriptor());
}
});
}
public Self isFirstSubtag(@NotNull final ElementPattern pattern) {
public Self isFirstSubtag(final @NotNull ElementPattern pattern) {
return with(new PatternCondition<>("isFirstSubtag") {
@Override
public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) {
public boolean accepts(final @NotNull XmlTag xmlTag, final ProcessingContext context) {
final XmlTag parent = xmlTag.getParentTag();
return parent != null &&
pattern.accepts(parent, context) && parent.getSubTags()[0] == xmlTag;
@@ -78,20 +79,20 @@ public class XmlTagPattern<Self extends XmlTagPattern<Self>> extends XmlNamedEle
});
}
public Self withFirstSubTag(@NotNull final ElementPattern<? extends XmlTag> pattern) {
public Self withFirstSubTag(final @NotNull ElementPattern<? extends XmlTag> pattern) {
return withSubTags(StandardPatterns.<XmlTag>collection().first(pattern));
}
public Self withSubTags(@NotNull final ElementPattern<? extends Collection<XmlTag>> pattern) {
public Self withSubTags(final @NotNull ElementPattern<? extends Collection<XmlTag>> pattern) {
return with(new PatternCondition<>("withSubTags") {
@Override
public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) {
public boolean accepts(final @NotNull XmlTag xmlTag, final ProcessingContext context) {
return pattern.accepts(Arrays.asList(xmlTag.getSubTags()), context);
}
});
}
public Self withoutAttributeValue(@NotNull @NonNls final String attributeName, @NotNull final String attributeValue) {
public Self withoutAttributeValue(final @NotNull @NonNls String attributeName, final @NotNull String attributeValue) {
return and(StandardPatterns.not(withAttributeValue(attributeName, attributeValue)));
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi;
import com.intellij.lang.Language;
@@ -26,8 +26,7 @@ public abstract class XmlElementFactory {
* @return the created element.
* @throws IncorrectOperationException if the creation failed for some reason.
*/
@NotNull
public abstract XmlText createDisplayText(@NotNull @NonNls String s) throws IncorrectOperationException;
public abstract @NotNull XmlText createDisplayText(@NotNull @NonNls String s) throws IncorrectOperationException;
/**
* Creates an XHTML tag with the specified text.
@@ -36,8 +35,7 @@ public abstract class XmlElementFactory {
* @return the created tag instance.
* @throws IncorrectOperationException if the text does not specify a valid XML fragment.
*/
@NotNull
public abstract XmlTag createXHTMLTagFromText(@NotNull @NonNls String s) throws IncorrectOperationException;
public abstract @NotNull XmlTag createXHTMLTagFromText(@NotNull @NonNls String s) throws IncorrectOperationException;
/**
* Creates an HTML tag with the specified text.
@@ -46,8 +44,7 @@ public abstract class XmlElementFactory {
* @return the created tag instance.
* @throws IncorrectOperationException if the text does not specify a valid XML fragment.
*/
@NotNull
public abstract XmlTag createHTMLTagFromText(@NotNull @NonNls String s) throws IncorrectOperationException;
public abstract @NotNull XmlTag createHTMLTagFromText(@NotNull @NonNls String s) throws IncorrectOperationException;
/**
* Creates an XML tag with the specified text.
@@ -57,8 +54,7 @@ public abstract class XmlElementFactory {
* @throws IncorrectOperationException if the text does not specify a valid XML fragment.
* @see #createTagFromText(CharSequence text, Language language)
*/
@NotNull
public abstract XmlTag createTagFromText(@NotNull @NonNls CharSequence text) throws IncorrectOperationException;
public abstract @NotNull XmlTag createTagFromText(@NotNull @NonNls CharSequence text) throws IncorrectOperationException;
/**
* Creates XML like tag with the specified text and language.
@@ -69,8 +65,7 @@ public abstract class XmlElementFactory {
* @throws IncorrectOperationException if the text does not specify a valid XML fragment.
* @see #createTagFromText(CharSequence)
*/
@NotNull
public abstract XmlTag createTagFromText(@NotNull @NonNls CharSequence text, @NotNull Language language) throws IncorrectOperationException;
public abstract @NotNull XmlTag createTagFromText(@NotNull @NonNls CharSequence text, @NotNull Language language) throws IncorrectOperationException;
/**
* Creates an XML attribute with the specified name and value.
@@ -80,8 +75,7 @@ public abstract class XmlElementFactory {
* @return the created attribute instance.
* @throws IncorrectOperationException if either {@code name} or {@code value} are not valid.
*/
@NotNull
public abstract XmlAttribute createXmlAttribute(@NotNull @NonNls String name, @NotNull String value) throws IncorrectOperationException;
public abstract @NotNull XmlAttribute createXmlAttribute(@NotNull @NonNls String name, @NotNull String value) throws IncorrectOperationException;
/**
* Creates an attribute with the specified name and value with given context.
@@ -92,8 +86,7 @@ public abstract class XmlElementFactory {
* @return the created attribute instance.
* @throws IncorrectOperationException if either {@code name} or {@code value} are not valid.
*/
@NotNull
public abstract XmlAttribute createAttribute(@NotNull @NonNls String name, @NotNull String value, @Nullable PsiElement context) throws IncorrectOperationException;
public abstract @NotNull XmlAttribute createAttribute(@NotNull @NonNls String name, @NotNull String value, @Nullable PsiElement context) throws IncorrectOperationException;
/**
* Creates an attribute with the specified name and value quoted with given quotes and with given context.
@@ -105,7 +98,6 @@ public abstract class XmlElementFactory {
* @return the created attribute instance.
* @throws IncorrectOperationException if either {@code name} or {@code value} are not valid.
*/
@NotNull
public abstract XmlAttribute createAttribute(@NotNull @NonNls String name, @NotNull String value, @Nullable Character quoteStyle,
public abstract @NotNull XmlAttribute createAttribute(@NotNull @NonNls String name, @NotNull String value, @Nullable Character quoteStyle,
@Nullable PsiElement context) throws IncorrectOperationException;
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* @author max
@@ -35,12 +21,12 @@ public class XmlRecursiveElementVisitor extends XmlElementVisitor implements Psi
}
@Override
public void visitElement(@NotNull final PsiElement element) {
public void visitElement(final @NotNull PsiElement element) {
element.acceptChildren(this);
}
@Override
public void visitFile(@NotNull final PsiFile file) {
public void visitFile(final @NotNull PsiFile file) {
if (myVisitAllFileRoots) {
final FileViewProvider viewProvider = file.getViewProvider();
final List<PsiFile> allFiles = viewProvider.getAllFiles();

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* @author max
@@ -36,12 +22,12 @@ public class XmlRecursiveElementWalkingVisitor extends XmlElementVisitor impleme
}
@Override
public void visitElement(@NotNull final PsiElement element) {
public void visitElement(final @NotNull PsiElement element) {
myWalkingState.elementStarted(element);
}
@Override
public void visitFile(@NotNull final PsiFile file) {
public void visitFile(final @NotNull PsiFile file) {
if (myVisitAllFileRoots) {
final FileViewProvider viewProvider = file.getViewProvider();
final List<PsiFile> allFiles = viewProvider.getAllFiles();

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.xml;
import com.intellij.openapi.util.NlsSafe;
@@ -24,9 +24,8 @@ public interface XmlAttributeValue extends XmlElement, PsiLiteralValue, XmlNamed
TextRange getValueTextRange();
@Experimental
@Nullable
@Override
default String getHostName() {
default @Nullable String getHostName() {
return XmlAttributeValuePattern.getLocalName(this);
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.xml;
import com.intellij.openapi.util.NlsSafe;
@@ -99,15 +99,13 @@ public interface XmlTag extends XmlElement, PsiNamedElement, PsiMetaOwner, XmlTa
return true;
}
@Nullable
default @NlsSafe String getRealNs(@Nullable String value) {
default @Nullable @NlsSafe String getRealNs(@Nullable String value) {
return value;
}
@Experimental
@Nullable
@Override
default @NlsSafe String getHostName() {
default @Nullable @NlsSafe String getHostName() {
return getLocalName();
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xml;
@@ -33,8 +33,7 @@ public interface XmlAttributeDescriptor extends PsiMetaData {
@DetailedDescription
String validateValue(XmlElement context, String value);
@NotNull
default Collection<PsiElement> getDeclarations() {
default @NotNull Collection<PsiElement> getDeclarations() {
PsiElement declaration = getDeclaration();
return declaration != null ? Collections.singleton(declaration)
: Collections.emptyList();

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xml;
import com.intellij.openapi.project.PossiblyDumbAware;
@@ -13,9 +13,9 @@ public interface XmlNSDescriptor extends PsiMetaData, PossiblyDumbAware {
@Nullable
XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag);
XmlElementDescriptor @NotNull [] getRootElementsDescriptors(@Nullable final XmlDocument document);
XmlElementDescriptor @NotNull [] getRootElementsDescriptors(final @Nullable XmlDocument document);
default XmlElementDescriptor @NotNull [] getAllElementsDescriptors(@Nullable final XmlDocument document) {
default XmlElementDescriptor @NotNull [] getAllElementsDescriptors(final @Nullable XmlDocument document) {
return getRootElementsDescriptors(document);
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xml;
import com.intellij.diagnostic.PluginException;
@@ -68,19 +68,16 @@ public class XmlNamedReferenceProviderBean extends CustomLoadingExtensionPointBe
@RequiredElement
public String implementationClass;
@Nullable
@Override
protected String getImplementationClassName() {
protected @Nullable String getImplementationClassName() {
return implementationClass;
}
@NotNull
public Class<? extends XmlNamedReferenceHost> getHostElementClass() {
public @NotNull Class<? extends XmlNamedReferenceHost> getHostElementClass() {
return loadClass(hostElementClass);
}
@NotNull
public Class<? extends Symbol> getResolveTargetClass() {
public @NotNull Class<? extends Symbol> getResolveTargetClass() {
return loadClass(targetClass);
}

View File

@@ -24,8 +24,36 @@ import java.util.Set;
public abstract class XmlSchemaProvider implements PossiblyDumbAware {
public static final ExtensionPointName<XmlSchemaProvider> EP_NAME = new ExtensionPointName<>("com.intellij.xml.schemaProvider");
@Nullable
public static XmlFile findSchema(@NotNull @NonNls String namespace, @Nullable Module module, @NotNull PsiFile file) {
public abstract @Nullable XmlFile getSchema(@NotNull @NonNls String url, @Nullable Module module, final @NotNull PsiFile baseFile);
public boolean isAvailable(final @NotNull XmlFile file) {
return false;
}
public static @NotNull List<XmlSchemaProvider> getAvailableProviders(@NotNull XmlFile file) {
return ContainerUtil.findAll(EP_NAME.getExtensionList(), xmlSchemaProvider -> xmlSchemaProvider.isAvailable(file));
}
/**
* Provides specific namespaces for given XML file.
*
* @param file XML or JSP file.
* @param tagName optional
* @return available namespace uris, or {@code null} if the provider did not recognize the file.
*/
public @NotNull Set<String> getAvailableNamespaces(final @NotNull XmlFile file, final @Nullable String tagName) {
return Collections.emptySet();
}
public @Nullable String getDefaultPrefix(@NotNull @NonNls String namespace, final @NotNull XmlFile context) {
return null;
}
public @Nullable Set<String> getLocations(@NotNull @NonNls String namespace, final @NotNull XmlFile context) {
return null;
}
public static @Nullable XmlFile findSchema(@NotNull @NonNls String namespace, @Nullable Module module, @NotNull PsiFile file) {
if (file.getProject().isDefault()) return null;
for (XmlSchemaProvider provider : EP_NAME.getExtensionList()) {
if (!DumbService.getInstance(file.getProject()).isUsableInCurrentContext(provider)) {
@@ -43,43 +71,8 @@ public abstract class XmlSchemaProvider implements PossiblyDumbAware {
return null;
}
@Nullable
public static XmlFile findSchema(@NotNull @NonNls String namespace, @NotNull PsiFile baseFile) {
public static @Nullable XmlFile findSchema(@NotNull @NonNls String namespace, @NotNull PsiFile baseFile) {
final Module module = ModuleUtilCore.findModuleForPsiElement(baseFile);
return findSchema(namespace, module, baseFile);
}
public static @NotNull List<XmlSchemaProvider> getAvailableProviders(@NotNull XmlFile file) {
return ContainerUtil.findAll(EP_NAME.getExtensionList(), xmlSchemaProvider -> xmlSchemaProvider.isAvailable(file));
}
@Nullable
public abstract XmlFile getSchema(@NotNull @NonNls String url, @Nullable Module module, @NotNull final PsiFile baseFile);
public boolean isAvailable(@NotNull final XmlFile file) {
return false;
}
/**
* Provides specific namespaces for given XML file.
*
* @param file XML or JSP file.
* @param tagName optional
* @return available namespace uris, or {@code null} if the provider did not recognize the file.
*/
@NotNull
public Set<String> getAvailableNamespaces(@NotNull final XmlFile file, @Nullable final String tagName) {
return Collections.emptySet();
}
@Nullable
public String getDefaultPrefix(@NotNull @NonNls String namespace, @NotNull final XmlFile context) {
return null;
}
@Nullable
public Set<String> getLocations(@NotNull @NonNls String namespace, @NotNull final XmlFile context) {
return null;
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xml.psi;
import com.intellij.DynamicBundle;
@@ -10,19 +10,17 @@ import org.jetbrains.annotations.PropertyKey;
import java.util.function.Supplier;
public final class XmlPsiBundle {
@NonNls private static final String BUNDLE = "messages.XmlPsiBundle";
private static final @NonNls String BUNDLE = "messages.XmlPsiBundle";
private static final DynamicBundle INSTANCE = new DynamicBundle(XmlPsiBundle.class, BUNDLE);
private XmlPsiBundle() {
}
@NotNull
public static @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
public static @NotNull @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
return INSTANCE.getMessage(key, params);
}
@NotNull
public static Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
public static @NotNull Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
return INSTANCE.getLazyMessage(key, params);
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xml.util;
import com.intellij.lang.ASTNode;
@@ -85,8 +85,7 @@ public final class XmlTagUtil {
return c==-1?0:(char)c;
}
@Nullable
public static XmlToken getStartTagNameElement(@NotNull XmlTag tag) {
public static @Nullable XmlToken getStartTagNameElement(@NotNull XmlTag tag) {
final ASTNode node = tag.getNode();
if (node == null) return null;
@@ -100,8 +99,7 @@ public final class XmlTagUtil {
return current == null ? null : (XmlToken)current.getPsi();
}
@Nullable
public static XmlToken getEndTagNameElement(@NotNull XmlTag tag) {
public static @Nullable XmlToken getEndTagNameElement(@NotNull XmlTag tag) {
final ASTNode node = tag.getNode();
if (node == null) return null;
@@ -121,8 +119,7 @@ public final class XmlTagUtil {
return null;
}
@NotNull
public static TextRange getTrimmedValueRange(final @NotNull XmlTag tag) {
public static @NotNull TextRange getTrimmedValueRange(final @NotNull XmlTag tag) {
XmlTagValue tagValue = tag.getValue();
final String text = tagValue.getText();
final String trimmed = text.trim();
@@ -131,21 +128,18 @@ public final class XmlTagUtil {
return new TextRange(startOffset, startOffset + trimmed.length());
}
@Nullable
public static TextRange getStartTagRange(@NotNull XmlTag tag) {
public static @Nullable TextRange getStartTagRange(@NotNull XmlTag tag) {
XmlToken tagName = getStartTagNameElement(tag);
return getTagRange(tagName, XmlTokenType.XML_START_TAG_START);
}
@Nullable
public static TextRange getEndTagRange(@NotNull XmlTag tag) {
public static @Nullable TextRange getEndTagRange(@NotNull XmlTag tag) {
XmlToken tagName = getEndTagNameElement(tag);
return getTagRange(tagName, XmlTokenType.XML_END_TAG_START);
}
@Nullable
private static TextRange getTagRange(@Nullable XmlToken tagName, IElementType tagStart) {
private static @Nullable TextRange getTagRange(@Nullable XmlToken tagName, IElementType tagStart) {
if (tagName == null) {
return null;
}