diff --git a/plugin/src/main/java/git4idea/GitBranch.java b/plugin/src/main/java/git4idea/GitBranch.java
index 30580f25..4e1a3452 100644
--- a/plugin/src/main/java/git4idea/GitBranch.java
+++ b/plugin/src/main/java/git4idea/GitBranch.java
@@ -16,13 +16,11 @@
package git4idea;
import consulo.versionControlSystem.log.Hash;
-import jakarta.annotation.Nonnull;
-import org.jetbrains.annotations.NonNls;
-
import git4idea.branch.GitBranchUtil;
import git4idea.repo.GitRepository;
-
+import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
+import org.jetbrains.annotations.NonNls;
/**
*
Represents a Git branch, local or remote.
@@ -42,7 +40,6 @@
*/
public abstract class GitBranch extends GitReference
{
-
@NonNls
public static final String REFS_HEADS_PREFIX = "refs/heads/"; // Prefix for local branches ({@value})
@NonNls
@@ -66,6 +63,7 @@ protected GitBranch(@Nonnull String name)
public abstract boolean isRemote();
@Nonnull
+ @Override
public String getFullName()
{
return (isRemote() ? REFS_REMOTES_PREFIX : REFS_HEADS_PREFIX) + myName;
diff --git a/plugin/src/main/java/git4idea/GitReference.java b/plugin/src/main/java/git4idea/GitReference.java
index 4fe13e93..e84c99a6 100644
--- a/plugin/src/main/java/git4idea/GitReference.java
+++ b/plugin/src/main/java/git4idea/GitReference.java
@@ -15,7 +15,7 @@
*/
package git4idea;
-import consulo.application.util.SystemInfo;
+import consulo.platform.Platform;
import consulo.util.collection.HashingStrategy;
import consulo.util.lang.StringUtil;
import consulo.virtualFileSystem.util.FilePathHashingStrategy;
@@ -72,7 +72,8 @@ public int hashCode() {
return BRANCH_NAME_HASHING_STRATEGY.hashCode(myName);
}
+ @Override
public int compareTo(GitReference o) {
- return o == null ? 1 : StringUtil.compare(getFullName(), o.getFullName(), SystemInfo.isFileSystemCaseSensitive);
+ return o == null ? 1 : StringUtil.compare(getFullName(), o.getFullName(), Platform.current().fs().isCaseSensitive());
}
}
diff --git a/plugin/src/main/java/git4idea/GitRevisionSelector.java b/plugin/src/main/java/git4idea/GitRevisionSelector.java
index 5a405004..3e11d444 100644
--- a/plugin/src/main/java/git4idea/GitRevisionSelector.java
+++ b/plugin/src/main/java/git4idea/GitRevisionSelector.java
@@ -15,8 +15,8 @@
*/
package git4idea;
-import consulo.versionControlSystem.history.VcsRevisionNumber;
import consulo.versionControlSystem.diff.RevisionSelector;
+import consulo.versionControlSystem.history.VcsRevisionNumber;
import consulo.virtualFileSystem.VirtualFile;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
@@ -29,6 +29,7 @@ public class GitRevisionSelector implements RevisionSelector {
* {@inheritDoc}
*/
@Nullable
+ @Override
public VcsRevisionNumber selectNumber(@Nonnull VirtualFile file) {
//GitVirtualFile gitFile = (GitVirtualFile) file;
//TODO: implement selectNumber()
diff --git a/plugin/src/main/java/git4idea/GitUserRegistry.java b/plugin/src/main/java/git4idea/GitUserRegistry.java
index 72cd4b08..85b19646 100644
--- a/plugin/src/main/java/git4idea/GitUserRegistry.java
+++ b/plugin/src/main/java/git4idea/GitUserRegistry.java
@@ -18,14 +18,12 @@
import consulo.annotation.component.ComponentScope;
import consulo.annotation.component.ServiceAPI;
import consulo.annotation.component.ServiceImpl;
-import consulo.application.ApplicationManager;
-import consulo.disposer.Disposable;
import consulo.application.Application;
+import consulo.disposer.Disposable;
import consulo.logging.Logger;
import consulo.project.Project;
import consulo.util.collection.ContainerUtil;
import consulo.util.lang.StringUtil;
-import consulo.util.lang.function.Condition;
import consulo.versionControlSystem.ProjectLevelVcsManager;
import consulo.versionControlSystem.VcsException;
import consulo.versionControlSystem.VcsListener;
@@ -33,11 +31,11 @@
import consulo.versionControlSystem.log.VcsUser;
import consulo.virtualFileSystem.VirtualFile;
import git4idea.config.GitConfigUtil;
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
-import jakarta.annotation.Nonnull;
-import jakarta.annotation.Nullable;
import java.util.Collection;
import java.util.Map;
@@ -113,22 +111,14 @@ public void directoryMappingChanged() {
if (vcs == null) {
return;
}
- final VirtualFile[] roots = myVcsManager.getRootsUnderVcs(vcs);
- final Collection rootsToCheck = ContainerUtil.filter(roots, new Condition() {
- @Override
- public boolean value(VirtualFile root) {
- return getUser(root) == null;
- }
- });
+ VirtualFile[] roots = myVcsManager.getRootsUnderVcs(vcs);
+ Collection rootsToCheck = ContainerUtil.filter(roots, root -> getUser(root) == null);
if (!rootsToCheck.isEmpty()) {
- ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
- public void run() {
- for (VirtualFile root : rootsToCheck) {
- getOrReadUser(root);
- }
+ Application.get().executeOnPooledThread((Runnable) () -> {
+ for (VirtualFile root : rootsToCheck) {
+ getOrReadUser(root);
}
});
}
}
-
}
diff --git a/plugin/src/main/java/git4idea/changes/GitOutgoingChangesProvider.java b/plugin/src/main/java/git4idea/changes/GitOutgoingChangesProvider.java
index 9d6bebad..5027e248 100644
--- a/plugin/src/main/java/git4idea/changes/GitOutgoingChangesProvider.java
+++ b/plugin/src/main/java/git4idea/changes/GitOutgoingChangesProvider.java
@@ -34,9 +34,9 @@
import git4idea.GitUtil;
import git4idea.history.GitHistoryUtils;
import git4idea.history.browser.SHAHash;
-
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
+
import java.util.*;
public class GitOutgoingChangesProvider implements VcsOutgoingChangesProvider {
@@ -47,74 +47,79 @@ public GitOutgoingChangesProvider(Project project) {
myProject = project;
}
- public Pair> getOutgoingChanges(final VirtualFile vcsRoot, final boolean findRemote)
+ @Override
+ public Pair> getOutgoingChanges(VirtualFile vcsRoot, boolean findRemote)
throws VcsException {
LOG.debug("getOutgoingChanges root: " + vcsRoot.getPath());
- final GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, findRemote);
+ GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, findRemote);
if (searcher.getLocal() == null || searcher.getRemote() == null) {
- return new Pair>(null, Collections.emptyList());
+ return new Pair<>(null, Collections.emptyList());
}
- final GitRevisionNumber base = getMergeBase(myProject, vcsRoot, searcher.getLocal(), searcher.getRemote());
+ GitRevisionNumber base = getMergeBase(myProject, vcsRoot, searcher.getLocal(), searcher.getRemote());
if (base == null) {
- return new Pair>(null, Collections.emptyList());
+ return new Pair<>(null, Collections.emptyList());
}
- final List lists =
+ List lists =
GitUtil.getLocalCommittedChanges(myProject, vcsRoot, handler -> handler.addParameters(base.asString() + "..HEAD"));
return new Pair<>(base, ObjectsConvertor.convert(lists, o -> o));
}
@Nullable
- public VcsRevisionNumber getMergeBaseNumber(final VirtualFile anyFileUnderRoot) throws VcsException {
+ @Override
+ public VcsRevisionNumber getMergeBaseNumber(VirtualFile anyFileUnderRoot) throws VcsException {
LOG.debug("getMergeBaseNumber parameter: " + anyFileUnderRoot.getPath());
- final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
- final VirtualFile root = vcsManager.getVcsRootFor(anyFileUnderRoot);
+ ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
+ VirtualFile root = vcsManager.getVcsRootFor(anyFileUnderRoot);
if (root == null) {
LOG.info("VCS root not found");
return null;
}
- final GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, root, true);
+ GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, root, true);
if (searcher.getLocal() == null || searcher.getRemote() == null) {
LOG.info("local or remote not found");
return null;
}
- final GitRevisionNumber base = getMergeBase(myProject, root, searcher.getLocal(), searcher.getRemote());
+ GitRevisionNumber base = getMergeBase(myProject, root, searcher.getLocal(), searcher.getRemote());
LOG.debug("found base: " + ((base == null) ? null : base.asString()));
return base;
}
- public Collection filterLocalChangesBasedOnLocalCommits(final Collection localChanges,
- final VirtualFile vcsRoot) throws VcsException {
- final GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, true);
+ @Override
+ public Collection filterLocalChangesBasedOnLocalCommits(Collection localChanges, VirtualFile vcsRoot)
+ throws VcsException {
+ GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, true);
if (searcher.getLocal() == null || searcher.getRemote() == null) {
- return new ArrayList(localChanges); // no information, better strict approach (see getOutgoingChanges() code)
+ return new ArrayList<>(localChanges); // no information, better strict approach (see getOutgoingChanges() code)
}
- final GitRevisionNumber base;
+ GitRevisionNumber base;
try {
base = getMergeBase(myProject, vcsRoot, searcher.getLocal(), searcher.getRemote());
}
catch (VcsException e) {
LOG.info(e);
- return new ArrayList(localChanges);
+ return new ArrayList<>(localChanges);
}
if (base == null) {
- return new ArrayList(localChanges); // no information, better strict approach (see getOutgoingChanges() code)
+ return new ArrayList<>(localChanges); // no information, better strict approach (see getOutgoingChanges() code)
}
- final List> hashes = GitHistoryUtils.onlyHashesHistory(myProject,
- VcsContextFactory.getInstance().createFilePathOn(vcsRoot),
- vcsRoot,
- (base.asString() + "..HEAD"));
+ List> hashes = GitHistoryUtils.onlyHashesHistory(
+ myProject,
+ VcsContextFactory.getInstance().createFilePathOn(vcsRoot),
+ vcsRoot,
+ (base.asString() + "..HEAD")
+ );
if (hashes.isEmpty()) return Collections.emptyList(); // no local commits
- final String first = hashes.get(0).getFirst().getValue(); // optimization
- final Set localHashes = new HashSet();
+ String first = hashes.get(0).getFirst().getValue(); // optimization
+ Set localHashes = new HashSet<>();
for (Pair hash : hashes) {
localHashes.add(hash.getFirst().getValue());
}
- final Collection result = new ArrayList();
+ Collection result = new ArrayList<>();
for (Change change : localChanges) {
if (change.getBeforeRevision() != null) {
- final String changeBeforeRevision = change.getBeforeRevision().getRevisionNumber().asString().trim();
+ String changeBeforeRevision = change.getBeforeRevision().getRevisionNumber().asString().trim();
if (first.equals(changeBeforeRevision) || localHashes.contains(changeBeforeRevision)) {
result.add(change);
}
@@ -124,6 +129,7 @@ public Collection filterLocalChangesBasedOnLocalCommits(final Collection
}
@Nullable
+ @Override
public Date getRevisionDate(VcsRevisionNumber revision, FilePath file) {
if (VcsRevisionNumber.NULL.equals(revision)) return null;
try {
diff --git a/plugin/src/main/java/git4idea/changes/GitRepositoryLocation.java b/plugin/src/main/java/git4idea/changes/GitRepositoryLocation.java
index 81920beb..3438c576 100644
--- a/plugin/src/main/java/git4idea/changes/GitRepositoryLocation.java
+++ b/plugin/src/main/java/git4idea/changes/GitRepositoryLocation.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package git4idea.changes;
import consulo.versionControlSystem.RepositoryLocation;
@@ -30,6 +29,7 @@ public GitRepositoryLocation(String url, File root) {
myRoot = root;
}
+ @Override
public String toPresentableString() {
return myUrl;
}
@@ -39,6 +39,7 @@ public String toString() {
return toPresentableString();
}
+ @Override
public String getKey() {
return myUrl;
}
diff --git a/plugin/src/main/java/git4idea/commands/GitLineHandler.java b/plugin/src/main/java/git4idea/commands/GitLineHandler.java
index 20ad60d1..4a963482 100644
--- a/plugin/src/main/java/git4idea/commands/GitLineHandler.java
+++ b/plugin/src/main/java/git4idea/commands/GitLineHandler.java
@@ -22,8 +22,8 @@
import consulo.util.lang.StringUtil;
import consulo.versionControlSystem.util.LineHandlerHelper;
import consulo.virtualFileSystem.VirtualFile;
-
import jakarta.annotation.Nonnull;
+
import java.io.File;
import java.util.Iterator;
@@ -63,14 +63,15 @@ public GitLineHandler(@Nonnull Project project, @Nonnull File directory, @Nonnul
* @param vcsRoot a process directory
* @param command a command to execute
*/
- public GitLineHandler(@Nonnull final Project project, @Nonnull final VirtualFile vcsRoot, @Nonnull final GitCommand command) {
+ public GitLineHandler(@Nonnull Project project, @Nonnull VirtualFile vcsRoot, @Nonnull GitCommand command) {
super(project, vcsRoot, command);
}
/**
* {@inheritDoc}
*/
- protected void processTerminated(final int exitCode) {
+ @Override
+ protected void processTerminated(int exitCode) {
// force newline
if (myStdoutLine.length() != 0) {
onTextAvailable("\n\r", ProcessOutputTypes.STDOUT);
@@ -94,7 +95,8 @@ public void addLineListener(GitLineHandlerListener listener) {
/**
* {@inheritDoc}
*/
- protected void onTextAvailable(final String text, final Key outputType) {
+ @Override
+ protected void onTextAvailable(String text, Key outputType) {
Iterator lines = LineHandlerHelper.splitText(text).iterator();
if (ProcessOutputTypes.STDOUT == outputType) {
notifyLines(outputType, lines, myStdoutLine);
@@ -111,13 +113,13 @@ else if (ProcessOutputTypes.STDERR == outputType) {
* @param lines line iterator
* @param lineBuilder a line builder
*/
- private void notifyLines(final Key outputType, final Iterator lines, final StringBuilder lineBuilder) {
+ private void notifyLines(Key outputType, Iterator lines, StringBuilder lineBuilder) {
if (!lines.hasNext()) return;
if (lineBuilder.length() > 0) {
lineBuilder.append(lines.next());
if (lines.hasNext()) {
// line is complete
- final String line = lineBuilder.toString();
+ String line = lineBuilder.toString();
notifyLine(line, outputType);
lineBuilder.setLength(0);
}
@@ -146,7 +148,7 @@ private void notifyLines(final Key outputType, final Iterator lines, fin
* @param line a line to notify
* @param outputType output type
*/
- private void notifyLine(final String line, final Key outputType) {
+ private void notifyLine(String line, Key outputType) {
String trimmed = LineHandlerHelper.trimLineSeparator(line);
// if line ends with return, then it is a progress line, ignore it
if (myVcs != null && !"\r".equals(line.substring(trimmed.length()))) {
diff --git a/plugin/src/main/java/git4idea/commands/GitLineHandlerAdapter.java b/plugin/src/main/java/git4idea/commands/GitLineHandlerAdapter.java
index 5da633e2..848922d2 100644
--- a/plugin/src/main/java/git4idea/commands/GitLineHandlerAdapter.java
+++ b/plugin/src/main/java/git4idea/commands/GitLineHandlerAdapter.java
@@ -24,21 +24,24 @@ public class GitLineHandlerAdapter implements GitLineHandlerListener {
/**
* {@inheritDoc}
*/
- public void onLineAvailable(final String line, final Key outputType) {
+ @Override
+ public void onLineAvailable(String line, Key outputType) {
// do nothing
}
/**
* {@inheritDoc}
*/
- public void processTerminated(final int exitCode) {
+ @Override
+ public void processTerminated(int exitCode) {
// do nothing
}
/**
* {@inheritDoc}
*/
- public void startFailed(final Throwable exception) {
+ @Override
+ public void startFailed(Throwable exception) {
// do nothing
}
}
diff --git a/plugin/src/main/java/git4idea/commands/GitLineHandlerListener.java b/plugin/src/main/java/git4idea/commands/GitLineHandlerListener.java
index 7055f187..66524552 100644
--- a/plugin/src/main/java/git4idea/commands/GitLineHandlerListener.java
+++ b/plugin/src/main/java/git4idea/commands/GitLineHandlerListener.java
@@ -30,6 +30,7 @@ public interface GitLineHandlerListener extends LineProcessEventListener
* @param line a line of the text
* @param outputType a type of output (one of constants from {@link ProcessOutputTypes})
*/
+ @Override
@SuppressWarnings({"UnusedParameters", "UnnecessaryFullyQualifiedName"})
void onLineAvailable(String line, Key outputType);
}
diff --git a/plugin/src/main/java/git4idea/ui/GitCommitListPanel.java b/plugin/src/main/java/git4idea/ui/GitCommitListPanel.java
index 2f02cef4..3f1e0b9d 100644
--- a/plugin/src/main/java/git4idea/ui/GitCommitListPanel.java
+++ b/plugin/src/main/java/git4idea/ui/GitCommitListPanel.java
@@ -25,8 +25,6 @@
import consulo.ui.ex.awt.UIUtil;
import consulo.ui.ex.awt.table.ListTableModel;
import consulo.ui.ex.awt.table.TableView;
-import consulo.util.collection.ArrayUtil;
-import consulo.util.dataholder.Key;
import consulo.versionControlSystem.VcsDataKeys;
import consulo.versionControlSystem.change.Change;
import consulo.versionControlSystem.change.ChangesBrowserUtil;
@@ -36,8 +34,6 @@
import jakarta.annotation.Nullable;
import javax.swing.*;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@@ -50,14 +46,13 @@
* @author Kirill Likhodedov
*/
public class GitCommitListPanel extends JPanel implements UiDataProvider {
-
private final List myCommits;
private final TableView myTable;
public GitCommitListPanel(@Nonnull List commits, @Nullable String emptyText) {
myCommits = commits;
- myTable = new TableView();
+ myTable = new TableView<>();
updateModel();
myTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
myTable.setStriped(true);
@@ -72,33 +67,29 @@ public GitCommitListPanel(@Nonnull List commits, @Nullable String emp
/**
* Adds a listener that would be called once user selects a commit in the table.
*/
- public void addListSelectionListener(final @Nonnull Consumer listener) {
- myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(final ListSelectionEvent e) {
- ListSelectionModel lsm = (ListSelectionModel) e.getSource();
- int i = lsm.getMaxSelectionIndex();
- int j = lsm.getMinSelectionIndex();
- if (i >= 0 && i == j) {
- listener.accept(myCommits.get(i));
- }
+ public void addListSelectionListener(@Nonnull Consumer listener) {
+ myTable.getSelectionModel().addListSelectionListener(e -> {
+ ListSelectionModel lsm = (ListSelectionModel) e.getSource();
+ int i = lsm.getMaxSelectionIndex();
+ int j = lsm.getMinSelectionIndex();
+ if (i >= 0 && i == j) {
+ listener.accept(myCommits.get(i));
}
});
}
- public void addListMultipleSelectionListener(final @Nonnull Consumer> listener) {
- myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(final ListSelectionEvent e) {
- List commits = myTable.getSelectedObjects();
-
- final List changes = new ArrayList();
- // We need changes in asc order for zipChanges, and they are in desc order in Table
- ListIterator iterator = commits.listIterator(commits.size());
- while (iterator.hasPrevious()) {
- changes.addAll(iterator.previous().getChanges());
- }
+ public void addListMultipleSelectionListener(@Nonnull Consumer> listener) {
+ myTable.getSelectionModel().addListSelectionListener(e -> {
+ List commits = myTable.getSelectedObjects();
- listener.accept(ChangesBrowserUtil.zipChanges(changes));
+ List changes = new ArrayList<>();
+ // We need changes in asc order for zipChanges, and they are in desc order in Table
+ ListIterator iterator = commits.listIterator(commits.size());
+ while (iterator.hasPrevious()) {
+ changes.addAll(iterator.previous().getChanges());
}
+
+ listener.accept(ChangesBrowserUtil.zipChanges(changes));
});
}
@@ -125,7 +116,6 @@ public void uiDataSnapshot(DataSink sink) {
});
}
-
@Nonnull
public JComponent getPreferredFocusComponent() {
return myTable;
@@ -143,7 +133,7 @@ public void setCommits(@Nonnull List commits) {
}
private void updateModel() {
- myTable.setModelAndUpdateColumns(new ListTableModel(generateColumnsInfo(myCommits), myCommits, 0));
+ myTable.setModelAndUpdateColumns(new ListTableModel<>(generateColumnsInfo(myCommits), myCommits, 0));
}
@Nonnull
@@ -216,7 +206,6 @@ private static String getTime(GitCommit commit) {
}
private abstract static class GitCommitColumnInfo extends ColumnInfo {
-
@Nonnull
private final String myMaxString;
@@ -235,5 +224,4 @@ public int getAdditionalWidth() {
return UIUtil.DEFAULT_HGAP;
}
}
-
}
diff --git a/plugin/src/main/java/git4idea/ui/GitReferenceValidator.java b/plugin/src/main/java/git4idea/ui/GitReferenceValidator.java
index 650232a1..020ae698 100644
--- a/plugin/src/main/java/git4idea/ui/GitReferenceValidator.java
+++ b/plugin/src/main/java/git4idea/ui/GitReferenceValidator.java
@@ -16,8 +16,8 @@
package git4idea.ui;
import consulo.project.Project;
-import consulo.versionControlSystem.VcsException;
import consulo.ui.ex.awt.event.DocumentAdapter;
+import consulo.versionControlSystem.VcsException;
import consulo.virtualFileSystem.VirtualFile;
import git4idea.GitRevisionNumber;
import git4idea.GitUtil;
@@ -25,8 +25,6 @@
import javax.swing.*;
import javax.swing.event.DocumentEvent;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
/**
* The class setups validation for references in the text fields.
@@ -66,43 +64,42 @@ public class GitReferenceValidator {
* @param button the button that initiates validation action
* @param statusChanged the action that is invoked when validation status changed
*/
- public GitReferenceValidator(final Project project,
- final JComboBox gitRoot,
- final JTextField textField,
- final JButton button,
- final Runnable statusChanged) {
+ public GitReferenceValidator(
+ Project project,
+ JComboBox gitRoot,
+ JTextField textField,
+ JButton button,
+ Runnable statusChanged
+ ) {
myProject = project;
myGitRoot = gitRoot;
myTextField = textField;
myButton = button;
- myGitRoot.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- myLastResult = false;
- myLastResultText = null;
- }
+ myGitRoot.addActionListener(e -> {
+ myLastResult = false;
+ myLastResultText = null;
});
myTextField.getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
+ @Override
+ protected void textChanged(DocumentEvent e) {
// note that checkOkButton is called in other listener
myButton.setEnabled(myTextField.getText().trim().length() != 0);
}
});
- myButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- final String revisionExpression = myTextField.getText();
- myLastResultText = revisionExpression;
- myLastResult = false;
- try {
- GitRevisionNumber revision = GitRevisionNumber.resolve(myProject, gitRoot(), revisionExpression);
- GitUtil.showSubmittedFiles(myProject, revision.asString(), gitRoot(), false, false);
- myLastResult = true;
- }
- catch (VcsException ex) {
- GitUIUtil.showOperationError(myProject, ex, "Validating revision: " + revisionExpression);
- }
- if (statusChanged != null) {
- statusChanged.run();
- }
+ myButton.addActionListener(e -> {
+ String revisionExpression = myTextField.getText();
+ myLastResultText = revisionExpression;
+ myLastResult = false;
+ try {
+ GitRevisionNumber revision = GitRevisionNumber.resolve(myProject, gitRoot(), revisionExpression);
+ GitUtil.showSubmittedFiles(myProject, revision.asString(), gitRoot(), false, false);
+ myLastResult = true;
+ }
+ catch (VcsException ex) {
+ GitUIUtil.showOperationError(myProject, ex, "Validating revision: " + revisionExpression);
+ }
+ if (statusChanged != null) {
+ statusChanged.run();
}
});
myButton.setEnabled(myTextField.getText().length() != 0);
@@ -112,7 +109,7 @@ public void actionPerformed(final ActionEvent e) {
* @return true if the reference is known to be invalid
*/
public boolean isInvalid() {
- final String revisionExpression = myTextField.getText();
+ String revisionExpression = myTextField.getText();
return revisionExpression.equals(myLastResultText) && !myLastResult;
}
diff --git a/plugin/src/main/java/git4idea/validators/GitBranchNameValidator.java b/plugin/src/main/java/git4idea/validators/GitBranchNameValidator.java
index 23094f18..a005ee98 100644
--- a/plugin/src/main/java/git4idea/validators/GitBranchNameValidator.java
+++ b/plugin/src/main/java/git4idea/validators/GitBranchNameValidator.java
@@ -15,6 +15,7 @@
*/
package git4idea.validators;
+import consulo.ui.annotation.RequiredUIAccess;
import consulo.ui.ex.InputValidator;
import java.util.regex.Pattern;
@@ -33,8 +34,8 @@ public class GitBranchNameValidator implements InputValidator {
static {
// based on the git-check-ref-format command description
- final String goodChar = "[!-~&&[^\\^~:\\[\\]\\?\\*\\./<>\\|'`]]";
- final String component = "(?:" + goodChar + "+\\.?)+";
+ String goodChar = "[!-~&&[^\\^~:\\[\\]\\?\\*\\./<>\\|'`]]";
+ String component = "(?:" + goodChar + "+\\.?)+";
REF_FORMAT_PATTERN = Pattern.compile("^" + component + "+(?:/*" + component + ")*$");
}
@@ -46,6 +47,8 @@ public class GitBranchNameValidator implements InputValidator {
/**
* {@inheritDoc}
*/
+ @Override
+ @RequiredUIAccess
public boolean checkInput(String inputString) {
return REF_FORMAT_PATTERN.matcher(inputString).matches();
}
@@ -53,6 +56,8 @@ public boolean checkInput(String inputString) {
/**
* {@inheritDoc}
*/
+ @Override
+ @RequiredUIAccess
public boolean canClose(String inputString) {
return checkInput(inputString);
}
diff --git a/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/GitSSHXmlRpcClient.java b/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/GitSSHXmlRpcClient.java
index a58773e5..20d14df3 100644
--- a/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/GitSSHXmlRpcClient.java
+++ b/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/GitSSHXmlRpcClient.java
@@ -15,12 +15,12 @@
*/
package org.jetbrains.git4idea.rt.ssh;
+import jakarta.annotation.Nullable;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.client.XmlRpcHttpClientConfig;
-import jakarta.annotation.Nullable;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@@ -46,7 +46,7 @@ public class GitSSHXmlRpcClient implements GitSSHHandler
* @param batchMode if true, the client is run in the batch mode, so nothing should be prompted
* @throws IOException if there is IO problem
*/
- GitSSHXmlRpcClient(final int port, final boolean batchMode) throws IOException
+ GitSSHXmlRpcClient(int port, boolean batchMode) throws IOException
{
//noinspection HardCodedStringLiteral
if(batchMode)
@@ -67,9 +67,16 @@ public class GitSSHXmlRpcClient implements GitSSHHandler
/**
* {@inheritDoc}
*/
+ @Override
@SuppressWarnings("unchecked")
- public boolean verifyServerHostKey(String token, final String hostname, final int port, final String serverHostKeyAlgorithm, final String serverHostKey, final boolean isNew)
- {
+ public boolean verifyServerHostKey(
+ String token,
+ String hostname,
+ int port,
+ String serverHostKeyAlgorithm,
+ String serverHostKey,
+ boolean isNew
+ ) {
if(myClient == null)
{
return false;
@@ -83,7 +90,7 @@ public boolean verifyServerHostKey(String token, final String hostname, final in
parameters.add(isNew);
try
{
- return ((Boolean) myClient.execute(methodName("verifyServerHostKey"), parameters)).booleanValue();
+ return (Boolean) myClient.execute(methodName("verifyServerHostKey"), parameters);
}
catch(XmlRpcException e)
{
@@ -97,7 +104,7 @@ public boolean verifyServerHostKey(String token, final String hostname, final in
* @param method short name of the method
* @return full method name
*/
- private static String methodName(final String method)
+ private static String methodName(String method)
{
return GitSSHHandler.HANDLER_NAME + "." + method;
}
@@ -106,8 +113,9 @@ private static String methodName(final String method)
* {@inheritDoc}
*/
@Nullable
+ @Override
@SuppressWarnings("unchecked")
- public String askPassphrase(String token, final String username, final String keyPath, final boolean resetPassword, final String lastError)
+ public String askPassphrase(String token, String username, String keyPath, boolean resetPassword, String lastError)
{
if(myClient == null)
{
@@ -133,16 +141,18 @@ public String askPassphrase(String token, final String username, final String ke
* {@inheritDoc}
*/
@Nullable
+ @Override
@SuppressWarnings("unchecked")
- public List replyToChallenge(String token,
- final String username,
- final String name,
- final String instruction,
- final int numPrompts,
- final Vector prompt,
- final Vector echo,
- final String lastError)
- {
+ public List replyToChallenge(
+ String token,
+ String username,
+ String name,
+ String instruction,
+ int numPrompts,
+ Vector prompt,
+ Vector echo,
+ String lastError
+ ) {
if(myClient == null)
{
return null;
@@ -170,8 +180,9 @@ public List replyToChallenge(String token,
* {@inheritDoc}
*/
@Nullable
+ @Override
@SuppressWarnings("unchecked")
- public String askPassword(String token, final String username, final boolean resetPassword, final String lastError)
+ public String askPassword(String token, String username, boolean resetPassword, String lastError)
{
if(myClient == null)
{
@@ -249,7 +260,7 @@ public String getLastSuccessful(String token, String userName)
* @return adjusted value.
*/
@Nullable
- private static String adjustNull(final String s)
+ private static String adjustNull(String s)
{
return s.charAt(0) == '-' ? null : s.substring(1);
}
@@ -262,7 +273,7 @@ private static String adjustNull(final String s)
* @return adjusted value.
*/
@Nullable
- private static List adjustNull(final List s)
+ private static List adjustNull(List s)
{
return s.size() == 0 ? null : s;
}
diff --git a/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/SSHMain.java b/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/SSHMain.java
index 8ecd4f8a..398f8067 100644
--- a/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/SSHMain.java
+++ b/rt/src/main/java/org/jetbrains/git4idea/rt/ssh/SSHMain.java
@@ -180,7 +180,7 @@ private void start() throws IOException, InterruptedException
c.connect(new HostKeyVerifier());
authenticate(c);
- final Session s = c.openSession();
+ Session s = c.openSession();
try
{
s.execCommand(myCommand);
@@ -199,7 +199,7 @@ private void start() throws IOException, InterruptedException
// broken exit status
exitStatus = 1;
}
- System.exit(exitStatus.intValue() == 0 ? myExitCode : exitStatus.intValue());
+ System.exit(exitStatus == 0 ? myExitCode : exitStatus);
}
finally
{
@@ -219,7 +219,7 @@ private void start() throws IOException, InterruptedException
* @param c the connection to use for authentication
* @throws IOException in case of IO error or authentication failure
*/
- private void authenticate(final Connection c) throws IOException
+ private void authenticate(Connection c) throws IOException
{
LinkedList methods = new LinkedList<>(myHost.getPreferredMethods());
log("authenticating... " + this);
@@ -362,11 +362,11 @@ private String getUserHostString()
* @param keyPath a path to key
* @return true if authentication is successful
*/
- private boolean tryPublicKey(final Connection c, final String keyPath)
+ private boolean tryPublicKey(Connection c, String keyPath)
{
try
{
- final File file = new File(keyPath);
+ File file = new File(keyPath);
if(file.exists())
{
// if encrypted ask user for passphrase
@@ -478,56 +478,53 @@ private static boolean isEncryptedKey(char[] text) throws IOException
* @param in the input stream
* @param releaseSemaphore if true the semaphore will be released
*/
- private void forward(final String name, final OutputStream out, final InputStream in, final boolean releaseSemaphore)
+ private void forward(String name, OutputStream out, InputStream in, boolean releaseSemaphore)
{
- final Runnable action = new Runnable()
- {
- public void run()
- {
- byte[] buffer = new byte[BUFFER_SIZE];
- int rc;
- try
- {
- try
- {
- try
- {
- while((rc = in.read(buffer)) != -1)
- {
- out.write(buffer, 0, rc);
- }
- }
- finally
- {
- out.close();
- }
- }
- finally
- {
- in.close();
- }
- }
- catch(IOException e)
- {
- System.err.println(SSHMainBundle.message("sshmain.forwarding.failed", name, e.getMessage()));
- e.printStackTrace();
- myExitCode = 1;
- if(releaseSemaphore)
- {
- // in the case of error, release semaphore, so that application could exit
- myForwardCompleted.release(1);
- }
- }
- finally
- {
- if(releaseSemaphore)
- {
- myForwardCompleted.release(1);
- }
- }
- }
- };
- @SuppressWarnings({"HardCodedStringLiteral"}) final Thread t = new Thread(action, "Forwarding " + name);
+ Runnable action = () -> {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int rc;
+ try
+ {
+ try
+ {
+ try
+ {
+ while((rc = in.read(buffer)) != -1)
+ {
+ out.write(buffer, 0, rc);
+ }
+ }
+ finally
+ {
+ out.close();
+ }
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+ catch(IOException e)
+ {
+ System.err.println(SSHMainBundle.message("sshmain.forwarding.failed", name, e.getMessage()));
+ e.printStackTrace();
+ myExitCode = 1;
+ if(releaseSemaphore)
+ {
+ // in the case of error, release semaphore, so that application could exit
+ myForwardCompleted.release(1);
+ }
+ }
+ finally
+ {
+ if(releaseSemaphore)
+ {
+ myForwardCompleted.release(1);
+ }
+ }
+ };
+ @SuppressWarnings("HardCodedStringLiteral")
+ Thread t = new Thread(action, "Forwarding " + name);
t.setDaemon(true);
t.start();
}
@@ -546,7 +543,7 @@ private void configureKnownHosts(Connection c) throws IOException
{
database.addHostkeys(knownHostFile);
}
- final List algorithms = myHost.getHostKeyAlgorithms();
+ List algorithms = myHost.getHostKeyAlgorithms();
c.setServerHostKeyAlgorithms(algorithms.toArray(String[]::new));
}
@@ -606,9 +603,10 @@ class InteractiveSupport implements InteractiveCallback
/**
* {@inheritDoc}
*/
- @SuppressWarnings({"UseOfObsoleteCollectionType"})
+ @Override
+ @SuppressWarnings({"UseOfObsoleteCollectionType"})
@Nullable
- public String[] replyToChallenge(final String name, final String instruction, final int numPrompts, final String[] prompt, final boolean[] echo) throws Exception
+ public String[] replyToChallenge(String name, String instruction, int numPrompts, String[] prompt, boolean[] echo) throws Exception
{
if(numPrompts == 0)
{
@@ -622,7 +620,7 @@ public String[] replyToChallenge(final String name, final String instruction, fi
{
vEcho.add(e);
}
- final List result = myXmlRpcClient.replyToChallenge(myHandlerNo, getUserHostString(), name, instruction, numPrompts, vPrompts, vEcho, myLastError);
+ List result = myXmlRpcClient.replyToChallenge(myHandlerNo, getUserHostString(), name, instruction, numPrompts, vPrompts, vEcho, myLastError);
if(result == null)
{
myCancelled = true;
@@ -645,7 +643,8 @@ private class HostKeyVerifier implements ServerHostKeyVerifier
/**
* {@inheritDoc}
*/
- public boolean verifyServerHostKey(String hostname, int port, String serverHostKeyAlgorithm, byte[] serverHostKey) throws Exception
+ @Override
+ public boolean verifyServerHostKey(String hostname, int port, String serverHostKeyAlgorithm, byte[] serverHostKey) throws Exception
{
try
{
@@ -661,8 +660,8 @@ public boolean verifyServerHostKey(String hostname, int port, String serverHostK
}
try
{
- final int result = database.verifyHostkey(hostname, serverHostKeyAlgorithm, serverHostKey);
- final boolean isNew;
+ int result = database.verifyHostkey(hostname, serverHostKeyAlgorithm, serverHostKey);
+ boolean isNew;
switch(result)
{
case KnownHosts.HOSTKEY_IS_OK: