Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Dennis Ushakov
2010-06-24 17:57:11 +04:00
18 changed files with 145 additions and 92 deletions
@@ -396,6 +396,9 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
return info;
}
}
else if (isImplicitUsage(field, progress)) {
return null;
}
else if (!myRefCountHolder.isReferenced(field) && weAreSureThereAreNoUsages(field, progress)) {
return formatUnusedSymbolHighlightInfo("field.is.not.used", field, "fields", myDeadCodeKey, myDeadCodeInfoType);
}
@@ -336,18 +336,23 @@ public class ClsMethodImpl extends ClsRepositoryPsiElement<PsiMethodStub> implem
}
@NotNull
public PsiElement getNavigationElement() {
public PsiMethod getSourceMirrorMethod() {
PsiClass sourceClassMirror = ((ClsClassImpl)getParent()).getSourceMirrorClass();
if (sourceClassMirror == null) return this;
final PsiMethod[] methodsByName = sourceClassMirror.findMethodsByName(getName(), false);
for (PsiMethod sourceMethod : methodsByName) {
if (MethodSignatureUtil.areParametersErasureEqual(this, sourceMethod) && sourceMethod != this) {
return sourceMethod.getNavigationElement();
for (PsiMethod sourceMethod : sourceClassMirror.findMethodsByName(getName(), false)) {
if (MethodSignatureUtil.areParametersErasureEqual(this, sourceMethod)) {
return sourceMethod;
}
}
return this;
}
@NotNull
public PsiElement getNavigationElement() {
final PsiMethod method = getSourceMirrorMethod();
return method != this ? method.getNavigationElement() : this;
}
public PsiTypeParameterList getTypeParameterList() {
return getStub().findChildStubByType(JavaStubElementTypes.TYPE_PARAMETER_LIST).getPsi();
}
@@ -63,7 +63,7 @@ public class ClsParameterImpl extends ClsRepositoryPsiElement<PsiParameterStub>
}
ClsMethodImpl method = (ClsMethodImpl)getDeclarationScope();
PsiMethod sourceMethod = (PsiMethod)method.getNavigationElement();
PsiMethod sourceMethod = method.getSourceMirrorMethod();
if (sourceMethod == method) {
final PsiParameterStubImpl parameterStub = (PsiParameterStubImpl) getStub();
if (!parameterStub.isAutoGeneratedName()) {
@@ -26,8 +26,6 @@ import org.jetbrains.annotations.Nullable;
* @author Maxim.Mossienko
*/
public interface SelfManagingCommenter<T extends CommenterDataHolder> {
ExtensionPointName<SelfManagingCommenter> EP_NAME = ExtensionPointName.create("com.intellij.selfManagingCommenter");
@Nullable T createLineCommentingState(int startLine, int endLine, @NotNull Document document, @NotNull PsiFile file);
@Nullable T createBlockCommentingState(int selectionStart, int selectionEnd, @NotNull Document document, @NotNull PsiFile file);
@@ -141,7 +141,8 @@ public class PositionPanel implements StatusBarWidget, StatusBarWidget.TextPrese
public void caretPositionChanged(final CaretEvent e) {
final Editor editor = e.getEditor();
if (FileEditorManager.getInstance(editor.getProject()).getSelectedTextEditor() == e.getEditor()) {
Project project = editor.getProject();
if (project != null && FileEditorManager.getInstance(project).getSelectedTextEditor() == e.getEditor()) {
updatePosition(editor);
}
}
@@ -121,8 +121,6 @@
<extensionPoint name="fileType.fileViewProviderFactory" beanClass="com.intellij.openapi.fileTypes.FileTypeExtensionPoint"/>
<extensionPoint name="multiLangCommenter"
interface="com.intellij.psi.templateLanguages.MultipleLangCommentProvider"/>
<extensionPoint name="selfManagingCommenter"
interface="com.intellij.codeInsight.generation.SelfManagingCommenter"/>
<extensionPoint name="cacheBuilder"
beanClass="com.intellij.lang.cacheBuilder.CacheBuilderEP"/>
@@ -491,7 +491,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
}
}
List<VirtualFile> getUnversionedFiles() {
public List<VirtualFile> getUnversionedFiles() {
return myComposite.getVFHolder(FileHolder.HolderType.UNVERSIONED).getFiles();
}
@@ -24,7 +24,6 @@ package com.intellij.openapi.vcs.changes.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
@@ -36,7 +35,7 @@ import com.intellij.openapi.vcs.changes.ui.ChangesListView;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
public class ScheduleForAdditionAction extends AnAction implements DumbAware {
@@ -45,46 +44,44 @@ public class ScheduleForAdditionAction extends AnAction implements DumbAware {
}
public void update(AnActionEvent e) {
List<VirtualFile> files = e.getData(ChangesListView.UNVERSIONED_FILES_DATA_KEY);
boolean enabled = files != null && !files.isEmpty();
if (!enabled) {
final DataContext dataContext = e.getDataContext();
enabled = getUnversionedFile(dataContext) != null;
}
final boolean enabled = e.getData(PlatformDataKeys.PROJECT) != null && (getUnversionedFiles(e) != null);
e.getPresentation().setEnabled(enabled);
e.getPresentation().setVisible(enabled);
}
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
final List<VirtualFile> files;
final List<VirtualFile> unversionedFiles = e.getData(ChangesListView.UNVERSIONED_FILES_DATA_KEY);
if (unversionedFiles == null || unversionedFiles.isEmpty()) {
final VirtualFile unversionedFile = getUnversionedFile(e.getDataContext());
if (unversionedFile == null) {
return;
}
files = Collections.singletonList(unversionedFile);
} else {
files = unversionedFiles;
final List<VirtualFile> unversionedFiles = getUnversionedFiles(e);
if (unversionedFiles == null) {
return;
}
final ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(project);
changeListManager.addUnversionedFiles(changeListManager.getDefaultChangeList(), files);
final ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(e.getData(PlatformDataKeys.PROJECT));
changeListManager.addUnversionedFiles(changeListManager.getDefaultChangeList(), unversionedFiles);
}
@Nullable
private VirtualFile getUnversionedFile(final DataContext dataContext) {
if (dataContext == null) {
private static List<VirtualFile> getUnversionedFiles(final AnActionEvent e) {
// first get from the ChangeListView
List<VirtualFile> unversionedFiles = e.getData(ChangesListView.UNVERSIONED_FILES_DATA_KEY);
if (unversionedFiles != null && !unversionedFiles.isEmpty()) {
return unversionedFiles;
}
// then get from selection
final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(e.getDataContext());
if (files == null) {
return null;
}
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final VirtualFile file = project == null ? null : PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file != null && FileStatusManager.getInstance(project).getStatus(file) == FileStatus.UNKNOWN) {
return file;
final Project project = e.getData(PlatformDataKeys.PROJECT);
if (project == null) {
return null;
}
return null;
unversionedFiles = new ArrayList<VirtualFile>(files.length);
for (VirtualFile file : files) {
if (file != null && FileStatusManager.getInstance(project).getStatus(file) == FileStatus.UNKNOWN) {
unversionedFiles.add(file);
}
}
return unversionedFiles.isEmpty() ? null : unversionedFiles;
}
}
@@ -27,9 +27,9 @@ import java.io.File;
* The application wide settings for the git
*/
@State(
name = "PasswordSafe",
name = "Git.Application.Settings",
storages = {@Storage(
id = "PasswordSafe",
id = "Git.Application.Settings",
file = "$APP_CONFIG$/vcs.xml")})
public class GitVcsApplicationSettings implements PersistentStateComponent<GitVcsApplicationSettings.State> {
/**
@@ -24,6 +24,8 @@ import org.codehaus.groovy.tools.javac.JavaAwareResolveVisitor;
import org.codehaus.groovy.tools.javac.JavaStubGenerator;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -341,10 +343,17 @@ public class GroovycRunner {
final Enumeration resources = super.getResources(name);
final ArrayList list = Collections.list(resources);
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
String file = ((URL)iterator.next()).getFile();
System.out.println("Enumerated:" + file);
if (file.startsWith(finalOutput) || file.startsWith("/" + finalOutput)) {
iterator.remove();
final URL url = (URL)iterator.next();
if ("file".equals(url.getProtocol())) {
try {
final String file = new File(new URI(url.toString())).getCanonicalPath();
System.out.println("Enumerated:" + file);
if (file.startsWith(finalOutput) || file.startsWith("/" + finalOutput)) {
iterator.remove();
}
}
catch (URISyntaxException ignored) {
}
}
}
return Collections.enumeration(list);
@@ -71,7 +71,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
import org.jetbrains.plugins.groovy.util.GroovyUtils;
import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.*;
@@ -304,9 +303,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
printer.println(PathUtil.getLocalPath(outputDir));
printer.println(GroovycRunner.FINAL_OUTPUTPATH);
final URL finalUrl = VfsUtil.convertToURL(finalOutputDir.getUrl());
LOG.assertTrue(finalUrl != null, finalOutputDir.getPath());
printer.println(finalUrl.getFile());
printer.println(FileUtil.toSystemDependentName(finalOutputDir.getPath()));
printer.close();
@@ -12,41 +12,59 @@
// limitations under the License.
package org.zmlx.hg4idea;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.ui.GuiUtils;
import org.zmlx.hg4idea.command.HgVersionCommand;
import org.zmlx.hg4idea.ui.HgSetExecutableDialog;
import java.lang.reflect.InvocationTargetException;
public class HgExecutableValidator {
private static final Logger LOG = Logger.getInstance(HgExecutableValidator.class.getName());
private final Project project;
private boolean myValidHgExecutable;
public HgExecutableValidator(Project project) {
this.project = project;
}
public boolean check(HgGlobalSettings globalSettings) {
HgVersionCommand command = new HgVersionCommand();
public boolean check(final HgGlobalSettings globalSettings) {
final HgVersionCommand command = new HgVersionCommand();
if (command.isValid(globalSettings.getHgExecutable())) {
return true;
}
String previousHgPath = globalSettings.getHgExecutable();
boolean validHgExecutable;
HgSetExecutableDialog dialog;
do {
dialog = new HgSetExecutableDialog(project);
dialog.setBadHgPath(previousHgPath);
dialog.show();
validHgExecutable = dialog.isOK() && command.isValid(dialog.getNewHgPath());
previousHgPath = dialog.getNewHgPath();
} while (!validHgExecutable && dialog.isOK());
if (validHgExecutable) {
globalSettings.setHgExecutable(dialog.getNewHgPath());
return true;
if (ApplicationManager.getApplication().isUnitTestMode()) {
return false;
}
myValidHgExecutable = false;
return false;
try {
GuiUtils.runOrInvokeAndWait(new Runnable() {
public void run() {
String previousHgPath = globalSettings.getHgExecutable();
HgSetExecutableDialog dialog;
do {
dialog = new HgSetExecutableDialog(project);
dialog.setBadHgPath(previousHgPath);
dialog.show();
myValidHgExecutable = dialog.isOK() && command.isValid(dialog.getNewHgPath());
previousHgPath = dialog.getNewHgPath();
} while (!myValidHgExecutable && dialog.isOK());
if (myValidHgExecutable) {
globalSettings.setHgExecutable(dialog.getNewHgPath());
}
}
});
} catch (InvocationTargetException e) {
LOG.error(e);
} catch (InterruptedException e) {
LOG.error(e);
}
return myValidHgExecutable;
}
}
@@ -22,7 +22,7 @@ import com.intellij.openapi.components.Storage;
)
public class HgGlobalSettings implements PersistentStateComponent<HgGlobalSettings> {
private static final String HG = "hg";
private static final String HG = HgVcs.HG_EXECUTABLE_FILE_NAME;
private static final int FIVE_MINUTES = 300;
private String hgExecutable = HG;
@@ -47,7 +47,7 @@ public class HgGlobalSettings implements PersistentStateComponent<HgGlobalSettin
hgExecutable = HG;
}
public int getIncomingCheckIntervalSeconds() {
public static int getIncomingCheckIntervalSeconds() {
return FIVE_MINUTES;
}
@@ -16,10 +16,8 @@
package org.zmlx.hg4idea;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsVFSListener;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ui.VcsBackgroundTask;
@@ -29,9 +27,7 @@ import org.zmlx.hg4idea.command.HgCopyCommand;
import org.zmlx.hg4idea.command.HgMoveCommand;
import org.zmlx.hg4idea.command.HgRemoveCommand;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* Listens to VFS events (such as adding or deleting bunch of files) and performs necessary operations with the VCS.
@@ -98,6 +94,44 @@ public class HgVFSListener extends VcsVFSListener {
return HgVcsMessages.message("hg4idea.remove.single.body");
}
protected void executeDelete() {
final List<FilePath> filesToDelete = new ArrayList<FilePath>(myDeletedWithoutConfirmFiles);
final List<FilePath> deletedFiles = new ArrayList<FilePath>(myDeletedFiles);
myDeletedWithoutConfirmFiles.clear();
myDeletedFiles.clear();
// skip unversioned files
final List<FilePath> unversionedFilePaths = new ArrayList<FilePath>();
for (VirtualFile vf : ChangeListManagerImpl.getInstanceImpl(myProject).getUnversionedFiles()) {
unversionedFilePaths.add(VcsUtil.getFilePath(vf.getPath()));
}
for (Iterator<FilePath> iter = filesToDelete.iterator(); iter.hasNext(); ) {
if (unversionedFilePaths.contains(iter.next())) {
iter.remove();
}
}
for (Iterator<FilePath> iter = deletedFiles.iterator(); iter.hasNext(); ) {
if (unversionedFilePaths.contains(iter.next())) {
iter.remove();
}
}
// confirm removal from the VCS if needed
if (myRemoveOption.getValue() != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
if (myRemoveOption.getValue() == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY || deletedFiles.isEmpty()) {
filesToDelete.addAll(deletedFiles);
}
else {
Collection<FilePath> filePaths = selectFilePathsToDelete(deletedFiles);
if (filePaths != null) {
filesToDelete.addAll(filePaths);
}
}
}
performDeletion(filesToDelete);
}
@Override
protected void performDeletion(List<FilePath> filesToDelete) {
(new VcsBackgroundTask<FilePath>(myProject,
@@ -1,6 +1,7 @@
package org.zmlx.hg4idea.command;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nullable;
import java.nio.charset.Charset;
import java.util.Collections;
@@ -24,6 +25,7 @@ public class HgIdentifyCommand {
this.source = source;
}
@Nullable
public HgCommandResult execute() {
List<String> arguments = new LinkedList<String>();
arguments.add(source);
@@ -20,9 +20,6 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.zmlx.hg4idea.HgVcsMessages;
import org.zmlx.hg4idea.command.HgCommandResult;
import org.zmlx.hg4idea.command.HgIdentifyCommand;
@@ -30,13 +27,11 @@ import org.zmlx.hg4idea.command.HgIdentifyCommand;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ResourceBundle;
/**
* A dialog for the mercurial clone options
@@ -346,11 +341,10 @@ public class HgCloneDialog extends DialogWrapper {
}
private static boolean testRepository(Project project, final String repositoryUrl) {
HgIdentifyCommand identifyCommand = new HgIdentifyCommand(project);
final HgIdentifyCommand identifyCommand = new HgIdentifyCommand(project);
identifyCommand.setSource(repositoryUrl);
HgCommandResult result = identifyCommand.execute();
return result.getExitValue() == 0;
final HgCommandResult result = identifyCommand.execute();
return result != null && result.getExitValue() == 0;
}
}
@@ -14,7 +14,6 @@ package org.zmlx.hg4idea;
import com.intellij.execution.process.ProcessOutput;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsShowConfirmationOption;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
@@ -136,8 +135,7 @@ public abstract class AbstractHgTestCase extends AbstractVcsTestCase {
}
protected ProcessOutput runHg(File aHgRepository, String... commandLine) throws IOException {
String exe = SystemInfo.isWindows ? "hg.exe" : "hg";
return runClient(exe, null, aHgRepository, commandLine);
return runClient(HgVcs.HG_EXECUTABLE_FILE_NAME, null, aHgRepository, commandLine);
}
protected File fillFile(File aParentDir, String[] filePath, String fileContents) throws FileNotFoundException {
@@ -16,7 +16,6 @@
package com.theoryinpractice.testng.inspection;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInsight.actions.OptimizeImportsProcessor;
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -196,7 +195,7 @@ public class JUnitConvertTool extends BaseJavaLocalInspectionTool {
element.delete();
}
}
new OptimizeImportsProcessor(project, javaFile).run(); //delete unused imports
JavaCodeStyleManager.getInstance(project).optimizeImports(javaFile);//delete unused imports
}
catch (IncorrectOperationException e) {
LOG.error("Error converting testcase", e);