mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplify some constant conditions and greenify
This commit is contained in:
@@ -114,10 +114,9 @@ public class StackTraceLine {
|
||||
}
|
||||
}
|
||||
|
||||
private PsiClass findClass(final Project project, final String className, final int lineNumber) {
|
||||
private static PsiClass findClass(final Project project, final String className, final int lineNumber) {
|
||||
if (project == null) return null;
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
if (psiManager == null) return null;
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(className, GlobalSearchScope.allScope(project));
|
||||
if (psiClass == null || (psiClass.getNavigationElement() instanceof PsiCompiledElement)) return null;
|
||||
psiClass = (PsiClass)psiClass.getNavigationElement();
|
||||
@@ -132,8 +131,7 @@ public class StackTraceLine {
|
||||
if (methods.length == 0) return null;
|
||||
final PsiFile psiFile = methods[0].getContainingFile();
|
||||
final int offset = offsetOfLine(psiFile, lineNumber);
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
final PsiMethod method = methods[i];
|
||||
for (final PsiMethod method : methods) {
|
||||
if (method.getTextRange().contains(offset)) return method;
|
||||
}
|
||||
//if (!methods.hasNext() || location == null) return null;
|
||||
@@ -152,7 +150,6 @@ public class StackTraceLine {
|
||||
private static int offsetOfLine(final PsiFile psiFile, final int lineNumber) {
|
||||
final LineTokenizer lineTokenizer = new LineTokenizer(psiFile.getViewProvider().getContents());
|
||||
for (int i = 0; i < lineNumber; i++) lineTokenizer.advance();
|
||||
final int offset = lineTokenizer.getOffset();
|
||||
return offset;
|
||||
return lineTokenizer.getOffset();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -102,7 +102,7 @@ public class CommittedChangesPanel extends JPanel implements TypeSafeDataProvide
|
||||
|
||||
if (auxiliary != null) {
|
||||
myShouldBeCalledOnDispose.add(auxiliary.getCalledOnViewDispose());
|
||||
myBrowser.setTableContextMenu(group, (auxiliary.getPopupActions() == null) ? Collections.<AnAction>emptyList() : auxiliary.getPopupActions());
|
||||
myBrowser.setTableContextMenu(group, auxiliary.getPopupActions());
|
||||
} else {
|
||||
myBrowser.setTableContextMenu(group, Collections.<AnAction>emptyList());
|
||||
}
|
||||
@@ -252,9 +252,9 @@ public class CommittedChangesPanel extends JPanel implements TypeSafeDataProvide
|
||||
for(String word: filterWords) {
|
||||
final String comment = changeList.getComment();
|
||||
final String committer = changeList.getCommitterName();
|
||||
if ((comment != null && comment.toLowerCase().indexOf(word) >= 0) ||
|
||||
(committer != null && committer.toLowerCase().indexOf(word) >= 0) ||
|
||||
Long.toString(changeList.getNumber()).indexOf(word) >= 0) {
|
||||
if ((comment != null && comment.toLowerCase().contains(word)) ||
|
||||
(committer != null && committer.toLowerCase().contains(word)) ||
|
||||
Long.toString(changeList.getNumber()).contains(word)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,13 +102,10 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
|
||||
if (myUseUserManifest.isSelected() && myManifest.getText() != null && !new File(myManifest.getText()).exists()){
|
||||
throw new ConfigurationException(DevKitBundle.message("error.file.not.found.message", myManifest.getText()));
|
||||
}
|
||||
final File plugin = myBuildProperties.getPluginXmlPath() != null ? new File(myBuildProperties.getPluginXmlPath()) : null;
|
||||
final File plugin = new File(myBuildProperties.getPluginXmlPath());
|
||||
final String newPluginPath = myPluginXML.getText() + File.separator + META_INF + File.separator + PLUGIN_XML;
|
||||
if (plugin != null &&
|
||||
plugin.exists() &&
|
||||
!plugin.getPath().equals(newPluginPath) &&
|
||||
Messages.showYesNoDialog(myModule.getProject(),
|
||||
DevKitBundle.message("deployment.view.delete", plugin.getPath()),
|
||||
if (plugin.exists() && !plugin.getPath().equals(newPluginPath) &&
|
||||
Messages.showYesNoDialog(myModule.getProject(), DevKitBundle.message("deployment.view.delete", plugin.getPath()),
|
||||
DevKitBundle.message("deployment.cleanup", META_INF), null) == DialogWrapper.OK_EXIT_CODE) {
|
||||
|
||||
CommandProcessor.getInstance().executeCommand(myModule.getProject(),
|
||||
|
||||
+3
-6
@@ -35,10 +35,7 @@ import com.intellij.openapi.vcs.changes.TransparentlyFailedValueI;
|
||||
import com.intellij.openapi.vcs.changes.patch.ApplyPatchExecutor;
|
||||
import com.intellij.openapi.vcs.changes.patch.FilePatchInProgress;
|
||||
import com.intellij.openapi.vcs.changes.patch.PatchWriter;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWrapper;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.WaitForProgressToShow;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
|
||||
@@ -79,7 +76,7 @@ public class ApplyPatchSaveToFileExecutor implements ApplyPatchExecutor {
|
||||
new FileSaverDescriptor("Save patch to", ""), myProject);
|
||||
final VirtualFile baseDir = myProject.getBaseDir();
|
||||
final VirtualFileWrapper save = dialog.save(baseDir, "TheirsChanges.patch");
|
||||
if (save != null && save.getFile() != null) {
|
||||
if (save != null) {
|
||||
final CommitContext commitContext = new CommitContext();
|
||||
|
||||
final VirtualFile baseForPatch = myBaseForPatch == null ? baseDir : myBaseForPatch;
|
||||
@@ -107,7 +104,7 @@ public class ApplyPatchSaveToFileExecutor implements ApplyPatchExecutor {
|
||||
for (Map.Entry<VirtualFile, Collection<FilePatchInProgress>> entry : patchGroups.entrySet()) {
|
||||
final VirtualFile vf = entry.getKey();
|
||||
final String currBasePath = vf.getPath();
|
||||
final String relativePath = VfsUtil.getRelativePath(vf, baseDir, '/');
|
||||
final String relativePath = VfsUtilCore.getRelativePath(vf, baseDir, '/');
|
||||
final boolean toConvert = !StringUtil.isEmptyOrSpaces(relativePath) && !".".equals(relativePath);
|
||||
for (FilePatchInProgress patchInProgress : entry.getValue()) {
|
||||
final TextFilePatch patch = patchInProgress.getPatch();
|
||||
|
||||
Reference in New Issue
Block a user