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

This commit is contained in:
Irina Chernushina
2009-10-01 10:29:56 +04:00
217 changed files with 14443 additions and 3168 deletions
+1
View File
@@ -1,2 +1,3 @@
/config
/system
.idea/workspace.xml
+1
View File
@@ -0,0 +1 @@
90.SNAPSHOT
+11855
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -62,7 +62,8 @@ def layoutFull(String targetDirectory) {
"dom-impl",
"execution-impl",
"jsp-spi",
"idea-ui"].flatten()
"idea-ui",
"RegExpSupport"].flatten()
ant.patternset(id: "resources.included") {
include(name: "**/*.properties")
@@ -21,8 +21,5 @@
<plugins url="http://plugins.intellij.net"/>
<plugins-page category="VCS Integration" title="Select VCS Integration Plugins"/>
<plugins-page category="Web/JavaEE Technologies" title="Select Web/JavaEE Technology Plugins"/>
<plugins-page category="Application Servers" title="Select Application Server Plugins" depends="com.intellij.javaee"/>
<plugins-page category="HTML/JavaScript Development" title="Select HTML/JavaScript Development Plugins"/>
<plugins-page title="Select Other Plugins"/>
</component>
@@ -8,6 +8,7 @@ import com.intellij.openapi.editor.ex.FoldingModelEx;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -16,7 +17,7 @@ public class CollapseBlockHandler implements CodeInsightActionHandler {
public static final String ourPlaceHolderText = "{...}";
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.folding.impl.CollapseBlockHandler");
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
editor.getFoldingModel().runBatchFoldingOperation(new Runnable() {
public void run() {
final EditorFoldingInfo info = EditorFoldingInfo.get(editor);
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.javadoc.PsiDocComment;
import org.jetbrains.annotations.NotNull;
public class CollapseExpandJavadocsHandler implements CodeInsightActionHandler {
private final boolean myExpand;
@@ -17,7 +18,7 @@ public class CollapseExpandJavadocsHandler implements CodeInsightActionHandler {
myExpand = isExpand;
}
public void invoke(Project project, final Editor editor, PsiFile file){
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file){
PsiDocumentManager.getInstance(project).commitAllDocuments();
CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project);
@@ -18,6 +18,7 @@ import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -31,7 +32,7 @@ import java.util.Set;
public class GenerateDelegateHandler implements CodeInsightActionHandler {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.GenerateDelegateHandler");
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
return;
}
@@ -43,7 +43,7 @@ public abstract class GenerateMembersHandlerBase implements CodeInsightActionHan
myChooserTitle = chooserTitle;
}
public final void invoke(final Project project, final Editor editor, PsiFile file) {
public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
return;
}
@@ -183,4 +183,4 @@ public abstract class GenerateMembersHandlerBase implements CodeInsightActionHan
public boolean startInWriteAction() {
return false;
}
}
}
@@ -7,6 +7,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
@@ -21,7 +22,7 @@ public class JavaImplementMethodsHandler implements LanguageCodeInsightActionHan
return aClass != null;
}
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
PsiClass aClass = OverrideImplementUtil.getContextClass(project, editor, file, false);
if (aClass == null) {
return;
@@ -6,6 +6,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
@@ -15,7 +16,7 @@ public class JavaOverrideMethodsHandler implements LanguageCodeInsightActionHand
return file instanceof PsiJavaFile && OverrideImplementUtil.getContextClass(file.getProject(), editor, file, true) != null;
}
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
PsiClass aClass = OverrideImplementUtil.getContextClass(project, editor, file, true);
if (aClass != null) {
OverrideImplementUtil.chooseAndOverrideMethods(project, editor, aClass);
@@ -465,7 +465,7 @@ public class OverrideImplementUtil {
super.fillToolbarActions(group);
if (toImplement) return;
final ToggleAction mergeAction = new ToggleAction("Show methods to implement", "Show methods to implement", IconLoader.findIcon("/general/show_to_implement.png")) {
final ToggleAction mergeAction = new ToggleAction("Show methods to implement", "Show methods to implement", IconLoader.getIcon("/general/show_to_implement.png")) {
@Override
public boolean isSelected(AnActionEvent e) {
return merge.get().booleanValue();
@@ -13,13 +13,14 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class GenerateSuperMethodCallHandler implements CodeInsightActionHandler {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.actions.GenerateSuperMethodCallHandler");
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiMethod method = canInsertSuper(project, editor, file);
try {
PsiMethod template = (PsiMethod)method.copy();
@@ -64,4 +65,4 @@ public class GenerateSuperMethodCallHandler implements CodeInsightActionHandler
return null;
}
}
}
@@ -15,6 +15,7 @@ import com.intellij.psi.*;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.ui.LightweightHint;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -24,7 +25,7 @@ public class ShowContainerInfoHandler implements CodeInsightActionHandler {
private static final Key<WeakReference<LightweightHint>> MY_LAST_HINT_KEY = Key.create("MY_LAST_HINT_KEY");
private static final Key<PsiElement> CONTAINER_KEY = Key.create("CONTAINER_KEY");
public void invoke(final Project project, final Editor editor, PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiElement container = null;
@@ -120,4 +121,4 @@ public class ShowContainerInfoHandler implements CodeInsightActionHandler {
Point loc = editor.logicalPositionToXY(pos);
return loc.y >= viewRect.y;
}
}
}
@@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiSuperMethodUtil;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -17,7 +18,7 @@ import java.util.Iterator;
import java.util.List;
public class JavaGotoSuperHandler implements CodeInsightActionHandler {
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
int offset = editor.getCaretModel().getOffset();
PsiElement[] superElements = findSuperElements(file, offset);
if (superElements == null || superElements.length == 0) return;
@@ -452,42 +452,4 @@ public class DefUseUtil {
}
};
@NotNull
public static PsiElement[] getDefsRefs (final boolean defs, PsiFile file, final PsiElement target) {
if (!(target instanceof PsiIdentifier)) {
return PsiElement.EMPTY_ARRAY;
}
if (file instanceof PsiCompiledElement) {
file = (PsiFile)((PsiCompiledElement)file).getMirror();
}
if (file instanceof PsiJavaFile) {
final PsiElement def;
final PsiElement refElem = target.getParent ();
if (refElem instanceof PsiReference) {
def = ((PsiReference)refElem).resolve();
}
else {
def = refElem;
}
if (def instanceof PsiLocalVariable || def instanceof PsiParameter) {
final PsiVariable var = (PsiVariable) def;
PsiElement p = var;
while (!(p instanceof PsiMethod)) {
final PsiElement parent = p.getParent();
LOG.assertTrue (parent != null);
p = parent;
}
final PsiMethod method = (PsiMethod)p;
final PsiCodeBlock body = method.getBody();
return defs
? getDefs(body, var, refElem)
: getRefs(body, var, refElem);
}
}
return PsiElement.EMPTY_ARRAY;
}
}
@@ -1,12 +1,16 @@
package com.intellij.psi.impl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.UserDataHolderEx;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.filters.OrFilter;
import com.intellij.psi.impl.compiled.ClsElementImpl;
import com.intellij.psi.impl.source.PsiImmediateClassType;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.scope.ElementClassFilter;
@@ -826,7 +830,38 @@ public class PsiClassImplUtil {
return false;
}
}
return qName1.hashCode() == qName2.hashCode() && qName1.equals(qName2);
if (qName1.hashCode() != qName2.hashCode() || !qName1.equals(qName2)) {
return false;
}
if (originalElement(aClass).equals(originalElement((PsiClass)another))) {
return true;
}
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(aClass.getProject()).getFileIndex();
final PsiFile file1 = aClass.getContainingFile().getOriginalFile();
final PsiFile file2 = another.getContainingFile().getOriginalFile();
if (file1.equals(file2)) {
return true;
}
final VirtualFile vfile1 = file1.getViewProvider().getVirtualFile();
final VirtualFile vfile2 = file2.getViewProvider().getVirtualFile();
if ((fileIndex.isInSource(vfile1) || fileIndex.isInLibraryClasses(vfile1)) &&
(fileIndex.isInSource(vfile2) || fileIndex.isInLibraryClasses(vfile2))) {
return true;
}
return false;
}
private static PsiElement originalElement(PsiClass aClass) {
final PsiElement originalElement = aClass.getOriginalElement();
final PsiCompiledElement compiled = originalElement.getUserData(ClsElementImpl.COMPILED_ELEMENT);
if (compiled != null) {
return compiled;
}
return originalElement;
}
public static boolean isFieldEquivalentTo(PsiField field, PsiElement another) {
@@ -4,6 +4,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
@@ -19,6 +20,7 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsElementImpl");
private static final boolean CHECK_MIRROR_ENABLED = false;
protected static final Object LAZY_BUILT_LOCK = new String("lazy cls tree initialization lock");
public static final Key<PsiCompiledElement> COMPILED_ELEMENT = Key.create("COMPILED_ELEMENT");
private TreeElement myMirror = null;
@@ -216,7 +218,7 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil
return null;
}
protected void setMirrorCheckingType(TreeElement element, IElementType type) {
protected void setMirrorCheckingType(@NotNull TreeElement element, IElementType type) {
if (CHECK_MIRROR_ENABLED) {
LOG.assertTrue(myMirror == null);
}
@@ -225,6 +227,7 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil
LOG.assertTrue(element.getElementType() == type);
}
element.putUserData(COMPILED_ELEMENT, this);
myMirror = element;
}
}
@@ -7,6 +7,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -19,7 +20,7 @@ public class SliceHandler implements CodeInsightActionHandler {
myDataFlowToThis = dataFlowToThis;
}
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments(); // prevents problems with smart pointers creation
PsiElement expression = getExpressionAtCaret(editor, file);
if (expression == null) {
@@ -47,7 +47,7 @@ public class GenerateTestMethodAction extends BaseGenerateAction {
}
private static class MyHandler implements CodeInsightActionHandler {
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
try {
PsiMethod method = generateDummyMethod(editor, file);
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
<option name="PROJECT_PROFILE" value="p1" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
<profiles>
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
@@ -17,6 +14,9 @@
</inspection_tool>
</profile>
</profiles>
<option name="PROJECT_PROFILE" value="p1" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
<list size="5">
<item index="0" class="java.lang.String" itemvalue="TYPO" />
<item index="1" class="java.lang.String" itemvalue="SERVER PROBLEM" />
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
<option name="PROJECT_PROFILE" value="p1" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
<profiles>
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
@@ -21,6 +18,9 @@
</inspection_tool>
</profile>
</profiles>
<option name="PROJECT_PROFILE" value="p1" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
<list size="5">
<item index="0" class="java.lang.String" itemvalue="TYPO" />
<item index="1" class="java.lang.String" itemvalue="SERVER PROBLEM" />
@@ -11,7 +11,7 @@ public class DefaultFileTemplateInspectionTest extends InspectionTestCase {
}
private void doTest() throws Exception {
doTest("defaultFileTemplateUsage/" + getTestName(false), new DefaultFileTemplateUsageInspection());
doTest("defaultFileTemplateUsage/" + getTestName(true), new DefaultFileTemplateUsageInspection());
}
public void testDefaultFile() throws Exception{
@@ -101,7 +101,7 @@ public class TurnRefsToSuperTest extends MultiFileTestCase {
doTest("Xyz", "Xint", false);
}
public void testIDEADEV5517Noop() throws Exception {
public void testIDEADEV5517NOOP() throws Exception {
doTest("Xyz", "Xint", false);
}
Binary file not shown.
@@ -19,9 +19,10 @@ package com.intellij.codeInsight;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public interface CodeInsightActionHandler {
void invoke(Project project, Editor editor, PsiFile file);
void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file);
boolean startInWriteAction();
}
@@ -115,22 +115,39 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
}
public void writeExternal(Element element) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, element);
Element version = new Element("version");
version.setAttribute("value", VERSION);
element.addContent(version);
final List<String> sortedProfiles = new ArrayList<String>(myProfiles.keySet());
Element profiles = null;
Collections.sort(sortedProfiles);
final Element profiles = new Element(PROFILES);
for (String profile : sortedProfiles) {
final Profile projectProfile = myProfiles.get(profile);
if (projectProfile != null) {
final Element profileElement = new Element(PROFILE);
projectProfile.writeExternal(profileElement);
boolean hasSmthToSave = sortedProfiles.size() > 1;
for (Object child : profileElement.getChildren()) {
if (!((Element)child).getName().equals("option")) {
hasSmthToSave = true;
break;
}
}
if (!hasSmthToSave) continue;
if (profiles == null) {
profiles = new Element(PROFILES);
element.addContent(profiles);
}
profiles.addContent(profileElement);
}
}
element.addContent(profiles);
if (profiles != null) {
DefaultJDOMExternalizer.writeExternal(this, element);
final Element version = new Element("version");
version.setAttribute("value", VERSION);
element.addContent(version);
}
}
public NamedScopesHolder getScopesManager() {
@@ -230,7 +247,7 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
}
result.add(new Pair<Element, String>(e, generator.generateUniqueName("profiles_settings") + ".xml"));
if (!e.getContent().isEmpty()) result.add(new Pair<Element, String>(e, generator.generateUniqueName("profiles_settings") + ".xml"));
return result;
}
@@ -20,6 +20,7 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.DifferenceFilter;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Element;
@@ -62,7 +63,7 @@ public class CodeStyleSettingsManager implements PersistentStateComponent<Elemen
}
public void writeExternal(Element element) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, element);
DefaultJDOMExternalizer.writeExternal(this, element, new DifferenceFilter<CodeStyleSettingsManager>(this, new CodeStyleSettingsManager()));
}
public Element getState() {
@@ -67,7 +67,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
invoke(project, editor, PsiUtilBase.getPsiFileInEditor(editor, project));
}
public final void invoke(final Project project, final Editor editor, PsiFile psiFile) {
public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile psiFile) {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
assert !ApplicationManager.getApplication().isWriteAccessAllowed();
}
@@ -38,7 +38,7 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
BACKWARD
}
public void invoke(Project project, final Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
final CharSequence charsSequence = editor.getDocument().getCharsSequence();
@@ -8,6 +8,7 @@ import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
/**
* @author peter
@@ -20,7 +21,7 @@ public class SmartCodeCompletionAction extends BaseCodeCompletionAction{
public static CodeInsightActionHandler createHandler() {
return new CodeInsightActionHandler() {
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_SMARTTYPE_GENERAL);
new CodeCompletionHandlerBase(CompletionType.SMART).invoke(project, editor, file);
}
@@ -14,6 +14,7 @@ import com.intellij.openapi.editor.ScrollingModel;
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -24,7 +25,7 @@ public class GotoNextErrorHandler implements CodeInsightActionHandler {
myGoForward = goForward;
}
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
int caretOffset = editor.getCaretModel().getOffset();
gotoNextError(project, editor, file, caretOffset);
}
@@ -128,4 +129,4 @@ public class GotoNextErrorHandler implements CodeInsightActionHandler {
int offset = info.highlighter.getStartOffset() + shift;
return Math.min(offset, document.getTextLength());
}
}
}
@@ -155,7 +155,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
myOrder.retainAll(knownSeverities);
if (myOrder.isEmpty()) {
initOrder();
myOrder.addAll(getDefaultOrder());
}
//enforce include all known
for (int i = 0; i < knownSeverities.size(); i++) {
@@ -175,7 +175,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
}
public void writeExternal(Element element) throws WriteExternalException {
for (String severity : myOrder) {
for (String severity : getOrder()) {
Element info = new Element(INFO);
final SeverityBasedTextAttributes infoType = ourMap.get(severity);
if (infoType != null) {
@@ -187,10 +187,12 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
element.addContent(info);
}
}
if (myReadOrder != null) {
if (myReadOrder != null && !myReadOrder.isEmpty()) {
myReadOrder.writeExternal(element);
} else {
myOrder.writeExternal(element);
if (!getDefaultOrder().equals(getOrder())) {
getOrder().writeExternal(element);
}
}
}
@@ -238,12 +240,12 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
private JDOMExternalizableStringList getOrder() {
if (myOrder.isEmpty()) {
initOrder();
myOrder.addAll(getDefaultOrder());
}
return myOrder;
}
private void initOrder() {
private List<String> getDefaultOrder() {
final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>();
for (HighlightInfoType type : STANDART_SEVERITIES.values()) {
order.add(type.getSeverity(null));
@@ -252,9 +254,11 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
order.add(attributes.getSeverity());
}
Collections.sort(order);
final List<String> result = new ArrayList<String>();
for (HighlightSeverity severity : order) {
myOrder.add(severity.toString());
result.add(severity.toString());
}
return result;
}
public void setOrder(List<String> order) {
@@ -5,6 +5,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class ShowErrorDescriptionHandler implements CodeInsightActionHandler {
private final int myWidth;
@@ -13,7 +14,7 @@ public class ShowErrorDescriptionHandler implements CodeInsightActionHandler {
myWidth = width;
}
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
int offset = editor.getCaretModel().getOffset();
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
HighlightInfo info = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(editor.getDocument(), offset, false);
@@ -16,6 +16,7 @@ import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.DumbService;
import com.intellij.psi.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class ShowJavaDocInfoAction extends BaseCodeInsightAction implements HintManagerImpl.ActionToIgnore, DumbAware {
@NonNls public static final String CODEASSISTS_QUICKJAVADOC_LOOKUP_FEATURE = "codeassists.quickjavadoc.lookup";
@@ -28,7 +29,7 @@ public class ShowJavaDocInfoAction extends BaseCodeInsightAction implements Hint
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
DocumentationManager.getInstance(project).showJavaDocInfo(editor, file, true);
}
@@ -16,6 +16,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
public class EmacsStyleIndentAction extends BaseCodeInsightAction implements DumbAware {
@@ -33,7 +34,7 @@ public class EmacsStyleIndentAction extends BaseCodeInsightAction implements Dum
//----------------------------------------------------------------------
private static class Handler implements CodeInsightActionHandler {
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
@@ -67,4 +68,4 @@ public class EmacsStyleIndentAction extends BaseCodeInsightAction implements Dum
return true;
}
}
}
}
@@ -6,9 +6,10 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
public class CollapseAllRegionsHandler implements CodeInsightActionHandler {
public void invoke(Project project, final Editor editor, PsiFile file){
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file){
PsiDocumentManager.getInstance(project).commitAllDocuments();
CodeFoldingManager.getInstance(project).updateFoldRegions(editor);
@@ -6,9 +6,10 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
public class CollapseRegionHandler implements CodeInsightActionHandler {
public void invoke(Project project, final Editor editor, PsiFile file){
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file){
CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project);
foldingManager.updateFoldRegions(editor);
@@ -8,6 +8,7 @@ import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.editor.ex.FoldingModelEx;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
/**
* Created by IntelliJ IDEA.
@@ -20,7 +21,7 @@ public class CollapseSelectionHandler implements CodeInsightActionHandler {
private static final String ourPlaceHolderText = "...";
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.folding.impl.CollapseSelectionHandler");
public void invoke(Project project, final Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
editor.getFoldingModel().runBatchFoldingOperation(
new Runnable() {
public void run() {
@@ -8,9 +8,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class ExpandAllRegionsHandler implements CodeInsightActionHandler {
public void invoke(Project project, final Editor editor, PsiFile file){
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file){
PsiDocumentManager.getInstance(project).commitAllDocuments();
CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project);
@@ -6,11 +6,12 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ExpandRegionHandler implements CodeInsightActionHandler {
public void invoke(Project project, final Editor editor, PsiFile file){
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file){
expandRegionAtCaret(project, editor);
}
@@ -10,11 +10,12 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
public class AutoIndentLinesHandler implements CodeInsightActionHandler {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.AutoIndentLinesHandler");
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
@@ -72,4 +73,4 @@ public class AutoIndentLinesHandler implements CodeInsightActionHandler {
public boolean startInWriteAction() {
return true;
}
}
}
@@ -38,7 +38,7 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler {
private PsiFile myFile;
private Document myDocument;
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
myProject = project;
myEditor = editor;
myFile = file;
@@ -42,7 +42,7 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
private Commenter[] myCommenters;
private CodeStyleManager myCodeStyleManager;
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
myProject = project;
myFile = file.getViewProvider().getPsi(file.getViewProvider().getBaseLanguage());
myDocument = editor.getDocument();
@@ -9,9 +9,10 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
public class ImplementMethodsHandler implements CodeInsightActionHandler{
public final void invoke(final Project project, final Editor editor, PsiFile file) {
public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
return;
}
@@ -26,4 +27,4 @@ public class ImplementMethodsHandler implements CodeInsightActionHandler{
public boolean startInWriteAction() {
return false;
}
}
}
@@ -9,9 +9,10 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
public class OverrideMethodsHandler implements CodeInsightActionHandler{
public final void invoke(final Project project, final Editor editor, PsiFile file) {
public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
return;
}
@@ -26,4 +27,4 @@ public class OverrideMethodsHandler implements CodeInsightActionHandler{
public boolean startInWriteAction() {
return false;
}
}
}
@@ -19,6 +19,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -27,7 +28,7 @@ public class SurroundWithHandler implements CodeInsightActionHandler{
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler");
private static final String CHOOSER_TITLE = CodeInsightBundle.message("surround.with.chooser.title");
public void invoke(final Project project, final Editor editor, PsiFile file){
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file){
invoke(project, editor, file, null);
}
@@ -125,7 +125,6 @@ public class HighlightUsagesHandler extends HighlightHandlerBase {
if (element == null) return null;
}
if (target instanceof PsiCompiledElement) target = ((PsiCompiledElement)target).getMirror();
return target;
}
@@ -22,7 +22,7 @@ import java.awt.*;
import java.util.Set;
public class ShowParameterInfoHandler implements CodeInsightActionHandler {
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
invoke(project, editor, file, -1, null);
}
@@ -36,7 +36,7 @@ import javax.swing.*;
* @author mike
*/
public class ShowIntentionActionsHandler implements CodeInsightActionHandler {
public void invoke(final Project project, final Editor editor, final PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (HintManagerImpl.getInstanceImpl().performCurrentQuestionAction()) return;
@@ -73,8 +73,8 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
private final Set<String> myIgnoredActions = new LinkedHashSet<String>();
private final Map<MetaDataKey, IntentionActionMetaData> myMetaData = new LinkedHashMap<MetaDataKey, IntentionActionMetaData>();
private static final @NonNls String IGNORE_ACTION_TAG = "ignoreAction";
private static final @NonNls String NAME_ATT = "name";
@NonNls private static final String IGNORE_ACTION_TAG = "ignoreAction";
@NonNls private static final String NAME_ATT = "name";
private static final Pattern HTML_PATTERN = Pattern.compile("<[^<>]*>");
@@ -87,12 +87,9 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
}
private static ClassLoader getClassLoader(final IntentionAction intentionAction) {
if (intentionAction instanceof IntentionActionWrapper) {
return ((IntentionActionWrapper)intentionAction).getImplementationClassLoader();
}
else {
return intentionAction.getClass().getClassLoader();
}
return intentionAction instanceof IntentionActionWrapper
? ((IntentionActionWrapper)intentionAction).getImplementationClassLoader()
: intentionAction.getClass().getClassLoader();
}
public void registerIntentionMetaData(final IntentionAction intentionAction, final String[] category, final String descriptionDirectoryName,
@@ -130,17 +127,12 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
return !myIgnoredActions.contains(getFamilyName(metaData));
}
private String getFamilyName(final IntentionActionMetaData metaData) {
private static String getFamilyName(final IntentionActionMetaData metaData) {
return StringUtil.join(metaData.myCategory, "/") + "/" + metaData.getFamily();
}
private String getFamilyName(final IntentionAction action) {
if (action instanceof IntentionActionWrapper) {
return ((IntentionActionWrapper)action).getFullFamilyName();
}
else {
return action.getFamilyName();
}
private static String getFamilyName(final IntentionAction action) {
return action instanceof IntentionActionWrapper ? ((IntentionActionWrapper)action).getFullFamilyName() : action.getFamilyName();
}
public synchronized void setEnabled(IntentionActionMetaData metaData, boolean enabled) {
@@ -173,31 +165,29 @@ public class IntentionManagerSettings implements PersistentStateComponent<Elemen
myMetaData.put(key, metaData);
}
private synchronized static void processMetaData(@NotNull final IntentionActionMetaData metaData) {
private static synchronized void processMetaData(@NotNull final IntentionActionMetaData metaData) {
final Application app = ApplicationManager.getApplication();
if (app.isUnitTestMode() || app.isHeadlessEnvironment()) return;
final TextDescriptor description = metaData.getDescription();
if (description != null) {
app.executeOnPooledThread(new Runnable(){
public void run() {
try {
SearchableOptionsRegistrar registrar = SearchableOptionsRegistrar.getInstance();
if (registrar == null) return;
@NonNls String descriptionText = description.getText().toLowerCase();
descriptionText = HTML_PATTERN.matcher(descriptionText).replaceAll(" ");
final Set<String> words = registrar.getProcessedWordsWithoutStemming(descriptionText);
words.addAll(registrar.getProcessedWords(metaData.getFamily()));
for (String word : words) {
registrar.addOption(word, metaData.getFamily(), metaData.getFamily(), IntentionSettingsConfigurable.HELP_ID, IntentionSettingsConfigurable.DISPLAY_NAME);
}
}
catch (IOException e) {
LOG.error(e);
app.executeOnPooledThread(new Runnable(){
public void run() {
try {
SearchableOptionsRegistrar registrar = SearchableOptionsRegistrar.getInstance();
if (registrar == null) return;
@NonNls String descriptionText = description.getText().toLowerCase();
descriptionText = HTML_PATTERN.matcher(descriptionText).replaceAll(" ");
final Set<String> words = registrar.getProcessedWordsWithoutStemming(descriptionText);
words.addAll(registrar.getProcessedWords(metaData.getFamily()));
for (String word : words) {
registrar.addOption(word, metaData.getFamily(), metaData.getFamily(), IntentionSettingsConfigurable.HELP_ID, IntentionSettingsConfigurable.DISPLAY_NAME);
}
}
});
}
catch (IOException e) {
LOG.error(e);
}
}
});
}
public synchronized void unregisterMetaData(IntentionAction intentionAction) {
@@ -17,6 +17,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiNamedElement;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Arrays;
@@ -26,7 +27,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
return false;
}
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(getFeatureUsedKey());
try {
@@ -7,9 +7,10 @@ import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class MethodDownHandler implements CodeInsightActionHandler {
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
int caretOffset = editor.getCaretModel().getOffset();
@@ -32,4 +33,4 @@ public class MethodDownHandler implements CodeInsightActionHandler {
public boolean startInWriteAction() {
return true;
}
}
}
@@ -7,9 +7,10 @@ import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class MethodUpHandler implements CodeInsightActionHandler {
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
int caretOffset = editor.getCaretModel().getOffset();
@@ -33,4 +34,4 @@ public class MethodUpHandler implements CodeInsightActionHandler {
public boolean startInWriteAction() {
return true;
}
}
}
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.text.MessageFormat;
@@ -45,7 +46,7 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
return true;
}
public void invoke(final Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiElement element;
@@ -10,6 +10,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
/**
*
@@ -20,7 +21,7 @@ public class GotoSuperAction extends BaseCodeInsightAction implements CodeInsigh
return this;
}
public void invoke(final Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
int offset = editor.getCaretModel().getOffset();
@@ -44,7 +44,7 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements
}
}
public void invoke(final Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
int offset = editor.getCaretModel().getOffset();
@@ -127,4 +127,4 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements
return null;
}
}
}
@@ -15,11 +15,12 @@ import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
public class ListTemplatesHandler implements CodeInsightActionHandler{
public void invoke(final Project project, final Editor editor, PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!file.isWritable()) return;
EditorUtil.fillVirtualSpaceUntilCaret(editor);
@@ -78,4 +79,4 @@ public class ListTemplatesHandler implements CodeInsightActionHandler{
private boolean isInPrefix(final char c) {
return Character.isJavaIdentifierPart(c) || c == '.';
}
}
}
@@ -12,6 +12,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -19,7 +20,7 @@ import java.util.*;
* @author mike
*/
public class SurroundWithTemplateHandler implements CodeInsightActionHandler {
public void invoke(final Project project, final Editor editor, PsiFile file) {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (!editor.getSelectionModel().hasSelection()) {
editor.getSelectionModel().selectLineAtCaret();
if (!editor.getSelectionModel().hasSelection()) return;
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -36,7 +37,7 @@ public class UnwrapHandler implements CodeInsightActionHandler {
return true;
}
public void invoke(Project project, Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
List<AnAction> options = collectOptions(project, editor, file);
selectOption(options, editor, file);
}
@@ -87,6 +87,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
myRegistrar = inspectionProfile.myRegistrar;
myTools = new HashMap<String, ToolsImpl>();
myVisibleTreeState = new VisibleTreeState(inspectionProfile.myVisibleTreeState);
myDeinstalledInspectionsSettings = new LinkedHashMap<String, Element>(inspectionProfile.myDeinstalledInspectionsSettings);
myBaseProfile = inspectionProfile.myBaseProfile;
myLocal = inspectionProfile.myLocal;
@@ -598,7 +598,7 @@ public class EditorSearchComponent extends JPanel implements DataProvider {
private class ShowHistoryAction extends AnAction implements DumbAware {
private ShowHistoryAction() {
getTemplatePresentation().setIcon(IconLoader.findIcon("/actions/search.png"));
getTemplatePresentation().setIcon(IconLoader.getIcon("/actions/search.png"));
getTemplatePresentation().setDescription("Search history");
getTemplatePresentation().setText("Search History");
@@ -619,7 +619,7 @@ public class EditorSearchComponent extends JPanel implements DataProvider {
private class FindAllAction extends AnAction implements DumbAware {
private FindAllAction() {
getTemplatePresentation().setIcon(IconLoader.findIcon("/actions/export.png"));
getTemplatePresentation().setIcon(IconLoader.getIcon("/actions/export.png"));
getTemplatePresentation().setDescription("Export matches to Find tool window");
getTemplatePresentation().setText("Find All");
registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_USAGES).getShortcutSet(), mySearchField);
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
abstract class GotoBookmarkActionBase extends BaseCodeInsightAction implements CodeInsightActionHandler, DumbAware {
protected GotoBookmarkActionBase() {
@@ -20,7 +21,7 @@ abstract class GotoBookmarkActionBase extends BaseCodeInsightAction implements C
return this;
}
public void invoke(Project project, final Editor editor, PsiFile file) {
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
if (ToolWindowManager.getInstance(project).isEditorComponentActive()) {
final Bookmark bookmark = getBookmarkToGo(project, editor);
if (bookmark == null) return;
@@ -831,7 +831,8 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
else {
final Container container = focusedWindow != null ? focusedWindow : editor.getContentComponent();
final Point p = AbstractPopup.getCenterOf(container, this);
p.y = container.getHeight() / 4;
p.x -= container.getLocation().x; //make NavBar visible in case of two monitors; p should be relative
p.y = container.getHeight() / 4;
HintManagerImpl.getInstanceImpl().showEditorHint(myHint, editor, p, HintManagerImpl.HIDE_BY_ESCAPE, 0, true);
}
select();
@@ -88,6 +88,11 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
}
}
@Override
public boolean isEmpty() {
return super.isEmpty() && myOptions.isEmpty();
}
@NotNull
protected Element save() {
final Element root = super.save();
@@ -112,14 +112,18 @@ public class ModuleVcsDetector implements ProjectComponent {
}
private void autoDetectModuleVcsMapping(final Module module) {
boolean mappingsUpdated = false;
final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
for(VirtualFile file: files) {
AbstractVcs vcs = myVcsManager.findVersioningVcs(file);
if (vcs != null && vcs != myVcsManager.getVcsFor(file)) {
myVcsManager.setAutoDirectoryMapping(file.getPath(), vcs.getName());
mappingsUpdated = true;
}
}
myVcsManager.cleanupMappings();
if (mappingsUpdated) {
myVcsManager.cleanupMappings();
}
}
private void checkRemoveVcsRoot(final Module module) {
@@ -64,10 +64,6 @@ public class VcsManagerPerModuleConfiguration implements JDOMExternalizable, Mod
}
public void writeExternal(Element element) throws WriteExternalException {
if (!USE_PROJECT_VCS) {
DefaultJDOMExternalizer.writeExternal(this, element);
} else {
throw new WriteExternalException();
}
throw new WriteExternalException();
}
}
@@ -12,6 +12,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.PomTargetPsiElement;
import com.intellij.psi.*;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.meta.PsiMetaOwner;
@@ -23,10 +24,8 @@ import com.intellij.refactoring.util.*;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.HashMap;
import com.intellij.pom.PomTargetPsiElement;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.*;
public class RenameUtil {
@@ -283,7 +282,7 @@ public class RenameUtil {
return inputValidator.value(newName);
}
if (psiElement instanceof PsiFile || psiElement instanceof PsiDirectory) {
return newName.indexOf(File.separatorChar) < 0 && newName.indexOf('/') < 0;
return newName.indexOf('\\') < 0 && newName.indexOf('/') < 0;
}
if (psiElement instanceof PomTargetPsiElement) {
return !StringUtil.isEmptyOrSpaces(newName);
@@ -15,19 +15,13 @@ import com.intellij.openapi.editor.impl.DocumentImpl;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.*;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.progress.*;
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
import com.intellij.openapi.project.*;
import com.intellij.openapi.roots.CollectingContentIterator;
import com.intellij.openapi.roots.ContentIterator;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.*;
@@ -542,6 +536,7 @@ public class FileBasedIndex implements ApplicationComponent {
myReentrancyGuard.set(Boolean.TRUE);
try {
myChangedFilesUpdater.ensureAllInvalidateTasksCompleted();
if (isUpToDateCheckEnabled()) {
try {
checkRebuild(indexId, false);
@@ -1095,11 +1090,14 @@ public class FileBasedIndex implements ApplicationComponent {
}
public void indexFileContent(com.intellij.ide.startup.FileContent content) {
myChangedFilesUpdater.ensureAllInvalidateTasksCompleted();
final VirtualFile file = content.getVirtualFile();
FileContent fc = null;
PsiFile psiFile = null;
final Ref<ProcessCanceledException> pce = Ref.create(null);
final List<Runnable> tasks = new ArrayList<Runnable>();
for (final ID<?, ?> indexId : myIndices.keySet()) {
if (shouldIndexFile(file, indexId)) {
@@ -1131,7 +1129,8 @@ public class FileBasedIndex implements ApplicationComponent {
try {
updateSingleIndex(indexId, file, _fc);
}
catch (ProcessCanceledException ignored) {
catch (ProcessCanceledException e) {
pce.set(e);
}
catch (StorageException e) {
requestRebuild(indexId);
@@ -1162,6 +1161,10 @@ public class FileBasedIndex implements ApplicationComponent {
}
}
if (!pce.isNull()) {
throw pce.get();
}
if (psiFile != null) {
psiFile.putUserData(PsiFileImpl.BUILDING_STUB, null);
}
@@ -1213,8 +1216,21 @@ public class FileBasedIndex implements ApplicationComponent {
return !myNotRequiringContentIndices.contains(indexId);
}
private abstract static class InvalidationTask implements Runnable {
private final VirtualFile mySubj;
protected InvalidationTask(final VirtualFile subj) {
mySubj = subj;
}
public VirtualFile getSubj() {
return mySubj;
}
}
private final class ChangedFilesUpdater extends VirtualFileAdapter implements BackgroundableCacheUpdater {
private final Set<VirtualFile> myFilesToUpdate = new LinkedHashSet<VirtualFile>();
private final Queue<InvalidationTask> myFutureInvalidations = new LinkedList<InvalidationTask>();
private final JBReentrantReadWriteLock myLock = LockFactory.createReadWriteLock();
private final JBLock r = myLock.readLock();
private final JBLock w = myLock.writeLock();
@@ -1297,14 +1313,8 @@ public class FileBasedIndex implements ApplicationComponent {
if (!isTooLarge(file)) {
for (ID<?, ?> indexId : myIndices.keySet()) {
if (needsFileContentLoading(indexId) && getInputFilter(indexId).acceptInput(file)) {
w.lock();
try {
myFilesToUpdate.add(file);
break; // no need to iterate further, as the file is already marked
}
finally {
w.unlock();
}
scheduleForUpdate(file);
break; // no need to iterate further, as the file is already marked
}
}
}
@@ -1315,6 +1325,16 @@ public class FileBasedIndex implements ApplicationComponent {
IndexingStamp.flushCache();
}
public void scheduleForUpdate(VirtualFile file) {
w.lock();
try {
myFilesToUpdate.add(file);
}
finally {
w.unlock();
}
}
void invalidateIndices(final VirtualFile file, final boolean markForReindex) {
if (isUnderConfigOrSystem(file)) {
return;
@@ -1332,7 +1352,7 @@ public class FileBasedIndex implements ApplicationComponent {
else {
cleanProcessedFlag(file);
IndexingStamp.flushCache();
boolean indicesAffected = false;
final List<ID<?, ?>> affectedIndices = new ArrayList<ID<?, ?>>(myIndices.size());
final boolean isTooLarge = isTooLarge(file);
for (final ID<?, ?> indexId : myIndices.keySet()) {
@@ -1344,18 +1364,7 @@ public class FileBasedIndex implements ApplicationComponent {
}
else { // the index requires file content
if (!isTooLarge && shouldUpdateIndex(file, indexId)) {
indicesAffected = true;
if (markForReindex) {
// only mark the file as unindexed, reindex will be done lazily
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
IndexingStamp.update(file, indexId, -1L);
}
});
}
else {
updateSingleIndex(indexId, file, null);
}
affectedIndices.add(indexId);
}
}
}
@@ -1364,21 +1373,95 @@ public class FileBasedIndex implements ApplicationComponent {
requestRebuild(indexId);
}
}
IndexingStamp.flushCache();
if (indicesAffected && markForReindex) {
iterateIndexableFiles(file, new Processor<VirtualFile>() {
public boolean process(final VirtualFile file) {
w.lock();
try {
myFilesToUpdate.add(file);
if (affectedIndices.size() > 0) {
if (markForReindex) {
// only mark the file as unindexed, reindex will be done lazily
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
for (ID<?, ?> indexId : affectedIndices) {
IndexingStamp.update(file, indexId, -1L);
}
}
finally {
w.unlock();
});
iterateIndexableFiles(file, new Processor<VirtualFile>() {
public boolean process(final VirtualFile file) {
scheduleForUpdate(file);
return true;
}
return true;
});
}
else {
final InvalidationTask invalidator = new InvalidationTask(file) {
public void run() {
Throwable unexpectedError = null;
for (ID<?, ?> indexId : affectedIndices) {
try {
updateSingleIndex(indexId, file, null);
}
catch (StorageException e) {
LOG.info(e);
requestRebuild(indexId);
}
catch (ProcessCanceledException ignored) {
}
catch (Throwable e) {
LOG.info(e);
if (unexpectedError == null) {
unexpectedError = e;
}
}
}
IndexingStamp.flushCache();
if (unexpectedError != null) {
LOG.error(unexpectedError);
}
}
};
w.lock();
try {
myFutureInvalidations.offer(invalidator);
}
});
finally {
w.unlock();
}
}
}
IndexingStamp.flushCache();
}
}
public void ensureAllInvalidateTasksCompleted() {
final int size;
r.lock();
try {
size = myFutureInvalidations.size();
if (size == 0) return;
}
finally {
r.unlock();
}
final ProgressIndicator current = ProgressManager.getInstance().getProgressIndicator();
final ProgressIndicator indicator = current != null ? current : new EmptyProgressIndicator();
indicator.setText("");
int count = 0;
while (true) {
InvalidationTask task;
w.lock();
try {
task = myFutureInvalidations.poll();
}
finally {
w.unlock();
}
if (task == null) {
break;
}
indicator.setFraction(((double)count++)/size);
indicator.setText2(task.getSubj().getPresentableUrl());
task.run();
}
}
@@ -1436,12 +1519,14 @@ public class FileBasedIndex implements ApplicationComponent {
}
public void processFile(final com.intellij.ide.startup.FileContent fileContent) {
myChangedFilesUpdater.ensureAllInvalidateTasksCompleted();
processFileImpl(fileContent);
}
private final Semaphore myForceUpdateSemaphore = new Semaphore();
public void forceUpdate() {
myChangedFilesUpdater.ensureAllInvalidateTasksCompleted();
final VirtualFile[] files = queryNeededFiles();
if (files.length > 0) {
myForceUpdateSemaphore.down();
@@ -61,7 +61,7 @@ public class ChangeRevertionVisitor extends ChangeVisitor {
String newName = getName(e);
VirtualFile existing = f.getParent().findChild(newName);
if (existing != null) {
if (existing != null && existing != f) {
existing.delete(this);
}
f.rename(this, newName);
@@ -32,7 +32,7 @@ public class ChangeRange {
last[0] = c;
}
};
myVcs.removeListener(l);
myVcs.addListener(l);
try {
myVcs.acceptWrite(new ChangeRangeRevertionVisitor(myGateway, myToChange, myFromChange));
}
@@ -7,6 +7,7 @@ import com.intellij.history.core.changes.Change;
import com.intellij.history.integration.IdeaGateway;
import com.intellij.history.integration.LocalHistoryComponent;
import com.intellij.openapi.command.undo.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootEvent;
import com.intellij.openapi.roots.ModuleRootListener;
@@ -18,6 +19,8 @@ import com.intellij.util.messages.MessageBusConnection;
import java.io.IOException;
public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider {
public static final Logger LOG = Logger.getInstance("#" + FileUndoProvider.class.getName());
private final Key<DocumentReference> DELETION_WAS_UNDOABLE = new Key<DocumentReference>("DeletionWasUndoable");
private final Project myProject;
@@ -193,6 +196,7 @@ public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider
myUndoChangeRange = myActionChangeRange.revert(myUndoChangeRange);
}
catch (IOException e) {
LOG.warn(e);
throw new UnexpectedUndoException(e.getMessage());
}
}
@@ -202,6 +206,7 @@ public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider
myActionChangeRange = myUndoChangeRange.revert(myActionChangeRange);
}
catch (IOException e) {
LOG.warn(e);
throw new UnexpectedUndoException(e.getMessage());
}
}
@@ -1,3 +1,19 @@
/*
* 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.
*/
package com.intellij.ide.plugins;
import com.intellij.ide.ClassloaderUtil;
@@ -13,6 +29,7 @@ import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.LogProvider;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.BuildNumber;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.io.FileUtil;
@@ -56,7 +73,7 @@ public class PluginManager {
static final Object lock = new Object();
private static String ourBuildNumber;
private static BuildNumber ourBuildNumber;
@NonNls public static final String PLUGIN_XML = "plugin.xml";
@NonNls public static final String META_INF = "META-INF";
private static final Map<PluginId,Integer> ourId2Index = new THashMap<PluginId, Integer>();
@@ -381,37 +398,20 @@ public class PluginManager {
}
public static boolean isIncompatible(final IdeaPluginDescriptor descriptor) {
final String buildNumberString = getBuildNumber();
if (buildNumberString != null) {
int buildNumber;
try {
buildNumber = Integer.parseInt(buildNumberString);
}
catch (NumberFormatException e) {
return false;
}
final String sinceBuild = descriptor.getSinceBuild();
try {
int sinceBuildNumber = Integer.parseInt(sinceBuild);
if (sinceBuildNumber > buildNumber) {
return true;
}
}
catch (NumberFormatException e) {
//skip invalid numbers
}
BuildNumber buildNumber = getBuildNumber();
final String untilBuild = descriptor.getUntilBuild();
try {
int untilBuildNumber = Integer.parseInt(untilBuild);
if (untilBuildNumber < buildNumber) {
return true;
}
}
catch (NumberFormatException e) {
//skip invalid numbers
if (descriptor.getSinceBuild() != null) {
BuildNumber sinceBuild = BuildNumber.fromString(descriptor.getSinceBuild());
if (sinceBuild.compareTo(buildNumber) > 0) {
return true;
}
}
if (descriptor.getUntilBuild() != null && !buildNumber.isSnapshot()) {
BuildNumber untilBuild = BuildNumber.fromString(descriptor.getUntilBuild());
if (untilBuild.compareTo(buildNumber) < 0) return true;
}
return false;
}
@@ -687,16 +687,23 @@ public class PluginManager {
return true;
}
@Nullable
static String getBuildNumber() {
static BuildNumber getBuildNumber() {
if (ourBuildNumber == null) {
ourBuildNumber = System.getProperty("idea.plugins.compatible.build");
ourBuildNumber = BuildNumber.fromString(System.getProperty("idea.plugins.compatible.build"));
if (ourBuildNumber == null) {
try {
ourBuildNumber = new String(FileUtil.loadFileText(new File(PathManager.getHomePath() + "/build.txt"))).trim();
File buildTxtFile =
FileUtil.findFirstThatExist(PathManager.getHomePath() + "/build.txt", PathManager.getHomePath() + "/community/build.txt");
if (buildTxtFile != null) {
ourBuildNumber = BuildNumber.fromString(new String(FileUtil.loadFileText(buildTxtFile)).trim());
}
else {
ourBuildNumber = BuildNumber.fromString("90.SNAPSHOT");
}
}
catch (IOException e) {
ourBuildNumber = null;
ourBuildNumber = BuildNumber.fromString("90.SNAPSHOT");
}
}
}
@@ -1,25 +1,37 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
* 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
* 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
* 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.
* 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.
*/
package com.intellij.openapi.application;
import com.intellij.openapi.util.BuildNumber;
import java.util.Calendar;
public abstract class ApplicationInfo {
public abstract Calendar getBuildDate();
public abstract String getBuildNumber();
@Deprecated()
/**
* Use {@link #getBuild()} instead
*/
public String getBuildNumber() {
return getBuild().asString();
}
public abstract BuildNumber getBuild();
public abstract String getMajorVersion();
public abstract String getMinorVersion();
public abstract String getVersionName();
@@ -25,6 +25,8 @@ import java.awt.event.MouseMotionListener;
import java.util.List;
public abstract class DialogWrapperPeer {
public static Object HAVE_INITIAL_SELECTION = new Object();
public abstract void setUndecorated(boolean undecorated);
/**
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.BrowserHyperlinkListener;
import com.intellij.ui.DocumentAdapter;
@@ -290,6 +291,38 @@ public class Messages {
}
}
@Nullable
public static String showInputDialog(Project project,
@Nls String message,
@Nls String title,
Icon icon,
@NonNls String initialValue,
@Nullable InputValidator validator,
@Nullable TextRange selection) {
final Application application = ApplicationManager.getApplication();
if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
return ourTestInputImplementation.show(message);
}
else {
InputDialog dialog = new InputDialog(project, message, title, icon, initialValue, validator);
final JTextField field = dialog.getTextField();
if (selection != null) {
// set custom selection
field.select(selection.getStartOffset(),
selection.getEndOffset());
} else {
// reset selection
final int length = field.getDocument().getLength();
field.select(length, length);
}
field.putClientProperty(DialogWrapperPeer.HAVE_INITIAL_SELECTION, true);
dialog.show();
return dialog.getInputString();
}
}
@Nullable
public static String showInputDialog(Component parent,
String message,
@@ -37,10 +37,7 @@ public class RawCommandLineEditor extends JPanel {
Messages.showTextAreaDialog(myTextField.getTextField(), myDialogCaption, "EditParametersPopupWindow");
}
});
final Icon icon = IconLoader.findIcon("/actions/showViewer.png");
if (icon != null) {
myTextField.setButtonIcon(icon);
}
myTextField.setButtonIcon(IconLoader.getIcon("/actions/showViewer.png"));
add(myTextField, BorderLayout.CENTER);
setDescriptor(null);
}
@@ -78,7 +78,7 @@ public class SearchTextField extends JPanel {
}
}
else {
myToggleHistoryLabel = new JLabel(IconLoader.findIcon("/actions/search.png"));
myToggleHistoryLabel = new JLabel(IconLoader.getIcon("/actions/search.png"));
myToggleHistoryLabel.setOpaque(true);
myToggleHistoryLabel.setBackground(myTextField.getBackground());
myToggleHistoryLabel.addMouseListener(new MouseAdapter() {
@@ -90,7 +90,7 @@ public class SearchTextField extends JPanel {
add(myToggleHistoryLabel, BorderLayout.WEST);
}
myClearFieldLabel = new JLabel(IconLoader.findIcon("/actions/cleanLight.png"));
myClearFieldLabel = new JLabel(IconLoader.getIcon("/actions/cleanLight.png"));
myClearFieldLabel.setOpaque(true);
myClearFieldLabel.setBackground(myTextField.getBackground());
add(myClearFieldLabel, BorderLayout.EAST);
@@ -363,4 +363,4 @@ public class SearchTextField extends JPanel {
protected boolean preprocessEventForTextField(KeyEvent e) {
return false;
}
}
}
@@ -0,0 +1,71 @@
package com.intellij.ide.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
/**
* @author yole
*/
public class FixLineSeparatorsAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
final VirtualFile[] vFiles = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
if (project == null || vFiles == null) return;
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
public void run() {
for (VirtualFile vFile : vFiles) {
fixSeparators(vFile);
}
}
}, "fixing line separators", null);
}
private static void fixSeparators(VirtualFile vFile) {
if (vFile.isDirectory()) {
for (VirtualFile child : vFile.getChildren()) {
fixSeparators(child);
}
}
else {
if (vFile.getFileType().isBinary()) {
return;
}
final Document document = FileDocumentManager.getInstance().getDocument(vFile);
if (areSeparatorsBroken(document)) {
fixSeparators(document);
}
}
}
private static boolean areSeparatorsBroken(Document document) {
final int count = document.getLineCount();
for (int i = 1; i < count; i += 2) {
if (document.getLineStartOffset(i) != document.getLineEndOffset(i)) {
return false;
}
}
return true;
}
private static void fixSeparators(final Document document) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
int i = 1;
while(i < document.getLineCount()) {
final int start = document.getLineEndOffset(i);
final int end = document.getLineEndOffset(i) + document.getLineSeparatorLength(i);
document.deleteString(start, end);
i++;
}
}
});
}
}
@@ -8,6 +8,7 @@ import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.Nullable;
public abstract class UndoRedoAction extends AnAction implements DumbAware {
public UndoRedoAction() {
@@ -36,7 +37,8 @@ public abstract class UndoRedoAction extends AnAction implements DumbAware {
UndoManager undoManager = getUndoManager(editor, dataContext);
boolean available = isAvailable(editor, undoManager);
presentation.setEnabled(available);
String actionName = available ? formatAction(editor, undoManager) : "";
String actionName = available ? formatAction(editor, undoManager) : null;
if (actionName == null) actionName = "";
String shortActionName = StringUtil.first(actionName, 30, true);
if (actionName.length() == 0) actionName = ActionsBundle.message(getActionDescriptionEmptyMessageKey());
@@ -70,5 +72,6 @@ public abstract class UndoRedoAction extends AnAction implements DumbAware {
protected abstract String getActionDescriptionEmptyMessageKey();
@Nullable
protected abstract String formatAction(FileEditor editor, UndoManager undoManager);
}
@@ -9,6 +9,7 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.updateSettings.impl.PluginDownloader;
import com.intellij.openapi.util.BuildNumber;
import com.intellij.ui.GuiUtils;
import org.jetbrains.annotations.NonNls;
@@ -138,10 +139,10 @@ public class PluginInstaller {
}
synchronized (PluginManager.lock) {
final String buildNumber = RepositoryHelper.extractBuildNumber();
final BuildNumber buildNumber = PluginManager.getBuildNumber();
final @NonNls String url = RepositoryHelper.DOWNLOAD_URL +
URLEncoder.encode(pluginNode.getPluginId().getIdString(), "UTF8") +
"&build=" + buildNumber;
"&build=" + buildNumber.asString();
final PluginDownloader downloader =
new PluginDownloader(pluginNode.getPluginId().getIdString(), url, null, null, pluginNode.getName());
if (downloader.prepareToInstall(ProgressManager.getInstance().getProgressIndicator())) {
@@ -3,6 +3,7 @@ package com.intellij.ide.plugins;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.util.BuildNumber;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.net.HttpConfigurable;
import com.intellij.util.ui.UIUtil;
@@ -38,8 +39,8 @@ public class RepositoryHelper {
public static ArrayList<IdeaPluginDescriptor> process(JLabel label) throws IOException, ParserConfigurationException, SAXException {
ArrayList<IdeaPluginDescriptor> plugins = null;
try {
String buildNumber = extractBuildNumber();
@NonNls String url = getListUrl() + "?build=" + buildNumber;
BuildNumber buildNumber = PluginManager.getBuildNumber();
@NonNls String url = getListUrl() + "?build=" + buildNumber.asString();
setLabelText(label, IdeBundle.message("progress.connecting.to.plugin.manager", getRepositoryHost()));
HttpConfigurable.getInstance().prepareURL(getRepositoryHost());
@@ -123,17 +124,6 @@ public class RepositoryHelper {
}
}
public static String extractBuildNumber() {
String build;
try {
build = Integer.valueOf(PluginManager.getBuildNumber()).toString();
}
catch (NumberFormatException e) {
build = "3000";
}
return build;
}
public static String getRepositoryHost() {
return ApplicationInfoImpl.getShadowInstance().getPluginManagerUrl();
}
@@ -366,6 +366,10 @@ public class NotificationsListPanel extends JPanel implements NotificationModelL
final Notification notification = (Notification)value;
final Component renderer = getCellRenderer().getListCellRendererComponent(this, value, index, false, false);
if (renderer instanceof NotificationsListRenderer) {
final Rectangle bounds = getCellBounds(index, index);
renderer.setBounds(bounds);
renderer.doLayout();
final JTextPane text = ((NotificationsListRenderer)renderer).getText();
Processor<Cursor> processor;
@@ -385,9 +389,6 @@ public class NotificationsListPanel extends JPanel implements NotificationModelL
((NotificationsListRenderer)renderer).setCursorHandler(processor);
}
final Rectangle bounds = getCellBounds(index, index);
renderer.setBounds(bounds);
final Point point = e.getPoint();
point.translate(-bounds.x, -bounds.y);
@@ -6,10 +6,7 @@ import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -107,8 +104,9 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern
return myBuildDate;
}
public String getBuildNumber() {
return myBuildNumber;
@Override
public BuildNumber getBuild() {
return BuildNumber.fromString(myBuildNumber);
}
public String getMajorVersion() {
@@ -50,6 +50,8 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
@NonNls private static final String COMPONENT = "component";
@NonNls private static final String NAME = "name";
private static final IFile[] EMPTY_FILES = new IFile[0];
private final FileTypeManager myFileTypeManager;
public DirectoryBasedStorage(final TrackingPathMacroSubstitutor pathMacroSubstitutor,
@@ -242,12 +244,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
assert mySession == this;
final Set<String> currentNames = new HashSet<String>();
if (!myDir.exists()) {
myDir.createParentDirs();
myDir.mkDir();
}
IFile[] children = myDir.listFiles();
IFile[] children = myDir.exists() ? myDir.listFiles() : EMPTY_FILES;
for (IFile child : children) {
final String fileName = child.getName();
if (!myFileTypeManager.isFileIgnored(fileName)) {
@@ -264,6 +261,11 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
}
if (file.getTimeStamp() <= myStorageData.getLastTimeStamp()) {
if (!myDir.exists()) {
myDir.createParentDirs();
myDir.mkDir();
}
StorageUtil.save(file, element);
myStorageData.updateLastTimestamp(file);
}
@@ -272,23 +274,25 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
for (String name : currentNames) {
IFile child = myDir.getChild(name);
if (myDir.exists()) {
for (String name : currentNames) {
IFile child = myDir.getChild(name);
if (child.getTimeStamp() > myStorageData.getLastTimeStamp()) {
// do not touch new files during VC update (which aren't read yet)
// now got an opposite problem: file is recreated if was removed by VC during update.
return;
}
final VirtualFile virtualFile = StorageUtil.getVirtualFile(child);
if (virtualFile != null) {
try {
LOG.debug("Removing configuration file: " + virtualFile.getPresentableUrl());
virtualFile.delete(DirectoryBasedStorage.this);
if (child.getTimeStamp() > myStorageData.getLastTimeStamp()) {
// do not touch new files during VC update (which aren't read yet)
// now got an opposite problem: file is recreated if was removed by VC during update.
return;
}
catch (IOException e) {
LOG.error(e);
final VirtualFile virtualFile = StorageUtil.getVirtualFile(child);
if (virtualFile != null) {
try {
LOG.debug("Removing configuration file: " + virtualFile.getPresentableUrl());
virtualFile.delete(DirectoryBasedStorage.this);
}
catch (IOException e) {
LOG.error(e);
}
}
}
}
@@ -133,7 +133,7 @@ public class FileBasedStorage extends XmlElementStorage {
@Override
protected boolean physicalContentNeedsSave() {
if (!myFile.exists()) return true;
if (!myFile.exists()) return !myStorageData.isEmpty();
return !StorageUtil.contentEquals(getDocumentToSave(), myFile);
}
@@ -730,6 +730,10 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
return diffs;
}
public boolean isEmpty() {
return myComponentStates.size() == 0;
}
public boolean hasState(final String componentName) {
return myComponentStates.containsKey(componentName);
}
@@ -289,9 +289,16 @@ public class ProgressManagerImpl extends ProgressManager {
}
public static void runProcessWithProgressAsynchronously(final Task.Backgroundable task) {
final BackgroundableProcessIndicator progressIndicator = new BackgroundableProcessIndicator(task);
final ProgressIndicator progressIndicator;
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
progressIndicator = new EmptyProgressIndicator();
}
else {
final BackgroundableProcessIndicator indicator = new BackgroundableProcessIndicator(task);
Disposer.register(ApplicationManager.getApplication(), indicator);
progressIndicator = indicator;
}
Disposer.register(ApplicationManager.getApplication(), progressIndicator);
final Runnable process = new TaskRunnable(task, progressIndicator);
@@ -50,8 +50,6 @@ import java.util.List;
import java.util.Map;
public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTrackbackProvider {
public static Object HAVE_INITIAL_SELECTION = new Object();
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.ui.DialogWrapper");
private DialogWrapper myWrapper;
@@ -13,7 +13,6 @@ import javax.swing.*;
public class MainImpl {
final static String APPLICATION_NAME = "idea";
private static final String LOG_CATEGORY = "#com.intellij.idea.Main";
private static boolean runStartupWizard = false;
private MainImpl() {
}
@@ -26,7 +25,6 @@ public class MainImpl {
StartupUtil.isHeadless = Main.isHeadless(args);
boolean isNewConfigFolder = PathManager.ensureConfigFolderExists(true);
if (!StartupUtil.isHeadless && isNewConfigFolder) {
runStartupWizard = true;
try {
if (SystemInfo.isWindowsVista || SystemInfo.isMac) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
@@ -87,11 +85,8 @@ public class MainImpl {
}
private static void startApplication(final String[] args) {
if (runStartupWizard) {
StartupUtil.runStartupWizard();
}
final IdeaApplication app = new IdeaApplication(args);
SwingUtilities.invokeLater(new Runnable() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
app.run();
}
@@ -382,6 +382,7 @@
<action internal="true" id="ReloadProjectAction" class="com.intellij.internal.ReloadProjectAction"/>
<action internal="true" id="RestartInfo" class="com.intellij.internal.RestartInfoAction" text="Restart Info"/>
<action internal="true" id="PruneEmptyDirectories" class="com.intellij.ide.actions.PruneEmptyDirectoriesAction" text="Prune Empty Directories"/>
<action internal="true" id="FixLineSeparators" class="com.intellij.ide.actions.FixLineSeparatorsAction" text="Fix Line Separators"/>
<add-to-group group-id="ToolsMenu" anchor="last"/>
</group>
@@ -24,6 +24,7 @@ import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diff.LineTokenizer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
@@ -58,7 +59,13 @@ public class AbstractVcsTestCase {
protected ProcessOutput runClient(String exeName, @Nullable String stdin, @Nullable final File workingDir, String[] commandLine) throws IOException {
final List<String> arguments = new ArrayList<String>();
arguments.add(new File(myClientBinaryPath, exeName).toString());
if (SystemInfo.isWindows) {
arguments.add(new File(myClientBinaryPath, exeName).toString());
}
else {
// assume client is in path
arguments.add(exeName);
}
Collections.addAll(arguments, commandLine);
final ProcessBuilder builder = new ProcessBuilder().command(arguments);
if (workingDir != null) {
@@ -85,7 +92,7 @@ public class AbstractVcsTestCase {
return result;
}
protected ProcessOutput runArbitrary(final String command, final String[] args) throws IOException {
protected static ProcessOutput runArbitrary(final String command, final String[] args) throws IOException {
final List<String> arguments = new ArrayList<String>();
arguments.add(command);
Collections.addAll(arguments, args);
@@ -0,0 +1,208 @@
/*
* 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.
*/
/*
* @author max
*/
package com.intellij.openapi.util;
import com.intellij.openapi.util.text.StringUtil;
public class BuildNumber implements Comparable<BuildNumber> {
private final String myProductCode;
private final int myBaselineVersion;
private final int myBuildNumber;
public BuildNumber(String productCode, int baselineVersion, int buildNumber) {
myProductCode = productCode;
myBaselineVersion = baselineVersion;
myBuildNumber = buildNumber;
}
public String asString() {
StringBuilder builder = new StringBuilder();
if (!StringUtil.isEmpty(myProductCode)) {
builder.append(myProductCode).append('-');
}
builder.append(myBaselineVersion).append('.');
if (myBuildNumber != Integer.MAX_VALUE) {
builder.append(myBuildNumber);
}
else {
builder.append("SNAPSHOT");
}
return builder.toString();
}
@Override
public String toString() {
return asString();
}
public static BuildNumber fromString(String version) {
if (version == null) return null;
if ("__BUILD_NUMBER__".equals(version)) return new BuildNumber("", 90, Integer.MAX_VALUE);
String code = version;
int productSeparator = code.indexOf('-');
final String productCode;
if (productSeparator > 0) {
productCode = code.substring(0, productSeparator);
code = code.substring(productSeparator + 1);
}
else {
productCode = "";
}
int baselineVersionSeparator = code.indexOf('.');
int baselineVersion;
int buildNumber;
if (baselineVersionSeparator > 0) {
try {
baselineVersion = Integer.parseInt(code.substring(0, baselineVersionSeparator));
code = code.substring(baselineVersionSeparator + 1);
}
catch (NumberFormatException e) {
throw new RuntimeException("Unparseable version number: " + version);
}
if ("SNAPSHOT".equals(code) || "__BUILD_NUMBER__".equals(code)) {
buildNumber = Integer.MAX_VALUE;
}
else {
try {
buildNumber = Integer.parseInt(code);
}
catch (NumberFormatException e) {
throw new RuntimeException("Unparseable version number: " + version);
}
}
}
else {
try {
buildNumber = Integer.parseInt(code);
}
catch (NumberFormatException e) {
throw new RuntimeException("Unparseable version number: " + version);
}
if (buildNumber <= 2000) {
// it's probably a baseline, not a build number
return new BuildNumber(productCode, buildNumber, 0);
}
baselineVersion = getBaseLineForHistoricBuilds(buildNumber);
}
return new BuildNumber(productCode, baselineVersion, buildNumber);
}
public int compareTo(BuildNumber o) {
if (myBaselineVersion == o.myBaselineVersion) return myBuildNumber - o.myBuildNumber;
return myBaselineVersion - o.myBaselineVersion;
}
public String getProductCode() {
return myProductCode;
}
public int getBaselineVersion() {
return myBaselineVersion;
}
public int getBuildNumber() {
return myBuildNumber;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BuildNumber that = (BuildNumber)o;
if (myBaselineVersion != that.myBaselineVersion) return false;
if (myBuildNumber != that.myBuildNumber) return false;
if (!myProductCode.equals(that.myProductCode)) return false;
return true;
}
@Override
public int hashCode() {
int result = myProductCode.hashCode();
result = 31 * result + myBaselineVersion;
result = 31 * result + myBuildNumber;
return result;
}
// See http://www.jetbrains.net/confluence/display/IDEADEV/Build+Number+Ranges for historic build ranges
private static int getBaseLineForHistoricBuilds(int bn) {
if (bn >= 10000) {
return 90; // Maia, 9x builds
}
if (bn >= 9500) {
return 85; // 8.1 builds
}
if (bn >= 9100) {
return 81; // 8.0.x builds
}
if (bn >= 8000) {
return 80; // 8.0, including pre-release builds
}
if (bn >= 7500) {
return 75; // 7.0.2+
}
if (bn >= 7200) {
return 72; // 7.0 final
}
if (bn >= 6900) {
return 69; // 7.0 pre-M2
}
if (bn >= 6500) {
return 65; // 7.0 pre-M1
}
if (bn >= 6000) {
return 60; // 6.0.2+
}
if (bn >= 5000) {
return 55; // 6.0 branch, including all 6.0 EAP builds
}
if (bn >= 4000) {
return 50; // 5.1 branch
}
return 40;
}
public boolean isSnapshot() {
return myBuildNumber == Integer.MAX_VALUE;
}
}
@@ -80,6 +80,10 @@ public final class IconLoader {
@Nullable
/**
* Might return null if icon was not found.
* Use only if you expected null return value, otherwise see {@link IconLoader#getIcon(java.lang.String)}
*/
public static Icon findIcon(@NonNls final String path) {
int stackFrameCount = 2;
Class callerClass = Reflection.getCallerClass(stackFrameCount);
@@ -110,6 +114,10 @@ public final class IconLoader {
}
@Nullable
/**
* Might return null if icon was not found.
* Use only if you expected null return value, otherwise see {@link IconLoader#getIcon(java.lang.String, java.lang.Class)}
*/
public static Icon findIcon(@NotNull final String path, @NotNull final Class aClass) {
URL url = aClass.getResource(path);
return findIcon(url);
@@ -56,7 +56,7 @@ class ClassPath {
final File orderFile = new File(PathManager.getBinPath() + File.separator + "order.txt");
try {
if (!FileUtil.ensureCanCreateFile(orderFile)) return;
ourOrder = new PrintStream(new FileOutputStream(orderFile));
ourOrder = new PrintStream(new FileOutputStream(orderFile, true));
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
public void run() {
ourOrder.close();
@@ -0,0 +1,17 @@
/*
* @author max
*/
package com.intellij.openapi.util;
import junit.framework.TestCase;
public class BuildNumberTest extends TestCase {
public void testHistoricBuild() {
assertEquals(new BuildNumber("", 75, 7512), BuildNumber.fromString("7512"));
}
public void testSnapshotDominates() {
assertTrue(BuildNumber.fromString("90.SNAPSHOT").compareTo(BuildNumber.fromString("90.12345")) > 0);
assertTrue(BuildNumber.fromString("IU-90.SNAPSHOT").compareTo(BuildNumber.fromString("RM-90.12345")) > 0);
}
}
@@ -350,7 +350,8 @@ public class NewMappings {
// already sorted
mySortedMappings = items.toArray(new VcsDirectoryMapping[items.size()]);
return filter.getRemovedRequests();
final List<LocalFileSystem.WatchRequest> watchRequestList = filter.getRemovedRequests();
return watchRequestList;
}
private boolean trySwitchVcs(final String path, final String activeVcsName) {
@@ -17,14 +17,5 @@
<orderEntry type="module" module-name="testFramework-java" />
<orderEntry type="module" module-name="java-impl" />
</component>
<component name="VcsManagerConfiguration">
<option name="ACTIVE_VCS_NAME" value="svn" />
<option name="USE_PROJECT_VCS" value="false" />
</component>
<component name="copyright">
<Base>
<setting name="state" value="2" />
</Base>
</component>
</module>

Some files were not shown because too many files have changed in this diff Show More