diff --git a/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java b/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java index 0a6f28b7eccd..fda1f3ecc8e3 100644 --- a/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java +++ b/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java @@ -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.util.ProcessingContext; @@ -31,7 +17,7 @@ public class DomElementPattern condition) { + protected DomElementPattern(final @NotNull InitialPatternCondition condition) { super(condition); } @@ -41,7 +27,7 @@ public class DomElementPattern children = new ArrayList<>(); domElement.acceptChildren(new DomElementVisitor() { @Override @@ -59,10 +45,10 @@ public class DomElementPattern("withChild") { @Override - public boolean accepts(@NotNull final T t, final ProcessingContext context) { + public boolean accepts(final @NotNull T t, final ProcessingContext context) { for (final AbstractDomChildrenDescription description : t.getGenericInfo().getChildrenDescriptions()) { if (!(description instanceof DomChildrenDescription) || localName.equals(((DomChildrenDescription)description).getXmlElementName())) { diff --git a/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java b/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java index e940689cbade..e2a17ae19c52 100644 --- a/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java +++ b/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java @@ -1,30 +1,16 @@ -/* - * 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.util.ProcessingContext; import com.intellij.util.xml.DomUtil; import com.intellij.util.xml.GenericDomValue; -import com.intellij.util.ProcessingContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class GenericDomValuePattern extends DomElementPattern, GenericDomValuePattern>{ private static final InitialPatternCondition CONDITION = new InitialPatternCondition(GenericDomValue.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 GenericDomValue; } }; @@ -36,7 +22,7 @@ public class GenericDomValuePattern extends DomElementPattern aClass) { super(new InitialPatternCondition(aClass) { @Override - public boolean accepts(@Nullable final Object o, final ProcessingContext context) { + public boolean accepts(final @Nullable Object o, final ProcessingContext context) { return o instanceof GenericDomValue && aClass.equals(DomUtil.getGenericValueParameter(((GenericDomValue)o).getDomElementType())); } @@ -46,20 +32,20 @@ public class GenericDomValuePattern extends DomElementPattern withStringValue(final ElementPattern pattern) { return with(new PatternCondition<>("withStringValue") { @Override - public boolean accepts(@NotNull final GenericDomValue genericDomValue, final ProcessingContext context) { + public boolean accepts(final @NotNull GenericDomValue genericDomValue, final ProcessingContext context) { return pattern.accepts(genericDomValue.getStringValue(), context); } }); } - public GenericDomValuePattern withValue(@NotNull final T value) { + public GenericDomValuePattern withValue(final @NotNull T value) { return withValue(StandardPatterns.object(value)); } public GenericDomValuePattern withValue(final ElementPattern pattern) { return with(new PatternCondition<>("withValue") { @Override - public boolean accepts(@NotNull final GenericDomValue genericDomValue, final ProcessingContext context) { + public boolean accepts(final @NotNull GenericDomValue genericDomValue, final ProcessingContext context) { return pattern.accepts(genericDomValue.getValue(), context); } }); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java b/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java index bf0697c63773..9c632ba04b52 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.util.xml; import com.intellij.openapi.module.Module; @@ -35,14 +21,12 @@ public abstract class AbstractConvertContext extends ConvertContext { } @Override - @Nullable - public XmlElement getXmlElement() { + public @Nullable XmlElement getXmlElement() { return getInvocationElement().getXmlElement(); } @Override - @NotNull - public final XmlFile getFile() { + public final @NotNull XmlFile getFile() { return DomUtil.getFile(getInvocationElement()); } @@ -57,8 +41,7 @@ public abstract class AbstractConvertContext extends ConvertContext { } @Override - @Nullable - public GlobalSearchScope getSearchScope() { + public @Nullable GlobalSearchScope getSearchScope() { GlobalSearchScope scope = null; Module[] modules = getConvertContextModules(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ConvertContext.java b/xml/dom-openapi/src/com/intellij/util/xml/ConvertContext.java index af4fa1a4e8c1..bb0c89c202de 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ConvertContext.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ConvertContext.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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.util.xml; import com.intellij.openapi.module.Module; @@ -28,17 +14,13 @@ import org.jetbrains.annotations.Nullable; public abstract class ConvertContext { - @NotNull - public abstract DomElement getInvocationElement(); + public abstract @NotNull DomElement getInvocationElement(); - @Nullable - public abstract XmlTag getTag(); + public abstract @Nullable XmlTag getTag(); - @Nullable - public abstract XmlElement getXmlElement(); + public abstract @Nullable XmlElement getXmlElement(); - @Nullable - public XmlElement getReferenceXmlElement() { + public @Nullable XmlElement getReferenceXmlElement() { final XmlElement element = getXmlElement(); if (element instanceof XmlTag) { return element; @@ -49,14 +31,11 @@ public abstract class ConvertContext { return null; } - @NotNull - public abstract XmlFile getFile(); + public abstract @NotNull XmlFile getFile(); - @Nullable - public abstract Module getModule(); + public abstract @Nullable Module getModule(); - @Nullable - public abstract GlobalSearchScope getSearchScope(); + public abstract @Nullable GlobalSearchScope getSearchScope(); public PsiManager getPsiManager() { return PsiManager.getInstance(getProject()); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/Converter.java b/xml/dom-openapi/src/com/intellij/util/xml/Converter.java index ab1541a39dad..5d1a34fed5c8 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/Converter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/Converter.java @@ -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.util.xml; import com.intellij.codeInspection.util.InspectionMessage; @@ -29,19 +15,15 @@ import org.jetbrains.annotations.Nullable; * @param Type to convert from/to. */ public abstract class Converter { - @Nullable - public abstract T fromString(@Nullable @NonNls String s, final ConvertContext context); - @Nullable - public abstract String toString(@Nullable T t, final ConvertContext context); + public abstract @Nullable T fromString(@Nullable @NonNls String s, final ConvertContext context); + public abstract @Nullable String toString(@Nullable T t, final ConvertContext context); /** * @param s string value that couldn't be resolved * @param context context * @return error message used to highlight the errors somewhere in the UI, most often - like unresolved references in XML */ - @InspectionMessage - @Nullable - public String getErrorMessage(@Nullable String s, final ConvertContext context) { + public @InspectionMessage @Nullable String getErrorMessage(@Nullable String s, final ConvertContext context) { return XmlDomBundle.message("dom.converter.cannot.convert.default", s); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomManager.java b/xml/dom-openapi/src/com/intellij/util/xml/DomManager.java index 0769104b39bd..e55df54045c3 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomManager.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomManager.java @@ -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.util.xml; import com.intellij.openapi.Disposable; @@ -38,22 +38,19 @@ public abstract class DomManager extends CompositeModificationTracker implements * If there is a {@link DomFileDescription} that is responsible for the file, but its {@link DomFileDescription#getRootElementClass()} * result is incompatible with domClass parameter, null is returned */ - @Nullable - public abstract DomFileElement getFileElement(XmlFile file, Class domClass); + public abstract @Nullable DomFileElement getFileElement(XmlFile file, Class domClass); /** * @deprecated use {@link #getFileElement(XmlFile, Class)} */ - @Nullable @Deprecated - public abstract DomFileElement getFileElement(XmlFile file); + public abstract @Nullable DomFileElement getFileElement(XmlFile file); /** * @deprecated use {@link #getFileElement(XmlFile, Class)} */ - @NotNull @Deprecated(forRemoval = true) - public abstract DomFileElement getFileElement(XmlFile file, Class aClass, @NonNls String rootTagName); + public abstract @NotNull DomFileElement getFileElement(XmlFile file, Class aClass, @NonNls String rootTagName); public abstract void addDomEventListener(DomEventListener listener, Disposable parentDisposable); @@ -67,15 +64,13 @@ public abstract class DomManager extends CompositeModificationTracker implements * @param element tag * @return DOM element for the given tag. If DOM isn't initialized for the containing file, it will be initialized */ - @Nullable - public abstract DomElement getDomElement(@Nullable final XmlTag element); + public abstract @Nullable DomElement getDomElement(final @Nullable XmlTag element); /** * @param element attribute * @return DOM element for the given XML attribute. If DOM isn't initialized for the containing file, it will be initialized */ - @Nullable - public abstract GenericAttributeValue getDomElement(final XmlAttribute element); + public abstract @Nullable GenericAttributeValue getDomElement(final XmlAttribute element); /** * @param aClass Desired DOM element class @@ -120,27 +115,23 @@ public abstract class DomManager extends CompositeModificationTracker implements * this method to resolve DOM references. This result's subtree will be traversed recursively searching for the reference target. See * {@link Resolve} annotation. */ - @NotNull - public abstract DomElement getResolvingScope(GenericDomValue element); + public abstract @NotNull DomElement getResolvingScope(GenericDomValue element); /** * @param element Named DOM element * @return The scope within which the element's name identity will be checked by * {@link com.intellij.util.xml.highlighting.DomHighlightingHelper#checkNameIdentity(DomElement, com.intellij.util.xml.highlighting.DomElementAnnotationHolder)} */ - @Nullable - public abstract DomElement getIdentityScope(DomElement element); + public abstract @Nullable DomElement getIdentityScope(DomElement element); /** * @return {@link TypeChooserManager} instance */ public abstract TypeChooserManager getTypeChooserManager(); - @Nullable - public abstract AbstractDomChildrenDescription findChildrenDescription(@NotNull XmlTag templateChildTag, @NotNull DomElement parent); + public abstract @Nullable AbstractDomChildrenDescription findChildrenDescription(@NotNull XmlTag templateChildTag, @NotNull DomElement parent); - @Nullable - public final DomFileDescription getDomFileDescription(final XmlFile xmlFile) { + public final @Nullable DomFileDescription getDomFileDescription(final XmlFile xmlFile) { final DomFileElement element = getFileElement(xmlFile); return element != null ? element.getFileDescription() : null; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java b/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java index 2eac9285df80..2a5eacdaa46c 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java @@ -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.util.xml; import com.intellij.psi.PsiElement; @@ -29,8 +15,7 @@ import javax.swing.*; public class DomMetaData implements PsiWritableMetaData, PsiPresentableMetaData, PsiMetaData { private T myElement; - @Nullable - private GenericDomValue myNameElement; + private @Nullable GenericDomValue myNameElement; @Override public final PsiElement getDeclaration() { @@ -42,14 +27,12 @@ public class DomMetaData implements PsiWritableMetaData, P } @Override - @NonNls - public String getName(PsiElement context) { + public @NonNls String getName(PsiElement context) { return getName(); } @Override - @NonNls - public final String getName() { + public final @NonNls String getName() { final String s = ElementPresentationManager.getElementName(myElement); if (s != null) return s; @@ -68,8 +51,7 @@ public class DomMetaData implements PsiWritableMetaData, P myElement = element; } - @Nullable - protected GenericDomValue getNameElement(final T t) { + protected @Nullable GenericDomValue getNameElement(final T t) { return myElement.getGenericInfo().getNameDomElement(t); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomNameStrategy.java b/xml/dom-openapi/src/com/intellij/util/xml/DomNameStrategy.java index 74e9ef904b31..85caf540aa16 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomNameStrategy.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomNameStrategy.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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.util.xml; import org.jetbrains.annotations.NotNull; @@ -29,8 +15,7 @@ public abstract class DomNameStrategy { * @param propertyName property name, i.e. method name without first 'get', 'set' or 'is' * @return XML element name */ - @NotNull - public abstract String convertName(@NotNull String propertyName); + public abstract @NotNull String convertName(@NotNull String propertyName); /** * Is used to get presentable DOM elements in UI diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomReflectionUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/DomReflectionUtil.java index ed43261210f8..fd8ade95919d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomReflectionUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomReflectionUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml; import com.intellij.openapi.progress.ProcessCanceledException; @@ -56,8 +56,7 @@ public final class DomReflectionUtil { return methods; } - @Nullable - public static JavaMethod findGetter(Class aClass, String propertyName) { + public static @Nullable JavaMethod findGetter(Class aClass, String propertyName) { final String capitalized = StringUtil.capitalize(propertyName); Method method = ReflectionUtil.getMethod(aClass, "get" + capitalized); if (method != null) return JavaMethod.getMethod(aClass, method); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java index c2c6d600a58e..b51e74c3a0cb 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. 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.util.xml; import com.intellij.codeInsight.CodeInsightBundle; @@ -31,8 +31,7 @@ public final class DomResolveConverter extends ResolvingCo private final boolean myAttribute; private final SoftFactoryMap>> myResolveCache = new SoftFactoryMap<>() { @Override - @NotNull - protected CachedValue> create(final @NotNull DomElement scope) { + protected @NotNull CachedValue> create(final @NotNull DomElement scope) { final DomManager domManager = scope.getManager(); //noinspection ConstantConditions if (domManager == null) throw new AssertionError("Null DomManager for " + scope.getClass()); @@ -109,8 +108,7 @@ public final class DomResolveConverter extends ResolvingCo } @Override - @NotNull - public Collection getVariants(final ConvertContext context) { + public @NotNull Collection getVariants(final ConvertContext context) { final DomElement reference = context.getInvocationElement(); final DomElement scope = reference.getManager().getResolvingScope((GenericDomValue)reference); return (Collection)myResolveCache.get(scope).getValue().values(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomService.java b/xml/dom-openapi/src/com/intellij/util/xml/DomService.java index 0f9b94e905f0..ddbbdd83d891 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomService.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomService.java @@ -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.util.xml; import com.intellij.ide.structureView.StructureViewBuilder; @@ -33,13 +33,11 @@ public abstract class DomService { * @return files containing given root element * @see #getFileElements(Class, Project, GlobalSearchScope) */ - @NotNull - public abstract Collection getDomFileCandidates(@NotNull Class rootElementClass, + public abstract @NotNull Collection getDomFileCandidates(@NotNull Class rootElementClass, @NotNull GlobalSearchScope scope); // used externally - @NotNull - public Collection getDomFileCandidates(@NotNull Class rootElementClass, + public @NotNull Collection getDomFileCandidates(@NotNull Class rootElementClass, Project project, @NotNull GlobalSearchScope scope) { return getDomFileCandidates(rootElementClass, scope); @@ -51,29 +49,23 @@ public abstract class DomService { * @param scope search scope * @return DOM file elements containing given root element */ - @NotNull - public abstract List> getFileElements(@NotNull Class rootElementClass, + public abstract @NotNull List> getFileElements(@NotNull Class rootElementClass, @NotNull Project project, @Nullable GlobalSearchScope scope); - @NotNull - public abstract ModelMerger createModelMerger(); + public abstract @NotNull ModelMerger createModelMerger(); public abstract DomAnchor createAnchor(T domElement); - @NotNull - public abstract XmlFile getContainingFile(@NotNull DomElement domElement); + public abstract @NotNull XmlFile getContainingFile(@NotNull DomElement domElement); - @NotNull - public abstract EvaluatedXmlName getEvaluatedXmlName(@NotNull DomElement element); + public abstract @NotNull EvaluatedXmlName getEvaluatedXmlName(@NotNull DomElement element); - @NotNull - public abstract XmlFileHeader getXmlFileHeader(@NotNull XmlFile file); + public abstract @NotNull XmlFileHeader getXmlFileHeader(@NotNull XmlFile file); public enum StructureViewMode { SHOW, SHOW_CHILDREN, SKIP } - @NotNull - public abstract StructureViewBuilder createSimpleStructureViewBuilder(@NotNull XmlFile file, @NotNull Function modeProvider); + public abstract @NotNull StructureViewBuilder createSimpleStructureViewBuilder(@NotNull XmlFile file, @NotNull Function modeProvider); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java b/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java index def2cc9b5929..0688929e2dfc 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java @@ -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.util.xml; import com.intellij.openapi.util.TextRange; @@ -26,8 +26,7 @@ public final class DomTarget extends DelegatePsiTarget implements PsiDeclaredTar myNameDomElement = nameElement; } - @Nullable - public static DomTarget getTarget(@NotNull DomElement element) { + public static @Nullable DomTarget getTarget(@NotNull DomElement element) { final GenericDomValue nameElement = element.getGenericInfo().getNameDomElement(element); if (nameElement == null) { return null; @@ -36,8 +35,7 @@ public final class DomTarget extends DelegatePsiTarget implements PsiDeclaredTar return getTarget(element, nameElement); } - @Nullable - public static DomTarget getTarget(DomElement element, GenericDomValue nameElement) { + public static @Nullable DomTarget getTarget(DomElement element, GenericDomValue nameElement) { if (nameElement instanceof GenericAttributeValue genericAttributeValue) { final XmlAttributeValue attributeValue = genericAttributeValue.getXmlAttributeValue(); if (attributeValue == null) { @@ -80,8 +78,7 @@ public final class DomTarget extends DelegatePsiTarget implements PsiDeclaredTar } @Override - @Nullable - public String getName() { + public @Nullable String getName() { return myNameDomElement.getStringValue(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java index e97e1d45b83f..8ed233d4527e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml; import com.intellij.openapi.diagnostic.Logger; @@ -78,8 +78,7 @@ public class DomUtil { return getGenericValueParameter(type) != null; } - @Nullable - public static T findByName(@NotNull Collection list, @NonNls @NotNull String name) { + public static @Nullable T findByName(@NotNull Collection list, @NonNls @NotNull String name) { for (T element: list) { String elementName = element.getGenericInfo().getElementName(element); if (elementName != null && elementName.equals(name)) { @@ -89,8 +88,7 @@ public class DomUtil { return null; } - @Nullable - public static List getFixedPath(DomElement element) { + public static @Nullable List getFixedPath(DomElement element) { assert element.isValid(); final LinkedList methods = new LinkedList<>(); while (true) { @@ -108,8 +106,7 @@ public class DomUtil { return methods; } - @Nullable - private static JavaMethod getGetterMethod(final DomElement element, final DomElement parent) { + private static @Nullable JavaMethod getGetterMethod(final DomElement element, final DomElement parent) { final String xmlElementName = element.getXmlElementName(); final String namespace = element.getXmlElementNamespaceKey(); final DomGenericInfo genericInfo = parent.getGenericInfo(); @@ -128,8 +125,7 @@ public class DomUtil { return ourVariableSubstitutions.get(Couple.of(genericType, classType)); } - @Nullable - public static Class getGenericValueParameter(Type type) { + public static @Nullable Class getGenericValueParameter(Type type) { final Class aClass = ourTypeParameters.get(type); return aClass == DUMMY ? null : aClass; } @@ -140,8 +136,7 @@ public class DomUtil { ourVariableSubstitutions.clear(); } - @Nullable - public static XmlElement getValueElement(GenericDomValue domValue) { + public static @Nullable XmlElement getValueElement(GenericDomValue domValue) { if (domValue instanceof GenericAttributeValue value) { XmlAttributeValue attributeValue = value.getXmlAttributeValue(); return attributeValue == null ? value.getXmlAttribute() : attributeValue; @@ -175,7 +170,7 @@ public class DomUtil { return Collections.emptyList(); } - public static List getChildrenOfType(@NotNull final DomElement parent, final Class type) { + public static List getChildrenOfType(final @NotNull DomElement parent, final Class type) { final List result = new SmartList<>(); parent.acceptChildren(new DomElementVisitor() { @Override @@ -188,7 +183,7 @@ public class DomUtil { return result; } - public static List getDefinedChildren(@NotNull final DomElement parent, final boolean tags, final boolean attributes) { + public static List getDefinedChildren(final @NotNull DomElement parent, final boolean tags, final boolean attributes) { if (parent instanceof MergedObject) { final SmartList result = new SmartList<>(); parent.acceptChildren(new DomElementVisitor() { @@ -252,16 +247,15 @@ public class DomUtil { return true; } - public static List getDefinedChildrenOfType(@NotNull final DomElement parent, final Class type, boolean tags, boolean attributes) { + public static List getDefinedChildrenOfType(final @NotNull DomElement parent, final Class type, boolean tags, boolean attributes) { return ContainerUtil.findAll(getDefinedChildren(parent, tags, attributes), type); } - public static List getDefinedChildrenOfType(@NotNull final DomElement parent, final Class type) { + public static List getDefinedChildrenOfType(final @NotNull DomElement parent, final Class type) { return getDefinedChildrenOfType(parent, type, true, true); } - @Nullable - public static DomElement findDuplicateNamedValue(DomElement element, String newName) { + public static @Nullable DomElement findDuplicateNamedValue(DomElement element, String newName) { return ElementPresentationManager.findByName(getIdentitySiblings(element), newName); } @@ -295,8 +289,7 @@ public class DomUtil { return result; } - @Nullable - public static T getParentOfType(final DomElement element, final Class requiredClass, final boolean strict) { + public static @Nullable T getParentOfType(final DomElement element, final Class requiredClass, final boolean strict) { for (DomElement curElement = strict && element != null? element.getParent() : element; curElement != null; curElement = curElement.getParent()) { @@ -307,14 +300,12 @@ public class DomUtil { return null; } - @Nullable - public static T getContextElement(@Nullable final Editor editor, Class clazz) { + public static @Nullable T getContextElement(final @Nullable Editor editor, Class clazz) { final DomElement element = getContextElement(editor); return getParentOfType(element, clazz, false); } - @Nullable - public static DomElement getContextElement(@Nullable final Editor editor) { + public static @Nullable DomElement getContextElement(final @Nullable Editor editor) { if(editor == null) return null; final Project project = editor.getProject(); @@ -328,13 +319,11 @@ public class DomUtil { return getDomElement(file.findElementAt(editor.getCaretModel().getOffset())); } - @Nullable - public static DomElement getDomElement(@NotNull final Editor editor, @NotNull final PsiFile file) { + public static @Nullable DomElement getDomElement(final @NotNull Editor editor, final @NotNull PsiFile file) { return getDomElement(file.findElementAt(editor.getCaretModel().getOffset())); } - @Nullable - public static DomElement getDomElement(@Nullable final PsiElement element) { + public static @Nullable DomElement getDomElement(final @Nullable PsiElement element) { if (element == null) return null; final Project project = element.getProject(); @@ -355,8 +344,7 @@ public class DomUtil { return null; } - @NotNull - public static T getOriginalElement(@NotNull final T domElement) { + public static @NotNull T getOriginalElement(final @NotNull T domElement) { final XmlElement psiElement = domElement.getXmlElement(); if (psiElement == null) return domElement; @@ -377,7 +365,7 @@ public class DomUtil { return (T)current; } - public static T addElementAfter(@NotNull final T anchor) { + public static T addElementAfter(final @NotNull T anchor) { final DomElement parent = anchor.getParent(); final DomCollectionChildDescription childDescription = (DomCollectionChildDescription)anchor.getChildDescription(); assert parent != null; @@ -387,13 +375,11 @@ public class DomUtil { return (T)childDescription.addValue(parent, i + 1); } - @Nullable - public static T findDomElement(@Nullable final PsiElement element, final Class beanClass) { + public static @Nullable T findDomElement(final @Nullable PsiElement element, final Class beanClass) { return findDomElement(element, beanClass, true); } - @Nullable - public static T findDomElement(@Nullable final PsiElement element, final Class beanClass, boolean strict) { + public static @Nullable T findDomElement(final @Nullable PsiElement element, final Class beanClass, boolean strict) { if (element == null) return null; XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, strict); @@ -425,8 +411,7 @@ public class DomUtil { return fileElement; } - @NotNull - public static XmlFile getFile(@NotNull DomElement element) { + public static @NotNull XmlFile getFile(@NotNull DomElement element) { return DomService.getInstance().getContainingFile(element); } @@ -436,8 +421,7 @@ public class DomUtil { * If root tag has changed, file may lose its domness, so there will be no DomFileElement, but the inner DomElement's * will be still alive because the underlying XML tags are valid */ - @NotNull - public static DomElement getRoot(@NotNull DomElement domElement) { + public static @NotNull DomElement getRoot(@NotNull DomElement domElement) { while (true) { final DomElement parent = domElement.getParent(); if (parent == null) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java b/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java index 981939bcf892..96c0941f1698 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java @@ -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.util.xml; import com.intellij.psi.xml.XmlElement; @@ -24,11 +10,11 @@ public class DummyEvaluatedXmlName implements EvaluatedXmlName { private final XmlName myXmlName; private final String myNamespace; - public DummyEvaluatedXmlName(final String localName, @NotNull final String namespace) { + public DummyEvaluatedXmlName(final String localName, final @NotNull String namespace) { this(new XmlName(localName), namespace); } - public DummyEvaluatedXmlName(final XmlName xmlName, @NotNull final String namespace) { + public DummyEvaluatedXmlName(final XmlName xmlName, final @NotNull String namespace) { myXmlName = xmlName; myNamespace = namespace; } @@ -39,7 +25,7 @@ public class DummyEvaluatedXmlName implements EvaluatedXmlName { } @Override - public EvaluatedXmlName evaluateChildName(@NotNull final XmlName name) { + public EvaluatedXmlName evaluateChildName(final @NotNull XmlName name) { String namespaceKey = name.getNamespaceKey(); if (namespaceKey == null) { return new DummyEvaluatedXmlName(name.getLocalName(), myNamespace); @@ -53,9 +39,7 @@ public class DummyEvaluatedXmlName implements EvaluatedXmlName { } @Override - @NotNull - @NonNls - public String getNamespace(@NotNull final XmlElement parentElement, final XmlFile file) { + public @NotNull @NonNls String getNamespace(final @NotNull XmlElement parentElement, final XmlFile file) { return myNamespace; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentation.java b/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentation.java index 1681ddca5b77..fc6ccbc90f55 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentation.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentation.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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.util.xml; import com.intellij.openapi.util.NlsSafe; @@ -26,15 +12,11 @@ import javax.swing.*; * @see ElementPresentationTemplate */ public abstract class ElementPresentation { - @Nullable - public abstract @NlsSafe String getElementName(); + public abstract @Nullable @NlsSafe String getElementName(); public abstract @NlsSafe String getTypeName(); - @Nullable - public abstract Icon getIcon(); + public abstract @Nullable Icon getIcon(); - @Nls - @Nullable - public String getDocumentation() { return null;} + public @Nls @Nullable String getDocumentation() { return null;} } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java b/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java index 6f39de447238..aec2beaaa67a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java @@ -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.util.xml; import com.intellij.ide.TypePresentationService; @@ -30,7 +30,7 @@ public abstract class ElementPresentationManager { .filter(method -> JavaMethod.getMethod(key, method).getAnnotation(NameValue.class) != null) .findFirst(), CollectionFactory::createConcurrentWeakKeySoftValueMap); - private final static Function DEFAULT_NAMER = element -> getElementName(element); + private static final Function DEFAULT_NAMER = element -> getElementName(element); public static ElementPresentationManager getInstance() { return ApplicationManager.getApplication().getService(ElementPresentationManager.class); @@ -67,8 +67,7 @@ public abstract class ElementPresentationManager { return (NullableFunction)NAMER; } - @Nullable - public static String getElementName(@NotNull Object element) { + public static @Nullable String getElementName(@NotNull Object element) { Object o = invokeNameValueMethod(element); if (o == null || o instanceof String) return (String)o; if (o instanceof GenericValue gv) { @@ -85,13 +84,11 @@ public abstract class ElementPresentationManager { } - @Nullable - public static Object invokeNameValueMethod(@NotNull final Object element) { + public static @Nullable Object invokeNameValueMethod(final @NotNull Object element) { return ourNameValueMethods.get(element.getClass()).map(method -> DomReflectionUtil.invokeMethod(method, element)).orElse(null); } - @NlsSafe - public static String getTypeNameForObject(Object o) { + public static @NlsSafe String getTypeNameForObject(Object o) { final Object firstImpl = ModelMergerUtil.getFirstImplementation(o); o = firstImpl != null ? firstImpl : o; String typeName = TypePresentationService.getService().getTypeName(o); @@ -116,19 +113,16 @@ public abstract class ElementPresentationManager { return getIconOld(o); } - @Nullable - public static Icon getIconOld(Object o) { + public static @Nullable Icon getIconOld(Object o) { return getFirst(getIconsForClass(o.getClass(), o)); } - @Nullable - private static T getFirst(final T @Nullable [] array) { + private static @Nullable T getFirst(final T @Nullable [] array) { return array == null || array.length == 0 ? null : array[0]; } - @Nullable - public static Icon getIconForClass(Class clazz) { + public static @Nullable Icon getIconForClass(Class clazz) { return getFirst(getIconsForClass(clazz, null)); } @@ -142,8 +136,7 @@ public abstract class ElementPresentationManager { return null; } - @Nullable - public static T findByName(Collection collection, final String name) { + public static @Nullable T findByName(Collection collection, final String name) { return ContainerUtil.find(collection, object -> Comparing.equal(name, getElementName(object), true)); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java b/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java index 7d9fda18239f..21765fd684c3 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. 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.util.xml; import com.intellij.openapi.util.Key; @@ -112,8 +112,7 @@ public final class EvaluatedXmlNameImpl implements EvaluatedXmlName { } @Override - @NonNls - public @NotNull String getNamespace(@NotNull XmlElement parentElement, final XmlFile file) { + public @NonNls @NotNull String getNamespace(@NotNull XmlElement parentElement, final XmlFile file) { final String xmlElementNamespace = getXmlElementNamespace(parentElement); if (myNamespaceKey != null && !myEqualToParent) { final List strings = getAllowedNamespaces(file); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java index ed6683c285e8..0860c810f414 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java @@ -1,13 +1,14 @@ -// 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.util.xml; import com.intellij.openapi.util.Comparing; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Objects; -import org.jetbrains.annotations.NotNull; /** * @author Gregory.Shrago @@ -34,24 +35,21 @@ public final class GenericValueUtil { return false; } - @NotNull - public static Collection getValueCollection(final Collection> collection, Collection result) { + public static @NotNull Collection getValueCollection(final Collection> collection, Collection result) { for (GenericValue o : collection) { ContainerUtil.addIfNotNull(result, o.getValue()); } return result; } - @NotNull - public static Collection getStringCollection(final Collection collection, Collection result) { + public static @NotNull Collection getStringCollection(final Collection collection, Collection result) { for (GenericValue o : collection) { ContainerUtil.addIfNotNull(result, o.getStringValue()); } return result; } - @NotNull - public static Collection getClassStringCollection(final Collection collection, Collection result) { + public static @NotNull Collection getClassStringCollection(final Collection collection, Collection result) { for (GenericValue o : collection) { final String value = o.getStringValue(); if (value != null) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java b/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java index da77b4d0ae55..abac71f96e33 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml; import com.intellij.openapi.util.text.StringUtil; @@ -10,9 +10,8 @@ import org.jetbrains.annotations.NotNull; * e.g. getXmlElementName() will correspond to xml-element-name */ public class HyphenNameStrategy extends DomNameStrategy { - @NotNull @Override - public String convertName(@NotNull String propertyName) { + public @NotNull String convertName(@NotNull String propertyName) { final String[] words = NameUtilCore.nameToWords(propertyName); for (int i = 0; i < words.length; i++) { words[i] = StringUtil.decapitalize(words[i]); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java b/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java index b0afcbcf5e57..ebc0b946dfdf 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. 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.util.xml; import com.intellij.util.SmartFMap; @@ -36,8 +36,7 @@ public final class JavaMethod implements AnnotatedElement { return mySignature; } - @NotNull - public List getHierarchy() { + public @NotNull List getHierarchy() { List hierarchy = myHierarchy; if (hierarchy == null) { hierarchy = Collections.unmodifiableList(mySignature.getAllMethods(myDeclaringClass)); @@ -78,8 +77,7 @@ public final class JavaMethod implements AnnotatedElement { return "JavaMethod: " + myMethod.toString(); } - @NonNls - public String getName() { + public @NonNls String getName() { return myMethod.getName(); } @@ -93,8 +91,7 @@ public final class JavaMethod implements AnnotatedElement { return annotation == NONE ? null : (T)annotation; } - @NotNull - private Object findAnnotation(Class annotationClass) { + private @NotNull Object findAnnotation(Class annotationClass) { for (Method method : getHierarchy()) { Annotation annotation = method.getAnnotation(annotationClass); if (annotation != null) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/JavaMethodSignature.java b/xml/dom-openapi/src/com/intellij/util/xml/JavaMethodSignature.java index 61c093f86c09..4cf505c7e6f9 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/JavaMethodSignature.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/JavaMethodSignature.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. 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.util.xml; import com.intellij.util.ArrayUtil; @@ -35,8 +35,7 @@ public final class JavaMethodSignature { return myMethodName; } - @Nullable - public Method findMethod(@NotNull Class aClass) { + public @Nullable Method findMethod(@NotNull Class aClass) { Method method = getDeclaredMethod(aClass); if (method == null && aClass.isInterface() && OBJECT_METHOD_NAMES.contains(myMethodName)) { method = ReflectionUtil.getDeclaredMethod(Object.class, myMethodName, myMethodParameters); @@ -44,8 +43,7 @@ public final class JavaMethodSignature { return method; } - @Nullable - private Method getDeclaredMethod(@NotNull Class aClass) { + private @Nullable Method getDeclaredMethod(@NotNull Class aClass) { Method method = ReflectionUtil.getMethod(aClass, myMethodName, myMethodParameters); return method == null ? ReflectionUtil.getDeclaredMethod(aClass, myMethodName, myMethodParameters) : method; } @@ -65,8 +63,7 @@ public final class JavaMethodSignature { return result; } - @Nullable - static Method findMethod(@NotNull Method sampleMethod, @NotNull Class startFrom, @NotNull Predicate checker) { + static @Nullable Method findMethod(@NotNull Method sampleMethod, @NotNull Class startFrom, @NotNull Predicate checker) { String sampleMethodName = sampleMethod.getName(); Class[] sampleMethodParameters = sampleMethod.getParameterCount() == 0 ? ArrayUtil.EMPTY_CLASS_ARRAY : sampleMethod.getParameterTypes(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java b/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java index 6b79769ac4da..55ea0641ee2d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml; import com.intellij.openapi.util.text.StringUtil; @@ -14,9 +14,8 @@ import java.util.Arrays; public class JavaNameStrategy extends DomNameStrategy { public static final Function DECAPITALIZE_FUNCTION = s -> StringUtil.decapitalize(s); - @NotNull @Override - public final String convertName(@NotNull String propertyName) { + public final @NotNull String convertName(@NotNull String propertyName) { return StringUtil.decapitalize(propertyName); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java b/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java index 990fe43482a5..0f23ea8b4d1d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml; import com.intellij.psi.xml.XmlFile; @@ -14,16 +14,14 @@ import java.util.Set; public abstract class MergingFileDescription extends DomFileDescription{ private ModelMerger myMerger; - protected MergingFileDescription(final Class rootElementClass, @NonNls final String rootTagName) { + protected MergingFileDescription(final Class rootElementClass, final @NonNls String rootTagName) { super(rootElementClass, rootTagName); } - @NotNull - protected abstract Set getFilesToMerge(DomElement element); + protected abstract @NotNull Set getFilesToMerge(DomElement element); @Override - @NotNull - public DomElement getResolveScope(GenericDomValue reference) { + public @NotNull DomElement getResolveScope(GenericDomValue reference) { final DomElement annotation = getScopeFromAnnotation(reference); if (annotation != null) return annotation; @@ -67,8 +65,7 @@ public abstract class MergingFileDescription extends DomFi } @Override - @NotNull - public DomElement getIdentityScope(DomElement element) { + public @NotNull DomElement getIdentityScope(DomElement element) { final DomElement annotation = getScopeFromAnnotation(element); if (annotation != null) return annotation; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ModelMerger.java b/xml/dom-openapi/src/com/intellij/util/xml/ModelMerger.java index 83628e40ae3d..746473dbe8d7 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ModelMerger.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ModelMerger.java @@ -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.util.xml; import org.jetbrains.annotations.Nullable; @@ -42,7 +28,6 @@ public interface ModelMerger { } abstract class MergingStrategy { - @Nullable - public abstract T mergeChildren(Class type, List implementations); + public abstract @Nullable T mergeChildren(Class type, List implementations); } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java index f0615984969c..14223e9e2f2e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml; import com.intellij.util.CommonProcessors; @@ -13,8 +13,7 @@ import java.util.*; public final class ModelMergerUtil { - @Nullable - public static T getFirstImplementation(final T t) { + public static @Nullable T getFirstImplementation(final T t) { T cur = t; while (cur instanceof MergedObject) { final List implementations = ((MergedObject)cur).getImplementations(); @@ -23,8 +22,7 @@ public final class ModelMergerUtil { return cur; } - @Nullable - public static V getImplementation(final Class clazz, final Collection elements) { + public static @Nullable V getImplementation(final Class clazz, final Collection elements) { for (final T element : elements) { final V implementation = getImplementation(element, clazz); if (implementation != null) { @@ -34,13 +32,11 @@ public final class ModelMergerUtil { return null; } - @Nullable - public static V getImplementation(final Class clazz, final T... elements) { + public static @Nullable V getImplementation(final Class clazz, final T... elements) { return getImplementation(clazz, Arrays.asList(elements)); } - @Nullable - public static V getImplementation(final T element, final Class clazz) { + public static @Nullable V getImplementation(final T element, final Class clazz) { if (element == null) return null; CommonProcessors.FindFirstProcessor processor = new CommonProcessors.FindFirstProcessor<>() { @Override @@ -52,8 +48,7 @@ public final class ModelMergerUtil { return (V)processor.getFoundValue(); } - @NotNull - public static Collection getImplementations(final T element, final Class clazz) { + public static @NotNull Collection getImplementations(final T element, final Class clazz) { if (element == null) return Collections.emptyList(); CommonProcessors.CollectProcessor processor = new CommonProcessors.CollectProcessor<>() { @Override @@ -65,8 +60,7 @@ public final class ModelMergerUtil { return (Collection)processor.getResults(); } - @NotNull - public static List getImplementations(T element) { + public static @NotNull List getImplementations(T element) { if (element instanceof MergedObject) { final MergedObject mergedObject = (MergedObject)element; return mergedObject.getImplementations(); @@ -79,8 +73,7 @@ public final class ModelMergerUtil { } } - @NotNull - public static List getFilteredImplementations(final T element) { + public static @NotNull List getFilteredImplementations(final T element) { if (element == null) return Collections.emptyList(); List result = new ArrayList<>(); Processor processor = Processors.cancelableCollectProcessor(result); @@ -88,8 +81,7 @@ public final class ModelMergerUtil { return result; } - @NotNull - public static Processor createFilteringProcessor(final Processor processor) { + public static @NotNull Processor createFilteringProcessor(final Processor processor) { return new ImplementationProcessor<>(processor, false); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java index b3fed5b2eb7e..597ba64beb52 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java @@ -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.util.xml; import com.intellij.analysis.AnalysisBundle; @@ -36,9 +22,8 @@ import java.util.Set; */ public abstract class ResolvingConverter extends Converter implements ResolvingHint { - @InspectionMessage @Override - public String getErrorMessage(@Nullable String s, final ConvertContext context) { + public @InspectionMessage String getErrorMessage(@Nullable String s, final ConvertContext context) { return AnalysisBundle.message("error.cannot.resolve.default.message", s); } @@ -46,15 +31,13 @@ public abstract class ResolvingConverter extends Converter implements Reso * @param context context * @return reference completion variants */ - @NotNull - public abstract Collection getVariants(final ConvertContext context); + public abstract @NotNull Collection getVariants(final ConvertContext context); /** * @return additional reference variants. They won't resolve to anywhere, but won't be highlighted as errors. * They will also appear in the completion dropdown. */ - @NotNull - public Set getAdditionalVariants(@NotNull final ConvertContext context) { + public @NotNull Set getAdditionalVariants(final @NotNull ConvertContext context) { return Collections.emptySet(); } @@ -88,8 +71,7 @@ public abstract class ResolvingConverter extends Converter implements Reso * @param resolvedValue {@link #fromString(String, ConvertContext)} result * @return the PSI element to which the {@link com.intellij.psi.PsiReference} will resolve */ - @Nullable - public PsiElement getPsiElement(@Nullable T resolvedValue) { + public @Nullable PsiElement getPsiElement(@Nullable T resolvedValue) { if (resolvedValue instanceof PsiElement) { return (PsiElement)resolvedValue; } @@ -123,8 +105,7 @@ public abstract class ResolvingConverter extends Converter implements Reso * @param context context * @return PSI element to resolve to. By default calls {@link #getPsiElement(Object)} method */ - @Nullable - public PsiElement resolve(final T o, final ConvertContext context) { + public @Nullable PsiElement resolve(final T o, final ConvertContext context) { final PsiElement psiElement = getPsiElement(o); return psiElement == null && o != null ? DomUtil.getValueElement((GenericDomValue)context.getInvocationElement()) : psiElement; } @@ -146,15 +127,14 @@ public abstract class ResolvingConverter extends Converter implements Reso * @param t DOM to create lookup element for. * @return Lookup element. */ - @Nullable - public LookupElement createLookupElement(T t) { + public @Nullable LookupElement createLookupElement(T t) { return null; } /** * Adds {@link #getVariants(ConvertContext)} functionality to a simple String value. */ - public static abstract class StringConverter extends ResolvingConverter { + public abstract static class StringConverter extends ResolvingConverter { @Override public String fromString(final String s, final ConvertContext context) { @@ -170,7 +150,7 @@ public abstract class ResolvingConverter extends Converter implements Reso /** * Adds {@link #getVariants(ConvertContext)} functionality to an existing converter. */ - public static abstract class WrappedResolvingConverter extends ResolvingConverter { + public abstract static class WrappedResolvingConverter extends ResolvingConverter { private final Converter myWrappedConverter; @@ -196,8 +176,7 @@ public abstract class ResolvingConverter extends Converter implements Reso @Deprecated public static final ResolvingConverter EMPTY_CONVERTER = new ResolvingConverter() { @Override - @NotNull - public Collection getVariants(final ConvertContext context) { + public @NotNull Collection getVariants(final ConvertContext context) { return Collections.emptyList(); } @@ -234,8 +213,7 @@ public abstract class ResolvingConverter extends Converter implements Reso } @Override - @NotNull - public Collection getVariants(final ConvertContext context) { + public @NotNull Collection getVariants(final ConvertContext context) { final DomElement element = context.getInvocationElement(); if (element instanceof GenericDomValue) { final SubTag annotation = element.getAnnotation(SubTag.class); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ScopeProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/ScopeProvider.java index f079b2612ee3..ddefe4743c1d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ScopeProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ScopeProvider.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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.util.xml; import org.jetbrains.annotations.NotNull; @@ -31,7 +17,6 @@ public abstract class ScopeProvider { * Basically it's parameter element's parent: {@link ParentScopeProvider}. * Searches within all children of returned element. */ - @Nullable - public abstract DomElement getScope(@NotNull DomElement element); + public abstract @Nullable DomElement getScope(@NotNull DomElement element); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java index 5a44a49a7f58..3b8e05fd48a3 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java @@ -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.util.xml; @@ -21,7 +7,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collections; import java.util.List; /** @@ -57,14 +42,12 @@ public abstract class WrappingConverter extends Converter { return null; } - @NotNull - public List getConverters(@NotNull final GenericDomValue domElement) { + public @NotNull List getConverters(final @NotNull GenericDomValue domElement) { final Converter converter = getConverter(domElement); return ContainerUtil.createMaybeSingletonList(converter); } - @Nullable - public abstract Converter getConverter(@NotNull final GenericDomValue domElement); + public abstract @Nullable Converter getConverter(final @NotNull GenericDomValue domElement); public static Converter getDeepestConverter(final Converter converter, final GenericDomValue domValue) { Converter cur = converter; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java b/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java index 709aee76f3a3..b7dca8cc6ff3 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java @@ -1,36 +1,35 @@ -// 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.util.xml; import com.intellij.openapi.util.Comparing; -import java.util.Objects; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + public class XmlName implements Comparable { private final String myLocalName; private final String myNamespaceKey; private final int myHashCode; - public XmlName(@NotNull @NonNls final String localName) { + public XmlName(final @NotNull @NonNls String localName) { this(localName, null); } - public XmlName(@NotNull @NonNls final String localName, @Nullable final String namespaceKey) { + public XmlName(final @NotNull @NonNls String localName, final @Nullable String namespaceKey) { myLocalName = localName; myNamespaceKey = namespaceKey; myHashCode = 31 * myLocalName.hashCode() + (myNamespaceKey != null ? myNamespaceKey.hashCode() : 0); } - @NotNull - public final String getLocalName() { + public final @NotNull String getLocalName() { return myLocalName; } - @Nullable - public final String getNamespaceKey() { + public final @Nullable String getNamespaceKey() { return myNamespaceKey; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java index f90e32ab2b02..836ef472eadb 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml.actions.generate; import com.intellij.openapi.editor.Editor; @@ -23,13 +23,13 @@ import java.util.Map; public abstract class AbstractDomGenerateProvider extends DefaultGenerateElementProvider { public static final String NAMESPACE_PREFIX_VAR = "NS_PREFIX"; - @Nullable private final String myMappingId; + private final @Nullable String myMappingId; /** * @deprecated Provide both action description and text, as they have different capitalization rules. */ @Deprecated(forRemoval = true) - public AbstractDomGenerateProvider(@Nls final String description, final Class aClass) { + public AbstractDomGenerateProvider(final @Nls String description, final Class aClass) { this(description, aClass, null); } @@ -37,7 +37,7 @@ public abstract class AbstractDomGenerateProvider extends * @deprecated Provide both action description and text, as they have different capitalization rules. */ @Deprecated(forRemoval = true) - public AbstractDomGenerateProvider(@Nls final String description, final Class aClass, @Nullable String mappingId) { + public AbstractDomGenerateProvider(final @Nls String description, final Class aClass, @Nullable String mappingId) { this(description, description, aClass, mappingId); } @@ -68,8 +68,7 @@ public abstract class AbstractDomGenerateProvider extends return createNamespacePrefixMap(parentDomElement); } - @NotNull - public static Map createNamespacePrefixMap(@Nullable DomElement domElement) { + public static @NotNull Map createNamespacePrefixMap(@Nullable DomElement domElement) { Map vars = new HashMap<>(); addNamespacePrefix(domElement, vars); @@ -105,8 +104,7 @@ public abstract class AbstractDomGenerateProvider extends } } - @Nullable - protected DomElement getElementToNavigate(final T t) { + protected @Nullable DomElement getElementToNavigate(final T t) { return t; } @@ -114,8 +112,7 @@ public abstract class AbstractDomGenerateProvider extends return StringUtil.join(Arrays.asList(NameUtilCore.nameToWords(aClass.getSimpleName())), " "); } - @Nullable - public String getMappingId() { + public @Nullable String getMappingId() { return myMappingId; } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java index 1d247defd73e..a4eab9ea55b6 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.actions.generate; @@ -33,17 +33,14 @@ public abstract class DefaultGenerateElementProvider exten } @Override - @Nullable - public T generate(final Project project, final Editor editor, final PsiFile file) { + public @Nullable T generate(final Project project, final Editor editor, final PsiFile file) { return generate(getParentDomElement(project, editor, file), editor); } - @Nullable - protected abstract DomElement getParentDomElement(final Project project, final Editor editor, final PsiFile file); + protected abstract @Nullable DomElement getParentDomElement(final Project project, final Editor editor, final PsiFile file); @SuppressWarnings({"unchecked"}) - @Nullable - public T generate(@Nullable final DomElement parent, final Editor editor) { + public @Nullable T generate(final @Nullable DomElement parent, final Editor editor) { if (parent == null) { return null; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java index 574074d07dd5..8499bf645032 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml.converters; @@ -24,7 +24,7 @@ import java.util.*; public abstract class DelimitedListConverter extends ResolvingConverter> implements CustomReferenceConverter> { - protected final static Object[] EMPTY_ARRAY = ArrayUtilRt.EMPTY_OBJECT_ARRAY; + protected static final Object[] EMPTY_ARRAY = ArrayUtilRt.EMPTY_OBJECT_ARRAY; private final String myDelimiters; @@ -33,24 +33,19 @@ public abstract class DelimitedListConverter extends ResolvingConverter> genericDomValue); - @Nullable - protected abstract PsiElement resolveReference(@Nullable final T t, final ConvertContext context); + protected abstract @Nullable PsiElement resolveReference(final @Nullable T t, final ConvertContext context); - @InspectionMessage - protected abstract String getUnresolvedMessage(String value); + protected abstract @InspectionMessage String getUnresolvedMessage(String value); @Override - @NotNull - public Collection> getVariants(final ConvertContext context) { + public @NotNull Collection> getVariants(final ConvertContext context) { return Collections.emptyList(); } @@ -74,7 +69,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter fromString(@Nullable final String str, final ConvertContext context) { + public List fromString(final @Nullable String str, final ConvertContext context) { if (str == null) { return null; } @@ -125,13 +120,12 @@ public abstract class DelimitedListConverter extends ResolvingConverter> genericDomValue, - final boolean delimitersOnly) { + protected @NotNull PsiReference createPsiReference(final PsiElement element, + int start, + int end, + final ConvertContext context, + final GenericDomValue> genericDomValue, + final boolean delimitersOnly) { return new MyPsiReference(element, getTextRange(genericDomValue, start, end), context, genericDomValue, delimitersOnly); } @@ -175,8 +169,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter extends ResolvingConverter ref = new Ref<>(); PsiElement element = referenceHandleElementRename(this, newElementName, getSuperElementRenameFunction(ref)); if (!ref.isNull()) { @@ -201,7 +194,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter ref = new Ref<>(); PsiElement bindElement = referenceBindToElement(this, element, getSuperBindToElementFunction(ref), getSuperElementRenameFunction(ref)); @@ -243,8 +236,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter implements CustomReferenceConverter { - public final static Converter INSTANCE = new PathReferenceConverter(); + public static final Converter INSTANCE = new PathReferenceConverter(); @Override - public PathReference fromString(@Nullable final String s, final ConvertContext context) { + public PathReference fromString(final @Nullable String s, final ConvertContext context) { final XmlElement element = context.getXmlElement(); return s == null || element == null ? null : PathReferenceManager.getInstance().getPathReference(s, element); } @@ -50,7 +36,7 @@ public class PathReferenceConverter extends Converter implements return createReferences(element, true); } - public PsiReference @NotNull [] createReferences(@NotNull final PsiElement psiElement, final boolean soft) { + public PsiReference @NotNull [] createReferences(final @NotNull PsiElement psiElement, final boolean soft) { return PathReferenceManager.getInstance().createReferences(psiElement, soft); } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/QuotedValueConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/QuotedValueConverter.java index 32293ffcd3a9..c098c80c9e8a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/QuotedValueConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/QuotedValueConverter.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2013 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.util.xml.converters; @@ -41,22 +27,19 @@ public abstract class QuotedValueConverter extends ResolvingConverter impl return 0; } - @Nullable - protected abstract T convertString(@Nullable final String string, final ConvertContext context); + protected abstract @Nullable T convertString(final @Nullable String string, final ConvertContext context); - @Nullable - protected abstract String convertValue(@Nullable final T t, final ConvertContext context); + protected abstract @Nullable String convertValue(final @Nullable T t, final ConvertContext context); protected abstract Object[] getReferenceVariants(final ConvertContext context, GenericDomValue genericDomValue, final TextRange rangeInElement); - protected abstract ResolveResult @NotNull [] multiResolveReference(@Nullable final T t, final ConvertContext context); + protected abstract ResolveResult @NotNull [] multiResolveReference(final @Nullable T t, final ConvertContext context); protected abstract @InspectionMessage String getUnresolvedMessage(String value); @Override - @NotNull - public Collection getVariants(final ConvertContext context) { + public @NotNull Collection getVariants(final ConvertContext context) { return Collections.emptyList(); } @@ -88,8 +71,7 @@ public abstract class QuotedValueConverter extends ResolvingConverter impl return new PsiReference[]{createPsiReference(element, start, end, true, context, genericDomValue, unclosedQuotation)}; } - @Nullable - public static String unquote(final String str) { + public static @Nullable String unquote(final String str) { return unquote(str, QUOTE_SIGNS); } @@ -110,13 +92,12 @@ public abstract class QuotedValueConverter extends ResolvingConverter impl return StringUtil.isNotEmpty(str) && str.charAt(0) != str.charAt(str.length()-1); } - @NotNull - protected PsiReference createPsiReference(final PsiElement element, - int start, int end, - final boolean isSoft, - final ConvertContext context, - final GenericDomValue genericDomValue, - final boolean badQuotation) { + protected @NotNull PsiReference createPsiReference(final PsiElement element, + int start, int end, + final boolean isSoft, + final ConvertContext context, + final GenericDomValue genericDomValue, + final boolean badQuotation) { return new MyPsiReference(element, new TextRange(start, end), isSoft, context, genericDomValue, badQuotation); } @@ -148,8 +129,7 @@ public abstract class QuotedValueConverter extends ResolvingConverter impl @SuppressWarnings("UnresolvedPropertyKey") @Override - @NotNull - public String getUnresolvedMessagePattern() { + public @NotNull String getUnresolvedMessagePattern() { return myBadQuotation ? XmlDomBundle.message("dom.inspections.invalid.value.quotation") : getUnresolvedMessage(getValue()); } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java index e7bcaac9a245..797c64397dc2 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java @@ -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.util.xml.converters.values; @@ -28,9 +14,9 @@ import java.util.Arrays; import java.util.Collection; public class BooleanValueConverter extends ResolvingConverter { - @NonNls private static final String BOOLEAN = "boolean"; + private static final @NonNls String BOOLEAN = "boolean"; - @NonNls private static final String[] VARIANTS = {"false", "true"}; + private static final @NonNls String[] VARIANTS = {"false", "true"}; private final boolean myAllowEmpty; @@ -46,8 +32,7 @@ public class BooleanValueConverter extends ResolvingConverter { myAllowEmpty = allowEmpty; } - @NonNls - public String[] getAllValues() { + public @NonNls String[] getAllValues() { final String[] strings = ArrayUtil.mergeArrays(getTrueValues(), getFalseValues()); Arrays.sort(strings); @@ -55,13 +40,11 @@ public class BooleanValueConverter extends ResolvingConverter { return strings; } - @NonNls - public String[] getTrueValues() { + public @NonNls String[] getTrueValues() { return new String[] {"true"}; } - @NonNls - public String[] getFalseValues() { + public @NonNls String[] getFalseValues() { return new String[] {"false"}; } @@ -70,7 +53,7 @@ public class BooleanValueConverter extends ResolvingConverter { } @Override - public String fromString(@Nullable @NonNls final String stringValue, final ConvertContext context) { + public String fromString(final @Nullable @NonNls String stringValue, final ConvertContext context) { if (stringValue != null && ((myAllowEmpty && stringValue.trim().length() == 0) || Arrays.binarySearch(getAllValues(), stringValue) >= 0)) { return stringValue; } @@ -78,18 +61,17 @@ public class BooleanValueConverter extends ResolvingConverter { } @Override - public String toString(@Nullable final String s, final ConvertContext context) { + public String toString(final @Nullable String s, final ConvertContext context) { return s; } @Override - @NotNull - public Collection getVariants(final ConvertContext context) { + public @NotNull Collection getVariants(final ConvertContext context) { return Arrays.asList(VARIANTS); } @Override - public String getErrorMessage(@Nullable final String s, final ConvertContext context) { + public String getErrorMessage(final @Nullable String s, final ConvertContext context) { return XmlDomBundle.message("dom.converter.format.exception", s, BOOLEAN); } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java index 88181bf71afe..15bf3e3251ed 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java @@ -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.util.xml.converters.values; import com.intellij.util.xml.ConvertContext; @@ -22,7 +8,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; public class CharacterValueConverter extends Converter { - @NonNls private static final String UNICODE_PREFIX = "\\u"; + private static final @NonNls String UNICODE_PREFIX = "\\u"; private static final int UNICODE_LENGTH = 6; private final boolean myAllowEmpty; @@ -59,7 +45,7 @@ public class CharacterValueConverter extends Converter { } @Override - public String getErrorMessage(@Nullable final String s, final ConvertContext context) { + public String getErrorMessage(final @Nullable String s, final ConvertContext context) { return XmlDomBundle.message("dom.converter.format.exception", s, "char"); } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java index b18bf570e687..792f3d963ab9 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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.util.xml.converters.values; @@ -33,13 +19,13 @@ public class NumberValueConverter extends ResolvingConverter numberClass, final boolean allowEmpty) { + public NumberValueConverter(final @NotNull Class numberClass, final boolean allowEmpty) { myNumberClass = numberClass; myAllowEmpty = allowEmpty; } @Override - public T fromString(@Nullable @NonNls final String s, final ConvertContext context) { + public T fromString(final @Nullable @NonNls String s, final ConvertContext context) { if (s == null) return null; if (myAllowEmpty && s.trim().length() == 0) { @@ -51,12 +37,12 @@ public class NumberValueConverter extends ResolvingConverter extends ResolvingConverter getVariants(ConvertContext context) { + public @NotNull Collection getVariants(ConvertContext context) { return Collections.emptySet(); } - @Nullable - public static String parseText(@NotNull Number value, @NotNull Class targetClass) { + public static @Nullable String parseText(@NotNull Number value, @NotNull Class targetClass) { if (targetClass.equals(Byte.class) || targetClass.equals(byte.class)) { return Byte.toString((Byte)value); } @@ -102,8 +86,7 @@ public class NumberValueConverter extends ResolvingConverter implements LocalQuickFi } @Override - @NotNull - public String getName() { + public @NotNull String getName() { return myName; } - @IntentionName - private String computeName() { + private @IntentionName String computeName() { final String name = myElement.getXmlElementName(); return XmlDomBundle.message(isTag() ? "dom.quickfix.add.element.name" : "dom.quickfix.add.attribute.name", name); } @@ -67,8 +51,7 @@ public class AddDomElementQuickFix implements LocalQuickFi } @Override - @NotNull - public String getFamilyName() { + public @NotNull String getFamilyName() { return XmlDomBundle.message("dom.quickfix.add.element.family"); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomCustomAnnotationChecker.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomCustomAnnotationChecker.java index 7890eb64cee4..61fc373f7d1e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomCustomAnnotationChecker.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomCustomAnnotationChecker.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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.util.xml.highlighting; import com.intellij.openapi.extensions.ExtensionPointName; @@ -29,8 +15,7 @@ import java.util.List; public abstract class DomCustomAnnotationChecker { static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.dom.customAnnotationChecker"); - @NotNull - public abstract Class getAnnotationClass(); + public abstract @NotNull Class getAnnotationClass(); public abstract List checkForProblems(@NotNull T t, @NotNull DomElement element, @NotNull DomElementAnnotationHolder holder, @NotNull DomHighlightingHelper helper); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManager.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManager.java index 12fc41587f36..84006152cf53 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManager.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManager.java @@ -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.util.xml.highlighting; @@ -19,11 +19,9 @@ public abstract class DomElementAnnotationsManager { return project.getService(DomElementAnnotationsManager.class); } - @NotNull - public abstract DomElementsProblemsHolder getProblemHolder(DomElement element); + public abstract @NotNull DomElementsProblemsHolder getProblemHolder(DomElement element); - @NotNull - public abstract DomElementsProblemsHolder getCachedProblemHolder(DomElement element); + public abstract @NotNull DomElementsProblemsHolder getCachedProblemHolder(DomElement element); public abstract List createProblemDescriptors(final InspectionManager manager, DomElementProblemDescriptor problemDescriptor); @@ -42,8 +40,7 @@ public abstract class DomElementAnnotationsManager { * @param inspection inspection to run on the given file element * @return collected DOM problem descriptors */ - @NotNull - public abstract List checkFileElement(@NotNull DomFileElement element, + public abstract @NotNull List checkFileElement(@NotNull DomFileElement element, @NotNull DomElementsInspection inspection, boolean onTheFly); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java index 194344ece7d2..958cc198d7f5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java @@ -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.util.xml.highlighting; @@ -99,8 +85,7 @@ public abstract class DomElementsInspection extends XmlSup /** * @return the classes passed earlier to the constructor */ - @NotNull - public final Set> getDomClasses() { + public final @NotNull Set> getDomClasses() { return myDomClasses; } @@ -124,8 +109,7 @@ public abstract class DomElementsInspection extends XmlSup } @Override - @NotNull - public HighlightDisplayLevel getDefaultLevel() { + public @NotNull HighlightDisplayLevel getDefaultLevel() { return HighlightDisplayLevel.ERROR; } @@ -137,8 +121,8 @@ public abstract class DomElementsInspection extends XmlSup /** * not intended to be overridden or called by implementors */ - protected ProblemDescriptor @Nullable [] checkDomFile(@NotNull final DomFileElement domFileElement, - @NotNull final InspectionManager manager, + protected ProblemDescriptor @Nullable [] checkDomFile(final @NotNull DomFileElement domFileElement, + final @NotNull InspectionManager manager, final boolean isOnTheFly) { final DomElementAnnotationsManager annotationsManager = DomElementAnnotationsManager.getInstance(manager.getProject()); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomHighlightingHelper.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomHighlightingHelper.java index 23a4f37f7dbf..16d9272e243b 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomHighlightingHelper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomHighlightingHelper.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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.util.xml.highlighting; import com.intellij.util.SmartList; @@ -12,14 +12,11 @@ import java.util.List; public abstract class DomHighlightingHelper { - @NotNull - public abstract List checkRequired(DomElement element, DomElementAnnotationHolder holder); + public abstract @NotNull List checkRequired(DomElement element, DomElementAnnotationHolder holder); - @NotNull - public abstract List checkResolveProblems(GenericDomValue element, DomElementAnnotationHolder holder); + public abstract @NotNull List checkResolveProblems(GenericDomValue element, DomElementAnnotationHolder holder); - @NotNull - public abstract List checkNameIdentity(DomElement element, DomElementAnnotationHolder holder); + public abstract @NotNull List checkNameIdentity(DomElement element, DomElementAnnotationHolder holder); public abstract void runAnnotators(DomElement element, DomElementAnnotationHolder holder, @NotNull Class rootClass); @@ -30,8 +27,7 @@ public abstract class DomHighlightingHelper { * @param holder Holder instance. * @return Collected problem descriptors. */ - @NotNull - public List checkCustomAnnotations(final DomElement element, final DomElementAnnotationHolder holder) { + public @NotNull List checkCustomAnnotations(final DomElement element, final DomElementAnnotationHolder holder) { List result = null; for (DomCustomAnnotationChecker checker : DomCustomAnnotationChecker.EP_NAME.getExtensionList()) { final List list = checkAnno(element, checker, holder); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java index 4594a0386ad5..b0b474abd548 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java @@ -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.util.xml.highlighting; @@ -40,14 +26,12 @@ public class RemoveDomElementQuickFix implements LocalQuickFix { } @Override - @NotNull - public String getName() { + public @NotNull String getName() { return XmlDomBundle.message(myIsTag ? "dom.quickfix.remove.element.name" : "dom.quickfix.remove.attribute.name", myName); } @Override - @NotNull - public String getFamilyName() { + public @NotNull String getFamilyName() { return XmlDomBundle.message("dom.quickfix.remove.element.family"); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java index ce6ff98b750d..491e27203c72 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java @@ -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.util.xml.highlighting; @@ -64,30 +50,27 @@ public class ResolvingElementQuickFix implements LocalQuickFix, IntentionAction } @Override - @NotNull - public String getName() { + public @NotNull String getName() { return XmlDomBundle.message("dom.quickfix.create.new.element.name", myTypeName, myNewName); } @Override - @NotNull - public String getText() { + public @NotNull String getText() { return getName(); } @Override - @NotNull - public String getFamilyName() { + public @NotNull String getFamilyName() { return XmlDomBundle.message("dom.quickfix.create.new.element.family"); } @Override - public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { + public boolean isAvailable(final @NotNull Project project, final Editor editor, final PsiFile file) { return true; } @Override - public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { + public void invoke(final @NotNull Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { applyFix(); } @@ -97,7 +80,7 @@ public class ResolvingElementQuickFix implements LocalQuickFix, IntentionAction } @Override - public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { + public void applyFix(final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) { applyFix(); } @@ -132,16 +115,14 @@ public class ResolvingElementQuickFix implements LocalQuickFix, IntentionAction } @Override - @NotNull - public String getTextFor(final DomElement value) { + public @NotNull String getTextFor(final DomElement value) { return DomUtil.getFile(value).getName(); } }).showInBestPositionFor(DataManager.getInstance().getDataContext()); } } - @Nullable - public static DomCollectionChildDescription getChildDescription(final List contexts, Class clazz) { + public static @Nullable DomCollectionChildDescription getChildDescription(final List contexts, Class clazz) { if (contexts.size() == 0) { return null; @@ -158,14 +139,12 @@ public class ResolvingElementQuickFix implements LocalQuickFix, IntentionAction return null; } - @Nullable - public static ResolvingElementQuickFix createFix(final String newName, final Class clazz, final DomElement scope) { + public static @Nullable ResolvingElementQuickFix createFix(final String newName, final Class clazz, final DomElement scope) { final List parents = ModelMergerUtil.getImplementations(scope); return createFix(newName, clazz, parents); } - @Nullable - public static ResolvingElementQuickFix createFix(final String newName, final Class clazz, final List parents) { + public static @Nullable ResolvingElementQuickFix createFix(final String newName, final Class clazz, final List parents) { final DomCollectionChildDescription childDescription = getChildDescription(parents, clazz); if (newName.length() > 0 && childDescription != null) { return new ResolvingElementQuickFix(clazz, newName, parents, childDescription); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java index 1a42c9a3dbde..4ab05488925e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java @@ -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.util.xml.model.impl; import com.intellij.openapi.project.Project; @@ -43,8 +29,7 @@ public abstract class BaseDomModelFactory computeAllModels(@NotNull S scope); + protected abstract @Nullable List computeAllModels(@NotNull S scope); protected abstract M createCombinedModel(Set configFiles, DomFileElement mergedModel, M firstModel, final S scope); @@ -108,9 +90,8 @@ public abstract class BaseDomModelFactory models = getAllModels(s); return switch (models.size()) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactory.java index 9cea76349b2f..43a1d23df393 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactory.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml.model.impl; @@ -31,8 +31,7 @@ public abstract class DomModelFactory getConfigFiles(@Nullable C context) { + public @NotNull Set getConfigFiles(@Nullable C context) { if (context == null) { return Collections.emptySet(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactoryHelper.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactoryHelper.java index 50e3c76be143..fd5f7c9b3739 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactoryHelper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelFactoryHelper.java @@ -1,25 +1,11 @@ -/* - * Copyright 2000-2009 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.util.xml.model.impl; -import com.intellij.util.xml.ModelMerger; +import com.intellij.psi.xml.XmlFile; +import com.intellij.util.xml.DomElement; import com.intellij.util.xml.DomFileElement; import com.intellij.util.xml.DomManager; -import com.intellij.util.xml.DomElement; -import com.intellij.psi.xml.XmlFile; +import com.intellij.util.xml.ModelMerger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -32,14 +18,12 @@ public class DomModelFactoryHelper { myModelMerger = modelMerger; } - @Nullable - public T getDom(@NotNull XmlFile configFile) { + public @Nullable T getDom(@NotNull XmlFile configFile) { final DomFileElement element = getDomRoot(configFile); return element == null ? null : element.getRootElement(); } - @Nullable - public DomFileElement getDomRoot(@NotNull XmlFile configFile) { + public @Nullable DomFileElement getDomRoot(@NotNull XmlFile configFile) { return DomManager.getDomManager(configFile.getProject()).getFileElement(configFile, myClass); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelImpl.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelImpl.java index f27af810144f..7428628d56f5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelImpl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/DomModelImpl.java @@ -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.util.xml.model.impl; @@ -51,8 +37,7 @@ public class DomModelImpl implements DomModel { } @Override - @NotNull - public T getMergedModel() { + public @NotNull T getMergedModel() { if (myMergedModel == null) { final DomManager domManager = DomManager.getDomManager(myProject); return domManager.createModelMerger().mergeModels(myClass, ContainerUtil.mapNotNull(myConfigFiles, @@ -65,22 +50,19 @@ public class DomModelImpl implements DomModel { } @Override - @NotNull - public Set getConfigFiles() { + public @NotNull Set getConfigFiles() { return myConfigFiles; } @Override - @NotNull - public List> getRoots() { + public @NotNull List> getRoots() { if (myMergedModel == null) { return ContainerUtil.mapNotNull(myConfigFiles, (NullableFunction>)xmlFile -> DomManager.getDomManager(xmlFile.getProject()).getFileElement(xmlFile, myClass)); } return myMergedModel instanceof MergedObject ? ((MergedObject) myMergedModel).getImplementations() : Collections.singletonList(myMergedModel); } - @NotNull - public Project getProject() { + public @NotNull Project getProject() { return myProject; } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/reflect/CustomDomChildrenDescription.java b/xml/dom-openapi/src/com/intellij/util/xml/reflect/CustomDomChildrenDescription.java index 3cecfd32b9f8..37d62d9fca45 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/reflect/CustomDomChildrenDescription.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/reflect/CustomDomChildrenDescription.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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.util.xml.reflect; @@ -39,13 +25,11 @@ public interface CustomDomChildrenDescription extends AbstractDomChildrenDescrip return Collections.emptySet(); } - @Nullable - public PomTarget findDeclaration(DomElement parent, @NotNull EvaluatedXmlName name) { + public @Nullable PomTarget findDeclaration(DomElement parent, @NotNull EvaluatedXmlName name) { return null; } - @Nullable - public PomTarget findDeclaration(@NotNull DomElement child) { + public @Nullable PomTarget findDeclaration(@NotNull DomElement child) { return child.getChildDescription(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtender.java b/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtender.java index cbcb2cf57522..e6b9833ad3fa 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtender.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtender.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml.reflect; import com.intellij.util.xml.DomElement; @@ -19,7 +19,7 @@ public abstract class DomExtender { * @param t DOM element where new children may be added to * @param registrar a place to register your own DOM children descriptions */ - public abstract void registerExtensions(@NotNull T t, @NotNull final DomExtensionsRegistrar registrar); + public abstract void registerExtensions(@NotNull T t, final @NotNull DomExtensionsRegistrar registrar); /** * Makes stub building for extensions available. diff --git a/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtensionsRegistrar.java b/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtensionsRegistrar.java index 55206bb548aa..69e788b9630c 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtensionsRegistrar.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomExtensionsRegistrar.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.util.xml.reflect; @@ -50,19 +36,19 @@ public interface DomExtensionsRegistrar { * @return dom extension object */ @NotNull - DomExtension registerAttributeChildExtension(@NotNull XmlName name, @NotNull final Type type); + DomExtension registerAttributeChildExtension(@NotNull XmlName name, final @NotNull Type type); /** * @see com.intellij.util.xml.CustomChildren */ @NotNull - DomExtension registerCustomChildrenExtension(@NotNull final Type type); + DomExtension registerCustomChildrenExtension(final @NotNull Type type); @NotNull - DomExtension registerCustomChildrenExtension(@NotNull final Type type, + DomExtension registerCustomChildrenExtension(final @NotNull Type type, @NotNull CustomDomChildrenDescription.TagNameDescriptor descriptor); @NotNull - DomExtension registerCustomChildrenExtension(@NotNull final Type type, + DomExtension registerCustomChildrenExtension(final @NotNull Type type, @NotNull CustomDomChildrenDescription.AttributeDescriptor attributeDescriptor); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java index 74e5d25e0f91..71fdeba32a5e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.ui; import com.intellij.codeInspection.util.InspectionMessage; @@ -37,14 +37,14 @@ import java.util.List; public abstract class AbstractTableView extends JPanel implements DataProvider { private final MyTableView myTable = new MyTableView(); - @NonNls private final String myHelpID; - @Nls(capitalization = Nls.Capitalization.Sentence) private final String myEmptyPaneText; + private final @NonNls String myHelpID; + private final @Nls(capitalization = Nls.Capitalization.Sentence) String myEmptyPaneText; private final JPanel myInnerPanel; private final Project myProject; private TableCellRenderer[][] myCachedRenderers; private EmptyPane myEmptyPane; - @NonNls private static final String TREE = "Tree"; - @NonNls private static final String EMPTY_PANE = "EmptyPane"; + private static final @NonNls String TREE = "Tree"; + private static final @NonNls String EMPTY_PANE = "EmptyPane"; private final EventDispatcher myDispatcher = EventDispatcher.create(ChangeListener.class); private final MyListTableModel myTableModel = new MyListTableModel(); @@ -53,8 +53,8 @@ public abstract class AbstractTableView extends JPanel implements DataProvide } public AbstractTableView(final Project project, - @Nls(capitalization = Nls.Capitalization.Sentence) @Nullable final String emptyPaneText, - @NonNls @Nullable final String helpID) { + final @Nls(capitalization = Nls.Capitalization.Sentence) @Nullable String emptyPaneText, + final @NonNls @Nullable String helpID) { super(new BorderLayout()); myProject = project; myTableModel.setSortable(false); @@ -183,8 +183,7 @@ public abstract class AbstractTableView extends JPanel implements DataProvide return width; } - @Nls(capitalization = Nls.Capitalization.Sentence) - protected String getEmptyPaneText() { + protected @Nls(capitalization = Nls.Capitalization.Sentence) String getEmptyPaneText() { return myEmptyPaneText; } @@ -210,9 +209,8 @@ public abstract class AbstractTableView extends JPanel implements DataProvide return myTableModel; } - @Nullable @Override - public Object getData(@NotNull String dataId) { + public @Nullable Object getData(@NotNull String dataId) { if (PlatformCoreDataKeys.HELP_ID.is(dataId)) { return getHelpId(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java index 93c26193ef79..e3f1f6f089c0 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.util.xml.ui; import com.intellij.openapi.command.WriteCommandAction; @@ -104,8 +90,7 @@ public abstract class BaseControl extends DomUICont updateComponent(); } - @Nullable - protected JComponent getComponentToListenFocusLost(Bound component) { + protected @Nullable JComponent getComponentToListenFocusLost(Bound component) { return null; } @@ -243,8 +228,7 @@ public abstract class BaseControl extends DomUICont public void navigate(DomElement element) { } - @Nullable - protected abstract T getValue(); + protected abstract @Nullable T getValue(); protected abstract void setValue(T value); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java index 17a7dc7714ee..b45efc543289 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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.util.xml.ui; @@ -58,7 +44,7 @@ public abstract class BasicDomElementComponent extends Abs DomElementAnnotationsManager.getInstance(domElement.getManager().getProject()).addHighlightingListener(new DomElementAnnotationsManager.DomHighlightingListener() { @Override - public void highlightingFinished(@NotNull final DomFileElement element) { + public void highlightingFinished(final @NotNull DomFileElement element) { ApplicationManager.getApplication().invokeLater(() -> { if (getComponent().isShowing() && element.isValid()) { updateHighlighting(); @@ -114,8 +100,7 @@ public abstract class BasicDomElementComponent extends Abs return null; } - @NotNull - private String convertFieldName(@NotNull String propertyName, final DomChildrenDescription description) { + private @NotNull String convertFieldName(@NotNull String propertyName, final DomChildrenDescription description) { propertyName = StringUtil.trimStart(propertyName, "my"); String convertedName = description.getDomNameStrategy(getDomElement()).convertName(propertyName); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java index 14a2b6993376..44e9c8b7d780 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java @@ -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.util.xml.ui; @@ -71,8 +57,7 @@ public class CaptionComponent extends JPanel implements Committable, Highlightab myCaptionLabel.setText(text); } - @Nls - public String getText() { + public @Nls String getText() { return myCaptionLabel.getText(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java index 84870365ac54..5dbdebffcdc2 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.ui; import com.intellij.openapi.util.NlsContexts.ColumnName; @@ -18,7 +18,7 @@ public class ChildGenericValueColumnInfo extends DomColumn private final DomFixedChildDescription myChildDescription; public ChildGenericValueColumnInfo(final @ColumnName String name, - @NotNull final DomFixedChildDescription description, + final @NotNull DomFixedChildDescription description, final TableCellRenderer renderer, final TableCellEditor editor) { super(name, renderer); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java index af6b9303c291..b458d9fad08c 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java @@ -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.util.xml.ui; import com.intellij.lang.annotation.HighlightSeverity; @@ -88,8 +74,7 @@ public class ComboControl extends BaseModifiableControl pair = (Pair)getComponent().getSelectedItem(); return pair == null || pair == EMPTY ? null : pair.first; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java index 8806f14afe8f..2c409987ee20 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java @@ -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.util.xml.ui; @@ -25,7 +25,7 @@ public class CommitablePanelUserActivityListener implements UserActivityListener } @Override - final public void stateChanged() { + public final void stateChanged() { if (myApplying) return; cancel(); cancelAllRequests(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java index 7883b3a3fb9a..87102b268719 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.ui; import com.intellij.codeInspection.util.InspectionMessage; @@ -117,22 +117,19 @@ public class DomCollectionControl extends DomUIControl imp myCollectionPanel.getTable().setRowSelectionInterval(index, index); } - @Nullable @Override - public Object getData(@NotNull String dataId) { + public @Nullable Object getData(@NotNull String dataId) { if (DOM_COLLECTION_CONTROL.is(dataId)) { return this; } return null; } - @Nullable @NonNls - protected String getHelpId() { + protected @Nullable @NonNls String getHelpId() { return null; } - @Nullable @Nls - protected String getEmptyPaneText() { + protected @Nullable @Nls String getEmptyPaneText() { return null; } @@ -295,8 +292,7 @@ public class DomCollectionControl extends DomUIControl imp }; } - @Nullable - private static DomEditorManager getDomEditorManager(DomUIControl control) { + private static @Nullable DomEditorManager getDomEditorManager(DomUIControl control) { JComponent component = control.getComponent(); while (component != null && !(component instanceof DomEditorManager)) { final Container parent = component.getParent(); @@ -356,7 +352,7 @@ public class DomCollectionControl extends DomUIControl imp } @Override - protected final void afterAddition(@NotNull final T newElement) { + protected final void afterAddition(final @NotNull T newElement) { reset(); afterAddition(myCollectionPanel.getTable(), myCollectionElements.size() - 1); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java index 8a8c8fefeea5..b0e3e8b881a5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java @@ -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.util.xml.ui; import com.intellij.codeHighlighting.BackgroundEditorHighlighter; @@ -66,8 +66,7 @@ public class DomFileEditor extends Perspecti } @Override - @Nullable - public JComponent getPreferredFocusedComponent() { + public @Nullable JComponent getPreferredFocusedComponent() { ensureInitialized(); return myComponent.getComponent(); } @@ -77,8 +76,7 @@ public class DomFileEditor extends Perspecti } @Override - @NotNull - protected JComponent createCustomComponent() { + protected @NotNull JComponent createCustomComponent() { MnemonicHelper.init(getComponent()); myComponent = myComponentFactory.create(); DomUIFactory.getDomUIFactory().setupErrorOutdatingUserActivityWatcher(this, getDomElement()); @@ -93,8 +91,7 @@ public class DomFileEditor extends Perspecti } @Override - @NotNull - public final String getName() { + public final @NotNull String getName() { return myName; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java index 7c77a67d6559..fcc390cfc078 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java @@ -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.util.xml.ui; import com.intellij.util.xml.DomElement; @@ -45,8 +31,7 @@ public class DomFixedWrapper extends DomWrapper{ } @Override - @NotNull - public DomElement getExistingDomElement() { + public @NotNull DomElement getExistingDomElement() { return myDomElement; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java index 521f9302ca6b..724ff5d6d315 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java @@ -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.util.xml.ui; import com.intellij.util.xml.DomElement; @@ -29,8 +15,7 @@ public class DomStringWrapper extends DomWrapper{ } @Override - @NotNull - public DomElement getExistingDomElement() { + public @NotNull DomElement getExistingDomElement() { return myDomElement; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java index 3b1a6541cd97..54f6018e3685 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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.util.xml.ui; import com.intellij.openapi.actionSystem.DataProvider; @@ -42,9 +28,8 @@ public class DomTableView extends AbstractTableView { myCustomDataProviders.add(provider); } - @Nullable @Override - public Object getData(@NotNull String dataId) { + public @Nullable Object getData(@NotNull String dataId) { for (DataProvider provider : myCustomDataProviders) { Object data = provider.getData(dataId); if (data != null) return data; @@ -53,7 +38,7 @@ public class DomTableView extends AbstractTableView { } @Override - protected void wrapValueSetting(@NotNull final DomElement domElement, final Runnable valueSetter) { + protected void wrapValueSetting(final @NotNull DomElement domElement, final Runnable valueSetter) { if (domElement.isValid()) { WriteCommandAction.writeCommandAction(getProject(), DomUtil.getFile(domElement)).run(() -> valueSetter.run()); fireChanged(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIControl.java index b51420fc3bbc..1cc5fe1153a0 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIControl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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.util.xml.ui; import com.intellij.util.xml.DomElement; @@ -40,7 +26,7 @@ public abstract class DomUIControl implements CommittableP public void addDependency(final DomUIControl control) { control.addCommitListener(new CommitAdapter() { @Override - public void afterCommit(@NotNull final DomUIControl control) { + public void afterCommit(final @NotNull DomUIControl control) { reset(); } }); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java index fecb0e4b9589..4421a2c6bc7e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.ui; import com.intellij.codeHighlighting.BackgroundEditorHighlighter; @@ -86,8 +86,7 @@ public abstract class DomUIFactory { protected abstract TableCellEditor createCellEditor(DomElement element, Class type); - @NotNull - public abstract UserActivityWatcher createEditorAwareUserActivityWatcher(); + public abstract @NotNull UserActivityWatcher createEditorAwareUserActivityWatcher(); public abstract void setupErrorOutdatingUserActivityWatcher(CommittablePanel panel, DomElement... elements); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomWrapper.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomWrapper.java index aa3e8e2564d8..5f518fe4edca 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomWrapper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomWrapper.java @@ -1,37 +1,21 @@ -/* - * Copyright 2000-2009 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.util.xml.ui; -import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomUtil; import com.intellij.openapi.project.Project; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.xml.XmlFile; -import org.jetbrains.annotations.Nullable; +import com.intellij.util.xml.DomElement; +import com.intellij.util.xml.DomUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.lang.reflect.InvocationTargetException; public abstract class DomWrapper { - @NotNull - public abstract DomElement getExistingDomElement(); + public abstract @NotNull DomElement getExistingDomElement(); - @Nullable - public abstract DomElement getWrappedElement(); + public abstract @Nullable DomElement getWrappedElement(); public abstract void setValue(T value) throws IllegalAccessException, InvocationTargetException; public abstract T getValue() throws IllegalAccessException, InvocationTargetException; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java index 062daf489faa..b53ee3733dc7 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java @@ -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.util.xml.ui; @@ -40,7 +26,7 @@ public class ErrorableTableCellRenderer extends DefaultTab private final T myCellValueDomElement; private final DomElement myRoot; - public ErrorableTableCellRenderer(@Nullable final T cellValueDomElement, final TableCellRenderer renderer, @NotNull final DomElement rowDomElement) { + public ErrorableTableCellRenderer(final @Nullable T cellValueDomElement, final TableCellRenderer renderer, final @NotNull DomElement rowDomElement) { myCellValueDomElement = cellValueDomElement; myRenderer = renderer; myRowDomElement = rowDomElement; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/MultiLineTextPanel.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/MultiLineTextPanel.java index 0e7d71309412..68901034ffc6 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/MultiLineTextPanel.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/MultiLineTextPanel.java @@ -1,28 +1,14 @@ -/* - * Copyright 2000-2009 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.util.xml.ui; -public class MultiLineTextPanel extends TextPanel{ - private int myRowCount = 3; +public final class MultiLineTextPanel extends TextPanel { + private int rowCount = 3; - public final int getRowCount() { - return myRowCount; + public int getRowCount() { + return rowCount; } - public final void setRowCount(final int rowCount) { - myRowCount = rowCount; + public void setRowCount(final int rowCount) { + this.rowCount = rowCount; } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java index 98b4fb8e4b1a..f42767123ac5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.util.xml.ui; import com.intellij.openapi.fileEditor.FileEditorPolicy; @@ -24,25 +10,19 @@ import org.jetbrains.annotations.NotNull; public abstract class PerspectiveFileEditorProvider extends WeighedFileEditorProvider { @Override - @NotNull - public abstract PerspectiveFileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file); + public abstract @NotNull PerspectiveFileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file); @Override - @NotNull - @NonNls - public final String getEditorTypeId() { + public final @NotNull @NonNls String getEditorTypeId() { return getComponentName(); } @Override - @NotNull - public final FileEditorPolicy getPolicy() { + public final @NotNull FileEditorPolicy getPolicy() { return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR; } - @NonNls - public final String getComponentName() { + public final @NonNls String getComponentName() { return getClass().getName(); } - } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/TooltipUtils.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/TooltipUtils.java index ebed58569382..c0e4b6bf0b84 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/TooltipUtils.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/TooltipUtils.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.ui; @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NonNls; import java.util.List; public final class TooltipUtils { - @NonNls private static final HtmlChunk MESSAGE_DELIMITER = HtmlChunk.hr().attr("size", "1") + private static final @NonNls HtmlChunk MESSAGE_DELIMITER = HtmlChunk.hr().attr("size", "1") .attr("noshade", "noshade"); public static @NlsContexts.Tooltip String getTooltipText(List annotations) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java index ceaa2233b2bc..b86786cddd89 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.ui.actions; import com.intellij.icons.AllIcons; @@ -79,8 +79,7 @@ public abstract class AddDomElementAction extends AnAction { } } - @NlsActions.ActionText - protected String getActionText(final AnActionEvent e) { + protected @NlsActions.ActionText String getActionText(final AnActionEvent e) { return e.getPresentation().getText(); } @@ -146,8 +145,7 @@ public abstract class AddDomElementAction extends AnAction { protected abstract DomCollectionChildDescription @NotNull [] getDomCollectionChildDescriptions(final AnActionEvent e); - @Nullable - protected abstract DomElement getParentDomElement(final AnActionEvent e); + protected abstract @Nullable DomElement getParentDomElement(final AnActionEvent e); protected abstract JComponent getComponent(AnActionEvent e); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java index aeef4bdd9e81..5859395193fc 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.util.xml.ui.actions; import com.intellij.openapi.actionSystem.AnAction; @@ -48,15 +48,14 @@ public abstract class DefaultAddAction extends AnAction { } @Override - public final void actionPerformed(@NotNull final AnActionEvent e) { + public final void actionPerformed(final @NotNull AnActionEvent e) { final T result = performElementAddition(); if (result != null) { afterAddition(result); } } - @Nullable - protected T performElementAddition() { + protected @Nullable T performElementAddition() { final DomElement parent = getParentDomElement(); final DomManager domManager = parent.getManager(); final TypeChooser[] oldChoosers = new TypeChooser[]{null}; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/CreateDomElementAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/CreateDomElementAction.java index da4aae693793..2519d8c2fdda 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/CreateDomElementAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/CreateDomElementAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 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.util.xml.ui.actions.generate; import com.intellij.codeInsight.actions.SimpleCodeInsightAction; @@ -38,8 +38,7 @@ public abstract class CreateDomElementAction extends Simpl return getContextElement(editor) != null; } - @Nullable - protected T getContextElement(Editor editor) { + protected @Nullable T getContextElement(Editor editor) { return DomUtil.getContextElement(editor, myContextClass); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java index 5672659f5490..276ccc55b34e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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.util.xml.ui.actions.generate; @@ -33,7 +19,7 @@ public class GenerateDomElementAction extends CodeInsightAction { protected final GenerateDomElementProvider myProvider; - public GenerateDomElementAction(@NotNull final GenerateDomElementProvider generateProvider, @Nullable Icon icon) { + public GenerateDomElementAction(final @NotNull GenerateDomElementProvider generateProvider, @Nullable Icon icon) { getTemplatePresentation().setDescription(generateProvider.getDescription()); getTemplatePresentation().setText(generateProvider.getText()); getTemplatePresentation().setIcon(icon); @@ -47,11 +33,10 @@ public class GenerateDomElementAction extends CodeInsightAction { } @Override - @NotNull - protected CodeInsightActionHandler getHandler() { + protected @NotNull CodeInsightActionHandler getHandler() { return 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) { final Runnable runnable = () -> { final DomElement element = myProvider.generate(project, editor, file); myProvider.navigate(element); @@ -77,7 +62,7 @@ public class GenerateDomElementAction extends CodeInsightAction { } @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) { final DomElement element = DomUtil.getContextElement(editor); return element != null && myProvider.isAvailableForElement(element); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java index c4c60984ca04..2c1b76bfdce6 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java @@ -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.util.xml.ui.actions.generate; @@ -41,8 +27,7 @@ public abstract class GenerateDomElementProvider { return true; } - @Nullable - public abstract T generate(final Project project, final Editor editor, final PsiFile file); + public abstract @Nullable T generate(final Project project, final Editor editor, final PsiFile file); public void navigate(final DomElement element) { if (element != null && element.isValid()) {