Cleanup (typos; formatting)

GitOrigin-RevId: 9733aeebbae11f645b17261f25692b92557ccd3a
This commit is contained in:
Roman Shevchenko
2024-05-12 20:17:53 +02:00
committed by intellij-monorepo-bot
parent fb5023db6b
commit ac742921c5
6 changed files with 43 additions and 51 deletions

View File

@@ -18,12 +18,12 @@ public class PsiClassControl extends JavaControlBase<PsiClassPanel> {
}
@Override
protected EditorTextField getEditorTextField(final @NotNull PsiClassPanel component) {
protected EditorTextField getEditorTextField(@NotNull PsiClassPanel component) {
return ((ReferenceEditorWithBrowseButton)component.getComponent(0)).getEditorTextField();
}
@Override
protected PsiClassPanel createMainComponent(PsiClassPanel boundedComponent, final Project project) {
protected PsiClassPanel createMainComponent(PsiClassPanel boundedComponent, Project project) {
if (boundedComponent == null) {
boundedComponent = new PsiClassPanel();
}
@@ -32,7 +32,7 @@ public class PsiClassControl extends JavaControlBase<PsiClassPanel> {
PsiCodeFragmentImpl fragment = (PsiCodeFragmentImpl) PsiDocumentManager.getInstance(project).getPsiFile(document);
assert fragment != null;
fragment.setIntentionActionsFilter(IntentionFilterOwner.IntentionActionsFilter.EVERYTHING_AVAILABLE);
fragment.putUserData(ModuleUtil.KEY_MODULE, getDomWrapper().getExistingDomElement().getModule());
fragment.putUserData(ModuleUtilCore.KEY_MODULE, getDomWrapper().getExistingDomElement().getModule());
return initReferenceEditorWithBrowseButton(boundedComponent, editor, this);
}
}

View File

@@ -20,22 +20,21 @@ public class PsiTypeControl extends JavaControlBase<PsiTypePanel> {
@Override
protected @NotNull String getValue() {
final String rawValue = super.getValue();
String rawValue = super.getValue();
try {
final PsiType psiType = JavaPsiFacade.getElementFactory(getProject()).createTypeFromText(rawValue, null);
final String s = JvmPsiTypeConverterImpl.convertToString(psiType);
PsiType psiType = JavaPsiFacade.getElementFactory(getProject()).createTypeFromText(rawValue, null);
String s = JvmPsiTypeConverterImpl.convertToString(psiType);
if (s != null) {
return s;
}
}
catch (IncorrectOperationException ignored) {
}
catch (IncorrectOperationException ignored) { }
return rawValue;
}
@Override
protected void setValue(String value) {
final PsiType type = JvmPsiTypeConverterImpl.convertFromString(value, new AbstractConvertContext() {
PsiType type = JvmPsiTypeConverterImpl.convertFromString(value, new AbstractConvertContext() {
@Override
public @NotNull DomElement getInvocationElement() {
return getDomElement();
@@ -48,12 +47,12 @@ public class PsiTypeControl extends JavaControlBase<PsiTypePanel> {
}
@Override
protected EditorTextField getEditorTextField(final @NotNull PsiTypePanel component) {
protected EditorTextField getEditorTextField(@NotNull PsiTypePanel component) {
return ((ReferenceEditorWithBrowseButton)component.getComponent(0)).getEditorTextField();
}
@Override
protected PsiTypePanel createMainComponent(PsiTypePanel boundedComponent, final Project project) {
protected PsiTypePanel createMainComponent(PsiTypePanel boundedComponent, Project project) {
if (boundedComponent == null) {
boundedComponent = new PsiTypePanel();
}

View File

@@ -121,7 +121,7 @@ checkbox.use.throws.rather.than.exception=Use @throws rather than @exception
checkbox.warn.if.only.foreach.replacement.is.available=Warn if only 'forEach' replacement is available
checkbox.warn.if.the.loop.is.trivial=Warn if the loop is trivial
checkbox.wrap.at.right.margin=Wrap at right margin
choose.class=Choose class
choose.class=Choose Class
chooser.text.choose.where.to.save.0=Choose where to save ''{0}''
chooser.title.select.path.to.save.jar=Select Path to Save Jar
class.decorator.or.has.default.constructor=''{0}'' should have default constructor or implement ''Decorator'' pattern
@@ -1932,4 +1932,4 @@ intention.name.delete.method.title=Delete Method ''{0}()''
intention.name.delete.method.with.callees=... along with other private methods used only there
intention.name.delete.method.only=... and nothing else
intention.family.name.delete.private.method=Delete private method
checkbox.check.for.jdk.updates=Check for JDK updates
checkbox.check.for.jdk.updates=Check for JDK updates

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 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 org.jetbrains.kotlin.idea.codeInsight.inspections.shared
@@ -100,7 +100,7 @@ class NamingConventionInspectionSettings(
setNamePatternCallback.invoke(value)
nameRegex = try {
value.toRegex()
} catch (e: PatternSyntaxException) {
} catch (_: PatternSyntaxException) {
null
}
}
@@ -160,10 +160,6 @@ sealed class NamingConventionInspection(
namingSettings.verifyName(element, holder, additionalCheck, rules)
}
protected fun getNameMismatchMessage(name: String): String {
return namingSettings.getNameMismatchMessage(name, rules)
}
override fun getOptionsPane(): OptPane = namingSettings.getOptionsPane()
override fun getOptionController(): OptionController = namingSettings.getOptionController()
@@ -511,4 +507,4 @@ class PackageNameInspection : BaseGlobalInspection() {
override fun getSharedLocalInspectionTool(): LocalInspectionTool {
return PackageNameInspectionLocal(this, namingSettings)
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 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.lang.annotation.HighlightSeverity;
@@ -37,6 +37,7 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
throw new UnsupportedOperationException("Shouldn't be shown");
}
};
private final boolean myCommitOnEveryChange;
private final DocumentListener myListener = new DocumentListener() {
@Override
@@ -48,13 +49,12 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
}
};
protected EditorTextFieldControl(final DomWrapper<String> domWrapper, final boolean commitOnEveryChange) {
protected EditorTextFieldControl(DomWrapper<String> domWrapper, boolean commitOnEveryChange) {
super(domWrapper);
myCommitOnEveryChange = commitOnEveryChange;
}
protected EditorTextFieldControl(final DomWrapper<String> domWrapper) {
protected EditorTextFieldControl(DomWrapper<String> domWrapper) {
this(domWrapper, false);
}
@@ -62,28 +62,28 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
@Override
protected void doReset() {
final EditorTextField textField = getEditorTextField(getComponent());
EditorTextField textField = getEditorTextField(getComponent());
textField.getDocument().removeDocumentListener(myListener);
super.doReset();
textField.getDocument().addDocumentListener(myListener);
}
@Override
protected JComponent getComponentToListenFocusLost(final T component) {
protected JComponent getComponentToListenFocusLost(T component) {
return getEditorTextField(getComponent());
}
@Override
protected JComponent getHighlightedComponent(final T component) {
protected JComponent getHighlightedComponent(T component) {
return J_TEXT_FIELD;
}
@Override
protected T createMainComponent(T boundedComponent) {
final Project project = getProject();
Project project = getProject();
boundedComponent = createMainComponent(boundedComponent, project);
final EditorTextField editorTextField = getEditorTextField(boundedComponent);
EditorTextField editorTextField = getEditorTextField(boundedComponent);
editorTextField.setSupplementary(true);
editorTextField.getDocument().addDocumentListener(myListener);
return boundedComponent;
@@ -97,46 +97,46 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
}
@Override
protected void setValue(final String value) {
protected void setValue(String value) {
CommandProcessor.getInstance().runUndoTransparentAction(() -> WriteAction.run(() -> {
final T component = getComponent();
final Document document = getEditorTextField(component).getDocument();
T component = getComponent();
Document document = getEditorTextField(component).getDocument();
document.replaceString(0, document.getTextLength(), value == null ? "" : value);
}));
}
@Override
protected void updateComponent() {
final DomElement domElement = getDomElement();
DomElement domElement = getDomElement();
if (domElement == null || !domElement.isValid()) return;
final EditorTextField textField = getEditorTextField(getComponent());
final Project project = getProject();
EditorTextField textField = getEditorTextField(getComponent());
Project project = getProject();
ApplicationManager.getApplication().invokeLater(() -> {
if (!project.isOpen()) return;
if (!getDomWrapper().isValid()) return;
final DomElement domElement1 = getDomElement();
DomElement domElement1 = getDomElement();
if (domElement1 == null || !domElement1.isValid()) return;
final DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
final DomElementsProblemsHolder holder = manager.getCachedProblemHolder(domElement1);
final List<DomElementProblemDescriptor> errorProblems = holder.getProblems(domElement1);
final List<DomElementProblemDescriptor> warningProblems =
DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
DomElementsProblemsHolder holder = manager.getCachedProblemHolder(domElement1);
List<DomElementProblemDescriptor> errorProblems = holder.getProblems(domElement1);
List<DomElementProblemDescriptor> warningProblems =
new ArrayList<>(holder.getProblems(domElement1, true, HighlightSeverity.WARNING));
warningProblems.removeAll(errorProblems);
Color background = getDefaultBackground();
if (errorProblems.size() > 0 && textField.getText().trim().length() == 0) {
if (!errorProblems.isEmpty() && textField.getText().trim().isEmpty()) {
background = getErrorBackground();
}
else if (warningProblems.size() > 0) {
else if (!warningProblems.isEmpty()) {
background = getWarningBackground();
}
final Editor editor = textField.getEditor();
Editor editor = textField.getEditor();
if (editor != null) {
final MarkupModel markupModel = editor.getMarkupModel();
MarkupModel markupModel = editor.getMarkupModel();
markupModel.removeAllHighlighters();
if (!errorProblems.isEmpty() && editor.getDocument().getLineCount() > 0) {
markupModel.addLineHighlighter(CodeInsightColors.ERRORS_ATTRIBUTES, 0, 0);
@@ -146,17 +146,16 @@ public abstract class EditorTextFieldControl<T extends JComponent> extends BaseM
textField.setBackground(background);
});
}
@Override
public boolean canNavigate(final DomElement element) {
public boolean canNavigate(DomElement element) {
return getDomElement().equals(element);
}
@Override
public void navigate(final DomElement element) {
final EditorTextField field = getEditorTextField(getComponent());
public void navigate(DomElement element) {
EditorTextField field = getEditorTextField(getComponent());
SwingUtilities.invokeLater(() -> {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(field, true));
field.selectAll();

View File

@@ -225,10 +225,8 @@ public abstract class BaseControl<Bound extends JComponent, T> extends DomUICont
}
@Override
public void navigate(DomElement element) {
}
public void navigate(DomElement element) { }
protected abstract @Nullable T getValue();
protected abstract void setValue(T value);
}